Alexandre Julliard : services: Start the 32-bit winedevice. exe for 32-bit kernel drivers.

Alexandre Julliard julliard at winehq.org
Tue Jun 1 12:12:44 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jun  1 13:38:21 2010 +0200

services: Start the 32-bit winedevice.exe for 32-bit kernel drivers.

---

 programs/services/services.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/programs/services/services.c b/programs/services/services.c
index a5eb2f7..59fe8bc 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -38,6 +38,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(service);
 HANDLE g_hStartedEvent;
 struct scmdatabase *active_database;
 
+static const int is_win64 = (sizeof(void *) > sizeof(int));
+
 static const WCHAR SZ_LOCAL_SYSTEM[] = {'L','o','c','a','l','S','y','s','t','e','m',0};
 
 /* Registry constants */
@@ -548,25 +550,36 @@ static DWORD service_start_process(struct service_entry *service_entry, HANDLE *
 
     service_lock_exclusive(service_entry);
 
+    size = ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,NULL,0);
+    path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
+    if (!path) return ERROR_NOT_ENOUGH_SERVER_MEMORY;
+    ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,path,size);
+
     if (service_entry->config.dwServiceType == SERVICE_KERNEL_DRIVER)
     {
         static const WCHAR winedeviceW[] = {'\\','w','i','n','e','d','e','v','i','c','e','.','e','x','e',' ',0};
-        DWORD len = GetSystemDirectoryW( NULL, 0 ) + sizeof(winedeviceW)/sizeof(WCHAR) + strlenW(service_entry->name);
+        WCHAR system_dir[MAX_PATH];
+        DWORD type, len;
 
+        GetSystemDirectoryW( system_dir, MAX_PATH );
+        if (is_win64)
+        {
+            if (!GetBinaryTypeW( path, &type ))
+            {
+                HeapFree( GetProcessHeap(), 0, path );
+                return GetLastError();
+            }
+            if (type == SCS_32BIT_BINARY) GetSystemWow64DirectoryW( system_dir, MAX_PATH );
+        }
+
+        len = strlenW( system_dir ) + sizeof(winedeviceW)/sizeof(WCHAR) + strlenW(service_entry->name);
+        HeapFree( GetProcessHeap(), 0, path );
         if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
             return ERROR_NOT_ENOUGH_SERVER_MEMORY;
-        GetSystemDirectoryW( path, len );
+        lstrcpyW( path, system_dir );
         lstrcatW( path, winedeviceW );
         lstrcatW( path, service_entry->name );
     }
-    else
-    {
-        size = ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,NULL,0);
-        path = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
-        if (!path)
-            return ERROR_NOT_ENOUGH_SERVER_MEMORY;
-        ExpandEnvironmentStringsW(service_entry->config.lpBinaryPathName,path,size);
-    }
 
     ZeroMemory(&si, sizeof(STARTUPINFOW));
     si.cb = sizeof(STARTUPINFOW);




More information about the wine-cvs mailing list