76 PWSTR keyboardClass =
L"kbdclass\0";
77 PWSTR partMgr =
L"partmgr\0";
123 DPRINT1(
"Using driver '%S' for device '%S'\n", ImagePath, DeviceId);
131 DPRINT1(
"NtCreateKey('%wZ') failed with status 0x%08x\n", &StringU,
Status);
170 if (ClassGuid &&
_wcsicmp(ClassGuid,
L"{4D36E96B-E325-11CE-BFC1-08002BE10318}") == 0)
172 DPRINT1(
"Installing keyboard class driver for '%S'\n", DeviceId);
180 else if (ClassGuid &&
_wcsicmp(ClassGuid,
L"{4D36E967-E325-11CE-BFC1-08002BE10318}") == 0)
182 DPRINT1(
"Installing partition manager driver for '%S'\n", DeviceId);
209 DPRINT1(
"NtPlugPlayControl() failed with status 0x%08x\n",
Status);
217 return deviceInstalled;
244 DPRINT(
"Unable to open subkey '%S'\n", DeviceId);
258 if (!pPartialInformation)
260 DPRINT1(
"RtlAllocateHeap() failed\n");
278 DPRINT1(
"NtQueryValueKey() failed with status 0x%08x\n",
Status);
279 if (pPartialInformation)
284 else if (pPartialInformation)
289 && !bDriverInstalled;
296 if (!bDriverInstalled)
298 if (pPartialInformation)
301 pPartialInformation =
NULL;
313 if (!pPartialInformation)
315 DPRINT(
"RtlAllocateHeap() failed\n");
333 if (pPartialInformation)
336 DPRINT1(
"NtQueryValueKey() failed with status 0x%08x\n",
Status);
339 else if (pPartialInformation)
344 && !bDriverInstalled;
351 if (!bDriverInstalled)
352 DPRINT(
"No driver available for %S\n", DeviceId);
375 if (ListEntry ==
NULL)
385 Timeout.QuadPart = -10000000LL;
415 PnpEventSize = 0x1000;
417 if (PnpEvent ==
NULL)
425 DPRINT(
"Calling NtGetPlugPlayEvent()\n");
433 PnpEventSize += 0x400;
435 if (NewPnpEvent ==
NULL)
440 PnpEvent = NewPnpEvent;
446 DPRINT1(
"NtGetPlugPlayEvent() failed (Status 0x%08lx)\n",
Status);
451 DPRINT(
"Received PnP Event\n");
456 ULONG DeviceIdLength;
479 DPRINT1(
"Not enough memory (size %lu)\n",
len);
485 DPRINT(
"Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
495 sizeof(ResponseData));
498 DPRINT1(
"NtPlugPlayControl(PlugPlayControlUserResponse) failed (Status 0x%08lx)\n",
Status);
533 Timeout.QuadPart = -10000000LL;
548 DPRINT1(
"WaitNoPendingInstallEvents() failed to wait!\n");
575 DPRINT1(
"Could not create the Pending-Install Event! (Status 0x%08lx)\n",
Status);
590 DPRINT1(
"Could not create the List Event! (Status 0x%08lx)\n",
Status);
599 DPRINT1(
"Could not create the List Mutex! (Status 0x%08lx)\n",
Status);
608 DPRINT1(
"NtOpenKey('%wZ') failed (Status 0x%08lx)\n", &EnumU,
Status);
616 DPRINT1(
"NtCreateKey('%wZ') failed (Status 0x%08lx)\n", &ServicesU,
Status);
633 DPRINT1(
"Failed to create the PnP event thread (Status 0x%08lx)\n",
Status);
651 DPRINT1(
"Failed to create the device installation thread (Status 0x%08lx)\n",
Status);
static ULONG NTAPI DeviceInstallThread(IN PVOID Parameter)
static HANDLE hDeviceInstallThread
NTSTATUS InitializeUserModePnpManager(IN HINF *phSetupInf)
VOID TerminateUserModePnpManager(VOID)
static ULONG NTAPI PnpEventThread(IN PVOID Parameter)
static HANDLE hDeviceInstallListNotEmpty
static BOOLEAN InstallDriver(IN HINF hInf, IN HANDLE hServices, IN HANDLE hDeviceKey, IN LPCWSTR DeviceId, IN LPCWSTR HardwareId)
BOOLEAN DisableUserModePnpManager(VOID)
static VOID InstallDevice(IN HINF hInf, IN HANDLE hEnum, IN HANDLE hServices, IN LPCWSTR DeviceId)
static BOOLEAN AreDriversLoaded(IN PCWSTR DeviceId)
static HANDLE hServicesKey
NTSTATUS WaitNoPendingInstallEvents(IN PLARGE_INTEGER Timeout OPTIONAL)
BOOLEAN EnableUserModePnpManager(VOID)
static HANDLE hDeviceInstallListMutex
static HANDLE hNoPendingInstalls
static LIST_ENTRY DeviceInstallListHead
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
#define SpInfFindFirstLine
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
#define InitializeObjectAttributes(p, n, a, r, s)
NTSTATUS NTAPI NtCreateMutant(OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN BOOLEAN InitialOwner)
NTSTATUS NTAPI NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL)
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
@ PlugPlayControlUserResponse
@ PlugPlayControlDeviceStatus
@ PlugPlayControlStartDevice
#define PNP_GET_DEVICE_STATUS
#define MUTANT_ALL_ACCESS
NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread(_In_ PVOID ThreadContext, _Out_ HANDLE *OutThreadHandle, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3, _Reserved_ PVOID Reserved4, _Reserved_ PVOID Reserved5, _Reserved_ PVOID Reserved6, _Reserved_ PVOID Reserved7, _Reserved_ PVOID Reserved8)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
@ KeyValuePartialInformation
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define REG_OPTION_NON_VOLATILE
#define REG_CREATED_NEW_KEY
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
#define UNREFERENCED_PARAMETER(P)
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
NTSTATUS NTAPI NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
NTSTATUS NTAPI NtSuspendThread(IN HANDLE ThreadHandle, OUT PULONG PreviousSuspendCount OPTIONAL)
NTSTATUS NTAPI NtGetPlugPlayEvent(IN ULONG Reserved1, IN ULONG Reserved2, OUT PPLUGPLAY_EVENT_BLOCK Buffer, IN ULONG BufferSize)
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
static UNICODE_STRING HardwareIDU
#define IsEqualGUID(rguid1, rguid2)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_BUFFER_TOO_SMALL
PULONG MinorVersion OPTIONAL
UNICODE_STRING DeviceInstance
UNICODE_STRING DeviceInstance
struct _PLUGPLAY_EVENT_BLOCK::@2401::@2404 TargetDevice
#define RTL_CONSTANT_STRING(s)
#define FIELD_OFFSET(t, f)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ WDFDRIVER Driver
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING HardwareID
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
#define SERVICE_KERNEL_DRIVER
_Inout_opt_ PVOID Parameter
#define NtCurrentThread()