Fixed problem with driver entries in the registry which are missing the "ImagePath" key. On windows the default path is used in this case which is "system32/drivers". This patch implements this behavior.
Peter Dons Tychsen (none)
donpedro at dhcppc2.
Tue Sep 2 18:41:50 CDT 2008
---
programs/winedevice/device.c | 35 +++++++++++++++++++++++++----------
1 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index d48017a..dcc62a2 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -147,6 +147,8 @@ static NTSTATUS init_driver( HMODULE module, UNICODE_STRING *keyname )
/* load the .sys module for a device driver */
static BOOL load_driver(void)
{
+ static const WCHAR driversW[] = {'\\','d','r','i','v','e','r','s','\\',0};
+ static const WCHAR postfixW[] = {'.','s','y','s',0};
static const WCHAR ntprefixW[] = {'\\','?','?','\\',0};
static const WCHAR ImagePathW[] = {'I','m','a','g','e','P','a','t','h',0};
static const WCHAR servicesW[] = {'\\','R','e','g','i','s','t','r','y',
@@ -154,7 +156,6 @@ static BOOL load_driver(void)
'\\','S','y','s','t','e','m',
'\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t',
'\\','S','e','r','v','i','c','e','s','\\',0};
-
UNICODE_STRING keypath;
HMODULE module;
LPWSTR path = NULL, str;
@@ -174,17 +175,31 @@ static BOOL load_driver(void)
/* read the executable path from memory */
size = 0;
- if (RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, NULL, &size )) return FALSE;
-
- str = HeapAlloc( GetProcessHeap(), 0, size );
- if (!RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, (LPBYTE)str, &size ))
+ if (!RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, NULL, &size ))
+ {
+ str = HeapAlloc( GetProcessHeap(), 0, size );
+ if (!RegQueryValueExW( driver_hkey, ImagePathW, NULL, &type, (LPBYTE)str, &size ))
+ {
+ size = ExpandEnvironmentStringsW(str,NULL,0);
+ path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
+ ExpandEnvironmentStringsW(str,path,size);
+ }
+ HeapFree( GetProcessHeap(), 0, str );
+ if (!path) return FALSE;
+ }
+ else
{
- size = ExpandEnvironmentStringsW(str,NULL,0);
- path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
- ExpandEnvironmentStringsW(str,path,size);
+ /* default is to use the driver name + ".sys" */
+ WCHAR buffer[MAX_PATH];
+ GetSystemDirectoryW(buffer, MAX_PATH);
+ path = HeapAlloc(GetProcessHeap(),0,
+ (strlenW(buffer) + strlenW(driversW) + strlenW(driver_name) + strlenW(postfixW) + 1)
+ *sizeof(WCHAR));
+ lstrcpyW(path, buffer);
+ lstrcatW(path, driversW);
+ lstrcatW(path, driver_name);
+ lstrcatW(path, postfixW);
}
- HeapFree( GetProcessHeap(), 0, str );
- if (!path) return FALSE;
/* make sure msvcrt is loaded to resolve the ntoskrnl.exe forwards */
LoadLibraryA( "msvcrt.dll" );
--
1.5.4.1
--=-yy8jNzXQ4HhSvtj3EVZZ--
More information about the wine-devel
mailing list