[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

svn path=/trunk/; revision=51963
This commit is contained in:
Cameron Gutman 2011-05-27 20:50:17 +00:00
parent ccda38feca
commit 5d2112a43b
2 changed files with 25 additions and 24 deletions

View file

@ -2241,8 +2241,6 @@ DWORD PNP_DeleteServiceDevices(
static BOOL static BOOL
InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard) InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
{ {
PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
NTSTATUS Status;
BOOL DeviceInstalled = FALSE; BOOL DeviceInstalled = FALSE;
DWORD BytesWritten; DWORD BytesWritten;
DWORD Value; DWORD Value;
@ -2251,6 +2249,8 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
PROCESS_INFORMATION ProcessInfo; PROCESS_INFORMATION ProcessInfo;
STARTUPINFOW StartupInfo; STARTUPINFOW StartupInfo;
UUID RandomUuid; UUID RandomUuid;
WCHAR RegistryPath[MAX_PATH];
HKEY DeviceKey;
/* The following lengths are constant (see below), they cannot overflow */ /* The following lengths are constant (see below), they cannot overflow */
WCHAR CommandLine[116]; WCHAR CommandLine[116];
@ -2262,26 +2262,30 @@ InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
RtlInitUnicodeString(&PlugPlayData.DeviceInstance, wcscpy(RegistryPath, L"SYSTEM\\CurrentControlSet\\Enum\\");
DeviceInstance); wcscat(RegistryPath, DeviceInstance);
PlugPlayData.Operation = 0; /* Get status */
/* Get device status */ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
Status = NtPlugPlayControl(PlugPlayControlDeviceStatus, RegistryPath,
(PVOID)&PlugPlayData, 0,
sizeof(PLUGPLAY_CONTROL_STATUS_DATA)); KEY_QUERY_VALUE,
if (!NT_SUCCESS(Status)) &DeviceKey) == ERROR_SUCCESS)
{ {
DPRINT1("NtPlugPlayControl('%S') failed with status 0x%08lx\n", DeviceInstance, Status); if (RegQueryValueExW(DeviceKey,
return FALSE; 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) DPRINT1("Installing: %S\n", DeviceInstance);
{
/* Device is already started, or disabled due to some problem. Don't install it */
DPRINT("No need to install '%S'\n", DeviceInstance);
return TRUE;
}
/* Create a random UUID for the named pipe */ /* Create a random UUID for the named pipe */
UuidCreate(&RandomUuid); UuidCreate(&RandomUuid);
@ -2387,6 +2391,8 @@ cleanup:
if(ProcessInfo.hThread) if(ProcessInfo.hThread)
CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hThread);
DPRINT1("Success? %d\n", DeviceInstalled);
return DeviceInstalled; return DeviceInstalled;
} }

View file

@ -3776,14 +3776,10 @@ RunUSetup(VOID)
INPUT_RECORD Ir; INPUT_RECORD Ir;
PAGE_NUMBER Page; PAGE_NUMBER Page;
LARGE_INTEGER Time; LARGE_INTEGER Time;
// NTSTATUS Status; NTSTATUS Status;
NtQuerySystemTime(&Time); 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(), Status = RtlCreateUserThread(NtCurrentProcess(),
NULL, NULL,
TRUE, TRUE,
@ -3795,7 +3791,6 @@ RunUSetup(VOID)
&hPnpThread, &hPnpThread,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
#endif
hPnpThread = INVALID_HANDLE_VALUE; hPnpThread = INVALID_HANDLE_VALUE;
if (!CONSOLE_Init()) if (!CONSOLE_Init())