Author: cgutman
Date: Fri May 27 20:50:17 2011
New Revision: 51963

URL: http://svn.reactos.org/svn/reactos?rev=51963&view=rev
Log:
[UMPNPMGR]
- Determine whether the device is really installed by reading the ClassGUID key 
instead of looking at the device flags
- Add a debug print for device installation (shouldn't be too spammy except and 
will be helpful for hotplugging)
[USETUP]
- Reenable the 1st stage PnP manager

Modified:
    trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
    trunk/reactos/base/setup/usetup/interface/usetup.c

Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/umpnpmgr.c?rev=51963&r1=51962&r2=51963&view=diff
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] Fri May 27 
20:50:17 2011
@@ -2241,8 +2241,6 @@
 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 @@
     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 @@
 
     ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
 
-    RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
-                         DeviceInstance);
-    PlugPlayData.Operation = 0; /* Get status */
-
-    /* Get device status */
-    Status = NtPlugPlayControl(PlugPlayControlDeviceStatus,
-                               (PVOID)&PlugPlayData,
-                               sizeof(PLUGPLAY_CONTROL_STATUS_DATA));
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("NtPlugPlayControl('%S') failed with status 0x%08lx\n", 
DeviceInstance, Status);
-        return FALSE;
-    }
-
-    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;
-    }
+    wcscpy(RegistryPath, L"SYSTEM\\CurrentControlSet\\Enum\\");
+    wcscat(RegistryPath, DeviceInstance);
+
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                      RegistryPath,
+                      0,
+                      KEY_QUERY_VALUE,
+                      &DeviceKey) == ERROR_SUCCESS)
+    {
+        if (RegQueryValueExW(DeviceKey,
+                             L"ClassGUID",
+                             NULL,
+                             NULL,
+                             NULL,
+                             NULL) == ERROR_SUCCESS)
+        {
+            DPRINT("No need to install: %S\n", DeviceInstance);
+            return TRUE;
+        }
+
+        CloseHandle(DeviceKey);
+    }
+
+    DPRINT1("Installing: %S\n", DeviceInstance);
 
     /* Create a random UUID for the named pipe */
     UuidCreate(&RandomUuid);
@@ -2386,6 +2390,8 @@
 
     if(ProcessInfo.hThread)
         CloseHandle(ProcessInfo.hThread);
+
+    DPRINT1("Success? %d\n", DeviceInstalled);
 
     return DeviceInstalled;
 }

Modified: trunk/reactos/base/setup/usetup/interface/usetup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interface/usetup.c?rev=51963&r1=51962&r2=51963&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] Fri May 27 
20:50:17 2011
@@ -3776,14 +3776,10 @@
     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 @@
                                  &hPnpThread,
                                  NULL);
     if (!NT_SUCCESS(Status))
-#endif
         hPnpThread = INVALID_HANDLE_VALUE;
 
     if (!CONSOLE_Init())


Reply via email to