Author: tfaber
Date: Fri Apr 3 18:30:37 2015
New Revision: 67025
URL:
http://svn.reactos.org/svn/reactos?rev=67025&view=rev
Log:
[UMPNPMGR][NEWDEV]
- Actually create the "InstallEvent" as an event and use it to communicate
success from newdev back to umpnpmgr. This works better than checking the process exit
code from rundll32 (which always returns 0).
CORE-9477 #resolve
Modified:
trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
trunk/reactos/dll/win32/newdev/newdev.c
Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/ump…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] Fri Apr 3 18:30:37 2015
@@ -3016,6 +3016,7 @@
BOOL DeviceInstalled = FALSE;
DWORD BytesWritten;
DWORD Value;
+ HANDLE hInstallEvent;
HANDLE hPipe = INVALID_HANDLE_VALUE;
LPVOID Environment = NULL;
PROCESS_INFORMATION ProcessInfo;
@@ -3056,7 +3057,7 @@
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 @@
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 @@
}
/* 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 @@
/* 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);
Modified: trunk/reactos/dll/win32/newdev/newdev.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/newdev/newdev.c?…
==============================================================================
--- trunk/reactos/dll/win32/newdev/newdev.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/newdev/newdev.c [iso-8859-1] Fri Apr 3 18:30:37 2015
@@ -933,6 +933,7 @@
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 @@
}
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)