Added patch to emulate \Device\Null using /dev/null.

This commit is contained in:
Sebastian Lackner
2015-05-02 21:00:56 +02:00
parent f23ff69f86
commit b182064bef
6 changed files with 219 additions and 33 deletions

View File

@@ -0,0 +1,106 @@
From 6428642ac8f1e129d623d4a47cfbe6b09b7bbb39 Mon Sep 17 00:00:00 2001
From: Qian Hong <qhong@codeweavers.com>
Date: Fri, 13 Mar 2015 03:56:22 +0800
Subject: mountmgr.sys: Added Null Device.
---
dlls/mountmgr.sys/device.c | 40 ++++++++++++++++++++++++++++++++++++++++
dlls/mountmgr.sys/mountmgr.c | 7 +++++++
dlls/mountmgr.sys/mountmgr.h | 1 +
3 files changed, 48 insertions(+)
diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 5003d4d..990e6b5 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -972,6 +972,19 @@ static NTSTATUS WINAPI harddisk_ioctl( DEVICE_OBJECT *device, IRP *irp )
return STATUS_SUCCESS;
}
+static NTSTATUS WINAPI null_ioctl( DEVICE_OBJECT *device, IRP *irp )
+{
+ IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
+ ULONG code = irpsp->Parameters.DeviceIoControl.IoControlCode;
+
+ FIXME("Unsupported ioctl %x (device=%x access=%x func=%x method=%x)\n",
+ code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3);
+ irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+
+ IoCompleteRequest( irp, IO_NO_INCREMENT );
+ return STATUS_SUCCESS;
+}
+
/* driver entry point for the harddisk driver */
NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
{
@@ -987,3 +1000,30 @@ NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *pa
return STATUS_SUCCESS;
}
+
+/* driver entry point for the null driver */
+NTSTATUS WINAPI null_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
+{
+ static const WCHAR device_nullW[] = {'\\','D','e','v','i','c','e','\\','N','u','l','l',0};
+ static const WCHAR link_nullW[] = {'\\','?','?','\\','N','u','l','l',0};
+ UNICODE_STRING nameW, linkW;
+ DEVICE_OBJECT *device;
+ NTSTATUS status;
+
+ TRACE("(%p, %s)\n", driver, debugstr_w(path->Buffer));
+
+ driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = null_ioctl;
+ RtlInitUnicodeString( &nameW, device_nullW );
+ RtlInitUnicodeString( &linkW, link_nullW );
+
+ if (!(status = IoCreateDevice( driver, 0, &nameW, 0, 0, FALSE, &device )))
+ status = IoCreateSymbolicLink( &linkW, &nameW );
+
+ if (status)
+ {
+ FIXME( "failed to create device error %x\n", status );
+ return status;
+ }
+
+ return STATUS_SUCCESS;
+}
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index 10286dc..ea12313 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -422,6 +422,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
static const WCHAR devicemapW[] = {'H','A','R','D','W','A','R','E','\\','D','E','V','I','C','E','M','A','P',0};
static const WCHAR parallelW[] = {'P','A','R','A','L','L','E','L',' ','P','O','R','T','S',0};
static const WCHAR serialW[] = {'S','E','R','I','A','L','C','O','M','M',0};
+ static const WCHAR nullW[] = {'N','u','l','l',0};
UNICODE_STRING nameW, linkW;
DEVICE_OBJECT *device;
@@ -460,6 +461,12 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
RtlInitUnicodeString( &nameW, harddiskW );
status = IoCreateDriver( &nameW, harddisk_driver_entry );
+ if (!status)
+ {
+ RtlInitUnicodeString( &nameW, nullW );
+ status = IoCreateDriver( &nameW, null_driver_entry );
+ }
+
initialize_dbus();
initialize_diskarbitration();
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index 2f0db62..8b42785 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -57,6 +57,7 @@ extern NTSTATUS add_dos_device( int letter, const char *udi, const char *device,
extern NTSTATUS remove_dos_device( int letter, const char *udi ) DECLSPEC_HIDDEN;
extern NTSTATUS query_dos_device( int letter, enum device_type *type, char **device, char **mount_point ) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
+extern NTSTATUS WINAPI null_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
/* mount point functions */
--
2.3.5

View File

@@ -0,0 +1,48 @@
From 4ff0f3924789e3e2da8c7d408c43d4915ee5e247 Mon Sep 17 00:00:00 2001
From: Qian Hong <qhong@codeweavers.com>
Date: Thu, 30 Apr 2015 21:47:38 +0800
Subject: ntdll: Emulate \Device\Null using /dev/null in
wine_nt_to_unix_file_name.
---
dlls/ntdll/directory.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index bf15612..625e2ca 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -3008,6 +3008,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
static const WCHAR unixW[] = {'u','n','i','x'};
static const WCHAR pipeW[] = {'p','i','p','e'};
static const WCHAR invalid_charsW[] = { INVALID_NT_CHARS, 0 };
+ static const WCHAR device_nullW[] = {'\\','D','e','v','i','c','e','\\','N','u','l','l'};
NTSTATUS status = STATUS_SUCCESS;
const char *config_dir = wine_get_config_dir();
@@ -3024,6 +3025,22 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
if (!name_len || !IS_SEPARATOR(name[0])) return STATUS_OBJECT_PATH_SYNTAX_BAD;
+ if (name_len == sizeof(device_nullW) / sizeof(WCHAR) && !memicmpW( name, device_nullW, name_len ))
+ {
+ TRACE( "%s -> %s\n", debugstr_us(nameW), "/dev/null" );
+
+ unix_len = strlen("/dev/null");
+ if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len )))
+ return STATUS_NO_MEMORY;
+
+ strcpy( unix_name, "/dev/null" );
+ unix_name_ret->Buffer = unix_name;
+ unix_name_ret->Length = unix_len;
+ unix_name_ret->MaximumLength = unix_len + 1;
+
+ return STATUS_SUCCESS;
+ }
+
if (!(pos = get_dos_prefix_len( nameW )))
return STATUS_BAD_DEVICE_TYPE; /* no DOS prefix, assume NT native name */
--
2.3.5

View File

@@ -0,0 +1,2 @@
Fixes: [38107] Emulate \Device\Null using /dev/null
Depends: ntdll-Pipe_SpecialCharacters