Alex Henrie : mountmgr: Create devices and registry entries for parallel ports.

Alexandre Julliard julliard at winehq.org
Tue May 2 15:58:47 CDT 2017


Module: wine
Branch: master
Commit: b1203af6ba44ff8858ee9ca50fc05f4f3f633892
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b1203af6ba44ff8858ee9ca50fc05f4f3f633892

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Tue Apr 25 21:18:36 2017 -0600

mountmgr: Create devices and registry entries for parallel ports.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mountmgr.sys/device.c   | 66 ++++++++++++++++++++++++++++++++++++--------
 dlls/mountmgr.sys/mountmgr.c |  4 +++
 dlls/mountmgr.sys/mountmgr.h |  1 +
 dlls/ntdll/directory.c       | 21 --------------
 4 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index 5295988..ee25999 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, const char *unix_p
                                 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], nt_buffer[32];
     DWORD type, size;
@@ -1007,10 +1011,18 @@ static BOOL create_port_device( DRIVER_OBJECT *driver, int n, const char *unix_p
     DEVICE_OBJECT *dev_obj;
     NTSTATUS status;
 
-    dos_name_format = comW;
-    nt_name_format = device_serialW;
-    reg_value_format = comW;
-    /* TODO: support parallel ports */
+    if (driver == serial_driver)
+    {
+        dos_name_format = comW;
+        nt_name_format = device_serialW;
+        reg_value_format = comW;
+    }
+    else
+    {
+        dos_name_format = lptW;
+        nt_name_format = device_parallelW;
+        reg_value_format = dosdevices_lptW;
+    }
 
     sprintfW( dos_name, dos_name_format, n );
 
@@ -1065,9 +1077,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;
@@ -1078,13 +1100,24 @@ static void create_port_devices( DRIVER_OBJECT *driver )
     if (!(dosdevices_path = get_dosdevices_path( &p )))
         return;
 
-    p[0] = 'c';
-    p[1] = 'o';
-    p[2] = 'm';
-    search_paths = serial_search_paths;
-    num_search_paths = sizeof(serial_search_paths)/sizeof(serial_search_paths[0]);
-    windows_ports_key_name = serialcomm_keyW;
-    /* TODO: support parallel ports */
+    if (driver == serial_driver)
+    {
+        p[0] = 'c';
+        p[1] = 'o';
+        p[2] = 'm';
+        search_paths = serial_search_paths;
+        num_search_paths = sizeof(serial_search_paths)/sizeof(serial_search_paths[0]);
+        windows_ports_key_name = serialcomm_keyW;
+    }
+    else
+    {
+        p[0] = 'l';
+        p[1] = 'p';
+        p[2] = 't';
+        search_paths = parallel_search_paths;
+        num_search_paths = sizeof(parallel_search_paths)/sizeof(parallel_search_paths[0]);
+        windows_ports_key_name = parallel_ports_keyW;
+    }
     p += 3;
 
     RegOpenKeyExW( HKEY_LOCAL_MACHINE, ports_keyW, 0, KEY_QUERY_VALUE, &wine_ports_key );
@@ -1136,3 +1169,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 d40b8fc..d3f774a 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 4ef36a1..79f72a3 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 8c87a57..9d5cf92 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;
 




More information about the wine-cvs mailing list