diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 95944c63a2c..398812ad6b3 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -3016,6 +3016,7 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) BOOL DeviceInstalled = FALSE; DWORD BytesWritten; DWORD Value; + HANDLE hInstallEvent; HANDLE hPipe = INVALID_HANDLE_VALUE; LPVOID Environment = NULL; PROCESS_INFORMATION ProcessInfo; @@ -3056,7 +3057,7 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) DPRINT1("Installing: %S\n", DeviceInstance); - /* Create a random UUID for the named pipe */ + /* Create a random UUID for the named pipe & event*/ UuidCreate(&RandomUuid); swprintf(UuidString, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", RandomUuid.Data1, RandomUuid.Data2, RandomUuid.Data3, @@ -3064,11 +3065,20 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) RandomUuid.Data4[3], RandomUuid.Data4[4], RandomUuid.Data4[5], RandomUuid.Data4[6], RandomUuid.Data4[7]); + /* Create the event */ + wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0."); + wcscat(InstallEventName, UuidString); + hInstallEvent = CreateEventW(NULL, TRUE, FALSE, InstallEventName); + if (!hInstallEvent) + { + DPRINT1("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError()); + goto cleanup; + } + /* Create the named pipe */ wcscpy(PipeName, L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0."); wcscat(PipeName, UuidString); hPipe = CreateNamedPipeW(PipeName, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 512, 512, 0, NULL); - if (hPipe == INVALID_HANDLE_VALUE) { DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError()); @@ -3123,9 +3133,6 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) } /* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */ - wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0."); - wcscat(InstallEventName, UuidString); - Value = sizeof(InstallEventName); WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL); WriteFile(hPipe, InstallEventName, Value, &BytesWritten, NULL); @@ -3141,16 +3148,13 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) /* Wait for newdev.dll to finish processing */ WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - /* The following check for success is probably not compatible to Windows, but should do its job */ - if (!GetExitCodeProcess(ProcessInfo.hProcess, &Value)) - { - DPRINT1("GetExitCodeProcess failed with error %u\n", GetLastError()); - goto cleanup; - } - - DeviceInstalled = Value; + /* If the event got signalled, this is success */ + DeviceInstalled = WaitForSingleObject(hInstallEvent, 0) == WAIT_OBJECT_0; cleanup: + if (hInstallEvent) + CloseHandle(hInstallEvent); + if (hPipe != INVALID_HANDLE_VALUE) CloseHandle(hPipe); diff --git a/reactos/dll/win32/newdev/newdev.c b/reactos/dll/win32/newdev/newdev.c index fe88320a624..1b30c96dd51 100644 --- a/reactos/dll/win32/newdev/newdev.c +++ b/reactos/dll/win32/newdev/newdev.c @@ -933,6 +933,7 @@ ClientSideInstallW( HANDLE hPipe = INVALID_HANDLE_VALUE; PWSTR DeviceInstance = NULL; PWSTR InstallEventName = NULL; + HANDLE hInstallEvent; /* Open the pipe */ hPipe = CreateFileW(lpNamedPipeName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -983,6 +984,21 @@ ClientSideInstallW( } ReturnValue = DevInstallW(NULL, NULL, DeviceInstance, ShowWizard ? SW_SHOWNOACTIVATE : SW_HIDE); + if(!ReturnValue) + { + ERR("DevInstallW failed with error %lu\n", GetLastError()); + goto cleanup; + } + + hInstallEvent = CreateEventW(NULL, TRUE, FALSE, InstallEventName); + if(!hInstallEvent) + { + TRACE("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError()); + goto cleanup; + } + + SetEvent(hInstallEvent); + CloseHandle(hInstallEvent); cleanup: if(hPipe != INVALID_HANDLE_VALUE)