diff --git a/reactos/base/services/umpnpmgr/umpnpmgr.c b/reactos/base/services/umpnpmgr/umpnpmgr.c index 08c5b25978b..3f0cfc32159 100644 --- a/reactos/base/services/umpnpmgr/umpnpmgr.c +++ b/reactos/base/services/umpnpmgr/umpnpmgr.c @@ -2241,8 +2241,6 @@ DWORD PNP_DeleteServiceDevices( static BOOL InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) { - PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData; - NTSTATUS Status; BOOL DeviceInstalled = FALSE; DWORD BytesWritten; DWORD Value; @@ -2251,6 +2249,8 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) PROCESS_INFORMATION ProcessInfo; STARTUPINFOW StartupInfo; UUID RandomUuid; + WCHAR RegistryPath[MAX_PATH]; + HKEY DeviceKey; /* The following lengths are constant (see below), they cannot overflow */ WCHAR CommandLine[116]; @@ -2262,26 +2262,30 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); - RtlInitUnicodeString(&PlugPlayData.DeviceInstance, - DeviceInstance); - PlugPlayData.Operation = 0; /* Get status */ + wcscpy(RegistryPath, L"SYSTEM\\CurrentControlSet\\Enum\\"); + wcscat(RegistryPath, DeviceInstance); - /* Get device status */ - Status = NtPlugPlayControl(PlugPlayControlDeviceStatus, - (PVOID)&PlugPlayData, - sizeof(PLUGPLAY_CONTROL_STATUS_DATA)); - if (!NT_SUCCESS(Status)) + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + RegistryPath, + 0, + KEY_QUERY_VALUE, + &DeviceKey) == ERROR_SUCCESS) { - DPRINT1("NtPlugPlayControl('%S') failed with status 0x%08lx\n", DeviceInstance, Status); - return FALSE; + if (RegQueryValueExW(DeviceKey, + L"ClassGUID", + NULL, + NULL, + NULL, + NULL) == ERROR_SUCCESS) + { + DPRINT("No need to install: %S\n", DeviceInstance); + return TRUE; + } + + CloseHandle(DeviceKey); } - if ((PlugPlayData.DeviceStatus & (DNF_STARTED | DNF_START_FAILED)) != 0) - { - /* Device is already started, or disabled due to some problem. Don't install it */ - DPRINT("No need to install '%S'\n", DeviceInstance); - return TRUE; - } + DPRINT1("Installing: %S\n", DeviceInstance); /* Create a random UUID for the named pipe */ UuidCreate(&RandomUuid); @@ -2387,6 +2391,8 @@ cleanup: if(ProcessInfo.hThread) CloseHandle(ProcessInfo.hThread); + DPRINT1("Success? %d\n", DeviceInstalled); + return DeviceInstalled; } diff --git a/reactos/base/setup/usetup/interface/usetup.c b/reactos/base/setup/usetup/interface/usetup.c index 1adcb658518..e0f503e7503 100644 --- a/reactos/base/setup/usetup/interface/usetup.c +++ b/reactos/base/setup/usetup/interface/usetup.c @@ -3776,14 +3776,10 @@ RunUSetup(VOID) INPUT_RECORD Ir; PAGE_NUMBER Page; LARGE_INTEGER Time; -// NTSTATUS Status; + NTSTATUS Status; NtQuerySystemTime(&Time); -#if 0 /* This minimal PnP implementation causes problems because it writes - * half complete registry entries which cause devices installed by this - * method (PCI) to be improperly installed and not recognized by device manager - */ Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, @@ -3795,7 +3791,6 @@ RunUSetup(VOID) &hPnpThread, NULL); if (!NT_SUCCESS(Status)) -#endif hPnpThread = INVALID_HANDLE_VALUE; if (!CONSOLE_Init())