ReactOS  0.4.14-dev-50-g13bb5e2
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 INIT_FUNCTION IopInitPlugPlayEvents (VOID)
 
NTSTATUS IopQueueTargetDeviceEvent (const GUID *Guid, PUNICODE_STRING DeviceIds)
 
static NTSTATUS IopRemovePlugPlayEvent (VOID)
 
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 IopPnpEnumerateDevice (PPLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA DeviceData)
 
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 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 IopResetDevice (PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
 
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 169 of file plugplay.c.

170 {
172  volatile UNICODE_STRING Name;
173 
174  Name.Buffer = NULL;
175  _SEH2_TRY
176  {
177  Name.Length = SrcName->Length;
178  Name.MaximumLength = SrcName->MaximumLength;
179  if (Name.Length > Name.MaximumLength)
180  {
182  _SEH2_LEAVE;
183  }
184 
185  if (Name.MaximumLength)
186  {
187  ProbeForRead(SrcName->Buffer,
188  Name.MaximumLength,
189  sizeof(WCHAR));
190  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
191  if (Name.Buffer == NULL)
192  {
194  _SEH2_LEAVE;
195  }
196 
197  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
198  }
199 
200  *DstName = Name;
201  }
203  {
204  if (Name.Buffer)
205  {
206  ExFreePool(Name.Buffer);
207  }
209  }
210  _SEH2_END;
211 
212  return Status;
213 }
#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:4250
struct NameRec_ * Name
Definition: cdprocs.h:464
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopDeviceStatus(), IopGetDeviceDepth(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetInterfaceDeviceList(), IopGetRelatedDevice(), IopPnpEnumerateDevice(), and IopResetDevice().

◆ IopDeviceStatus()

static NTSTATUS IopDeviceStatus ( PPLUGPLAY_CONTROL_STATUS_DATA  StatusData)
static

Definition at line 739 of file plugplay.c.

740 {
743  ULONG Operation = 0;
744  ULONG DeviceStatus = 0;
745  ULONG DeviceProblem = 0;
748 
749  DPRINT("IopDeviceStatus() called\n");
750 
752  if (!NT_SUCCESS(Status))
753  {
754  return Status;
755  }
756 
757  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
758 
759  _SEH2_TRY
760  {
761  Operation = StatusData->Operation;
763  {
764  DeviceStatus = StatusData->DeviceStatus;
765  DeviceProblem = StatusData->DeviceProblem;
766  }
767  }
769  {
770  if (DeviceInstance.Buffer != NULL)
771  {
773  }
775  }
776  _SEH2_END;
777 
778  /* Get the device object */
780  if (DeviceInstance.Buffer != NULL)
781  {
783  }
784  if (DeviceObject == NULL)
785  {
786  return STATUS_NO_SUCH_DEVICE;
787  }
788 
790 
791  switch (Operation)
792  {
794  DPRINT("Get status data\n");
795  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
796  DeviceProblem = DeviceNode->Problem;
797  break;
798 
800  DPRINT1("Set status data is NOT SUPPORTED\n");
801  break;
802 
804  DPRINT1("FIXME: Clear status data!\n");
805  break;
806  }
807 
809 
811  {
812  _SEH2_TRY
813  {
814  StatusData->DeviceStatus = DeviceStatus;
815  StatusData->DeviceProblem = DeviceProblem;
816  }
818  {
820  }
821  _SEH2_END;
822  }
823 
824  return Status;
825 }
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:691
LONG NTSTATUS
Definition: precomp.h:26
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:506
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#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
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:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#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 986 of file plugplay.c.

987 {
992 
993  DPRINT("IopGetDeviceDepth() called\n");
994  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
995 
997  if (!NT_SUCCESS(Status))
998  {
999  return Status;
1000  }
1001 
1002  /* Get the device object */
1004  if (DeviceInstance.Buffer != NULL)
1005  {
1007  }
1008  if (DeviceObject == NULL)
1009  {
1010  return STATUS_NO_SUCH_DEVICE;
1011  }
1012 
1014 
1015  _SEH2_TRY
1016  {
1017  DepthData->Depth = DeviceNode->Level;
1018  }
1020  {
1022  }
1023  _SEH2_END;
1024 
1026 
1027  return Status;
1028 }
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
Definition: Node.h:9
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:515
#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 691 of file plugplay.c.

692 {
693  ULONG Output = 0;
694 
695  if (DeviceNode->Parent == IopRootDeviceNode)
697 
698  if (DeviceNode->Flags & DNF_ADDED)
700 
701  /* FIXME: DN_ENUM_LOADED */
702 
703  if (DeviceNode->Flags & DNF_STARTED)
704  Output |= DN_STARTED;
705 
706  /* FIXME: Manual */
707 
708  if (!(DeviceNode->Flags & DNF_PROCESSED))
710 
711  /* DN_NOT_FIRST_TIME is 9x only */
712 
713  /* FIXME: DN_HARDWARE_ENUM */
714 
715  /* DN_LIAR and DN_HAS_MARK are 9x only */
716 
717  if (DeviceNode->Problem != 0)
719 
720  /* FIXME: DN_FILTERED */
721 
722  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
724 
725  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
727 
728  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
730 
731  /* FIXME: Implement the rest */
732 
734 
735  return Output;
736 }
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
#define DNF_PROCESSED
Definition: iotypes.h:167
#define DNUF_NOT_DISABLEABLE
Definition: iotypes.h:204
#define DN_ROOT_ENUMERATED
Definition: cfg.h:118
#define DN_NEED_TO_ENUM
Definition: cfg.h:123
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define DN_DISABLEABLE
Definition: cfg.h:131
#define DNUF_DONT_SHOW_IN_UI
Definition: iotypes.h:203
#define DN_NO_SHOW_IN_DM
Definition: cfg.h:148
#define DNF_STARTED
Definition: iotypes.h:168
#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
Definition: arc.h:85
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:181
#define DN_LEGACY_DRIVER
Definition: cfg.h:155
#define DN_STARTED
Definition: cfg.h:121
unsigned int ULONG
Definition: retypes.h:1
#define DNF_ADDED
Definition: iotypes.h:179

Referenced by IopDeviceStatus().

◆ IopGetDeviceObjectFromDeviceInstance()

PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance ( PUNICODE_STRING  DeviceInstance)

Definition at line 148 of file plugplay.c.

149 {
150  if (IopRootDeviceNode == NULL)
151  return NULL;
152 
153  if (DeviceInstance == NULL ||
154  DeviceInstance->Length == 0)
155  {
157  {
160  }
161  else
162  return NULL;
163  }
164 
166 }
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:839
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
static PDEVICE_OBJECT IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:119
smooth NULL
Definition: ftsmooth.c:416
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by IopActionInterrogateDeviceStack(), IopDeviceStatus(), IopGetDeviceDepth(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopGetInterfaceDeviceList(), IopGetRelatedDevice(), IopPnpEnumerateDevice(), IopResetDevice(), and IoSetDeviceInterfaceState().

◆ IopGetDeviceProperty()

static NTSTATUS IopGetDeviceProperty ( PPLUGPLAY_CONTROL_PROPERTY_DATA  PropertyData)
static

Definition at line 327 of file plugplay.c.

328 {
333  ULONG Property;
335  PVOID Buffer;
337 
338  DPRINT("IopGetDeviceProperty() called\n");
339  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
340 
342  if (!NT_SUCCESS(Status))
343  {
344  return Status;
345  }
346 
347  _SEH2_TRY
348  {
349  Property = PropertyData->Property;
350  BufferSize = PropertyData->BufferSize;
351  ProbeForWrite(PropertyData->Buffer,
352  BufferSize,
353  sizeof(UCHAR));
354  }
356  {
357  if (DeviceInstance.Buffer != NULL)
358  {
360  }
362  }
363  _SEH2_END;
364 
365  /* Get the device object */
367  if (DeviceInstance.Buffer != NULL)
368  {
370  }
371  if (DeviceObject == NULL)
372  {
373  return STATUS_NO_SUCH_DEVICE;
374  }
375 
377  if (Buffer == NULL)
378  {
381  }
382 
383 
384  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
385 
387  {
388  if (BufferSize < sizeof(CM_POWER_DATA))
389  {
390  BufferSize = 0;
392  }
393  else
394  {
396  PCM_POWER_DATA PowerData;
397  IO_STACK_LOCATION Stack;
399 
400  PowerData = (PCM_POWER_DATA)Buffer;
401  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
402  PowerData->PD_Size = sizeof(CM_POWER_DATA);
403 
406  DeviceCapabilities.Version = 1;
407  DeviceCapabilities.Address = -1;
408  DeviceCapabilities.UINumber = -1;
409 
410  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
411 
413  &IoStatusBlock,
415  &Stack);
416  if (NT_SUCCESS(Status))
417  {
418  DPRINT("Got device capabiliities\n");
419 
420  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
421  if (DeviceCapabilities.DeviceD1)
422  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
423  if (DeviceCapabilities.DeviceD2)
424  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
425  if (DeviceCapabilities.WakeFromD0)
427  if (DeviceCapabilities.WakeFromD1)
429  if (DeviceCapabilities.WakeFromD2)
431  if (DeviceCapabilities.WakeFromD3)
433  if (DeviceCapabilities.WarmEjectSupported)
435  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
436  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
437  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
439  &DeviceCapabilities.DeviceState,
440  sizeof(DeviceCapabilities.DeviceState));
441  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
442  }
443  else
444  {
445  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
446 
449  }
450  }
451  }
453  {
454  }
456  {
457  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
458  {
459  BufferSize = 0;
461  }
462  else
463  {
464  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
466  &DeviceNode->HardwareRemovalPolicy,
467  BufferSize);
468  }
469  }
470  else
471  {
472  switch (Property)
473  {
476  break;
477 
480  break;
481 
484  break;
485 
488  break;
489 
492  break;
493 
496  break;
497 
500  break;
501 
504  break;
505 
508  break;
509 
510 #if (WINVER >= _WIN32_WINNT_WS03)
512  break;
513 #endif
514 
515 #if (WINVER >= _WIN32_WINNT_WIN7)
518  break;
519 #endif
520 
521  default:
522  BufferSize = 0;
524  break;
525  }
526 
527  if (Status == STATUS_SUCCESS)
528  {
531  BufferSize,
532  Buffer,
533  &BufferSize);
534  }
535  }
536 
538 
539  if (NT_SUCCESS(Status))
540  {
541  _SEH2_TRY
542  {
543  RtlCopyMemory(PropertyData->Buffer, Buffer, BufferSize);
544  PropertyData->BufferSize = BufferSize;
545  }
547  {
549  }
550  _SEH2_END;
551  }
552 
554  return Status;
555 }
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1154
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define PDCAP_WARM_EJECT_SUPPORTED
Definition: advprop.cpp:44
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PDCAP_D1_SUPPORTED
Definition: advprop.cpp:37
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
DEVICE_CAPABILITIES
Definition: iotypes.h:928
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
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:64
_SEH2_TRY
Definition: create.c:4250
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
ULONG PD_D2Latency
Definition: advprop.cpp:52
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define DeviceCapabilities
Definition: wingdi.h:4444
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
void DPRINT(...)
Definition: polytest.cpp:61
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
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:488
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
#define BufferSize
Definition: classpnp.h:419
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:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
Status
Definition: gdiplustypes.h:24
#define PDCAP_WAKE_FROM_D1_SUPPORTED
Definition: advprop.cpp:41
_In_ DWORD Property
Definition: setupapi.h:1545
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
SYSTEM_POWER_STATE PD_DeepestSystemWake
Definition: advprop.cpp:55
_SEH2_END
Definition: create.c:4424
ULONG PD_D1Latency
Definition: advprop.cpp:51
_In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: iofuncs.h:1003
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
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define PDCAP_WAKE_FROM_D0_SUPPORTED
Definition: advprop.cpp:40
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
DEVICE_POWER_STATE PD_MostRecentPowerState
Definition: advprop.cpp:49
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define PDCAP_WAKE_FROM_D2_SUPPORTED
Definition: advprop.cpp:42
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966
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 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 829 of file plugplay.c.

830 {
833  IO_STACK_LOCATION Stack;
835  PDEVICE_RELATIONS DeviceRelations = NULL;
836  PDEVICE_OBJECT ChildDeviceObject;
837  PDEVICE_NODE ChildDeviceNode;
838  ULONG i;
839  ULONG Relations;
841  ULONG BufferLeft;
842  PWCHAR Buffer, Ptr;
844 
845  DPRINT("IopGetDeviceRelations() called\n");
846  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
847  DPRINT("Relations: %lu\n", RelationsData->Relations);
848  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
849  DPRINT("Buffer: %p\n", RelationsData->Buffer);
850 
851  _SEH2_TRY
852  {
853  Relations = RelationsData->Relations;
854  BufferSize = RelationsData->BufferSize;
855  Buffer = RelationsData->Buffer;
856 
857  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
858  }
860  {
862  }
863  _SEH2_END;
864 
866  if (!NT_SUCCESS(Status))
867  {
868  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
869  return Status;
870  }
871 
872  /* Get the device object */
874  if (DeviceObject == NULL)
875  {
876  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
878  goto done;
879  }
880 
881  switch (Relations)
882  {
883  case PNP_EJECT_RELATIONS:
884  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
885  break;
886 
888  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
889  break;
890 
891  case PNP_POWER_RELATIONS:
892  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
893  break;
894 
895  case PNP_BUS_RELATIONS:
896  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
897  break;
898 
899  default:
901  goto done;
902  }
903 
905  &IoStatusBlock,
907  &Stack);
908  if (!NT_SUCCESS(Status))
909  {
910  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
911  goto done;
912  }
913 
914  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
915 
916  DPRINT("Found %d device relations\n", DeviceRelations->Count);
917 
918  _SEH2_TRY
919  {
920  RequiredSize = 0;
921  BufferLeft = BufferSize;
922  Ptr = Buffer;
923 
924  for (i = 0; i < DeviceRelations->Count; i++)
925  {
926  ChildDeviceObject = DeviceRelations->Objects[i];
927 
928  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
929  if (ChildDeviceNode)
930  {
931  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
932  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
933 
934  if (Ptr != NULL)
935  {
936  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
937  {
939  break;
940  }
941 
943  ChildDeviceNode->InstancePath.Buffer,
944  ChildDeviceNode->InstancePath.Length);
945  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
946  *Ptr = UNICODE_NULL;
947  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
948 
949  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
950  }
951 
952  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
953  }
954  }
955 
956  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
957  *Ptr = UNICODE_NULL;
958 
959  if (RequiredSize > 0)
960  RequiredSize += sizeof(WCHAR);
961 
962  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
963 
964  RelationsData->BufferSize = RequiredSize;
965  }
967  {
969  }
970  _SEH2_END;
971 
972 done:
973  if (DeviceRelations != NULL)
974  ExFreePool(DeviceRelations);
975 
976  if (DeviceObject != NULL)
978 
979  if (DeviceInstance.Buffer != NULL)
981 
982  return Status;
983 }
#define PNP_REMOVAL_RELATIONS
Definition: cmtypes.h:67
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define PNP_POWER_RELATIONS
Definition: cmtypes.h:68
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
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
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
uint16_t * PWCHAR
Definition: typedefs.h:54
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:64
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
#define UNICODE_NULL
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__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 BufferSize
Definition: classpnp.h:419
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
UNICODE_STRING InstancePath
Definition: iotypes.h:842
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#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 _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966
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)

Referenced by NtPlugPlayControl().

◆ IopGetInterfaceDeviceList()

static NTSTATUS IopGetInterfaceDeviceList ( PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA  DeviceList)
static

Definition at line 249 of file plugplay.c.

250 {
255  GUID FilterGuid;
256  PZZWSTR SymbolicLinkList = NULL, LinkList;
258 
259  _SEH2_TRY
260  {
262 
263  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
264  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
265 
266  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
267  {
268  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
269  }
270  }
272  {
274  }
275  _SEH2_END;
276 
278  if (NT_SUCCESS(Status))
279  {
280  /* Get the device object */
282  if (DeviceInstance.Buffer != NULL)
283  {
285  }
286  }
287 
288  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
290 
291  if (!NT_SUCCESS(Status))
292  {
293  /* failed */
294  return Status;
295  }
296 
297  LinkList = SymbolicLinkList;
298  while (*SymbolicLinkList != UNICODE_NULL)
299  {
300  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
301  }
302  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
303 
304  _SEH2_TRY
305  {
306  if (StackList.Buffer != NULL &&
307  StackList.BufferSize >= TotalLength)
308  {
309  // We've already probed the buffer for writing above.
310  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
311  }
312 
313  DeviceList->BufferSize = TotalLength;
314  }
316  {
317  ExFreePool(LinkList);
319  }
320  _SEH2_END;
321 
322  ExFreePool(LinkList);
323  return STATUS_SUCCESS;
324 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_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
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:427
_In_ ULONG TotalLength
Definition: usbdlib.h:145
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define UNICODE_NULL
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_SEH2_END
Definition: create.c:4424
PDEVICE_LIST DeviceList
Definition: utils.c:27
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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 559 of file plugplay.c.

560 {
561  UNICODE_STRING RootDeviceName;
564  PDEVICE_NODE RelatedDeviceNode;
565  UNICODE_STRING TargetDeviceInstance;
567  ULONG Relation = 0;
568  ULONG MaximumLength = 0;
569 
570  DPRINT("IopGetRelatedDevice() called\n");
571  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
572 
573  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
574  if (!NT_SUCCESS(Status))
575  {
576  return Status;
577  }
578 
579  _SEH2_TRY
580  {
581  Relation = RelatedDeviceData->Relation;
582  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
583  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
585  sizeof(WCHAR));
586  }
588  {
589  if (TargetDeviceInstance.Buffer != NULL)
590  {
591  ExFreePool(TargetDeviceInstance.Buffer);
592  }
594  }
595  _SEH2_END;
596 
597  RtlInitUnicodeString(&RootDeviceName,
598  L"HTREE\\ROOT\\0");
599  if (RtlEqualUnicodeString(&TargetDeviceInstance,
600  &RootDeviceName,
601  TRUE))
602  {
604  if (TargetDeviceInstance.Buffer != NULL)
605  {
606  ExFreePool(TargetDeviceInstance.Buffer);
607  }
608  }
609  else
610  {
611  /* Get the device object */
612  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
613  if (TargetDeviceInstance.Buffer != NULL)
614  {
615  ExFreePool(TargetDeviceInstance.Buffer);
616  }
617  if (DeviceObject == NULL)
618  return STATUS_NO_SUCH_DEVICE;
619 
620  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
621  }
622 
623  switch (Relation)
624  {
626  RelatedDeviceNode = DeviceNode->Parent;
627  break;
628 
630  RelatedDeviceNode = DeviceNode->Child;
631  break;
632 
634  RelatedDeviceNode = DeviceNode->Sibling;
635  break;
636 
637  default:
638  if (DeviceObject != NULL)
639  {
641  }
642 
644  }
645 
646  if (RelatedDeviceNode == NULL)
647  {
648  if (DeviceObject)
649  {
651  }
652 
653  return STATUS_NO_SUCH_DEVICE;
654  }
655 
656  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
657  {
658  if (DeviceObject)
659  {
661  }
662 
664  }
665 
666  /* Copy related device instance name */
667  _SEH2_TRY
668  {
669  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
670  RelatedDeviceNode->InstancePath.Buffer,
671  RelatedDeviceNode->InstancePath.Length);
672  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
673  }
675  {
677  }
678  _SEH2_END;
679 
680  if (DeviceObject != NULL)
681  {
683  }
684 
685  DPRINT("IopGetRelatedDevice() done\n");
686 
687  return Status;
688 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
#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 ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
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:64
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__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
Definition: Node.h:9
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:169
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
UNICODE_STRING InstancePath
Definition: iotypes.h:842
Status
Definition: gdiplustypes.h:24
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopInitPlugPlayEvents()

NTSTATUS INIT_FUNCTION IopInitPlugPlayEvents ( VOID  )

Definition at line 34 of file plugplay.c.

35 {
37 
40  FALSE);
41 
42  return STATUS_SUCCESS;
43 }
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:28
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:29
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by IopInitializePlugPlayServices().

◆ IopPnpEnumerateDevice()

static NTSTATUS IopPnpEnumerateDevice ( PPLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA  DeviceData)
static

Definition at line 216 of file plugplay.c.

217 {
221 
223  if (!NT_SUCCESS(Status))
224  {
225  return Status;
226  }
227 
228  DPRINT("IopPnpEnumerateDevice(%wZ)\n", &DeviceInstance);
229 
230  /* Get the device object */
232  if (DeviceInstance.Buffer != NULL)
233  {
235  }
236  if (DeviceObject == NULL)
237  {
238  return STATUS_NO_SUCH_DEVICE;
239  }
240 
242 
244 
245  return Status;
246 }
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS IopEnumerateDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:2670
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopQueueTargetDeviceEvent()

NTSTATUS IopQueueTargetDeviceEvent ( const GUID Guid,
PUNICODE_STRING  DeviceIds 
)

Definition at line 46 of file plugplay.c.

48 {
49  PPNP_EVENT_ENTRY EventEntry;
51  ULONG TotalSize;
53 
54  ASSERT(DeviceIds);
55 
56  /* Allocate a big enough buffer */
57  Copy.Length = 0;
58  Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
59  TotalSize =
61  Copy.MaximumLength;
62 
63  EventEntry = ExAllocatePool(NonPagedPool,
64  TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
65  if (!EventEntry)
67 
68  /* Fill the buffer with the event GUID */
69  RtlCopyMemory(&EventEntry->Event.EventGuid,
70  Guid,
71  sizeof(GUID));
73  EventEntry->Event.TotalSize = TotalSize;
74 
75  /* Fill the device id */
76  Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
78  if (!NT_SUCCESS(Status))
79  {
80  ExFreePool(EventEntry);
81  return Status;
82  }
83 
85  &EventEntry->ListEntry);
87  0,
88  FALSE);
89 
90  return STATUS_SUCCESS;
91 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
Definition: plugplay.c:19
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:22
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:28
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:399
#define UNICODE_NULL
static GUID * Guid
Definition: apphelp.c:93
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:29
struct _PLUGPLAY_EVENT_BLOCK::@2278::@2281 TargetDevice
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Status
Definition: gdiplustypes.h:24
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:131
LIST_ENTRY ListEntry
Definition: plugplay.c:21
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IoInvalidateDeviceState(), IopActionInterrogateDeviceStack(), IopEnumerateDevice(), IopHandleDeviceRemoval(), IopInitializePlugPlayServices(), IopQueryRemoveDevice(), IopRemoveDevice(), IoReportDetectedDevice(), and IoRequestDeviceEject().

◆ IopRemovePlugPlayEvent()

static NTSTATUS IopRemovePlugPlayEvent ( VOID  )
static

Definition at line 99 of file plugplay.c.

100 {
101  /* Remove a pnp event entry from the tail of the queue */
103  {
105  }
106 
107  /* Signal the next pnp event in the queue */
109  {
111  0,
112  FALSE);
113  }
114 
115  return STATUS_SUCCESS;
116 }
Definition: plugplay.c:19
FORCEINLINE PLIST_ENTRY RemoveTailList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:154
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:28
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
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:29
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
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtPlugPlayControl().

◆ IopResetDevice()

static NTSTATUS IopResetDevice ( PPLUGPLAY_CONTROL_RESET_DEVICE_DATA  ResetDeviceData)
static

Definition at line 1032 of file plugplay.c.

1033 {
1038 
1040  if (!NT_SUCCESS(Status))
1041  {
1042  return Status;
1043  }
1044 
1045  DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
1046 
1047  /* Get the device object */
1049  if (DeviceInstance.Buffer != NULL)
1050  {
1052  }
1053  if (DeviceObject == NULL)
1054  {
1055  return STATUS_NO_SUCH_DEVICE;
1056  }
1057 
1058  /* Get the device node */
1060 
1061  ASSERT(DeviceNode->Flags & DNF_ENUMERATED);
1062  ASSERT(DeviceNode->Flags & DNF_PROCESSED);
1063 
1064  /* Check if there's already a driver loaded for this device */
1065  if (DeviceNode->Flags & DNF_ADDED)
1066  {
1067 #if 0
1068  /* Remove the device node */
1070  if (NT_SUCCESS(Status))
1071  {
1072  /* Invalidate device relations for the parent to reenumerate the device */
1073  DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode->InstancePath);
1074  Status = IoSynchronousInvalidateDeviceRelations(DeviceNode->Parent->PhysicalDeviceObject, BusRelations);
1075  }
1076  else
1077 #endif
1078  {
1079  /* A driver has already been loaded for this device */
1080  DPRINT("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode->InstancePath);
1081  DeviceNode->Problem = CM_PROB_NEED_RESTART;
1082  }
1083  }
1084  else
1085  {
1086  /* FIXME: What if the device really is disabled? */
1087  DeviceNode->Flags &= ~DNF_DISABLED;
1088  DeviceNode->Problem = 0;
1089 
1090  /* Load service data from the registry */
1092 
1093  if (NT_SUCCESS(Status))
1094  {
1095  /* Start the service and begin PnP initialization of the device again */
1096  DPRINT("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode->InstancePath);
1098  }
1099  }
1100 
1102 
1103  return Status;
1104 }
NTSTATUS NTAPI IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5147
#define DNF_PROCESSED
Definition: iotypes.h:167
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
NTSTATUS IopRemoveDevice(IN PDEVICE_NODE DeviceNode)
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:169
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define DNF_DISABLED
Definition: iotypes.h:188
#define CM_PROB_NEED_RESTART
Definition: cfg.h:44
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DPRINT1
Definition: precomp.h:8
#define DNF_ENUMERATED
Definition: iotypes.h:170
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define DNF_ADDED
Definition: iotypes.h:179
NTSTATUS IopActionInitChildServices(IN PDEVICE_NODE DeviceNode, IN PVOID Context)
NTSTATUS IopActionConfigureChildServices(IN PDEVICE_NODE DeviceNode, IN PVOID Context)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)

Referenced by NtPlugPlayControl().

◆ IopTraverseDeviceNode()

static PDEVICE_OBJECT IopTraverseDeviceNode ( PDEVICE_NODE  Node,
PUNICODE_STRING  DeviceInstance 
)
static

Definition at line 119 of file plugplay.c.

120 {
122  PDEVICE_NODE ChildNode;
123 
124  if (RtlEqualUnicodeString(&Node->InstancePath,
126  {
127  ObReferenceObject(Node->PhysicalDeviceObject);
128  return Node->PhysicalDeviceObject;
129  }
130 
131  /* Traversal of all children nodes */
132  for (ChildNode = Node->Child;
133  ChildNode != NULL;
134  ChildNode = ChildNode->Sibling)
135  {
137  if (DeviceObject != NULL)
138  {
139  return DeviceObject;
140  }
141  }
142 
143  return NULL;
144 }
#define TRUE
Definition: types.h:120
static PDEVICE_OBJECT IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:119
smooth NULL
Definition: ftsmooth.c:416
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _DEVICE_NODE * Sibling
Definition: iotypes.h:823
#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 1169 of file plugplay.c.

1173 {
1175  NTSTATUS Status;
1176 
1177  DPRINT("NtGetPlugPlayEvent() called\n");
1178 
1179  /* Function can only be called from user-mode */
1180  if (KeGetPreviousMode() == KernelMode)
1181  {
1182  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1183  return STATUS_ACCESS_DENIED;
1184  }
1185 
1186  /* Check for Tcb privilege */
1188  UserMode))
1189  {
1190  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1192  }
1193 
1194  /* Wait for a PnP event */
1195  DPRINT("Waiting for pnp notification event\n");
1197  UserRequest,
1198  UserMode,
1199  FALSE,
1200  NULL);
1202  {
1203  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1205  return Status;
1206  }
1207 
1208  /* Get entry from the tail of the queue */
1211  ListEntry);
1212 
1213  /* Check the buffer size */
1214  if (BufferSize < Entry->Event.TotalSize)
1215  {
1216  DPRINT1("Buffer is too small for the pnp-event\n");
1217  return STATUS_BUFFER_TOO_SMALL;
1218  }
1219 
1220  /* Copy event data to the user buffer */
1221  _SEH2_TRY
1222  {
1224  Entry->Event.TotalSize,
1225  sizeof(UCHAR));
1227  &Entry->Event,
1228  Entry->Event.TotalSize);
1229  }
1231  {
1233  }
1234  _SEH2_END;
1235 
1236  DPRINT("NtGetPlugPlayEvent() done\n");
1237 
1238  return STATUS_SUCCESS;
1239 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _Entry Entry
Definition: kefuncs.h:640
Definition: plugplay.c:19
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
#define KeGetPreviousMode()
Definition: ketypes.h:1107
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:28
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:64
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:29
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 _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
const LUID SeTcbPrivilege
Definition: priv.c:28
#define STATUS_USER_APC
Definition: ntstatus.h:78
_SEH2_END
Definition: create.c:4424
#define DPRINT1
Definition: precomp.h:8
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
base of all file and directory entries
Definition: entries.h:82

Referenced by PnpEventThread().

◆ NtPlugPlayControl()

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

Definition at line 1299 of file plugplay.c.

1302 {
1303  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1304  PlugPlayControlClass, Buffer, BufferLength);
1305 
1306  /* Function can only be called from user-mode */
1307  if (KeGetPreviousMode() == KernelMode)
1308  {
1309  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1310  return STATUS_ACCESS_DENIED;
1311  }
1312 
1313  /* Check for Tcb privilege */
1315  UserMode))
1316  {
1317  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1319  }
1320 
1321  /* Probe the buffer */
1322  _SEH2_TRY
1323  {
1325  BufferLength,
1326  sizeof(ULONG));
1327  }
1329  {
1331  }
1332  _SEH2_END;
1333 
1334  switch (PlugPlayControlClass)
1335  {
1338  return STATUS_INVALID_PARAMETER;
1340 
1341 // case PlugPlayControlRegisterNewDevice:
1342 // case PlugPlayControlDeregisterDevice:
1343 // case PlugPlayControlInitializeDevice:
1344 // case PlugPlayControlStartDevice:
1345 // case PlugPlayControlUnlockDevice:
1346 // case PlugPlayControlQueryAndRemoveDevice:
1347 
1350  return STATUS_INVALID_PARAMETER;
1351  return IopRemovePlugPlayEvent();
1352 
1353 // case PlugPlayControlGenerateLegacyDevice:
1354 
1357  return STATUS_INVALID_PARAMETER;
1359 
1362  return STATUS_INVALID_PARAMETER;
1364 
1365 // case PlugPlayControlDeviceClassAssociation:
1366 
1369  return STATUS_INVALID_PARAMETER;
1371 
1372 // case PlugPlayControlGetInterfaceDeviceAlias:
1373 
1376  return STATUS_INVALID_PARAMETER;
1378 
1381  return STATUS_INVALID_PARAMETER;
1383 
1386  return STATUS_INVALID_PARAMETER;
1388 
1389 // case PlugPlayControlTargetDeviceRelation:
1390 // case PlugPlayControlQueryConflictList:
1391 // case PlugPlayControlRetrieveDock:
1392 
1395  return STATUS_INVALID_PARAMETER;
1397 
1398 // case PlugPlayControlHaltDevice:
1399 // case PlugPlayControlGetBlockedDriverList:
1400 
1401  default:
1402  return STATUS_NOT_IMPLEMENTED;
1403  }
1404 
1405  return STATUS_NOT_IMPLEMENTED;
1406 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
static NTSTATUS IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
Definition: plugplay.c:559
static NTSTATUS IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
Definition: plugplay.c:1032
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define KeGetPreviousMode()
Definition: ketypes.h:1107
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:829
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
static NTSTATUS IopRemovePlugPlayEvent(VOID)
Definition: plugplay.c:99
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:327
_In_ ULONG BufferLength
Definition: usbdlib.h:225
static NTSTATUS IopPnpEnumerateDevice(PPLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA DeviceData)
Definition: plugplay.c:216
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
static NTSTATUS IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
Definition: plugplay.c:739
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:986
const LUID SeTcbPrivilege
Definition: priv.c:28
_SEH2_END
Definition: create.c:4424
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
static NTSTATUS IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
Definition: plugplay.c:249

Referenced by EnableDeviceInstance(), GetDeviceStatus(), GetRelationsInstanceList(), GetRelationsInstanceListSize(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetRelatedDeviceInstance(), PNP_QueryRemove(), PNP_RequestDeviceEject(), PnpEventThread(), ReenumerateDeviceInstance(), and ResetDevice().

Variable Documentation

◆ IopPnpEventQueueHead

LIST_ENTRY IopPnpEventQueueHead
static

◆ IopPnpNotifyEvent

KEVENT IopPnpNotifyEvent
static