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

This commit is contained in:
Alexandre Julliard 2010-06-01 13:38:21 +02:00
parent 0dd44a3776
commit 3f6f036b4d
1 changed files with 23 additions and 10 deletions

View File

@ -38,6 +38,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(service);
HANDLE g_hStartedEvent; HANDLE g_hStartedEvent;
struct scmdatabase *active_database; 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}; static const WCHAR SZ_LOCAL_SYSTEM[] = {'L','o','c','a','l','S','y','s','t','e','m',0};
/* Registry constants */ /* Registry constants */
@ -548,25 +550,36 @@ static DWORD service_start_process(struct service_entry *service_entry, HANDLE *
service_lock_exclusive(service_entry); 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) 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}; 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) ))) if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return ERROR_NOT_ENOUGH_SERVER_MEMORY; return ERROR_NOT_ENOUGH_SERVER_MEMORY;
GetSystemDirectoryW( path, len ); lstrcpyW( path, system_dir );
lstrcatW( path, winedeviceW ); lstrcatW( path, winedeviceW );
lstrcatW( path, service_entry->name ); 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)); ZeroMemory(&si, sizeof(STARTUPINFOW));
si.cb = sizeof(STARTUPINFOW); si.cb = sizeof(STARTUPINFOW);