ReactOS 0.4.16-dev-300-g2aadf2e
pnpmap.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for pnpmap.c:

Go to the source code of this file.

Classes

struct  _PNP_MAPPER_DEVICE_ID
 
struct  _PNP_DETECT_IDENTIFIER_MAP
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _PNP_MAPPER_DEVICE_ID PNP_MAPPER_DEVICE_ID
 
typedef struct _PNP_MAPPER_DEVICE_IDPPNP_MAPPER_DEVICE_ID
 
typedef struct _PNP_DETECT_IDENTIFIER_MAP PNP_DETECT_IDENTIFIER_MAP
 

Functions

static PWSTR IopMapPeripheralId (_In_ PCUNICODE_STRING Value, _In_ PPNP_MAPPER_DEVICE_ID DeviceList)
 
static PWSTR IopMapDetectedDeviceId (_In_ PUNICODE_STRING DetectId, _In_ PUNICODE_STRING Value, _Out_ PULONG DeviceIndex)
 
static NTSTATUS IopEnumerateDetectedDevices (_In_ HANDLE hBaseKey, _In_opt_ PUNICODE_STRING RelativePath, _In_ HANDLE hRootKey, _In_ BOOLEAN EnumerateSubKeys, _In_opt_ PCM_FULL_RESOURCE_DESCRIPTOR BootResources, _In_opt_ ULONG BootResourcesLength, _In_ PCM_FULL_RESOURCE_DESCRIPTOR ParentBootResources, _In_ ULONG ParentBootResourcesLength)
 
static BOOLEAN IopIsFirmwareMapperDisabled (VOID)
 
NTSTATUS NTAPI IopUpdateRootKey (VOID)
 

Variables

static UNICODE_STRING IdentifierU = RTL_CONSTANT_STRING(L"Identifier")
 
static UNICODE_STRING HardwareIDU = RTL_CONSTANT_STRING(L"HardwareID")
 
static UNICODE_STRING ConfigurationDataU = RTL_CONSTANT_STRING(L"Configuration Data")
 
static UNICODE_STRING BootConfigU = RTL_CONSTANT_STRING(L"BootConfig")
 
static UNICODE_STRING LogConfU = RTL_CONSTANT_STRING(L"LogConf")
 
static PNP_MAPPER_DEVICE_ID KeyboardMap []
 
static PNP_MAPPER_DEVICE_ID PointerMap []
 
static PNP_DETECT_IDENTIFIER_MAP PnPMap []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file pnpmap.c.

Typedef Documentation

◆ PNP_DETECT_IDENTIFIER_MAP

◆ PNP_MAPPER_DEVICE_ID

◆ PPNP_MAPPER_DEVICE_ID

Function Documentation

◆ IopEnumerateDetectedDevices()

static NTSTATUS IopEnumerateDetectedDevices ( _In_ HANDLE  hBaseKey,
_In_opt_ PUNICODE_STRING  RelativePath,
_In_ HANDLE  hRootKey,
_In_ BOOLEAN  EnumerateSubKeys,
_In_opt_ PCM_FULL_RESOURCE_DESCRIPTOR  BootResources,
_In_opt_ ULONG  BootResourcesLength,
_In_ PCM_FULL_RESOURCE_DESCRIPTOR  ParentBootResources,
_In_ ULONG  ParentBootResourcesLength 
)
static

Definition at line 153 of file pnpmap.c.

162{
163 HANDLE hDevicesKey = NULL;
164 ULONG KeyIndex = 0;
165 PKEY_BASIC_INFORMATION pDeviceInformation = NULL;
166 ULONG DeviceInfoLength = sizeof(KEY_BASIC_INFORMATION) + 50 * sizeof(WCHAR);
168
169 if (!BootResources && RelativePath)
170 {
171 Status = IopOpenRegistryKeyEx(&hDevicesKey, hBaseKey, RelativePath, KEY_ENUMERATE_SUB_KEYS);
172
173 if (!NT_SUCCESS(Status))
174 {
175 DPRINT("ZwOpenKey() failed with status 0x%08lx\n", Status);
176 goto cleanup;
177 }
178 }
179 else
180 hDevicesKey = hBaseKey;
181
182 pDeviceInformation = ExAllocatePool(PagedPool, DeviceInfoLength);
183 if (!pDeviceInformation)
184 {
185 DPRINT("ExAllocatePool() failed\n");
187 goto cleanup;
188 }
189
190 while (TRUE)
191 {
193 HANDLE hDeviceKey = NULL;
194 HANDLE hLevel1Key, hLevel2Key = NULL, hLogConf;
195 UNICODE_STRING Level2NameU;
196 WCHAR Level2Name[5];
197 PKEY_VALUE_PARTIAL_INFORMATION pValueInformation = NULL;
198 ULONG ValueInfoLength = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 50 * sizeof(WCHAR);
201
202 UNICODE_STRING HardwareIdKey;
203 PWSTR pHardwareId;
204 ULONG DeviceIndex = 0;
205
206 Status = ZwEnumerateKey(hDevicesKey,
207 KeyIndex,
209 pDeviceInformation,
210 DeviceInfoLength,
211 &RequiredSize);
212
214 break;
216 {
217 ExFreePool(pDeviceInformation);
218 DeviceInfoLength = RequiredSize;
219 pDeviceInformation = ExAllocatePool(PagedPool, DeviceInfoLength);
220
221 if (!pDeviceInformation)
222 {
223 DPRINT("ExAllocatePool() failed\n");
225 goto cleanup;
226 }
227
228 Status = ZwEnumerateKey(hDevicesKey,
229 KeyIndex,
231 pDeviceInformation,
232 DeviceInfoLength,
233 &RequiredSize);
234 }
235
236 if (!NT_SUCCESS(Status))
237 {
238 DPRINT("ZwEnumerateKey() failed with status 0x%08lx\n", Status);
239 goto cleanup;
240 }
241 KeyIndex++;
242
243 /* Open device key */
244 DeviceName.Length = DeviceName.MaximumLength = (USHORT)pDeviceInformation->NameLength;
245 DeviceName.Buffer = pDeviceInformation->Name;
246
247 if (BootResources)
248 {
250 hDevicesKey,
251 &DeviceName,
252 hRootKey,
253 TRUE,
254 NULL,
255 0,
256 BootResources,
257 BootResourcesLength);
258
259 if (!NT_SUCCESS(Status))
260 goto cleanup;
261
262 continue;
263 }
264
265 pValueInformation = ExAllocatePool(PagedPool, ValueInfoLength);
266 if (!pValueInformation)
267 {
268 DPRINT("ExAllocatePool() failed\n");
270 goto cleanup;
271 }
272
273 Status = IopOpenRegistryKeyEx(&hDeviceKey, hDevicesKey, &DeviceName,
274 KEY_QUERY_VALUE + (EnumerateSubKeys ? KEY_ENUMERATE_SUB_KEYS : 0));
275
276 if (!NT_SUCCESS(Status))
277 {
278 DPRINT("ZwOpenKey() failed with status 0x%08lx\n", Status);
279 goto cleanup;
280 }
281
282 /* Read boot resources, and add then to parent ones */
283 Status = ZwQueryValueKey(hDeviceKey,
286 pValueInformation,
287 ValueInfoLength,
288 &RequiredSize);
289
291 {
292 ExFreePool(pValueInformation);
293 ValueInfoLength = RequiredSize;
294 pValueInformation = ExAllocatePool(PagedPool, ValueInfoLength);
295
296 if (!pValueInformation)
297 {
298 DPRINT("ExAllocatePool() failed\n");
299 ZwDeleteKey(hLevel2Key);
301 goto cleanup;
302 }
303
304 Status = ZwQueryValueKey(hDeviceKey,
307 pValueInformation,
308 ValueInfoLength,
309 &RequiredSize);
310 }
311
313 {
314 BootResources = ParentBootResources;
315 BootResourcesLength = ParentBootResourcesLength;
316 }
317 else if (!NT_SUCCESS(Status))
318 {
319 DPRINT("ZwQueryValueKey() failed with status 0x%08lx\n", Status);
320 goto nextdevice;
321 }
322 else if (pValueInformation->Type != REG_FULL_RESOURCE_DESCRIPTOR)
323 {
324 DPRINT("Wrong registry type: got 0x%lx, expected 0x%lx\n", pValueInformation->Type, REG_FULL_RESOURCE_DESCRIPTOR);
325 goto nextdevice;
326 }
327 else
328 {
329 static const ULONG Header = FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors);
330
331 /* Concatenate current resources and parent ones */
332 if (ParentBootResourcesLength == 0)
333 BootResourcesLength = pValueInformation->DataLength;
334 else
335 BootResourcesLength = ParentBootResourcesLength
336 + pValueInformation->DataLength
337 - Header;
338
339 BootResources = ExAllocatePool(PagedPool, BootResourcesLength);
340 if (!BootResources)
341 {
342 DPRINT("ExAllocatePool() failed\n");
343 goto nextdevice;
344 }
345
346 if (ParentBootResourcesLength < sizeof(CM_FULL_RESOURCE_DESCRIPTOR))
347 {
348 RtlCopyMemory(BootResources, pValueInformation->Data, pValueInformation->DataLength);
349 }
350 else if (ParentBootResources->PartialResourceList.PartialDescriptors[ParentBootResources->PartialResourceList.Count - 1].Type == CmResourceTypeDeviceSpecific)
351 {
352 RtlCopyMemory(BootResources, pValueInformation->Data, pValueInformation->DataLength);
354 (PVOID)((ULONG_PTR)BootResources + pValueInformation->DataLength),
355 (PVOID)((ULONG_PTR)ParentBootResources + Header),
356 ParentBootResourcesLength - Header);
357 BootResources->PartialResourceList.Count += ParentBootResources->PartialResourceList.Count;
358 }
359 else
360 {
361 RtlCopyMemory(BootResources, pValueInformation->Data, Header);
363 (PVOID)((ULONG_PTR)BootResources + Header),
364 (PVOID)((ULONG_PTR)ParentBootResources + Header),
365 ParentBootResourcesLength - Header);
367 (PVOID)((ULONG_PTR)BootResources + ParentBootResourcesLength),
368 pValueInformation->Data + Header,
369 pValueInformation->DataLength - Header);
370 BootResources->PartialResourceList.Count += ParentBootResources->PartialResourceList.Count;
371 }
372 }
373
374 if (EnumerateSubKeys)
375 {
377 hDeviceKey,
378 RelativePath,
379 hRootKey,
380 TRUE,
381 BootResources,
382 BootResourcesLength,
383 ParentBootResources,
384 ParentBootResourcesLength);
385
386 if (!NT_SUCCESS(Status))
387 goto cleanup;
388 }
389
390 /* Read identifier */
391 Status = ZwQueryValueKey(hDeviceKey,
394 pValueInformation,
395 ValueInfoLength,
396 &RequiredSize);
397
399 {
400 ExFreePool(pValueInformation);
401 ValueInfoLength = RequiredSize;
402 pValueInformation = ExAllocatePool(PagedPool, ValueInfoLength);
403
404 if (!pValueInformation)
405 {
406 DPRINT("ExAllocatePool() failed\n");
408 goto cleanup;
409 }
410
411 Status = ZwQueryValueKey(hDeviceKey,
414 pValueInformation,
415 ValueInfoLength,
416 &RequiredSize);
417 }
418
419 if (!NT_SUCCESS(Status))
420 {
422 {
423 DPRINT("ZwQueryValueKey() failed with status 0x%08lx\n", Status);
424 goto nextdevice;
425 }
426 ValueName.Length = ValueName.MaximumLength = 0;
427 }
428 else if (pValueInformation->Type != REG_SZ)
429 {
430 DPRINT("Wrong registry type: got 0x%lx, expected 0x%lx\n", pValueInformation->Type, REG_SZ);
431 goto nextdevice;
432 }
433 else
434 {
435 /* Assign hardware id to this device */
436 ValueName.Length = ValueName.MaximumLength = (USHORT)pValueInformation->DataLength;
437 ValueName.Buffer = (PWCHAR)pValueInformation->Data;
438 if (ValueName.Length >= sizeof(WCHAR) && ValueName.Buffer[ValueName.Length / sizeof(WCHAR) - 1] == UNICODE_NULL)
439 ValueName.Length -= sizeof(WCHAR);
440 }
441
442 pHardwareId = IopMapDetectedDeviceId(RelativePath, &ValueName, &DeviceIndex);
443 if (!pHardwareId)
444 {
445 /* Unknown key path */
446 DPRINT("Unknown key path '%wZ' value '%wZ'\n", RelativePath, &ValueName);
447 goto nextdevice;
448 }
449
450 /* Prepare hardware id key (hardware id value without final \0) */
451 HardwareIdKey.Length = (USHORT)wcslen(pHardwareId) * sizeof(WCHAR);
452 HardwareIdKey.MaximumLength = HardwareIdKey.Length + sizeof(UNICODE_NULL) * 2;
453 HardwareIdKey.Buffer = pHardwareId;
454
455 /* Add the detected device to Root key */
457
458 Status = ZwCreateKey(
459 &hLevel1Key,
462 0,
463 NULL,
465 NULL);
466
467 if (!NT_SUCCESS(Status))
468 {
469 DPRINT("ZwCreateKey() failed with status 0x%08lx\n", Status);
470 goto nextdevice;
471 }
472
473 swprintf(Level2Name, L"%04lu", DeviceIndex);
474 RtlInitUnicodeString(&Level2NameU, Level2Name);
476
477 Status = ZwCreateKey(
478 &hLevel2Key,
481 0,
482 NULL,
484 NULL);
485
486 ZwClose(hLevel1Key);
487 if (!NT_SUCCESS(Status))
488 {
489 DPRINT("ZwCreateKey() failed with status 0x%08lx\n", Status);
490 goto nextdevice;
491 }
492
493 DPRINT("Found %wZ #%lu (%wZ)\n", &ValueName, DeviceIndex, &HardwareIdKey);
494 Status = ZwSetValueKey(hLevel2Key, &HardwareIDU, 0, REG_MULTI_SZ, HardwareIdKey.Buffer, HardwareIdKey.MaximumLength);
495
496 if (!NT_SUCCESS(Status))
497 {
498 DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
499 ZwDeleteKey(hLevel2Key);
500 goto nextdevice;
501 }
502
503 /* Create 'LogConf' subkey */
505
506 Status = ZwCreateKey(
507 &hLogConf,
510 0,
511 NULL,
513 NULL);
514
515 if (!NT_SUCCESS(Status))
516 {
517 DPRINT("ZwCreateKey() failed with status 0x%08lx\n", Status);
518 ZwDeleteKey(hLevel2Key);
519 goto nextdevice;
520 }
521
522 if (BootResourcesLength >= sizeof(CM_FULL_RESOURCE_DESCRIPTOR))
523 {
524 PUCHAR CmResourceList;
525 ULONG ListCount;
526
527 CmResourceList = ExAllocatePool(PagedPool, BootResourcesLength + sizeof(ULONG));
528 if (!CmResourceList)
529 {
530 ZwClose(hLogConf);
531 ZwDeleteKey(hLevel2Key);
532 goto nextdevice;
533 }
534
535 /* Add the list count (1st member of CM_RESOURCE_LIST) */
536 ListCount = 1;
537 RtlCopyMemory(CmResourceList,
538 &ListCount,
539 sizeof(ULONG));
540
541 /* Now add the actual list (2nd member of CM_RESOURCE_LIST) */
542 RtlCopyMemory(CmResourceList + sizeof(ULONG),
543 BootResources,
544 BootResourcesLength);
545
546 /* Save boot resources to 'LogConf\BootConfig' */
547 Status = ZwSetValueKey(hLogConf,
549 0,
551 CmResourceList,
552 BootResourcesLength + sizeof(ULONG));
553
554 ExFreePool(CmResourceList);
555
556 if (!NT_SUCCESS(Status))
557 {
558 DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
559 ZwClose(hLogConf);
560 ZwDeleteKey(hLevel2Key);
561 goto nextdevice;
562 }
563 }
564 ZwClose(hLogConf);
565
566nextdevice:
567 if (BootResources && BootResources != ParentBootResources)
568 {
569 ExFreePool(BootResources);
570 BootResources = NULL;
571 }
572 if (hLevel2Key)
573 {
574 ZwClose(hLevel2Key);
575 hLevel2Key = NULL;
576 }
577 if (hDeviceKey)
578 {
579 ZwClose(hDeviceKey);
580 hDeviceKey = NULL;
581 }
582 if (pValueInformation)
583 ExFreePool(pValueInformation);
584 }
585
587
588cleanup:
589 if (hDevicesKey && hDevicesKey != hBaseKey)
590 ZwClose(hDevicesKey);
591 if (pDeviceInformation)
592 ExFreePool(pDeviceInformation);
593
594 return Status;
595}
LONG NTSTATUS
Definition: precomp.h:26
Definition: Header.h:9
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static void cleanup(void)
Definition: main.c:1335
#define swprintf
Definition: precomp.h:40
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:25
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define REG_SZ
Definition: layer.c:22
if(dx< 0)
Definition: linetemp.h:194
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyBasicInformation
Definition: nt_native.h:1131
@ KeyValuePartialInformation
Definition: nt_native.h:1182
struct _KEY_BASIC_INFORMATION KEY_BASIC_INFORMATION
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503
#define UNICODE_NULL
NTSTATUS NTAPI IopOpenRegistryKeyEx(PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
Definition: pnpmgr.c:885
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
static UNICODE_STRING ConfigurationDataU
Definition: pnpmap.c:35
static NTSTATUS IopEnumerateDetectedDevices(_In_ HANDLE hBaseKey, _In_opt_ PUNICODE_STRING RelativePath, _In_ HANDLE hRootKey, _In_ BOOLEAN EnumerateSubKeys, _In_opt_ PCM_FULL_RESOURCE_DESCRIPTOR BootResources, _In_opt_ ULONG BootResourcesLength, _In_ PCM_FULL_RESOURCE_DESCRIPTOR ParentBootResources, _In_ ULONG ParentBootResourcesLength)
Definition: pnpmap.c:153
static UNICODE_STRING LogConfU
Definition: pnpmap.c:37
static UNICODE_STRING BootConfigU
Definition: pnpmap.c:36
static UNICODE_STRING IdentifierU
Definition: pnpmap.c:33
static PWSTR IopMapDetectedDeviceId(_In_ PUNICODE_STRING DetectId, _In_ PUNICODE_STRING Value, _Out_ PULONG DeviceIndex)
Definition: pnpmap.c:122
static UNICODE_STRING HardwareIDU
Definition: pnpmap.c:34
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:73
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IopEnumerateDetectedDevices(), and IopUpdateRootKey().

◆ IopIsFirmwareMapperDisabled()

static BOOLEAN IopIsFirmwareMapperDisabled ( VOID  )
static

Definition at line 600 of file pnpmap.c.

601{
602 UNICODE_STRING KeyPathU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CURRENTCONTROLSET\\Control\\Pnp");
603 UNICODE_STRING KeyNameU = RTL_CONSTANT_STRING(L"DisableFirmwareMapper");
605 HANDLE hPnpKey;
606 PKEY_VALUE_PARTIAL_INFORMATION KeyInformation;
607 ULONG DesiredLength, Length;
608 ULONG KeyValue = 0;
610
612 Status = ZwOpenKey(&hPnpKey, KEY_QUERY_VALUE, &ObjectAttributes);
613 if (NT_SUCCESS(Status))
614 {
615 Status = ZwQueryValueKey(hPnpKey,
616 &KeyNameU,
618 NULL,
619 0,
620 &DesiredLength);
623 {
624 Length = DesiredLength;
625 KeyInformation = ExAllocatePool(PagedPool, Length);
626 if (KeyInformation)
627 {
628 Status = ZwQueryValueKey(hPnpKey,
629 &KeyNameU,
631 KeyInformation,
632 Length,
633 &DesiredLength);
634 if (NT_SUCCESS(Status) && KeyInformation->DataLength == sizeof(ULONG))
635 {
636 KeyValue = (ULONG)(*KeyInformation->Data);
637 }
638 else
639 {
640 DPRINT1("ZwQueryValueKey(%wZ%wZ) failed\n", &KeyPathU, &KeyNameU);
641 }
642
643 ExFreePool(KeyInformation);
644 }
645 else
646 {
647 DPRINT1("Failed to allocate memory for registry query\n");
648 }
649 }
650 else
651 {
652 DPRINT1("ZwQueryValueKey(%wZ%wZ) failed with status 0x%08lx\n", &KeyPathU, &KeyNameU, Status);
653 }
654
655 ZwClose(hPnpKey);
656 }
657 else
658 {
659 DPRINT1("ZwOpenKey(%wZ) failed with status 0x%08lx\n", &KeyPathU, Status);
660 }
661
662 DPRINT("Firmware mapper is %s\n", KeyValue != 0 ? "disabled" : "enabled");
663
664 return (KeyValue != 0) ? TRUE : FALSE;
665}
#define DPRINT1
Definition: precomp.h:8
#define FALSE
Definition: types.h:117
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IopUpdateRootKey().

◆ IopMapDetectedDeviceId()

static PWSTR IopMapDetectedDeviceId ( _In_ PUNICODE_STRING  DetectId,
_In_ PUNICODE_STRING  Value,
_Out_ PULONG  DeviceIndex 
)
static

Definition at line 122 of file pnpmap.c.

126{
127 ULONG i;
128 UNICODE_STRING CmpId;
129
130 if (!DetectId)
131 return NULL;
132
133 for (i = 0; PnPMap[i].DetectId; i++)
134 {
135 RtlInitUnicodeString(&CmpId, PnPMap[i].DetectId);
136
137 if (RtlCompareUnicodeString(DetectId, &CmpId, FALSE) == 0)
138 {
139 *DeviceIndex = PnPMap[i].Counter++;
140
141 if (PnPMap[i].PeripheralMap)
142 return IopMapPeripheralId(Value, PnPMap[i].PeripheralMap);
143 break;
144 }
145 }
146
147 return PnPMap[i].PnPId;
148}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PNP_DETECT_IDENTIFIER_MAP PnPMap[]
Definition: pnpmap.c:84
static PWSTR IopMapPeripheralId(_In_ PCUNICODE_STRING Value, _In_ PPNP_MAPPER_DEVICE_ID DeviceList)
Definition: pnpmap.c:101
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by IopEnumerateDetectedDevices().

◆ IopMapPeripheralId()

static PWSTR IopMapPeripheralId ( _In_ PCUNICODE_STRING  Value,
_In_ PPNP_MAPPER_DEVICE_ID  DeviceList 
)
static

Definition at line 101 of file pnpmap.c.

104{
105 ULONG i;
106 UNICODE_STRING CmpId;
107
108 for (i = 0; DeviceList[i].TypeName; i++)
109 {
110 RtlInitUnicodeString(&CmpId, DeviceList[i].TypeName);
111
112 if (RtlCompareUnicodeString(Value, &CmpId, FALSE) == 0)
113 break;
114 }
115
116 return DeviceList[i].PnPId;
117}
PDEVICE_LIST DeviceList
Definition: utils.c:27

Referenced by IopMapDetectedDeviceId().

◆ IopUpdateRootKey()

NTSTATUS NTAPI IopUpdateRootKey ( VOID  )

Definition at line 670 of file pnpmap.c.

671{
672 UNICODE_STRING EnumU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum");
673 UNICODE_STRING RootPathU = RTL_CONSTANT_STRING(L"Root");
674 UNICODE_STRING MultiKeyPathU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter");
676 HANDLE hEnum, hRoot;
678
681 if (!NT_SUCCESS(Status))
682 {
683 DPRINT1("ZwCreateKey() failed with status 0x%08lx\n", Status);
684 return Status;
685 }
686
689 ZwClose(hEnum);
690 if (!NT_SUCCESS(Status))
691 {
692 DPRINT1("ZwOpenKey() failed with status 0x%08lx\n", Status);
693 return Status;
694 }
695
697 {
698 Status = IopOpenRegistryKeyEx(&hEnum, NULL, &MultiKeyPathU, KEY_ENUMERATE_SUB_KEYS);
699 if (!NT_SUCCESS(Status))
700 {
701 /* Nothing to do, don't return with an error status */
702 DPRINT("ZwOpenKey() failed with status 0x%08lx\n", Status);
703 ZwClose(hRoot);
704 return STATUS_SUCCESS;
705 }
707 hEnum,
708 NULL,
709 hRoot,
710 TRUE,
711 NULL,
712 0,
713 NULL,
714 0);
715 ZwClose(hEnum);
716 }
717 else
718 {
719 /* Enumeration is disabled */
721 }
722
723 ZwClose(hRoot);
724
725 return Status;
726}
static HTREEITEM hRoot
Definition: treeview.c:383
static BOOLEAN IopIsFirmwareMapperDisabled(VOID)
Definition: pnpmap.c:600

Referenced by IopInitializePlugPlayServices().

Variable Documentation

◆ BootConfigU

UNICODE_STRING BootConfigU = RTL_CONSTANT_STRING(L"BootConfig")
static

Definition at line 36 of file pnpmap.c.

Referenced by IopEnumerateDetectedDevices().

◆ ConfigurationDataU

UNICODE_STRING ConfigurationDataU = RTL_CONSTANT_STRING(L"Configuration Data")
static

Definition at line 35 of file pnpmap.c.

Referenced by IopEnumerateDetectedDevices().

◆ HardwareIDU

UNICODE_STRING HardwareIDU = RTL_CONSTANT_STRING(L"HardwareID")
static

Definition at line 34 of file pnpmap.c.

Referenced by InstallDevice(), and IopEnumerateDetectedDevices().

◆ IdentifierU

UNICODE_STRING IdentifierU = RTL_CONSTANT_STRING(L"Identifier")
static

Definition at line 33 of file pnpmap.c.

Referenced by IopEnumerateDetectedDevices(), and IsAcpiComputer().

◆ KeyboardMap

PNP_MAPPER_DEVICE_ID KeyboardMap[]
static
Initial value:
=
{
{ L"XT_83KEY", L"*PNP0300\0" },
{ L"PCAT_86KEY", L"*PNP0301\0" },
{ L"PCXT_84KEY", L"*PNP0302\0" },
{ L"XT_84KEY", L"*PNP0302\0" },
{ L"101-KEY", L"*PNP0303\0" },
{ L"OLI_83KEY", L"*PNP0304\0" },
{ L"ATT_301", L"*PNP0304\0" },
{ L"OLI_102KEY", L"*PNP0305\0" },
{ L"OLI_86KEY", L"*PNP0306\0" },
{ L"OLI_A101_102KEY", L"*PNP0309\0" },
{ L"ATT_302", L"*PNP030a\0" },
{ L"PCAT_ENHANCED", L"*PNP030b\0" },
{ L"PC98_106KEY", L"*nEC1300\0" },
{ L"PC98_LaptopKEY", L"*nEC1300\0" },
{ L"PC98_N106KEY", L"*PNP0303\0" },
{ NULL, NULL }
}

Definition at line 45 of file pnpmap.c.

◆ LogConfU

UNICODE_STRING LogConfU = RTL_CONSTANT_STRING(L"LogConf")
static

Definition at line 37 of file pnpmap.c.

Referenced by IopEnumerateDetectedDevices().

◆ PnPMap

PNP_DETECT_IDENTIFIER_MAP PnPMap[]
static
Initial value:
=
{
{ L"SerialController", L"*PNP0501\0", NULL, 0 },
{ L"KeyboardPeripheral", NULL, KeyboardMap, 0 },
{ L"PointerPeripheral", NULL, PointerMap, 0 },
{ L"ParallelController", L"*PNP0400\0", NULL, 0 },
{ L"FloppyDiskPeripheral", L"*PNP0700\0", NULL, 0 },
{ NULL, NULL, NULL, 0 }
}
static PNP_MAPPER_DEVICE_ID KeyboardMap[]
Definition: pnpmap.c:45
static PNP_MAPPER_DEVICE_ID PointerMap[]
Definition: pnpmap.c:67

Definition at line 84 of file pnpmap.c.

Referenced by IopMapDetectedDeviceId().

◆ PointerMap

PNP_MAPPER_DEVICE_ID PointerMap[]
static
Initial value:
=
{
{ L"PS2 MOUSE", L"*PNP0F0E\0" },
{ L"SERIAL MOUSE", L"*PNP0F0C\0" },
{ L"MICROSOFT PS2 MOUSE", L"*PNP0F03\0" },
{ L"LOGITECH PS2 MOUSE", L"*PNP0F12\0" },
{ L"MICROSOFT INPORT MOUSE", L"*PNP0F02\0" },
{ L"MICROSOFT SERIAL MOUSE", L"*PNP0F01\0" },
{ L"MICROSOFT BALLPOINT SERIAL MOUSE", L"*PNP0F09\0" },
{ L"LOGITECH SERIAL MOUSE", L"*PNP0F08\0" },
{ L"MICROSOFT BUS MOUSE", L"*PNP0F00\0" },
{ L"NEC PC-9800 BUS MOUSE", L"*nEC1F00\0" },
{ NULL, NULL }
}

Definition at line 67 of file pnpmap.c.