[PATCH 2/2] mountmgr: Create devices and registry entries for parallel ports.

Alex Henrie alexhenrie24 at gmail.com
Sun Apr 16 23:23:10 CDT 2017


Tested on Arch Linux with a USB-attached parallel port.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/mountmgr.sys/device.c   | 35 +++++++++++++++++++++++++++++++++--
 dlls/mountmgr.sys/mountmgr.c |  4 ++++
 dlls/mountmgr.sys/mountmgr.h |  1 +
 dlls/ntdll/directory.c       | 21 ---------------------
 4 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 744bb22383..cb6fb0867b 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -95,6 +95,7 @@ static struct list volumes_list = LIST_INIT(volumes_list);
 
 static DRIVER_OBJECT *harddisk_driver;
 static DRIVER_OBJECT *serial_driver;
+static DRIVER_OBJECT *parallel_driver;
 
 static CRITICAL_SECTION device_section;
 static CRITICAL_SECTION_DEBUG critsect_debug =
@@ -998,7 +999,10 @@ static BOOL create_port_device( DRIVER_OBJECT *driver, int n, char *unix_path, c
                                 HKEY wine_ports_key, HKEY windows_ports_key )
 {
     static const WCHAR comW[] = {'C','O','M','%','u',0};
+    static const WCHAR lptW[] = {'L','P','T','%','u',0};
     static const WCHAR device_serialW[] = {'\\','D','e','v','i','c','e','\\','S','e','r','i','a','l','%','u',0};
+    static const WCHAR device_parallelW[] = {'\\','D','e','v','i','c','e','\\','P','a','r','a','l','l','e','l','%','u',0};
+    static const WCHAR dosdevices_lptW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\','L','P','T','%','u',0};
     const WCHAR *dos_name_format, *nt_name_format, *reg_value_format;
     WCHAR dos_name[7], reg_value[256];
     DWORD type, size;
@@ -1015,7 +1019,9 @@ static BOOL create_port_device( DRIVER_OBJECT *driver, int n, char *unix_path, c
     }
     else
     {
-        /* TODO: support parallel ports */
+        dos_name_format = lptW;
+        nt_name_format = device_parallelW;
+        reg_value_format = dosdevices_lptW;
     }
 
     sprintfW( dos_name, dos_name_format, n );
@@ -1076,9 +1082,19 @@ static void create_port_devices( DRIVER_OBJECT *driver )
         "",
 #endif
     };
+    static const char *parallel_search_paths[] = {
+#ifdef linux
+        "/dev/lp%u",
+#else
+        "",
+#endif
+    };
     static const WCHAR serialcomm_keyW[] = {'H','A','R','D','W','A','R','E','\\',
                                             'D','E','V','I','C','E','M','A','P','\\',
                                             'S','E','R','I','A','L','C','O','M','M',0};
+    static const WCHAR parallel_ports_keyW[] = {'H','A','R','D','W','A','R','E','\\',
+                                                'D','E','V','I','C','E','M','A','P','\\',
+                                                'P','A','R','A','L','L','E','L',' ','P','O','R','T','S',0};
     const char **search_paths;
     const WCHAR *windows_ports_key_name;
     char *dosdevices_path, *p;
@@ -1099,7 +1115,11 @@ static void create_port_devices( DRIVER_OBJECT *driver )
     }
     else
     {
-        /* TODO: support parallel ports */
+        p[0] = 'l';
+        p[1] = 'p';
+        p[2] = 't';
+        search_paths = parallel_search_paths;
+        windows_ports_key_name = parallel_ports_keyW;
     }
     p += 3;
 
@@ -1151,3 +1171,14 @@ NTSTATUS WINAPI serial_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path
 
     return STATUS_SUCCESS;
 }
+
+/* driver entry point for the parallel port driver */
+NTSTATUS WINAPI parallel_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
+{
+    parallel_driver = driver;
+    /* TODO: fill in driver->MajorFunction */
+
+    create_port_devices( driver );
+
+    return STATUS_SUCCESS;
+}
diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
index d40b8fca83..d3f774a8b9 100644
--- a/dlls/mountmgr.sys/mountmgr.c
+++ b/dlls/mountmgr.sys/mountmgr.c
@@ -420,6 +420,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
     static const WCHAR link_mountmgrW[] = {'\\','?','?','\\','M','o','u','n','t','P','o','i','n','t','M','a','n','a','g','e','r',0};
     static const WCHAR harddiskW[] = {'\\','D','r','i','v','e','r','\\','H','a','r','d','d','i','s','k',0};
     static const WCHAR driver_serialW[] = {'\\','D','r','i','v','e','r','\\','S','e','r','i','a','l',0};
+    static const WCHAR driver_parallelW[] = {'\\','D','r','i','v','e','r','\\','P','a','r','a','l','l','e','l',0};
     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};
@@ -467,5 +468,8 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
     RtlInitUnicodeString( &nameW, driver_serialW );
     IoCreateDriver( &nameW, serial_driver_entry );
 
+    RtlInitUnicodeString( &nameW, driver_parallelW );
+    IoCreateDriver( &nameW, parallel_driver_entry );
+
     return status;
 }
diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
index 4ef36a1be7..79f72a3c83 100644
--- a/dlls/mountmgr.sys/mountmgr.h
+++ b/dlls/mountmgr.sys/mountmgr.h
@@ -58,6 +58,7 @@ 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 serial_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
+extern NTSTATUS WINAPI parallel_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
 
 /* mount point functions */
 
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 8c87a57725..9d5cf92b2a 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -434,26 +434,6 @@ static void flush_dir_queue(void)
 }
 
 
-/***********************************************************************
- *           get_default_lpt_device
- *
- * Return the default device to use for parallel ports.
- */
-static char *get_default_lpt_device( int num )
-{
-    char *ret = NULL;
-
-    if (num < 1 || num > 256) return NULL;
-#ifdef linux
-    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/lp256") );
-    if (!ret) return NULL;
-    sprintf( ret, "/dev/lp%d", num - 1 );
-#else
-    FIXME( "no known default for device lpt%d\n", num );
-#endif
-    return ret;
-}
-
 #ifdef __ANDROID__
 
 static char *unescape_field( char *str )
@@ -2476,7 +2456,6 @@ static NTSTATUS get_dos_device( const WCHAR *name, UINT name_len, ANSI_STRING *u
             dev[2] = 0;  /* remove last ':' to get the drive mount point symlink */
             new_name = get_default_drive_device( unix_name );
         }
-        else if (!strncmp( dev, "lpt", 3 )) new_name = get_default_lpt_device( atoi(dev + 3 ));
 
         if (!new_name) break;
 
-- 
2.12.0




More information about the wine-patches mailing list