Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
3.1 KiB

  1. #include <ntddk.h>
  2. #include <irenum.h>
  3. #include <ircommdbg.h>
  4. extern ULONG EnumStaticDevice;
  5. #define DO_TYPE_PDO ' ODP'
  6. #define DO_TYPE_FDO ' ODF'
  7. #define DO_TYPE_DEL_PDO 'ODPx'
  8. #define DO_TYPE_DEL_FDO 'ODFx'
  9. typedef KEVENT PASSIVE_LOCK, *PPASSICE_LOCK;
  10. #define INIT_PASSIVE_LOCK(_lock) KeInitializeEvent(_lock,SynchronizationEvent,TRUE)
  11. #define ACQUIRE_PASSIVE_LOCK(_lock) KeWaitForSingleObject(_lock,Executive,KernelMode, FALSE, NULL)
  12. #define RELEASE_PASSIVE_LOCK(_lock) KeSetEvent(_lock,IO_NO_INCREMENT,FALSE)
  13. #define IRENUM_COMPAT_ID L"PNPC103"
  14. #define IRENUM_PREFIX L"IRENUM\\"
  15. #define MAX_COMPAT_IDS 17
  16. typedef struct _IR_DEVICE {
  17. ULONG DeviceId;
  18. WCHAR DeviceName[24];
  19. UCHAR Hint1;
  20. UCHAR Hint2;
  21. PWSTR HardwareId;
  22. LONG CompatIdCount;
  23. PWSTR CompatId[MAX_COMPAT_IDS];
  24. PWSTR Name;
  25. PWSTR Manufacturer;
  26. ULONG PresentCount;
  27. BOOLEAN InUse;
  28. BOOLEAN Enumerated;
  29. BOOLEAN Static;
  30. BOOLEAN Printer;
  31. BOOLEAN Modem;
  32. PDEVICE_OBJECT Pdo;
  33. } IR_DEVICE, *PIR_DEVICE;
  34. typedef PVOID ENUM_HANDLE;
  35. typedef struct _FDO_DEVICE_EXTENSION {
  36. ULONG DoType;
  37. PDEVICE_OBJECT DeviceObject;
  38. PDEVICE_OBJECT Pdo;
  39. PDEVICE_OBJECT LowerDevice;
  40. ENUM_HANDLE EnumHandle;
  41. BOOLEAN CreateStaticDevice;
  42. BOOLEAN Removing;
  43. BOOLEAN Removed;
  44. } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
  45. typedef struct _PDO_DEVICE_EXTENSION {
  46. ULONG DoType;
  47. PDEVICE_OBJECT ParentFdo;
  48. PIR_DEVICE DeviceDescription;
  49. } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
  50. NTSTATUS
  51. IrEnumAddDevice(
  52. IN PDRIVER_OBJECT DriverObject,
  53. IN PDEVICE_OBJECT Pdo
  54. );
  55. NTSTATUS
  56. IrEnumPnP(
  57. IN PDEVICE_OBJECT DeviceObject,
  58. IN PIRP Irp
  59. );
  60. NTSTATUS
  61. IrEnumPower(
  62. IN PDEVICE_OBJECT DeviceObject,
  63. IN PIRP Irp
  64. );
  65. NTSTATUS
  66. IrEnumWmi(
  67. IN PDEVICE_OBJECT DeviceObject,
  68. IN PIRP Irp
  69. );
  70. #define LEAVE_NEXT_AS_IS FALSE
  71. #define COPY_CURRENT_TO_NEXT TRUE
  72. NTSTATUS
  73. WaitForLowerDriverToCompleteIrp(
  74. PDEVICE_OBJECT TargetDeviceObject,
  75. PIRP Irp,
  76. BOOLEAN CopyCurrentToNext
  77. );
  78. NTSTATUS
  79. ForwardIrp(
  80. PDEVICE_OBJECT NextDevice,
  81. PIRP Irp
  82. );
  83. //
  84. // enumeration object
  85. //
  86. NTSTATUS
  87. CreateEnumObject(
  88. PDEVICE_OBJECT Fdo,
  89. ENUM_HANDLE *Object,
  90. BOOLEAN CreateStaticDevice
  91. );
  92. VOID
  93. CloseEnumObject(
  94. ENUM_HANDLE Handle
  95. );
  96. NTSTATUS
  97. GetDeviceList(
  98. ENUM_HANDLE Handle,
  99. PIRP Irp
  100. );
  101. VOID
  102. RemoveDevice(
  103. ENUM_HANDLE Handle,
  104. PIR_DEVICE IrDevice
  105. );
  106. //
  107. // child irp handlers
  108. //
  109. NTSTATUS
  110. IrEnumPdoPnp (
  111. IN PDEVICE_OBJECT DeviceObject,
  112. IN PIRP Irp
  113. );
  114. NTSTATUS
  115. IrEnumPdoPower(
  116. IN PDEVICE_OBJECT DeviceObject,
  117. IN PIRP Irp
  118. );
  119. NTSTATUS
  120. IrEnumPdoWmi(
  121. IN PDEVICE_OBJECT DeviceObject,
  122. IN PIRP Irp
  123. );
  124. NTSTATUS
  125. GetRegistryKeyValue(
  126. IN PDEVICE_OBJECT Pdo,
  127. IN ULONG DevInstKeyType,
  128. IN PWCHAR KeyNameString,
  129. IN PVOID Data,
  130. IN ULONG DataLength
  131. );