ReactOS 0.4.15-dev-7934-g1dc8d80
pnpreport.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for pnpreport.c:

Go to the source code of this file.

Classes

struct  _INTERNAL_WORK_QUEUE_ITEM
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _INTERNAL_WORK_QUEUE_ITEM INTERNAL_WORK_QUEUE_ITEM
 
typedef struct _INTERNAL_WORK_QUEUE_ITEMPINTERNAL_WORK_QUEUE_ITEM
 

Functions

NTSTATUS IopSetDeviceInstanceData (HANDLE InstanceKey, PDEVICE_NODE DeviceNode)
 
NTSTATUS PpSetCustomTargetEvent (IN PDEVICE_OBJECT DeviceObject, IN OUT PKEVENT SyncEvent OPTIONAL, IN OUT PNTSTATUS SyncStatus OPTIONAL, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL, IN PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure)
 
PWCHAR IopGetInterfaceTypeString (INTERFACE_TYPE IfType)
 
VOID NTAPI IopReportTargetDeviceChangeAsyncWorker (PVOID Context)
 
NTSTATUS NTAPI IoReportDetectedDevice (_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
 
NTSTATUS NTAPI IoReportResourceForDetection (IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected)
 
VOID NTAPI IopSetEvent (IN PVOID Context)
 
NTSTATUS NTAPI IoReportTargetDeviceChange (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure)
 
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file pnpreport.c.

Typedef Documentation

◆ INTERNAL_WORK_QUEUE_ITEM

◆ PINTERNAL_WORK_QUEUE_ITEM

Function Documentation

◆ IopGetInterfaceTypeString()

PWCHAR IopGetInterfaceTypeString ( INTERFACE_TYPE  IfType)

Definition at line 42 of file pnpreport.c.

43{
44 switch (IfType)
45 {
46 case Internal:
47 return L"Internal";
48
49 case Isa:
50 return L"Isa";
51
52 case Eisa:
53 return L"Eisa";
54
55 case MicroChannel:
56 return L"MicroChannel";
57
58 case TurboChannel:
59 return L"TurboChannel";
60
61 case PCIBus:
62 return L"PCIBus";
63
64 case VMEBus:
65 return L"VMEBus";
66
67 case NuBus:
68 return L"NuBus";
69
70 case PCMCIABus:
71 return L"PCMCIABus";
72
73 case CBus:
74 return L"CBus";
75
76 case MPIBus:
77 return L"MPIBus";
78
79 case MPSABus:
80 return L"MPSABus";
81
83 return L"ProcessorInternal";
84
85 case PNPISABus:
86 return L"PNPISABus";
87
88 case PNPBus:
89 return L"PNPBus";
90
91 case Vmcs:
92 return L"Vmcs";
93
94 default:
95 DPRINT1("Invalid bus type: %d\n", IfType);
96 return NULL;
97 }
98}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
@ Eisa
Definition: hwresource.cpp:139
@ VMEBus
Definition: hwresource.cpp:143
@ CBus
Definition: hwresource.cpp:146
@ TurboChannel
Definition: hwresource.cpp:141
@ PNPBus
Definition: hwresource.cpp:152
@ PCIBus
Definition: hwresource.cpp:142
@ MPIBus
Definition: hwresource.cpp:147
@ Vmcs
Definition: hwresource.cpp:153
@ MPSABus
Definition: hwresource.cpp:148
@ Internal
Definition: hwresource.cpp:137
@ NuBus
Definition: hwresource.cpp:144
@ MicroChannel
Definition: hwresource.cpp:140
@ PNPISABus
Definition: hwresource.cpp:151
@ ProcessorInternal
Definition: hwresource.cpp:149
@ Isa
Definition: hwresource.cpp:138
@ PCMCIABus
Definition: hwresource.cpp:145
#define L(x)
Definition: ntvdm.h:50

Referenced by IoReportDetectedDevice().

◆ IopReportTargetDeviceChangeAsyncWorker()

VOID NTAPI IopReportTargetDeviceChangeAsyncWorker ( PVOID  Context)

Definition at line 102 of file pnpreport.c.

103{
105
107 PpSetCustomTargetEvent(Item->PhysicalDeviceObject, NULL, NULL, Item->Callback, Item->Context, Item->NotificationStructure);
108 ObDereferenceObject(Item->PhysicalDeviceObject);
110}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
NTSTATUS PpSetCustomTargetEvent(IN PDEVICE_OBJECT DeviceObject, IN OUT PKEVENT SyncEvent OPTIONAL, IN OUT PNTSTATUS SyncStatus OPTIONAL, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL, IN PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure)
Definition: pnpreport.c:113
struct _INTERNAL_WORK_QUEUE_ITEM * PINTERNAL_WORK_QUEUE_ITEM
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by IoReportTargetDeviceChangeAsynchronous().

◆ IopSetDeviceInstanceData()

NTSTATUS IopSetDeviceInstanceData ( HANDLE  InstanceKey,
PDEVICE_NODE  DeviceNode 
)

Definition at line 606 of file pnpmgr.c.

608{
611 HANDLE LogConfKey, ControlKey, DeviceParamsKey;
612 ULONG ResCount;
615
616 DPRINT("IopSetDeviceInstanceData() called\n");
617
618 /* Create the 'LogConf' key */
619 RtlInitUnicodeString(&KeyName, L"LogConf");
621 &KeyName,
623 InstanceKey,
624 NULL);
625 Status = ZwCreateKey(&LogConfKey,
628 0,
629 NULL,
630 // FIXME? In r53694 it was silently turned from non-volatile into this,
631 // without any extra warning. Is this still needed??
633 NULL);
634 if (NT_SUCCESS(Status))
635 {
636 /* Set 'BootConfig' value */
637 if (DeviceNode->BootResources != NULL)
638 {
639 ResCount = DeviceNode->BootResources->Count;
640 if (ResCount != 0)
641 {
642 RtlInitUnicodeString(&KeyName, L"BootConfig");
643 Status = ZwSetValueKey(LogConfKey,
644 &KeyName,
645 0,
647 DeviceNode->BootResources,
649 }
650 }
651
652 /* Set 'BasicConfigVector' value */
653 if (DeviceNode->ResourceRequirements != NULL &&
654 DeviceNode->ResourceRequirements->ListSize != 0)
655 {
656 RtlInitUnicodeString(&KeyName, L"BasicConfigVector");
657 Status = ZwSetValueKey(LogConfKey,
658 &KeyName,
659 0,
661 DeviceNode->ResourceRequirements,
662 DeviceNode->ResourceRequirements->ListSize);
663 }
664
665 ZwClose(LogConfKey);
666 }
667
668 /* Set the 'ConfigFlags' value */
669 RtlInitUnicodeString(&KeyName, L"ConfigFlags");
670 Status = ZwQueryValueKey(InstanceKey,
671 &KeyName,
673 NULL,
674 0,
675 &ResultLength);
677 {
678 /* Write the default value */
679 ULONG DefaultConfigFlags = 0;
680 Status = ZwSetValueKey(InstanceKey,
681 &KeyName,
682 0,
683 REG_DWORD,
684 &DefaultConfigFlags,
685 sizeof(DefaultConfigFlags));
686 }
687
688 /* Create the 'Control' key */
689 RtlInitUnicodeString(&KeyName, L"Control");
691 &KeyName,
693 InstanceKey,
694 NULL);
695 Status = ZwCreateKey(&ControlKey,
696 0,
698 0,
699 NULL,
701 NULL);
702 if (NT_SUCCESS(Status))
703 ZwClose(ControlKey);
704
705 /* Create the 'Device Parameters' key and set the 'FirmwareIdentified' value for all ACPI-enumerated devices */
706 if (_wcsnicmp(DeviceNode->InstancePath.Buffer, L"ACPI\\", 5) == 0)
707 {
708 RtlInitUnicodeString(&KeyName, L"Device Parameters");
710 &KeyName,
712 InstanceKey,
713 NULL);
714 Status = ZwCreateKey(&DeviceParamsKey,
715 0,
717 0,
718 NULL,
720 NULL);
721 if (NT_SUCCESS(Status))
722 {
723 ULONG FirmwareIdentified = 1;
724 RtlInitUnicodeString(&KeyName, L"FirmwareIdentified");
725 Status = ZwSetValueKey(DeviceParamsKey,
726 &KeyName,
727 0,
728 REG_DWORD,
729 &FirmwareIdentified,
730 sizeof(FirmwareIdentified));
731
732 ZwClose(DeviceParamsKey);
733 }
734 }
735
736 DPRINT("IopSetDeviceInstanceData() done\n");
737
738 return Status;
739}
@ DeviceNode
Definition: Node.h:9
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValueBasicInformation
Definition: nt_native.h:1180
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:1237
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define DPRINT
Definition: sndvol32.h:71
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

Referenced by IoReportDetectedDevice().

◆ IopSetEvent()

VOID NTAPI IopSetEvent ( IN PVOID  Context)

Definition at line 435 of file pnpreport.c.

436{
438
439 /* Set the event */
441}
#define FALSE
Definition: types.h:117
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ IoReportDetectedDevice()

NTSTATUS NTAPI IoReportDetectedDevice ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ INTERFACE_TYPE  LegacyBusType,
_In_ ULONG  BusNumber,
_In_ ULONG  SlotNumber,
_In_opt_ PCM_RESOURCE_LIST  ResourceList,
_In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST  ResourceRequirements,
_In_ BOOLEAN  ResourceAssigned,
_Inout_ PDEVICE_OBJECT DeviceObject 
)

Definition at line 148 of file pnpreport.c.

157{
159 UNICODE_STRING DeviceReportedName = RTL_CONSTANT_STRING(L"DeviceReported");
164 HANDLE InstanceKey, ControlKey;
165 UNICODE_STRING ValueName, ServiceLongName, ServiceName;
166 WCHAR HardwareId[256];
167 PWCHAR IfString;
168 ULONG IdLength;
169 ULONG LegacyValue;
170 ULONG DeviceReported = 1;
171
172 DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n",
174
175 ServiceLongName = DriverObject->DriverExtension->ServiceKeyName;
176 ServiceName = ServiceLongName;
177
178 /* If the interface type is unknown, treat it as internal */
181
182 /* Get the string equivalent of the interface type */
184
185 /* If NULL is returned then it's a bad type */
186 if (!IfString)
188
189 /*
190 * Drivers that have been created via a direct IoCreateDriver() call
191 * have their ServiceKeyName set to \Driver\DriverName. We need to
192 * strip everything up to the last path separator and keep what remains.
193 */
195 {
196 /*
197 * Find the last path separator.
198 * NOTE: Since ServiceName is not necessarily NULL-terminated,
199 * we cannot use wcsrchr().
200 */
201 if (ServiceName.Buffer && ServiceName.Length >= sizeof(WCHAR))
202 {
203 ValueName.Length = 1;
204 ValueName.Buffer = ServiceName.Buffer + (ServiceName.Length / sizeof(WCHAR)) - 1;
205
206 while ((ValueName.Buffer > ServiceName.Buffer) && (*ValueName.Buffer != L'\\'))
207 {
208 --ValueName.Buffer;
209 ++ValueName.Length;
210 }
211 if (*ValueName.Buffer == L'\\')
212 {
213 ++ValueName.Buffer;
214 --ValueName.Length;
215 }
216 ValueName.Length *= sizeof(WCHAR);
217
218 /* Shorten the string */
219 ServiceName.MaximumLength -= (ServiceName.Length - ValueName.Length);
220 ServiceName.Length = ValueName.Length;
221 ServiceName.Buffer = ValueName.Buffer;
222 }
223 }
224
225 /* We use the caller's PDO if they supplied one */
226 UNICODE_STRING instancePath = {0};
228 {
229 Pdo = *DeviceObject;
230 }
231 else
232 {
233 /* Create the PDO */
234 Status = PnpRootCreateDevice(&ServiceName, &Pdo, &instancePath);
235 if (!NT_SUCCESS(Status))
236 {
237 DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status);
238 return Status;
239 }
240 }
241
242 /* Create the device node for the new PDO */
244 if (!DeviceNode)
245 {
246 DPRINT("PipAllocateDeviceNode() failed\n");
248 }
249
250 // The string comes from PnpRootCreateDevice, so it can be used right away
251 DeviceNode->InstancePath = instancePath;
252
253 /* Open a handle to the instance path key */
254 Status = IopCreateDeviceKeyPath(&DeviceNode->InstancePath, REG_OPTION_NON_VOLATILE, &InstanceKey);
255 if (!NT_SUCCESS(Status))
256 return Status;
257
258 /* Save the driver name */
259 RtlInitUnicodeString(&ValueName, L"Service");
260 Status = ZwSetValueKey(InstanceKey, &ValueName, 0, REG_SZ, ServiceLongName.Buffer, ServiceLongName.Length + sizeof(UNICODE_NULL));
261 if (!NT_SUCCESS(Status))
262 {
263 DPRINT("Failed to write the Service name value: 0x%x\n", Status);
264 }
265
266 /* Report as non-legacy driver */
268 LegacyValue = 0;
269 Status = ZwSetValueKey(InstanceKey, &ValueName, 0, REG_DWORD, &LegacyValue, sizeof(LegacyValue));
270 if (!NT_SUCCESS(Status))
271 {
272 DPRINT("Failed to write the Legacy value: 0x%x\n", Status);
273 }
274 Status = ZwSetValueKey(InstanceKey, &DeviceReportedName, 0, REG_DWORD, &DeviceReported, sizeof(DeviceReported));
275 if (!NT_SUCCESS(Status))
276 {
277 DPRINT("Failed to write the DeviceReported value: 0x%x\n", Status);
278 }
279
280 /* Set DeviceReported=1 in Control subkey */
282 &Control,
284 InstanceKey,
285 NULL);
286 Status = ZwCreateKey(&ControlKey,
289 0,
290 NULL,
292 NULL);
293 if (NT_SUCCESS(Status))
294 {
295 Status = ZwSetValueKey(ControlKey,
296 &DeviceReportedName,
297 0,
298 REG_DWORD,
299 &DeviceReported,
300 sizeof(DeviceReported));
301 ZwClose(ControlKey);
302 }
303 if (!NT_SUCCESS(Status))
304 {
305 DPRINT1("Failed to set ReportedDevice=1 for device %wZ (status 0x%08lx)\n", &instancePath, Status);
306 }
307
308 /* Add DETECTEDInterfaceType\DriverName */
309 IdLength = 0;
310 IdLength += swprintf(&HardwareId[IdLength],
311 L"DETECTED%ls\\%wZ",
312 IfString,
313 &ServiceName);
314 IdLength++;
315
316 /* Add DETECTED\DriverName */
317 IdLength += swprintf(&HardwareId[IdLength],
318 L"DETECTED\\%wZ",
319 &ServiceName);
320 IdLength++;
321
322 /* Terminate the string with another null */
323 HardwareId[IdLength++] = UNICODE_NULL;
324
325 /* Store the value for CompatibleIDs */
326 RtlInitUnicodeString(&ValueName, L"CompatibleIDs");
327 Status = ZwSetValueKey(InstanceKey, &ValueName, 0, REG_MULTI_SZ, HardwareId, IdLength * sizeof(WCHAR));
328 if (!NT_SUCCESS(Status))
329 {
330 DPRINT("Failed to write the compatible IDs: 0x%x\n", Status);
331 ZwClose(InstanceKey);
332 return Status;
333 }
334
335 // Set the device's DeviceDesc and LocationInformation fields
336 PiSetDevNodeText(DeviceNode, InstanceKey);
337
338 /* Assign the resources to the device node */
339 DeviceNode->BootResources = ResourceList;
340 DeviceNode->ResourceRequirements = ResourceRequirements;
341
342 /* Set appropriate flags */
343 if (DeviceNode->BootResources)
345
346 if (!DeviceNode->ResourceRequirements && !DeviceNode->BootResources)
348
349 /* Write the resource information to the registry */
351
352 /* If the caller didn't get the resources assigned for us, do it now */
353 if (!ResourceAssigned)
354 {
356
357 /* See if we failed */
358 if (!NT_SUCCESS(Status))
359 {
360 DPRINT("Assigning resources failed: 0x%x\n", Status);
361 ZwClose(InstanceKey);
362 return Status;
363 }
364 }
365
366 /* Close the instance key handle */
367 ZwClose(InstanceKey);
368
369 /* Register the given DO with PnP root if required */
372
375
376 // we still need to query IDs, send events and reenumerate this node
378
379 DPRINT("Reported device: %S (%wZ)\n", HardwareId, &DeviceNode->InstancePath);
380
382
383 /* Return the PDO */
385
386 return STATUS_SUCCESS;
387}
static WCHAR ServiceName[]
Definition: browser.c:19
#define swprintf
Definition: precomp.h:40
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
#define REG_SZ
Definition: layer.c:22
#define DNF_ENUMERATED
Definition: iotypes.h:174
@ DeviceNodeStartPostWork
Definition: iotypes.h:428
#define DNF_NO_RESOURCE_REQUIRED
Definition: iotypes.h:178
#define DNF_HAS_BOOT_CONFIG
Definition: iotypes.h:176
#define DNF_MADEUP
Definition: iotypes.h:170
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNICODE_NULL
@ PiActionEnumDeviceTree
Definition: io.h:526
VOID PiInsertDevNode(_In_ PDEVICE_NODE DeviceNode, _In_ PDEVICE_NODE ParentNode)
Definition: devnode.c:80
NTSTATUS NTAPI IopAssignDeviceResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:1116
PDEVICE_NODE PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject)
NTSTATUS NTAPI IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath, IN ULONG CreateOptions, OUT PHANDLE Handle)
Definition: pnpmgr.c:522
NTSTATUS PnpRootRegisterDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnproot.c:107
NTSTATUS PnpRootCreateDevice(IN PUNICODE_STRING ServiceName, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT PUNICODE_STRING FullInstancePath)
Definition: pnproot.c:184
#define IopDeviceNodeSetFlag(DeviceNode, Flag)
Definition: io.h:146
VOID PiSetDevNodeText(_In_ PDEVICE_NODE DeviceNode, _In_ HANDLE InstanceKey)
Sets the DeviceNode's DeviceDesc and LocationInformation registry values.
Definition: devaction.c:1089
PNP_DEVNODE_STATE PiSetDevNodeState(_In_ PDEVICE_NODE DeviceNode, _In_ PNP_DEVNODE_STATE NewState)
Definition: devnode.c:108
VOID PiQueueDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action, _In_opt_ PKEVENT CompletionEvent, _Out_opt_ NTSTATUS *CompletionStatus)
Queue a device operation to a worker thread.
Definition: devaction.c:2659
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
NTSTATUS IopSetDeviceInstanceData(HANDLE InstanceKey, PDEVICE_NODE DeviceNode)
Definition: pnpmgr.c:606
PWCHAR IopGetInterfaceTypeString(INTERFACE_TYPE IfType)
Definition: pnpreport.c:42
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
_In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG _In_opt_ PCM_RESOURCE_LIST _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST _In_ BOOLEAN ResourceAssigned
Definition: iofuncs.h:1552
_In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG _In_opt_ PCM_RESOURCE_LIST _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements
Definition: iofuncs.h:1551
_In_ INTERFACE_TYPE LegacyBusType
Definition: iofuncs.h:1547
#define DRVO_BUILTIN_DRIVER
Definition: iotypes.h:2227
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _Function_class_(), add_volume_device(), DriverEntry(), HalpDriverEntry(), ReportGreenPdo(), and ScsiPortInitialize().

◆ IoReportResourceForDetection()

NTSTATUS NTAPI IoReportResourceForDetection ( IN PDRIVER_OBJECT  DriverObject,
IN PCM_RESOURCE_LIST DriverList  OPTIONAL,
IN ULONG DriverListSize  OPTIONAL,
IN PDEVICE_OBJECT DeviceObject  OPTIONAL,
IN PCM_RESOURCE_LIST DeviceList  OPTIONAL,
IN ULONG DeviceListSize  OPTIONAL,
OUT PBOOLEAN  ConflictDetected 
)

Definition at line 394 of file pnpreport.c.

401{
404
405 *ConflictDetected = FALSE;
406
407 if (!DriverList && !DeviceList)
409
410 /* Find the real list */
411 if (!DriverList)
413 else
414 ResourceList = DriverList;
415
416 /* Look for a resource conflict */
419 {
420 /* Oh noes */
421 *ConflictDetected = TRUE;
422 }
423 else if (NT_SUCCESS(Status))
424 {
425 /* Looks like we're good to go */
426
427 /* TODO: Claim the resources in the ResourceMap */
428 }
429
430 return Status;
431}
#define TRUE
Definition: types.h:120
PDEVICE_LIST DeviceList
Definition: utils.c:27
NTSTATUS NTAPI IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1255
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:261

Referenced by IntVideoPortReleaseResources(), and VideoPortVerifyAccessRanges().

◆ IoReportTargetDeviceChange()

NTSTATUS NTAPI IoReportTargetDeviceChange ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PVOID  NotificationStructure 
)

Definition at line 448 of file pnpreport.c.

450{
451 KEVENT NotifyEvent;
452 NTSTATUS Status, NotifyStatus;
454
455 ASSERT(notifyStruct);
456
457 /* Check for valid PDO */
459 {
460 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG_PTR)PhysicalDeviceObject, 0, 0);
461 }
462
463 /* FileObject must be null. PnP will fill in it */
464 ASSERT(notifyStruct->FileObject == NULL);
465
466 /* Do not handle system PnP events */
467 if ((RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_QUERY_REMOVE), sizeof(GUID)) != sizeof(GUID)) ||
468 (RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_REMOVE_CANCELLED), sizeof(GUID)) != sizeof(GUID)) ||
469 (RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_REMOVE_COMPLETE), sizeof(GUID)) != sizeof(GUID)))
470 {
472 }
473
474 if (notifyStruct->Version != 1)
475 {
477 }
478
479 /* Initialize even that will let us know when PnP will have finished notify */
481
482 Status = PpSetCustomTargetEvent(PhysicalDeviceObject, &NotifyEvent, &NotifyStatus, NULL, NULL, notifyStruct);
483 /* If no error, wait for the notify to end and return the status of the notify and not of the event */
484 if (NT_SUCCESS(Status))
485 {
487 Status = NotifyStatus;
488 }
489
490 return Status;
491}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
#define IopIsValidPhysicalDeviceObject(PhysicalDeviceObject)
Definition: io.h:242
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
struct _FILE_OBJECT * FileObject
Definition: iotypes.h:1012
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206
struct _TARGET_DEVICE_CUSTOM_NOTIFICATION * PTARGET_DEVICE_CUSTOM_NOTIFICATION
@ Executive
Definition: ketypes.h:415

Referenced by FsRtlNotifyVolumeEvent(), and NtSetVolumeInformationFile().

◆ IoReportTargetDeviceChangeAsynchronous()

NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PVOID  NotificationStructure,
IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback  OPTIONAL,
IN PVOID Context  OPTIONAL 
)

Definition at line 498 of file pnpreport.c.

502{
505
506 ASSERT(notifyStruct);
507
508 /* Check for valid PDO */
510 {
511 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, 0x2, (ULONG_PTR)PhysicalDeviceObject, 0, 0);
512 }
513
514 /* FileObject must be null. PnP will fill in it */
515 ASSERT(notifyStruct->FileObject == NULL);
516
517 /* Do not handle system PnP events */
518 if ((RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_QUERY_REMOVE), sizeof(GUID)) != sizeof(GUID)) ||
519 (RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_REMOVE_CANCELLED), sizeof(GUID)) != sizeof(GUID)) ||
520 (RtlCompareMemory(&(notifyStruct->Event), &(GUID_TARGET_DEVICE_REMOVE_COMPLETE), sizeof(GUID)) != sizeof(GUID)))
521 {
523 }
524
525 if (notifyStruct->Version != 1)
526 {
528 }
529
530 /* We need to store all the data given by the caller with the WorkItem, so use our own struct */
533
534 /* Initialize all stuff */
536 Item->NotificationStructure = notifyStruct;
537 Item->PhysicalDeviceObject = PhysicalDeviceObject;
538 Item->Callback = Callback;
539 Item->Context = Context;
541
542 /* Finally, queue the item, our work here is done */
544
545 return STATUS_PENDING;
546}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IopReportTargetDeviceChangeAsyncWorker(PVOID Context)
Definition: pnpreport.c:102
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ DelayedWorkQueue
Definition: extypes.h:190
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by _IRQL_requires_max_(), DeviceSendNotification(), DiskIoctlUpdateDriveSize(), FdoIoctlDiskSetDriveLayout(), FdoIoctlDiskSetDriveLayoutEx(), FsRtlNotifyVolumeEvent(), and MountMgrNotifyNameChange().

◆ PpSetCustomTargetEvent()

NTSTATUS PpSetCustomTargetEvent ( IN PDEVICE_OBJECT  DeviceObject,
IN OUT PKEVENT SyncEvent  OPTIONAL,
IN OUT PNTSTATUS SyncStatus  OPTIONAL,
IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback  OPTIONAL,
IN PVOID Context  OPTIONAL,
IN PTARGET_DEVICE_CUSTOM_NOTIFICATION  NotificationStructure 
)

Definition at line 113 of file pnpreport.c.

119{
122
123 if (SyncEvent)
124 {
127 }
128
129 /* That call is totally wrong but notifications handler must be fixed first */
130 PiNotifyTargetDeviceChange(&GUID_PNP_CUSTOM_NOTIFICATION, DeviceObject, NotificationStructure);
131
132 if (SyncEvent)
133 {
134 KeSetEvent(SyncEvent, IO_NO_INCREMENT, FALSE);
136 }
137
138 return STATUS_SUCCESS;
139}
SYNC_STATUS SyncStatus
Definition: internettime.c:14
VOID PiNotifyTargetDeviceChange(_In_ LPCGUID Event, _In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PTARGET_DEVICE_CUSTOM_NOTIFICATION CustomNotification)
Delivers the event to all drivers subscribed to EventCategoryTargetDeviceChange PnP event.
Definition: pnpnotify.c:258

Referenced by IopReportTargetDeviceChangeAsyncWorker(), and IoReportTargetDeviceChange().