ReactOS  0.4.15-dev-5122-g72bdbdd
plugplay.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for plugplay.c:

Go to the source code of this file.

Classes

struct  _PNP_EVENT_ENTRY
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _PNP_EVENT_ENTRY PNP_EVENT_ENTRY
 
typedef struct _PNP_EVENT_ENTRYPPNP_EVENT_ENTRY
 

Functions

NTSTATUS IopInitPlugPlayEvents (VOID)
 
NTSTATUS IopQueueTargetDeviceEvent (const GUID *Guid, PUNICODE_STRING DeviceIds)
 
static PDEVICE_OBJECT IopTraverseDeviceNode (PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
 
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance (PUNICODE_STRING DeviceInstance)
 
static NTSTATUS IopCaptureUnicodeString (PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
 
static NTSTATUS IopInitializeDevice (_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData)
 
static NTSTATUS IopRemovePlugPlayEvent (_In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData)
 
static NTSTATUS IopGetInterfaceDeviceList (PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
 
static NTSTATUS IopGetDeviceProperty (PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
 
static NTSTATUS IopGetRelatedDevice (PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
 
static BOOLEAN PiIsDevNodeStarted (_In_ PDEVICE_NODE DeviceNode)
 
static ULONG IopGetDeviceNodeStatus (PDEVICE_NODE DeviceNode)
 
static NTSTATUS IopDeviceStatus (PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
 
static NTSTATUS IopGetDeviceRelations (PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
 
static NTSTATUS IopGetDeviceDepth (PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
 
static NTSTATUS PiControlSyncDeviceAction (_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceData, _In_ PLUGPLAY_CONTROL_CLASS ControlClass)
 
static NTSTATUS PiControlQueryRemoveDevice (_In_ PPLUGPLAY_CONTROL_QUERY_REMOVE_DATA ControlData)
 
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)
 

Variables

static LIST_ENTRY IopPnpEventQueueHead
 
static KEVENT IopPnpNotifyEvent
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file plugplay.c.

Typedef Documentation

◆ PNP_EVENT_ENTRY

◆ PPNP_EVENT_ENTRY

Function Documentation

◆ IopCaptureUnicodeString()

static NTSTATUS IopCaptureUnicodeString ( PUNICODE_STRING  DstName,
PUNICODE_STRING  SrcName 
)
static

Definition at line 143 of file plugplay.c.

144 {
146  volatile UNICODE_STRING Name;
147 
148  Name.Buffer = NULL;
149  _SEH2_TRY
150  {
151  Name.Length = SrcName->Length;
152  Name.MaximumLength = SrcName->MaximumLength;
153  if (Name.Length > Name.MaximumLength)
154  {
156  _SEH2_LEAVE;
157  }
158 
159  if (Name.MaximumLength)
160  {
161  ProbeForRead(SrcName->Buffer,
162  Name.MaximumLength,
163  sizeof(WCHAR));
164  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
165  if (Name.Buffer == NULL)
166  {
168  _SEH2_LEAVE;
169  }
170 
171  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
172  }
173 
174  *DstName = Name;
175  }
177  {
178  if (Name.Buffer)
179  {
180  ExFreePool(Name.Buffer);
181  }
183  }
184  _SEH2_END;
185 
186  return Status;
187 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4226
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_LEAVE
Definition: filesup.c:20
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopDeviceStatus(), IopGetDeviceDepth(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetInterfaceDeviceList(), IopGetRelatedDevice(), IopInitializeDevice(), PiControlQueryRemoveDevice(), and PiControlSyncDeviceAction().

◆ IopDeviceStatus()

static NTSTATUS IopDeviceStatus ( PPLUGPLAY_CONTROL_STATUS_DATA  StatusData)
static

Definition at line 804 of file plugplay.c.

805 {
808  ULONG Operation = 0;
809  ULONG DeviceStatus = 0;
810  ULONG DeviceProblem = 0;
813 
814  DPRINT("IopDeviceStatus() called\n");
815 
817  if (!NT_SUCCESS(Status))
818  {
819  return Status;
820  }
821 
822  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
823 
824  _SEH2_TRY
825  {
826  Operation = StatusData->Operation;
828  {
829  DeviceStatus = StatusData->DeviceStatus;
830  DeviceProblem = StatusData->DeviceProblem;
831  }
832  }
834  {
835  if (DeviceInstance.Buffer != NULL)
836  {
838  }
840  }
841  _SEH2_END;
842 
843  /* Get the device object */
845  if (DeviceInstance.Buffer != NULL)
846  {
848  }
849  if (DeviceObject == NULL)
850  {
851  return STATUS_NO_SUCH_DEVICE;
852  }
853 
855 
856  switch (Operation)
857  {
859  DPRINT("Get status data\n");
860  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
861  DeviceProblem = DeviceNode->Problem;
862  break;
863 
865  DPRINT1("Set status data is NOT SUPPORTED\n");
866  break;
867 
869  DPRINT1("FIXME: Clear status data!\n");
870  break;
871  }
872 
874 
876  {
877  _SEH2_TRY
878  {
879  StatusData->DeviceStatus = DeviceStatus;
880  StatusData->DeviceProblem = DeviceProblem;
881  }
883  {
885  }
886  _SEH2_END;
887  }
888 
889  return Status;
890 }
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:759
LONG NTSTATUS
Definition: precomp.h:26
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:525
_SEH2_TRY
Definition: create.c:4226
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
FP_OP Operation
Definition: fpcontrol.c:150
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: Node.h:9
#define PNP_CLEAR_DEVICE_STATUS
Definition: cmtypes.h:61
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)

Referenced by NtPlugPlayControl().

◆ IopGetDeviceDepth()

static NTSTATUS IopGetDeviceDepth ( PPLUGPLAY_CONTROL_DEPTH_DATA  DepthData)
static

Definition at line 1051 of file plugplay.c.

1052 {
1057 
1058  DPRINT("IopGetDeviceDepth() called\n");
1059  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
1060 
1062  if (!NT_SUCCESS(Status))
1063  {
1064  return Status;
1065  }
1066 
1067  /* Get the device object */
1069  if (DeviceInstance.Buffer != NULL)
1070  {
1072  }
1073  if (DeviceObject == NULL)
1074  {
1075  return STATUS_NO_SUCH_DEVICE;
1076  }
1077 
1079 
1080  _SEH2_TRY
1081  {
1082  DepthData->Depth = DeviceNode->Level;
1083  }
1085  {
1087  }
1088  _SEH2_END;
1089 
1091 
1092  return Status;
1093 }
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4226
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: Node.h:9
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:534
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)

Referenced by NtPlugPlayControl().

◆ IopGetDeviceNodeStatus()

static ULONG IopGetDeviceNodeStatus ( PDEVICE_NODE  DeviceNode)
static

Definition at line 759 of file plugplay.c.

760 {
762 
763  if (DeviceNode->Parent == IopRootDeviceNode)
765 
766  // FIXME: review for deleted and removed states
767  if (DeviceNode->State >= DeviceNodeDriversAdded)
769 
771  Output |= DN_STARTED;
772 
773  if (DeviceNode->UserFlags & DNUF_WILL_BE_REMOVED)
775 
776  if (DeviceNode->Flags & DNF_HAS_PROBLEM)
778 
779  if (DeviceNode->Flags & DNF_HAS_PRIVATE_PROBLEM)
781 
782  if (DeviceNode->Flags & DNF_DRIVER_BLOCKED)
784 
787 
788  if (DeviceNode->Flags & DNF_HAS_PRIVATE_PROBLEM)
790 
791  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
793 
794  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
796 
797  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
799 
800  return Output;
801 }
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
#define DNF_HAS_PROBLEM
Definition: iotypes.h:183
#define DNUF_NOT_DISABLEABLE
Definition: iotypes.h:211
#define DN_ROOT_ENUMERATED
Definition: cfg.h:118
#define DN_DRIVER_BLOCKED
Definition: cfg.h:154
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define DN_DISABLEABLE
Definition: cfg.h:131
#define DNUF_DONT_SHOW_IN_UI
Definition: iotypes.h:209
#define DN_NO_SHOW_IN_DM
Definition: cfg.h:148
#define DN_PRIVATE_PROBLEM
Definition: cfg.h:133
static BOOLEAN PiIsDevNodeStarted(_In_ PDEVICE_NODE DeviceNode)
Definition: plugplay.c:744
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define DN_NT_DRIVER
Definition: cfg.h:142
#define DN_NT_ENUMERATOR
Definition: cfg.h:141
Definition: Node.h:9
#define DNF_CHILD_WITH_INVALID_ID
Definition: iotypes.h:191
Definition: arc.h:85
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:182
#define DNF_HAS_PRIVATE_PROBLEM
Definition: iotypes.h:184
#define DN_LEGACY_DRIVER
Definition: cfg.h:155
#define DN_CHILD_WITH_INVALID_ID
Definition: cfg.h:156
#define DN_STARTED
Definition: cfg.h:121
unsigned int ULONG
Definition: retypes.h:1
#define DN_WILL_BE_REMOVED
Definition: cfg.h:136
#define DNF_DRIVER_BLOCKED
Definition: iotypes.h:190
#define DNUF_WILL_BE_REMOVED
Definition: iotypes.h:208

Referenced by IopDeviceStatus().

◆ IopGetDeviceObjectFromDeviceInstance()

PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance ( PUNICODE_STRING  DeviceInstance)

Definition at line 122 of file plugplay.c.

123 {
124  if (IopRootDeviceNode == NULL)
125  return NULL;
126 
127  if (DeviceInstance == NULL ||
128  DeviceInstance->Length == 0)
129  {
131  {
134  }
135  else
136  return NULL;
137  }
138 
140 }
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:855
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
static PDEVICE_OBJECT IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:93
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define NULL
Definition: types.h:112
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by IopDeviceStatus(), IopGetDeviceDepth(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetInterfaceDeviceList(), IopGetRelatedDevice(), IopInitializeBuiltinDriver(), IopInitializeDevice(), IoSetDeviceInterfaceState(), PiControlQueryRemoveDevice(), PiControlSyncDeviceAction(), and PiInitializeDevNode().

◆ IopGetDeviceProperty()

static NTSTATUS IopGetDeviceProperty ( PPLUGPLAY_CONTROL_PROPERTY_DATA  PropertyData)
static

Definition at line 373 of file plugplay.c.

374 {
379  ULONG Property;
381  PVOID Buffer;
383 
384  DPRINT("IopGetDeviceProperty() called\n");
385  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
386 
388  if (!NT_SUCCESS(Status))
389  {
390  return Status;
391  }
392 
393  _SEH2_TRY
394  {
395  Property = PropertyData->Property;
396  BufferSize = PropertyData->BufferSize;
397  ProbeForWrite(PropertyData->Buffer,
398  BufferSize,
399  sizeof(UCHAR));
400  }
402  {
403  if (DeviceInstance.Buffer != NULL)
404  {
406  }
408  }
409  _SEH2_END;
410 
411  /* Get the device object */
413  if (DeviceInstance.Buffer != NULL)
414  {
416  }
417  if (DeviceObject == NULL)
418  {
419  return STATUS_NO_SUCH_DEVICE;
420  }
421 
423  if (Buffer == NULL)
424  {
427  }
428 
429 
430  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
431 
433  {
434  if (BufferSize < sizeof(CM_POWER_DATA))
435  {
436  BufferSize = 0;
438  }
439  else
440  {
442  PCM_POWER_DATA PowerData;
445 
446  PowerData = (PCM_POWER_DATA)Buffer;
447  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
448  PowerData->PD_Size = sizeof(CM_POWER_DATA);
449 
452  DeviceCapabilities.Version = 1;
453  DeviceCapabilities.Address = -1;
454  DeviceCapabilities.UINumber = -1;
455 
456  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
457 
459  &IoStatusBlock,
461  &Stack);
462  if (NT_SUCCESS(Status))
463  {
464  DPRINT("Got device capabiliities\n");
465 
466  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
467  if (DeviceCapabilities.DeviceD1)
468  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
469  if (DeviceCapabilities.DeviceD2)
470  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
471  if (DeviceCapabilities.WakeFromD0)
473  if (DeviceCapabilities.WakeFromD1)
475  if (DeviceCapabilities.WakeFromD2)
477  if (DeviceCapabilities.WakeFromD3)
479  if (DeviceCapabilities.WarmEjectSupported)
481  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
482  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
483  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
485  &DeviceCapabilities.DeviceState,
486  sizeof(DeviceCapabilities.DeviceState));
487  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
488  }
489  else
490  {
491  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
492 
495  }
496  }
497  }
499  {
501  BufferSize = 0;
503  }
505  {
506  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
507  {
508  BufferSize = 0;
510  }
511  else
512  {
513  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
515  &DeviceNode->HardwareRemovalPolicy,
516  BufferSize);
517  }
518  }
519  else
520  {
521  switch (Property)
522  {
525  break;
526 
529  break;
530 
533  break;
534 
537  break;
538 
541  break;
542 
545  break;
546 
549  break;
550 
553  break;
554 
557  break;
558 
559 #if (WINVER >= _WIN32_WINNT_WS03)
562  BufferSize = 0;
564  break;
565 #endif
566 
567 #if (WINVER >= _WIN32_WINNT_WIN7)
570  break;
571 #endif
572 
573  default:
574  BufferSize = 0;
576  break;
577  }
578 
579  if (Status == STATUS_SUCCESS)
580  {
583  BufferSize,
584  Buffer,
585  &BufferSize);
586  }
587  }
588 
590 
591  if (NT_SUCCESS(Status))
592  {
593  _SEH2_TRY
594  {
596  PropertyData->BufferSize = BufferSize;
597  }
599  {
601  }
602  _SEH2_END;
603  }
604 
606  return Status;
607 }
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define PDCAP_WARM_EJECT_SUPPORTED
Definition: advprop.cpp:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PDCAP_D1_SUPPORTED
Definition: advprop.cpp:37
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
DEVICE_CAPABILITIES
Definition: iotypes.h:965
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
ULONG PD_D2Latency
Definition: advprop.cpp:52
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define DeviceCapabilities
Definition: wingdi.h:4449
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1952
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
Definition: bufpool.h:45
#define PDCAP_D3_SUPPORTED
Definition: advprop.cpp:39
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
ULONG PD_D3Latency
Definition: advprop.cpp:53
Status
Definition: gdiplustypes.h:24
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: Node.h:9
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE
Definition: cmtypes.h:41
unsigned char UCHAR
Definition: xmlstorage.h:181
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define PDCAP_WAKE_FROM_D1_SUPPORTED
Definition: advprop.cpp:41
_In_ DWORD Property
Definition: setupapi.h:1550
SYSTEM_POWER_STATE PD_DeepestSystemWake
Definition: advprop.cpp:55
_SEH2_END
Definition: create.c:4400
ULONG PD_D1Latency
Definition: advprop.cpp:51
struct CM_Power_Data_s CM_POWER_DATA
struct CM_Power_Data_s * PCM_POWER_DATA
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define NULL
Definition: types.h:112
DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]
Definition: advprop.cpp:54
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define PDCAP_WAKE_FROM_D0_SUPPORTED
Definition: advprop.cpp:40
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
DEVICE_POWER_STATE PD_MostRecentPowerState
Definition: advprop.cpp:49
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
#define PDCAP_WAKE_FROM_D2_SUPPORTED
Definition: advprop.cpp:42
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
#define PDCAP_WAKE_FROM_D3_SUPPORTED
Definition: advprop.cpp:43
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG PD_Capabilities
Definition: advprop.cpp:50
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define PDCAP_D0_SUPPORTED
Definition: advprop.cpp:36
#define IRP_MN_QUERY_CAPABILITIES

Referenced by NtPlugPlayControl().

◆ IopGetDeviceRelations()

static NTSTATUS IopGetDeviceRelations ( PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA  RelationsData)
static

Definition at line 894 of file plugplay.c.

895 {
900  PDEVICE_RELATIONS DeviceRelations = NULL;
901  PDEVICE_OBJECT ChildDeviceObject;
902  PDEVICE_NODE ChildDeviceNode;
903  ULONG i;
904  ULONG Relations;
906  ULONG BufferLeft;
907  PWCHAR Buffer, Ptr;
909 
910  DPRINT("IopGetDeviceRelations() called\n");
911  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
912  DPRINT("Relations: %lu\n", RelationsData->Relations);
913  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
914  DPRINT("Buffer: %p\n", RelationsData->Buffer);
915 
916  _SEH2_TRY
917  {
918  Relations = RelationsData->Relations;
919  BufferSize = RelationsData->BufferSize;
920  Buffer = RelationsData->Buffer;
921 
922  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
923  }
925  {
927  }
928  _SEH2_END;
929 
931  if (!NT_SUCCESS(Status))
932  {
933  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
934  return Status;
935  }
936 
937  /* Get the device object */
939  if (DeviceObject == NULL)
940  {
941  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
943  goto done;
944  }
945 
946  switch (Relations)
947  {
948  case PNP_EJECT_RELATIONS:
949  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
950  break;
951 
953  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
954  break;
955 
956  case PNP_POWER_RELATIONS:
957  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
958  break;
959 
960  case PNP_BUS_RELATIONS:
961  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
962  break;
963 
964  default:
966  goto done;
967  }
968 
970  &IoStatusBlock,
972  &Stack);
973  if (!NT_SUCCESS(Status))
974  {
975  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
976  goto done;
977  }
978 
979  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
980 
981  DPRINT("Found %d device relations\n", DeviceRelations->Count);
982 
983  _SEH2_TRY
984  {
985  RequiredSize = 0;
986  BufferLeft = BufferSize;
987  Ptr = Buffer;
988 
989  for (i = 0; i < DeviceRelations->Count; i++)
990  {
991  ChildDeviceObject = DeviceRelations->Objects[i];
992 
993  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
994  if (ChildDeviceNode)
995  {
996  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
997  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
998 
999  if (Ptr != NULL)
1000  {
1001  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
1002  {
1004  break;
1005  }
1006 
1008  ChildDeviceNode->InstancePath.Buffer,
1009  ChildDeviceNode->InstancePath.Length);
1010  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
1011  *Ptr = UNICODE_NULL;
1012  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
1013 
1014  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1015  }
1016 
1017  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1018  }
1019  }
1020 
1021  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
1022  *Ptr = UNICODE_NULL;
1023 
1024  if (RequiredSize > 0)
1025  RequiredSize += sizeof(WCHAR);
1026 
1027  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
1028 
1029  RelationsData->BufferSize = RequiredSize;
1030  }
1032  {
1034  }
1035  _SEH2_END;
1036 
1037 done:
1038  if (DeviceRelations != NULL)
1039  ExFreePool(DeviceRelations);
1040 
1041  if (DeviceObject != NULL)
1043 
1044  if (DeviceInstance.Buffer != NULL)
1046 
1047  return Status;
1048 }
#define PNP_REMOVAL_RELATIONS
Definition: cmtypes.h:67
#define PNP_POWER_RELATIONS
Definition: cmtypes.h:68
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
#define PNP_BUS_RELATIONS
Definition: cmtypes.h:69
uint16_t * PWCHAR
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNICODE_NULL
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
UNICODE_STRING InstancePath
Definition: iotypes.h:858
_SEH2_END
Definition: create.c:4400
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 OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
#define PNP_EJECT_RELATIONS
Definition: cmtypes.h:66
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by NtPlugPlayControl().

◆ IopGetInterfaceDeviceList()

static NTSTATUS IopGetInterfaceDeviceList ( PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA  DeviceList)
static

Definition at line 295 of file plugplay.c.

296 {
301  GUID FilterGuid;
302  PZZWSTR SymbolicLinkList = NULL, LinkList;
304 
305  _SEH2_TRY
306  {
308 
309  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
310  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
311 
312  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
313  {
314  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
315  }
316  }
318  {
320  }
321  _SEH2_END;
322 
324  if (NT_SUCCESS(Status))
325  {
326  /* Get the device object */
328  if (DeviceInstance.Buffer != NULL)
329  {
331  }
332  }
333 
334  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
336 
337  if (!NT_SUCCESS(Status))
338  {
339  /* failed */
340  return Status;
341  }
342 
343  LinkList = SymbolicLinkList;
344  while (*SymbolicLinkList != UNICODE_NULL)
345  {
346  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
347  }
348  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
349 
350  _SEH2_TRY
351  {
352  if (StackList.Buffer != NULL &&
353  StackList.BufferSize >= TotalLength)
354  {
355  // We've already probed the buffer for writing above.
356  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
357  }
358 
359  DeviceList->BufferSize = TotalLength;
360  }
362  {
363  ExFreePool(LinkList);
365  }
366  _SEH2_END;
367 
368  ExFreePool(LinkList);
369  return STATUS_SUCCESS;
370 }
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
PDEVICE_LIST DeviceList
Definition: utils.c:27
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:420
_In_ ULONG TotalLength
Definition: usbdlib.h:158
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define UNICODE_NULL
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopGetRelatedDevice()

static NTSTATUS IopGetRelatedDevice ( PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA  RelatedDeviceData)
static

Definition at line 611 of file plugplay.c.

612 {
613  UNICODE_STRING RootDeviceName;
616  PDEVICE_NODE RelatedDeviceNode;
617  UNICODE_STRING TargetDeviceInstance;
619  ULONG Relation = 0;
620  ULONG MaximumLength = 0;
621 
622  DPRINT("IopGetRelatedDevice() called\n");
623  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
624 
625  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
626  if (!NT_SUCCESS(Status))
627  {
628  return Status;
629  }
630 
631  _SEH2_TRY
632  {
633  Relation = RelatedDeviceData->Relation;
634  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
635  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
637  sizeof(WCHAR));
638  }
640  {
641  if (TargetDeviceInstance.Buffer != NULL)
642  {
643  ExFreePool(TargetDeviceInstance.Buffer);
644  }
646  }
647  _SEH2_END;
648 
649  RtlInitUnicodeString(&RootDeviceName,
650  L"HTREE\\ROOT\\0");
651  if (RtlEqualUnicodeString(&TargetDeviceInstance,
652  &RootDeviceName,
653  TRUE))
654  {
656  if (TargetDeviceInstance.Buffer != NULL)
657  {
658  ExFreePool(TargetDeviceInstance.Buffer);
659  }
660  }
661  else
662  {
663  /* Get the device object */
664  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
665  if (TargetDeviceInstance.Buffer != NULL)
666  {
667  ExFreePool(TargetDeviceInstance.Buffer);
668  }
669  if (DeviceObject == NULL)
670  return STATUS_NO_SUCH_DEVICE;
671 
672  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
673  }
674 
675  switch (Relation)
676  {
678  RelatedDeviceNode = DeviceNode->Parent;
679  break;
680 
682  RelatedDeviceNode = DeviceNode->Child;
683  break;
684 
686  RelatedDeviceNode = DeviceNode->Sibling;
687  break;
688 
689  default:
690  if (DeviceObject != NULL)
691  {
693  }
694 
696  }
697 
698  if (RelatedDeviceNode == NULL)
699  {
700  if (DeviceObject)
701  {
703  }
704 
705  return STATUS_NO_SUCH_DEVICE;
706  }
707 
708  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
709  {
710  if (DeviceObject)
711  {
713  }
714 
716  }
717 
718  /* Copy related device instance name */
719  _SEH2_TRY
720  {
721  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
722  RelatedDeviceNode->InstancePath.Buffer,
723  RelatedDeviceNode->InstancePath.Length);
724  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
725  }
727  {
729  }
730  _SEH2_END;
731 
732  if (DeviceObject != NULL)
733  {
735  }
736 
737  DPRINT("IopGetRelatedDevice() done\n");
738 
739  return Status;
740 }
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define PNP_GET_SIBLING_DEVICE
Definition: cmtypes.h:54
LONG NTSTATUS
Definition: precomp.h:26
#define PNP_GET_PARENT_DEVICE
Definition: cmtypes.h:52
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define L(x)
Definition: ntvdm.h:50
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Status
Definition: gdiplustypes.h:24
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: Node.h:9
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
UNICODE_STRING InstancePath
Definition: iotypes.h:858
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopInitializeDevice()

static NTSTATUS IopInitializeDevice ( _In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA  ControlData)
static

Definition at line 192 of file plugplay.c.

194 {
199 
200  DPRINT("IopInitializeDevice(%p)\n", ControlData);
201 
202  Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
203  if (!NT_SUCCESS(Status))
204  {
205  return Status;
206  }
207 
208  DPRINT("Device: %wZ\n", &DeviceInstance);
209 
210  /* Leave, if the device already exists */
212  if (DeviceInstance.Buffer != NULL)
213  {
214  DPRINT1("Device %wZ already exists!\n", &DeviceInstance);
216  goto done;
217  }
218 
220 
221  DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
222 
223  /* Create a device node for the device instance */
225  0,
226  NULL,
229  FALSE,
230  &DeviceObject);
231  if (!NT_SUCCESS(Status))
232  {
233  DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
234  goto done;
235  }
236 
237  /* Allocate a new device node */
239  if (DeviceNode == NULL)
240  {
241  DPRINT1("Failed to allocate a device node!\n");
244  goto done;
245  }
246 
247  /* Set the device instance of the device node */
249  if (!NT_SUCCESS(Status))
250  {
251  DPRINT1("RtlDuplicateUnicodeString() failed (Status 0x%08lx)\n", Status);
254  goto done;
255  }
256 
257  /* Insert as a root enumerated device node */
259 
260 done:
262 
263  return Status;
264 }
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define FALSE
Definition: types.h:117
PDEVICE_NODE PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject)
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: Node.h:9
PDRIVER_OBJECT IopRootDriverObject
Definition: pnpmgr.c:26
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
VOID PiInsertDevNode(_In_ PDEVICE_NODE DeviceNode, _In_ PDEVICE_NODE ParentNode)
Definition: devnode.c:80
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopInitPlugPlayEvents()

NTSTATUS IopInitPlugPlayEvents ( VOID  )

Definition at line 31 of file plugplay.c.

32 {
34 
37  FALSE);
38 
39  return STATUS_SUCCESS;
40 }
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:24
#define FALSE
Definition: types.h:117
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:25
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by IopInitializePlugPlayServices().

◆ IopQueueTargetDeviceEvent()

NTSTATUS IopQueueTargetDeviceEvent ( const GUID Guid,
PUNICODE_STRING  DeviceIds 
)

Definition at line 43 of file plugplay.c.

45 {
46  PPNP_EVENT_ENTRY EventEntry;
48  ULONG TotalSize;
50 
51  ASSERT(DeviceIds);
52 
53  /* Allocate a big enough buffer */
54  Copy.Length = 0;
55  Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
56  TotalSize =
58  Copy.MaximumLength;
59 
60  EventEntry = ExAllocatePool(NonPagedPool,
61  TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
62  if (!EventEntry)
64  RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
65 
66  /* Fill the buffer with the event GUID */
67  RtlCopyMemory(&EventEntry->Event.EventGuid,
68  Guid,
69  sizeof(GUID));
71  EventEntry->Event.TotalSize = TotalSize;
72 
73  /* Fill the device id */
74  Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
76  if (!NT_SUCCESS(Status))
77  {
78  ExFreePool(EventEntry);
79  return Status;
80  }
81 
83  &EventEntry->ListEntry);
85  0,
86  FALSE);
87 
88  return STATUS_SUCCESS;
89 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:690
Definition: plugplay.c:15
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
LONG NTSTATUS
Definition: precomp.h:26
PLUGPLAY_EVENT_BLOCK Event
Definition: plugplay.c:18
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:24
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:406
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
struct _PLUGPLAY_EVENT_BLOCK::@2347::@2350 TargetDevice
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:25
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
LIST_ENTRY ListEntry
Definition: plugplay.c:17
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopQueryRemoveDevice(), IopRemoveDevice(), IoRequestDeviceEject(), PiInitializeDevNode(), and PiStartDeviceFinal().

◆ IopRemovePlugPlayEvent()

static NTSTATUS IopRemovePlugPlayEvent ( _In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA  ResponseData)
static

Definition at line 273 of file plugplay.c.

275 {
276  /* Remove a pnp event entry from the tail of the queue */
278  {
280  }
281 
282  /* Signal the next pnp event in the queue */
284  {
286  0,
287  FALSE);
288  }
289 
290  return STATUS_SUCCESS;
291 }
Definition: plugplay.c:15
FORCEINLINE PLIST_ENTRY RemoveTailList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:154
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:24
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define FALSE
Definition: types.h:117
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:25
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopTraverseDeviceNode()

static PDEVICE_OBJECT IopTraverseDeviceNode ( PDEVICE_NODE  Node,
PUNICODE_STRING  DeviceInstance 
)
static

Definition at line 93 of file plugplay.c.

94 {
96  PDEVICE_NODE ChildNode;
97 
98  if (RtlEqualUnicodeString(&Node->InstancePath,
100  {
101  ObReferenceObject(Node->PhysicalDeviceObject);
102  return Node->PhysicalDeviceObject;
103  }
104 
105  /* Traversal of all children nodes */
106  for (ChildNode = Node->Child;
107  ChildNode != NULL;
108  ChildNode = ChildNode->Sibling)
109  {
111  if (DeviceObject != NULL)
112  {
113  return DeviceObject;
114  }
115  }
116 
117  return NULL;
118 }
#define TRUE
Definition: types.h:120
static PDEVICE_OBJECT IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:93
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define NULL
Definition: types.h:112
struct _DEVICE_NODE * Sibling
Definition: iotypes.h:839
#define ObReferenceObject
Definition: obfuncs.h:204
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
Definition: dlist.c:348

Referenced by IopGetDeviceObjectFromDeviceInstance().

◆ NtGetPlugPlayEvent()

NTSTATUS NTAPI NtGetPlugPlayEvent ( IN ULONG  Reserved1,
IN ULONG  Reserved2,
OUT PPLUGPLAY_EVENT_BLOCK  Buffer,
IN ULONG  BufferSize 
)

Definition at line 1246 of file plugplay.c.

1250 {
1252  NTSTATUS Status;
1253 
1254  DPRINT("NtGetPlugPlayEvent() called\n");
1255 
1256  /* Function can only be called from user-mode */
1257  if (KeGetPreviousMode() == KernelMode)
1258  {
1259  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1260  return STATUS_ACCESS_DENIED;
1261  }
1262 
1263  /* Check for Tcb privilege */
1265  UserMode))
1266  {
1267  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1269  }
1270 
1271  /* Wait for a PnP event */
1272  DPRINT("Waiting for pnp notification event\n");
1274  UserRequest,
1275  UserMode,
1276  FALSE,
1277  NULL);
1279  {
1280  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1282  return Status;
1283  }
1284 
1285  /* Get entry from the tail of the queue */
1288  ListEntry);
1289 
1290  /* Check the buffer size */
1291  if (BufferSize < Entry->Event.TotalSize)
1292  {
1293  DPRINT1("Buffer is too small for the pnp-event\n");
1294  return STATUS_BUFFER_TOO_SMALL;
1295  }
1296 
1297  /* Copy event data to the user buffer */
1298  _SEH2_TRY
1299  {
1301  Entry->Event.TotalSize,
1302  sizeof(UCHAR));
1304  &Entry->Event,
1305  Entry->Event.TotalSize);
1306  }
1308  {
1310  }
1311  _SEH2_END;
1312 
1313  DPRINT("NtGetPlugPlayEvent() done\n");
1314 
1315  return STATUS_SUCCESS;
1316 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
struct _Entry Entry
Definition: kefuncs.h:629
Definition: plugplay.c:15
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
#define KeGetPreviousMode()
Definition: ketypes.h:1108
LONG NTSTATUS
Definition: precomp.h:26
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:24
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:25
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
unsigned char UCHAR
Definition: xmlstorage.h:181
const LUID SeTcbPrivilege
Definition: priv.c:26
#define STATUS_USER_APC
Definition: ntstatus.h:78
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by PnpEventThread().

◆ NtPlugPlayControl()

NTSTATUS NTAPI NtPlugPlayControl ( IN PLUGPLAY_CONTROL_CLASS  PlugPlayControlClass,
IN OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 1376 of file plugplay.c.

1379 {
1380  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1381  PlugPlayControlClass, Buffer, BufferLength);
1382 
1383  /* Function can only be called from user-mode */
1384  if (KeGetPreviousMode() == KernelMode)
1385  {
1386  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1387  return STATUS_ACCESS_DENIED;
1388  }
1389 
1390  /* Check for Tcb privilege */
1392  UserMode))
1393  {
1394  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1396  }
1397 
1398  /* Probe the buffer */
1399  _SEH2_TRY
1400  {
1402  BufferLength,
1403  sizeof(ULONG));
1404  }
1406  {
1408  }
1409  _SEH2_END;
1410 
1411  switch (PlugPlayControlClass)
1412  {
1415  return STATUS_INVALID_PARAMETER;
1416  // the Flags field is not used anyway
1418  PlugPlayControlClass);
1419 
1420 // case PlugPlayControlRegisterNewDevice:
1421 // case PlugPlayControlDeregisterDevice:
1422 
1425  return STATUS_INVALID_PARAMETER;
1427 
1431  return STATUS_INVALID_PARAMETER;
1433  PlugPlayControlClass);
1434 
1435 // case PlugPlayControlUnlockDevice:
1438  return STATUS_INVALID_PARAMETER;
1440 
1443  return STATUS_INVALID_PARAMETER;
1445 
1446 // case PlugPlayControlGenerateLegacyDevice:
1447 
1450  return STATUS_INVALID_PARAMETER;
1452 
1455  return STATUS_INVALID_PARAMETER;
1457 
1458 // case PlugPlayControlDeviceClassAssociation:
1459 
1462  return STATUS_INVALID_PARAMETER;
1464 
1465 // case PlugPlayControlGetInterfaceDeviceAlias:
1466 
1469  return STATUS_INVALID_PARAMETER;
1471 
1474  return STATUS_INVALID_PARAMETER;
1476 
1479  return STATUS_INVALID_PARAMETER;
1481 
1482 // case PlugPlayControlTargetDeviceRelation:
1483 // case PlugPlayControlQueryConflictList:
1484 // case PlugPlayControlRetrieveDock:
1485 // case PlugPlayControlHaltDevice:
1486 // case PlugPlayControlGetBlockedDriverList:
1487 
1488  default:
1489  return STATUS_NOT_IMPLEMENTED;
1490  }
1491 
1492  return STATUS_NOT_IMPLEMENTED;
1493 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
static NTSTATUS IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
Definition: plugplay.c:611
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define KeGetPreviousMode()
Definition: ketypes.h:1108
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:894
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
static NTSTATUS IopRemovePlugPlayEvent(_In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData)
Definition: plugplay.c:273
_SEH2_TRY
Definition: create.c:4226
static NTSTATUS PiControlQueryRemoveDevice(_In_ PPLUGPLAY_CONTROL_QUERY_REMOVE_DATA ControlData)
Definition: plugplay.c:1152
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:373
return STATUS_NOT_IMPLEMENTED
Definition: bufpool.h:45
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static NTSTATUS IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
Definition: plugplay.c:804
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static NTSTATUS IopInitializeDevice(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData)
Definition: plugplay.c:192
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:1051
const LUID SeTcbPrivilege
Definition: priv.c:26
static NTSTATUS PiControlSyncDeviceAction(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceData, _In_ PLUGPLAY_CONTROL_CLASS ControlClass)
Definition: plugplay.c:1097
_SEH2_END
Definition: create.c:4400
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define DPRINT
Definition: sndvol32.h:71
static NTSTATUS IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
Definition: plugplay.c:295

Referenced by AreDriversLoaded(), ClearDeviceStatus(), DisableDeviceInstance(), EnableDeviceInstance(), GetDeviceStatus(), GetRelationsInstanceList(), GetRelationsInstanceListSize(), InstallDriver(), PNP_CreateDevInst(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetRelatedDeviceInstance(), PNP_QueryRemove(), PNP_RequestDeviceEject(), PNP_RequestEjectPC(), PnpEventThread(), ReenumerateDeviceInstance(), SetDeviceStatus(), and SetupDeviceInstance().

◆ PiControlQueryRemoveDevice()

static NTSTATUS PiControlQueryRemoveDevice ( _In_ PPLUGPLAY_CONTROL_QUERY_REMOVE_DATA  ControlData)
static

Definition at line 1152 of file plugplay.c.

1154 {
1156  NTSTATUS Status;
1158 
1159  Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
1160  if (!NT_SUCCESS(Status))
1161  {
1162  return Status;
1163  }
1164 
1166  if (DeviceInstance.Buffer != NULL)
1167  {
1169  }
1170  if (DeviceObject == NULL)
1171  {
1172  return STATUS_NO_SUCH_DEVICE;
1173  }
1174 
1175  UNIMPLEMENTED;
1177 
1179 
1180  return Status;
1181 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define ObDereferenceObject
Definition: obfuncs.h:203
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define NULL
Definition: types.h:112
#define UNIMPLEMENTED
Definition: debug.h:115
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ PiControlSyncDeviceAction()

static NTSTATUS PiControlSyncDeviceAction ( _In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA  DeviceData,
_In_ PLUGPLAY_CONTROL_CLASS  ControlClass 
)
static

Definition at line 1097 of file plugplay.c.

1100 {
1102  NTSTATUS Status;
1104 
1108 
1110  if (!NT_SUCCESS(Status))
1111  {
1112  return Status;
1113  }
1114 
1116  if (DeviceInstance.Buffer != NULL)
1117  {
1119  }
1120  if (DeviceObject == NULL)
1121  {
1122  return STATUS_NO_SUCH_DEVICE;
1123  }
1124 
1126 
1127  switch (ControlClass)
1128  {
1131  break;
1134  break;
1137  break;
1138  default:
1139  UNREACHABLE;
1140  break;
1141  }
1142 
1144 
1146 
1147  return Status;
1148 }
static const WCHAR ControlClass[]
Definition: cfgmgr.c:44
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
enum _DEVICE_ACTION DEVICE_ACTION
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define ObDereferenceObject
Definition: obfuncs.h:203
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
NTSTATUS PiPerformSyncDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action)
Perfom a device operation synchronously via PiQueueDeviceAction.
Definition: devaction.c:2714
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
#define NULL
Definition: types.h:112
#define UNREACHABLE
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ PiIsDevNodeStarted()

Variable Documentation

◆ IopPnpEventQueueHead

LIST_ENTRY IopPnpEventQueueHead
static

◆ IopPnpNotifyEvent

KEVENT IopPnpNotifyEvent
static