Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

pnp.h File Reference

Go to the source code of this file.

Classes

struct  _PNP_BUS_INFORMATION
struct  _LEGACY_BUS_INFORMATION
struct  _BUS_INTERFACE_STANDARD
struct  _ACPI_INTERFACE_STANDARD
struct  ACPI_REGS_INTERFACE_STANDARD
struct  ROUTING_TOKEN
struct  _INT_ROUTE_INTERFACE_STANDARD
struct  _IO_ASSIGNED_RESOURCES
struct  _ARBITER_CONFLICT_INFO
struct  _ARBITER_PARAMETERS
struct  _ARBITER_LIST_ENTRY
struct  _ARBITER_INTERFACE
struct  _TRANSLATOR_INTERFACE
struct  _LEGACY_DEVICE_DETECTION_INTERFACE
struct  _PLUGPLAY_NOTIFICATION_HEADER
struct  _HWPROFILE_CHANGE_NOTIFICATION
struct  _DEVICE_INTERFACE_CHANGE_NOTIFICATION
struct  _TARGET_DEVICE_REMOVAL_NOTIFICATION
struct  _TARGET_DEVICE_CUSTOM_NOTIFICATION

Defines

#define PCI_MSI_ROUTING   0x1
#define PCI_INT_ROUTE_INTRF_STANDARD_VER   1
#define PLUGPLAY_REGKEY_DEVICE   1
#define PLUGPLAY_REGKEY_DRIVER   2
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE   4
#define DEVICE_INTERFACE_INCLUDE_NONACTIVE   0x00000001
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES   0x00000001
#define IoAdjustPagingPathCount(_count_, _paging_)
#define ARBITER_FLAG_BOOT_CONFIG   0x00000001
#define ARBITER_PARTIAL   0x00000001
#define TDF_DEVICEEJECTABLE   0x00000001
#define TDF_NO_RESTART   0x00000002
#define TDF_KERNEL_INITIATED   0x00000004

Typedefs

typedef BOOLEAN(* PTRANSLATE_BUS_ADDRESS )(IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
typedef _DMA_ADAPTER *(* PGET_DMA_ADAPTER )(IN PVOID Context, IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, OUT PULONG NumberOfMapRegisters)
typedef ULONG(* PGET_SET_DEVICE_DATA )(IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
typedef _PNP_BUS_INFORMATION PNP_BUS_INFORMATION
typedef _PNP_BUS_INFORMATIONPPNP_BUS_INFORMATION
typedef _LEGACY_BUS_INFORMATION LEGACY_BUS_INFORMATION
typedef _LEGACY_BUS_INFORMATIONPLEGACY_BUS_INFORMATION
typedef _BUS_INTERFACE_STANDARD BUS_INTERFACE_STANDARD
typedef _BUS_INTERFACE_STANDARDPBUS_INTERFACE_STANDARD
typedef BOOLEAN(* PGPE_SERVICE_ROUTINE )(PVOID, PVOID)
typedef NTSTATUS(* PGPE_CONNECT_VECTOR )(PDEVICE_OBJECT, ULONG, KINTERRUPT_MODE, BOOLEAN, PGPE_SERVICE_ROUTINE, PVOID, PVOID)
typedef NTSTATUS(* PGPE_DISCONNECT_VECTOR )(PVOID)
typedef NTSTATUS(* PGPE_ENABLE_EVENT )(PDEVICE_OBJECT, PVOID)
typedef NTSTATUS(* PGPE_DISABLE_EVENT )(PDEVICE_OBJECT, PVOID)
typedef NTSTATUS(* PGPE_CLEAR_STATUS )(PDEVICE_OBJECT, PVOID)
typedef VOID(* PDEVICE_NOTIFY_CALLBACK )(PVOID, ULONG)
typedef NTSTATUS(* PREGISTER_FOR_DEVICE_NOTIFICATIONS )(PDEVICE_OBJECT, PDEVICE_NOTIFY_CALLBACK, PVOID)
typedef void(* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS )(PDEVICE_OBJECT, PDEVICE_NOTIFY_CALLBACK)
typedef _ACPI_INTERFACE_STANDARD ACPI_INTERFACE_STANDARD
typedef _ACPI_INTERFACE_STANDARDPACPI_INTERFACE_STANDARD
typedef enum _ACPI_REG_TYPE ACPI_REG_TYPE
typedef enum _ACPI_REG_TYPEPACPI_REG_TYPE
typedef USHORT(* PREAD_ACPI_REGISTER )(IN ACPI_REG_TYPE AcpiReg, IN ULONG Register)
typedef VOID(* PWRITE_ACPI_REGISTER )(IN ACPI_REG_TYPE AcpiReg, IN ULONG Register, IN USHORT Value)
typedef ACPI_REGS_INTERFACE_STANDARD ACPI_REGS_INTERFACE_STANDARD
typedef ACPI_REGS_INTERFACE_STANDARDPACPI_REGS_INTERFACE_STANDARD
typedef * PROUTING_TOKEN
typedef NTSTATUS(* PGET_INTERRUPT_ROUTING )(IN PDEVICE_OBJECT Pdo, OUT ULONG *Bus, OUT ULONG *PciSlot, OUT UCHAR *InterruptLine, OUT UCHAR *InterruptPin, OUT UCHAR *ClassCode, OUT UCHAR *SubClassCode, OUT PDEVICE_OBJECT *ParentPdo, OUT ROUTING_TOKEN *RoutingToken, OUT UCHAR *Flags)
typedef NTSTATUS(* PSET_INTERRUPT_ROUTING_TOKEN )(IN PDEVICE_OBJECT Pdo, IN PROUTING_TOKEN RoutingToken)
typedef VOID(* PUPDATE_INTERRUPT_LINE )(IN PDEVICE_OBJECT Pdo, IN UCHAR LineRegister)
typedef _INT_ROUTE_INTERFACE_STANDARD INT_ROUTE_INTERFACE_STANDARD
typedef _INT_ROUTE_INTERFACE_STANDARDPINT_ROUTE_INTERFACE_STANDARD
typedef _IO_ASSIGNED_RESOURCES IO_ASSIGNED_RESOURCES
typedef _IO_ASSIGNED_RESOURCESPIO_ASSIGNED_RESOURCES
typedef enum _IO_NOTIFICATION_EVENT_CATEGORY IO_NOTIFICATION_EVENT_CATEGORY
typedef NTSTATUS(* PDRIVER_NOTIFICATION_CALLBACK_ROUTINE )(IN PVOID NotificationStructure, IN PVOID Context)
typedef VOID(* PDEVICE_CHANGE_COMPLETE_CALLBACK )(IN PVOID Context)
typedef enum _ARBITER_ACTION ARBITER_ACTION
typedef enum _ARBITER_ACTIONPARBITER_ACTION
typedef _ARBITER_CONFLICT_INFO ARBITER_CONFLICT_INFO
typedef _ARBITER_CONFLICT_INFOPARBITER_CONFLICT_INFO
typedef _ARBITER_PARAMETERS ARBITER_PARAMETERS
typedef _ARBITER_PARAMETERSPARBITER_PARAMETERS
typedef enum _ARBITER_REQUEST_SOURCE ARBITER_REQUEST_SOURCE
typedef enum _ARBITER_RESULT ARBITER_RESULT
typedef _ARBITER_LIST_ENTRY ARBITER_LIST_ENTRY
typedef _ARBITER_LIST_ENTRYPARBITER_LIST_ENTRY
typedef NTSTATUS(* PARBITER_HANDLER )(IN PVOID Context, IN ARBITER_ACTION Action, IN OUT PARBITER_PARAMETERS Parameters)
typedef _ARBITER_INTERFACE ARBITER_INTERFACE
typedef _ARBITER_INTERFACEPARBITER_INTERFACE
typedef enum _RESOURCE_TRANSLATION_DIRECTION RESOURCE_TRANSLATION_DIRECTION
typedef NTSTATUS(* PTRANSLATE_RESOURCE_HANDLER )(IN PVOID Context, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount, OPTIONAL IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
typedef NTSTATUS(* PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER )(IN PVOID Context, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
typedef _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE
typedef _TRANSLATOR_INTERFACEPTRANSLATOR_INTERFACE
typedef NTSTATUS(* PLEGACY_DEVICE_DETECTION_HANDLER )(IN PVOID Context, IN INTERFACE_TYPE LegacyBusType, IN ULONG BusNumber, IN ULONG SlotNumber, OUT PDEVICE_OBJECT *PhysicalDeviceObject)
typedef _LEGACY_DEVICE_DETECTION_INTERFACE LEGACY_DEVICE_DETECTION_INTERFACE
typedef _LEGACY_DEVICE_DETECTION_INTERFACEPLEGACY_DEVICE_DETECTION_INTERFACE
typedef _PLUGPLAY_NOTIFICATION_HEADER PLUGPLAY_NOTIFICATION_HEADER
typedef _PLUGPLAY_NOTIFICATION_HEADERPPLUGPLAY_NOTIFICATION_HEADER
typedef _HWPROFILE_CHANGE_NOTIFICATION HWPROFILE_CHANGE_NOTIFICATION
typedef _HWPROFILE_CHANGE_NOTIFICATIONPHWPROFILE_CHANGE_NOTIFICATION
typedef _DEVICE_INTERFACE_CHANGE_NOTIFICATION DEVICE_INTERFACE_CHANGE_NOTIFICATION
typedef _DEVICE_INTERFACE_CHANGE_NOTIFICATIONPDEVICE_INTERFACE_CHANGE_NOTIFICATION
typedef _TARGET_DEVICE_REMOVAL_NOTIFICATION TARGET_DEVICE_REMOVAL_NOTIFICATION
typedef _TARGET_DEVICE_REMOVAL_NOTIFICATIONPTARGET_DEVICE_REMOVAL_NOTIFICATION
typedef _TARGET_DEVICE_CUSTOM_NOTIFICATION TARGET_DEVICE_CUSTOM_NOTIFICATION
typedef _TARGET_DEVICE_CUSTOM_NOTIFICATIONPTARGET_DEVICE_CUSTOM_NOTIFICATION

Enumerations

enum  DEVICE_REGISTRY_PROPERTY {
  DevicePropertyDeviceDescription, DevicePropertyHardwareID, DevicePropertyCompatibleIDs, DevicePropertyBootConfiguration,
  DevicePropertyBootConfigurationTranslated, DevicePropertyClassName, DevicePropertyClassGuid, DevicePropertyDriverKeyName,
  DevicePropertyManufacturer, DevicePropertyFriendlyName, DevicePropertyLocationInformation, DevicePropertyPhysicalDeviceObjectName,
  DevicePropertyBusTypeGuid, DevicePropertyLegacyBusType, DevicePropertyBusNumber, DevicePropertyEnumeratorName,
  DevicePropertyAddress, DevicePropertyUINumber
}
enum  _ACPI_REG_TYPE {
  PM1a_ENABLE, PM1b_ENABLE, PM1a_STATUS, PM1b_STATUS,
  PM1a_CONTROL, PM1b_CONTROL, GP_STATUS, GP_ENABLE,
  SMI_CMD, MaxRegType
}
enum  _IO_NOTIFICATION_EVENT_CATEGORY { EventCategoryReserved, EventCategoryHardwareProfileChange, EventCategoryDeviceInterfaceChange, EventCategoryTargetDeviceChange }
enum  _ARBITER_ACTION {
  ArbiterActionTestAllocation, ArbiterActionRetestAllocation, ArbiterActionCommitAllocation, ArbiterActionRollbackAllocation,
  ArbiterActionQueryAllocatedResources, ArbiterActionWriteReservedResources, ArbiterActionQueryConflict, ArbiterActionQueryArbitrate,
  ArbiterActionAddReserved, ArbiterActionBootAllocation
}
enum  _ARBITER_REQUEST_SOURCE {
  ArbiterRequestUndefined = -1, ArbiterRequestLegacyReported, ArbiterRequestHalReported, ArbiterRequestLegacyAssigned,
  ArbiterRequestPnpDetected, ArbiterRequestPnpEnumerated
}
enum  _ARBITER_RESULT { ArbiterResultUndefined = -1, ArbiterResultSuccess, ArbiterResultExternalConflict, ArbiterResultNullRequest }
enum  _RESOURCE_TRANSLATION_DIRECTION { TranslateChildToParent, TranslateParentToChild }

Functions

NTKERNELAPI BOOLEAN PpInitSystem (VOID)
NTKERNELAPI NTSTATUS PpDeviceRegistration (IN PUNICODE_STRING DeviceInstancePath, IN BOOLEAN Add, IN PUNICODE_STRING ServiceKeyName OPTIONAL)
NTKERNELAPI NTSTATUS IoSynchronousInvalidateDeviceRelations (PDEVICE_OBJECT DeviceObject, DEVICE_RELATION_TYPE Type)
NTKERNELAPI NTSTATUS IoGetAssignedResourcesForSuballocation (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PIO_RESOURCE_DESCRIPTOR ResourceDescriptor, OUT PIO_ASSIGNED_RESOURCES *List)
NTKERNELAPI NTSTATUS IoReportDetectedDevice (IN PDRIVER_OBJECT DriverObject, IN INTERFACE_TYPE LegacyBusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PCM_RESOURCE_LIST ResourceList, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, IN OUT PDEVICE_OBJECT *DeviceObject)
NTKERNELAPI VOID IoInvalidateDeviceRelations (IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
NTKERNELAPI VOID IoRequestDeviceEject (IN PDEVICE_OBJECT PhysicalDeviceObject)
NTKERNELAPI NTSTATUS IoGetDeviceProperty (IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
NTKERNELAPI NTSTATUS IoOpenDeviceRegistryKey (IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
NTKERNELAPI NTSTATUS NTAPI IoRegisterDeviceInterface (IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString, OPTIONAL OUT PUNICODE_STRING SymbolicLinkName)
NTKERNELAPI NTSTATUS IoOpenDeviceInterfaceRegistryKey (IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
NTKERNELAPI NTSTATUS IoSetDeviceInterfaceState (IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaces (IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaceAlias (IN PUNICODE_STRING SymbolicLinkName, IN CONST GUID *AliasInterfaceClassGuid, OUT PUNICODE_STRING AliasSymbolicLinkName)
NTKERNELAPI NTSTATUS IoRegisterPlugPlayNotification (IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN ULONG EventCategoryFlags, IN PVOID EventCategoryData OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Context, OUT PVOID *NotificationEntry)
NTKERNELAPI NTSTATUS IoUnregisterPlugPlayNotification (IN PVOID NotificationEntry)
NTKERNELAPI NTSTATUS IoReportTargetDeviceChange (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure)
NTKERNELAPI VOID IoInvalidateDeviceState (IN PDEVICE_OBJECT PhysicalDeviceObject)
NTKERNELAPI NTSTATUS IoReportTargetDeviceChangeAsynchronous (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback, OPTIONAL IN PVOID Context OPTIONAL)
NTKERNELAPI NTSTATUS IoReportResourceForDetection (IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected)
NTSTATUS PpSetCustomTargetEvent (IN PDEVICE_OBJECT DeviceObject, IN PKEVENT SyncEvent OPTIONAL, OUT PULONG Result OPTIONAL, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL, IN PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure)
NTSTATUS PpSetTargetDeviceRemove (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN KernelInitiated, IN BOOLEAN NoRestart, IN BOOLEAN DoEject, IN ULONG Problem, IN PKEVENT SyncEvent OPTIONAL, OUT PULONG Result OPTIONAL, OUT PPNP_VETO_TYPE VetoType OPTIONAL, OUT PUNICODE_STRING VetoName OPTIONAL)
NTSTATUS PpSetDeviceRemovalSafe (IN PDEVICE_OBJECT DeviceObject, IN PKEVENT SyncEvent OPTIONAL, OUT PULONG Result OPTIONAL)
NTSTATUS PpNotifyUserModeRemovalSafe (IN PDEVICE_OBJECT DeviceObject)
NTSTATUS PpSetDeviceClassChange (IN CONST GUID *EventGuid, IN CONST GUID *ClassGuid, IN PUNICODE_STRING SymbolicLinkName)
VOID PpSetPlugPlayEvent (IN CONST GUID *EventGuid, IN PDEVICE_OBJECT DeviceObject)
NTSTATUS PpInitializeNotification (VOID)
VOID PpShutdownSystem (IN BOOLEAN Reboot, IN ULONG Phase, IN OUT PVOID *Context)
NTSTATUS PpSetPowerEvent (IN ULONG EventCode, IN PKEVENT CompletionEvent OPTIONAL, OUT PNTSTATUS CompletionStatus OPTIONAL, OUT PPNP_VETO_TYPE VetoType OPTIONAL, OUT PUNICODE_STRING VetoName OPTIONAL)
NTSTATUS PpSetHwProfileChangeEvent (IN CONST GUID *EventGuid, IN PKEVENT CompletionEvent OPTIONAL, OUT PNTSTATUS CompletionStatus OPTIONAL, OUT PPNP_VETO_TYPE VetoType OPTIONAL, OUT PUNICODE_STRING VetoName OPTIONAL)
NTSTATUS PpSynchronizeDeviceEventQueue (VOID)
NTSTATUS PpSetPowerVetoEvent (IN POWER_ACTION VetoedPowerOperation, IN PKEVENT CompletionEvent OPTIONAL, OUT PNTSTATUS CompletionStatus OPTIONAL, IN PDEVICE_OBJECT DeviceObject, IN PNP_VETO_TYPE VetoType, IN PUNICODE_STRING VetoName OPTIONAL)
ULONG IoPnPDeliverServicePowerNotification (ULONG PwrNotification, BOOLEAN Synchronous)

Variables

ERESOURCE PpRegistryDeviceResource
PDRIVER_OBJECT IoPnpDriverObject


Define Documentation

#define ARBITER_FLAG_BOOT_CONFIG   0x00000001
 

Definition at line 719 of file pnp.h.

Referenced by IopMemFindSuitableRange(), IopPortFindSuitableRange(), and IopResourceRequirementsListToReqList().

#define ARBITER_PARTIAL   0x00000001
 

Definition at line 823 of file pnp.h.

Referenced by IopSetupArbiterAndTranslators().

#define DEVICE_INTERFACE_INCLUDE_NONACTIVE   0x00000001
 

Definition at line 444 of file pnp.h.

Referenced by IopGetDeviceInterfaces(), and IopRemoveDeviceInterfaces().

#define IoAdjustPagingPathCount _count_,
_paging_   ) 
 

Value:

{ \ if (_paging_) { \ InterlockedIncrement(_count_); \ } else { \ InterlockedDecrement(_count_); \ } \ }

Definition at line 518 of file pnp.h.

#define PCI_INT_ROUTE_INTRF_STANDARD_VER   1
 

Definition at line 308 of file pnp.h.

#define PCI_MSI_ROUTING   0x1
 

Definition at line 257 of file pnp.h.

#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE   4
 

Definition at line 394 of file pnp.h.

Referenced by IoOpenDeviceRegistryKey().

#define PLUGPLAY_REGKEY_DEVICE   1
 

Definition at line 392 of file pnp.h.

Referenced by IoOpenDeviceRegistryKey().

#define PLUGPLAY_REGKEY_DRIVER   2
 

Definition at line 393 of file pnp.h.

Referenced by IoOpenDeviceRegistryKey().

#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES   0x00000001
 

Definition at line 471 of file pnp.h.

Referenced by IoRegisterPlugPlayNotification(), and xxxRegisterForDeviceClassNotifications().

#define TDF_DEVICEEJECTABLE   0x00000001
 

Definition at line 1063 of file pnp.h.

#define TDF_KERNEL_INITIATED   0x00000004
 

Definition at line 1065 of file pnp.h.

#define TDF_NO_RESTART   0x00000002
 

Definition at line 1064 of file pnp.h.


Typedef Documentation

typedef struct _ACPI_INTERFACE_STANDARD ACPI_INTERFACE_STANDARD
 

typedef enum _ACPI_REG_TYPE ACPI_REG_TYPE
 

typedef struct ACPI_REGS_INTERFACE_STANDARD ACPI_REGS_INTERFACE_STANDARD
 

typedef enum _ARBITER_ACTION ARBITER_ACTION
 

Referenced by ArbArbiterHandler(), and IopAssignInner().

typedef struct _ARBITER_CONFLICT_INFO ARBITER_CONFLICT_INFO
 

Referenced by ArbQueryConflict(), and IopQueryConflictFillConflicts().

typedef struct _ARBITER_INTERFACE ARBITER_INTERFACE
 

typedef struct _ARBITER_LIST_ENTRY ARBITER_LIST_ENTRY
 

Referenced by ArbTestAllocation().

typedef struct _ARBITER_PARAMETERS ARBITER_PARAMETERS
 

typedef enum _ARBITER_REQUEST_SOURCE ARBITER_REQUEST_SOURCE
 

typedef enum _ARBITER_RESULT ARBITER_RESULT
 

typedef struct _BUS_INTERFACE_STANDARD BUS_INTERFACE_STANDARD
 

Referenced by IoGetDmaAdapter().

typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION DEVICE_INTERFACE_CHANGE_NOTIFICATION
 

typedef struct _HWPROFILE_CHANGE_NOTIFICATION HWPROFILE_CHANGE_NOTIFICATION
 

typedef struct _INT_ROUTE_INTERFACE_STANDARD INT_ROUTE_INTERFACE_STANDARD
 

typedef struct _IO_ASSIGNED_RESOURCES IO_ASSIGNED_RESOURCES
 

typedef enum _IO_NOTIFICATION_EVENT_CATEGORY IO_NOTIFICATION_EVENT_CATEGORY
 

Referenced by xxxRegisterForDeviceClassNotifications().

typedef struct _LEGACY_BUS_INFORMATION LEGACY_BUS_INFORMATION
 

typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE LEGACY_DEVICE_DETECTION_INTERFACE
 

typedef struct _ACPI_INTERFACE_STANDARD * PACPI_INTERFACE_STANDARD
 

typedef enum _ACPI_REG_TYPE * PACPI_REG_TYPE
 

typedef struct ACPI_REGS_INTERFACE_STANDARD * PACPI_REGS_INTERFACE_STANDARD
 

typedef enum _ARBITER_ACTION * PARBITER_ACTION
 

typedef struct _ARBITER_CONFLICT_INFO * PARBITER_CONFLICT_INFO
 

Referenced by ArbQueryConflict().

typedef NTSTATUS(* PARBITER_HANDLER)(IN PVOID Context, IN ARBITER_ACTION Action, IN OUT PARBITER_PARAMETERS Parameters)
 

Definition at line 807 of file pnp.h.

typedef struct _ARBITER_INTERFACE * PARBITER_INTERFACE
 

typedef struct _ARBITER_LIST_ENTRY * PARBITER_LIST_ENTRY
 

Referenced by ArbTestAllocation().

typedef struct _ARBITER_PARAMETERS * PARBITER_PARAMETERS
 

Referenced by ArbArbiterHandler().

typedef struct _BUS_INTERFACE_STANDARD * PBUS_INTERFACE_STANDARD
 

typedef VOID(* PDEVICE_CHANGE_COMPLETE_CALLBACK)(IN PVOID Context)
 

Definition at line 508 of file pnp.h.

typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION * PDEVICE_INTERFACE_CHANGE_NOTIFICATION
 

Referenced by DeviceClassCDROMNotify().

typedef VOID(* PDEVICE_NOTIFY_CALLBACK)(PVOID, ULONG)
 

Definition at line 163 of file pnp.h.

typedef NTSTATUS(* PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)(IN PVOID NotificationStructure, IN PVOID Context)
 

Definition at line 475 of file pnp.h.

Referenced by xxxRegisterForDeviceClassNotifications().

typedef struct _DMA_ADAPTER*(* PGET_DMA_ADAPTER)(IN PVOID Context, IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, OUT PULONG NumberOfMapRegisters)
 

Definition at line 74 of file pnp.h.

typedef NTSTATUS(* PGET_INTERRUPT_ROUTING)(IN PDEVICE_OBJECT Pdo, OUT ULONG *Bus, OUT ULONG *PciSlot, OUT UCHAR *InterruptLine, OUT UCHAR *InterruptPin, OUT UCHAR *ClassCode, OUT UCHAR *SubClassCode, OUT PDEVICE_OBJECT *ParentPdo, OUT ROUTING_TOKEN *RoutingToken, OUT UCHAR *Flags)
 

Definition at line 261 of file pnp.h.

typedef ULONG(* PGET_SET_DEVICE_DATA)(IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 

Definition at line 80 of file pnp.h.

typedef NTSTATUS(* PGPE_CLEAR_STATUS)(PDEVICE_OBJECT, PVOID)
 

Definition at line 159 of file pnp.h.

typedef NTSTATUS(* PGPE_CONNECT_VECTOR)(PDEVICE_OBJECT, ULONG, KINTERRUPT_MODE, BOOLEAN, PGPE_SERVICE_ROUTINE, PVOID, PVOID)
 

Definition at line 139 of file pnp.h.

typedef NTSTATUS(* PGPE_DISABLE_EVENT)(PDEVICE_OBJECT, PVOID)
 

Definition at line 155 of file pnp.h.

typedef NTSTATUS(* PGPE_DISCONNECT_VECTOR)(PVOID)
 

Definition at line 148 of file pnp.h.

typedef NTSTATUS(* PGPE_ENABLE_EVENT)(PDEVICE_OBJECT, PVOID)
 

Definition at line 151 of file pnp.h.

typedef BOOLEAN(* PGPE_SERVICE_ROUTINE)(PVOID, PVOID)
 

Definition at line 135 of file pnp.h.

typedef struct _HWPROFILE_CHANGE_NOTIFICATION * PHWPROFILE_CHANGE_NOTIFICATION
 

typedef struct _INT_ROUTE_INTERFACE_STANDARD * PINT_ROUTE_INTERFACE_STANDARD
 

typedef struct _IO_ASSIGNED_RESOURCES * PIO_ASSIGNED_RESOURCES
 

typedef struct _LEGACY_BUS_INFORMATION * PLEGACY_BUS_INFORMATION
 

typedef NTSTATUS(* PLEGACY_DEVICE_DETECTION_HANDLER)(IN PVOID Context, IN INTERFACE_TYPE LegacyBusType, IN ULONG BusNumber, IN ULONG SlotNumber, OUT PDEVICE_OBJECT *PhysicalDeviceObject)
 

Definition at line 906 of file pnp.h.

typedef struct _LEGACY_DEVICE_DETECTION_INTERFACE * PLEGACY_DEVICE_DETECTION_INTERFACE
 

typedef struct _PLUGPLAY_NOTIFICATION_HEADER PLUGPLAY_NOTIFICATION_HEADER
 

typedef struct _PNP_BUS_INFORMATION PNP_BUS_INFORMATION
 

typedef struct _PLUGPLAY_NOTIFICATION_HEADER * PPLUGPLAY_NOTIFICATION_HEADER
 

typedef struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
 

typedef USHORT(* PREAD_ACPI_REGISTER)(IN ACPI_REG_TYPE AcpiReg, IN ULONG Register)
 

Definition at line 213 of file pnp.h.

typedef NTSTATUS(* PREGISTER_FOR_DEVICE_NOTIFICATIONS)(PDEVICE_OBJECT, PDEVICE_NOTIFY_CALLBACK, PVOID)
 

Definition at line 167 of file pnp.h.

typedef * PROUTING_TOKEN
 

typedef NTSTATUS(* PSET_INTERRUPT_ROUTING_TOKEN)(IN PDEVICE_OBJECT Pdo, IN PROUTING_TOKEN RoutingToken)
 

Definition at line 276 of file pnp.h.

typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION * PTARGET_DEVICE_CUSTOM_NOTIFICATION
 

Referenced by DeviceCDROMNotify().

typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION * PTARGET_DEVICE_REMOVAL_NOTIFICATION
 

typedef BOOLEAN(* PTRANSLATE_BUS_ADDRESS)(IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 

Definition at line 66 of file pnp.h.

typedef NTSTATUS(* PTRANSLATE_RESOURCE_HANDLER)(IN PVOID Context, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount, OPTIONAL IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
 

Definition at line 864 of file pnp.h.

typedef NTSTATUS(* PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)(IN PVOID Context, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
 

Definition at line 876 of file pnp.h.

typedef struct _TRANSLATOR_INTERFACE * PTRANSLATOR_INTERFACE
 

typedef void(* PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(PDEVICE_OBJECT, PDEVICE_NOTIFY_CALLBACK)
 

Definition at line 172 of file pnp.h.

typedef VOID(* PUPDATE_INTERRUPT_LINE)(IN PDEVICE_OBJECT Pdo, IN UCHAR LineRegister)
 

Definition at line 283 of file pnp.h.

typedef VOID(* PWRITE_ACPI_REGISTER)(IN ACPI_REG_TYPE AcpiReg, IN ULONG Register, IN USHORT Value)
 

Definition at line 217 of file pnp.h.

typedef enum _RESOURCE_TRANSLATION_DIRECTION RESOURCE_TRANSLATION_DIRECTION
 

typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION TARGET_DEVICE_CUSTOM_NOTIFICATION
 

Referenced by FsRtlNotifyVolumeEvent().

typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION TARGET_DEVICE_REMOVAL_NOTIFICATION
 

typedef struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE
 


Enumeration Type Documentation

enum _ACPI_REG_TYPE
 

Enumeration values:
PM1a_ENABLE 
PM1b_ENABLE 
PM1a_STATUS 
PM1b_STATUS 
PM1a_CONTROL 
PM1b_CONTROL 
GP_STATUS 
GP_ENABLE 
SMI_CMD 
MaxRegType 

Definition at line 200 of file pnp.h.

00200 { 00201 PM1a_ENABLE, 00202 PM1b_ENABLE, 00203 PM1a_STATUS, 00204 PM1b_STATUS, 00205 PM1a_CONTROL, 00206 PM1b_CONTROL, 00207 GP_STATUS, 00208 GP_ENABLE, 00209 SMI_CMD, 00210 MaxRegType 00211 } ACPI_REG_TYPE, *PACPI_REG_TYPE;

enum _ARBITER_ACTION
 

Enumeration values:
ArbiterActionTestAllocation 
ArbiterActionRetestAllocation 
ArbiterActionCommitAllocation 
ArbiterActionRollbackAllocation 
ArbiterActionQueryAllocatedResources 
ArbiterActionWriteReservedResources 
ArbiterActionQueryConflict 
ArbiterActionQueryArbitrate 
ArbiterActionAddReserved 
ArbiterActionBootAllocation 

Definition at line 546 of file pnp.h.

enum _ARBITER_REQUEST_SOURCE
 

Enumeration values:
ArbiterRequestUndefined 
ArbiterRequestLegacyReported 
ArbiterRequestHalReported 
ArbiterRequestLegacyAssigned 
ArbiterRequestPnpDetected 
ArbiterRequestPnpEnumerated 

Definition at line 692 of file pnp.h.

00692 { 00693 00694 ArbiterRequestUndefined = -1, 00695 ArbiterRequestLegacyReported, // IoReportResourceUsage 00696 ArbiterRequestHalReported, // IoReportHalResourceUsage 00697 ArbiterRequestLegacyAssigned, // IoAssignResources 00698 ArbiterRequestPnpDetected, // IoReportResourceForDetection 00699 ArbiterRequestPnpEnumerated // IRP_MN_QUERY_RESOURCE_REQUIREMENTS 00700 00701 } ARBITER_REQUEST_SOURCE;

enum _ARBITER_RESULT
 

Enumeration values:
ArbiterResultUndefined 
ArbiterResultSuccess 
ArbiterResultExternalConflict 
ArbiterResultNullRequest 

Definition at line 704 of file pnp.h.

00704 { 00705 00706 ArbiterResultUndefined = -1, 00707 ArbiterResultSuccess, 00708 ArbiterResultExternalConflict, // This indicates that the request can never be solved for devices in this list 00709 ArbiterResultNullRequest // The request was for length zero and thus no translation should be attempted 00710 00711 } ARBITER_RESULT;

enum _IO_NOTIFICATION_EVENT_CATEGORY
 

Enumeration values:
EventCategoryReserved 
EventCategoryHardwareProfileChange 
EventCategoryDeviceInterfaceChange 
EventCategoryTargetDeviceChange 

Definition at line 459 of file pnp.h.

enum _RESOURCE_TRANSLATION_DIRECTION
 

Enumeration values:
TranslateChildToParent 
TranslateParentToChild 

Definition at line 853 of file pnp.h.

enum DEVICE_REGISTRY_PROPERTY
 

Enumeration values:
DevicePropertyDeviceDescription 
DevicePropertyHardwareID 
DevicePropertyCompatibleIDs 
DevicePropertyBootConfiguration 
DevicePropertyBootConfigurationTranslated 
DevicePropertyClassName 
DevicePropertyClassGuid 
DevicePropertyDriverKeyName 
DevicePropertyManufacturer 
DevicePropertyFriendlyName 
DevicePropertyLocationInformation 
DevicePropertyPhysicalDeviceObjectName 
DevicePropertyBusTypeGuid 
DevicePropertyLegacyBusType 
DevicePropertyBusNumber 
DevicePropertyEnumeratorName 
DevicePropertyAddress 
DevicePropertyUINumber 

Definition at line 45 of file pnp.h.


Function Documentation

NTKERNELAPI NTSTATUS IoGetAssignedResourcesForSuballocation IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PIO_RESOURCE_DESCRIPTOR  ResourceDescriptor,
OUT PIO_ASSIGNED_RESOURCES List
 

NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaceAlias IN PUNICODE_STRING  SymbolicLinkName,
IN CONST GUID *  AliasInterfaceClassGuid,
OUT PUNICODE_STRING  AliasSymbolicLinkName
 

Definition at line 4946 of file pnpioapi.c.

References ExAcquireResourceExclusive, ExFreePool(), ExReleaseResource, IopBuildSymbolicLinkStrings(), IopConstStringSize, IopDeviceInterfaceKeysFromSymbolicLink(), IopFreeAllocatedUnicodeString(), IopGetRegistryValue(), IopParseSymbolicLinkName(), IopRegistryDataToUnicodeString, KeEnterCriticalRegion, KeLeaveCriticalRegion, KEY_VALUE_DATA, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PpRegistryDeviceResource, RtlFreeUnicodeString(), RtlStringFromGUID(), TRUE, and USER_SYMLINK_STRING_PREFIX.

04954 : 04955 04956 This API returns a symbolic link name (i.e., device interface) of a 04957 particular interface class that 'aliases' the specified device interface. 04958 Two device interfaces are considered aliases of each other if the 04959 following two criteria are met: 04960 04961 1. Both interfaces are exposed by the same PDO (devnode). 04962 2. Both interfaces share the same RefString. 04963 04964 Parameters: 04965 04966 SymbolicLinkName - Supplies the name of the device interface whose alias is 04967 to be retrieved. 04968 04969 AliasInterfaceClassGuid - Supplies a pointer to the GUID representing the interface 04970 class for which an alias is to be retrieved. 04971 04972 AliasSymbolicLinkName - Supplies a pointer to a string which, upon success, 04973 will contain the name of the device interface in the specified class that 04974 aliases the SymbolicLinkName interface. (This symbolic link name will be 04975 returned in either kernel-mode or user-mode form, depeding upon the form 04976 of the SymbolicLinkName path). 04977 04978 It is the caller's responsibility to free the buffer allocated for this 04979 string via ExFreePool(). 04980 04981 Return Value: 04982 04983 Status code that indicates whether or not the function was successful. 04984 04985 --*/ 04986 04987 { 04988 NTSTATUS status; 04989 HANDLE hKey; 04990 PKEY_VALUE_FULL_INFORMATION pDeviceInstanceInfo; 04991 UNICODE_STRING deviceInstanceString, refString, guidString, otherString; 04992 PUNICODE_STRING pUserString, pKernelString; 04993 BOOLEAN refStringPresent, userModeFormat; 04994 04995 PAGED_CODE(); 04996 04997 // 04998 // Convert the class guid into string form 04999 // 05000 05001 status = RtlStringFromGUID(AliasInterfaceClassGuid, &guidString); 05002 if( !NT_SUCCESS(status) ){ 05003 goto clean0; 05004 } 05005 05006 // 05007 // Enter critical section and acquire a lock on the registry. Both these 05008 // mechanisms are required to prevent deadlock in the case where an APC 05009 // routine calls this routine after the registry resource has been claimed 05010 // in this case it would wait blocking this thread so the registry would 05011 // never be released -> deadlock. Critical sectioning the registry manipulation 05012 // portion solves this problem 05013 // 05014 05015 KeEnterCriticalRegion(); 05016 ExAcquireResourceExclusive(&PpRegistryDeviceResource, TRUE); 05017 05018 // 05019 // Open the (parent) device interface key--not the refstring-specific one. 05020 // 05021 05022 status = IopDeviceInterfaceKeysFromSymbolicLink(SymbolicLinkName, 05023 KEY_READ, 05024 NULL, 05025 &hKey, 05026 NULL 05027 ); 05028 if(!NT_SUCCESS(status)) { 05029 goto clean1; 05030 } 05031 05032 // 05033 // Get the name of the device instance that 'owns' this interface. 05034 // 05035 05036 status = IopGetRegistryValue(hKey, REGSTR_VAL_DEVICE_INSTANCE, &pDeviceInstanceInfo); 05037 05038 ZwClose(hKey); 05039 05040 if(!NT_SUCCESS(status)) { 05041 goto clean1; 05042 } 05043 05044 if(pDeviceInstanceInfo->Type == REG_SZ) { 05045 05046 IopRegistryDataToUnicodeString(&deviceInstanceString, 05047 (PWSTR)KEY_VALUE_DATA(pDeviceInstanceInfo), 05048 pDeviceInstanceInfo->DataLength 05049 ); 05050 05051 } else { 05052 05053 status = STATUS_INVALID_PARAMETER_1; 05054 goto clean2; 05055 05056 } 05057 05058 // 05059 // Now parse out the refstring, so that we can construct the name of the interface device's 05060 // alias. (NOTE: we have not yet verified that the alias actually exists, we're only 05061 // constructing what its name would be, if it did exist.) 05062 // 05063 // Don't bother to check the return code. If this were a bad string, we'd have already 05064 // failed above when we called IopDeviceInterfaceKeysFromSymbolicLink. 05065 // 05066 IopParseSymbolicLinkName(SymbolicLinkName, 05067 NULL, 05068 NULL, 05069 NULL, 05070 &refString, 05071 &refStringPresent, 05072 NULL 05073 ); 05074 05075 // 05076 // Did the caller supply us with a user-mode or kernel-mode format path? 05077 // 05078 userModeFormat = (IopConstStringSize(USER_SYMLINK_STRING_PREFIX) == 05079 RtlCompareMemory(SymbolicLinkName->Buffer, 05080 USER_SYMLINK_STRING_PREFIX, 05081 IopConstStringSize(USER_SYMLINK_STRING_PREFIX) 05082 )); 05083 05084 if(userModeFormat) { 05085 pUserString = AliasSymbolicLinkName; 05086 pKernelString = &otherString; 05087 } else { 05088 pKernelString = AliasSymbolicLinkName; 05089 pUserString = &otherString; 05090 } 05091 05092 status = IopBuildSymbolicLinkStrings(&deviceInstanceString, 05093 &guidString, 05094 refStringPresent ? &refString : NULL, 05095 pUserString, 05096 pKernelString 05097 ); 05098 if (!NT_SUCCESS(status)) { 05099 goto clean2; 05100 } 05101 05102 // 05103 // OK, we now have the symbolic link name of the alias, but we don't yet know whether 05104 // it actually exists. Check this by attempting to open the associated registry key. 05105 // 05106 status = IopDeviceInterfaceKeysFromSymbolicLink(AliasSymbolicLinkName, 05107 KEY_READ, 05108 NULL, 05109 NULL, 05110 &hKey 05111 ); 05112 05113 if(NT_SUCCESS(status)) { 05114 // 05115 // Alias exists--close the key handle. 05116 // 05117 ZwClose(hKey); 05118 } else { 05119 IopFreeAllocatedUnicodeString(AliasSymbolicLinkName); 05120 } 05121 05122 IopFreeAllocatedUnicodeString(&otherString); 05123 05124 clean2: 05125 ExFreePool(pDeviceInstanceInfo); 05126 05127 clean1: 05128 ExReleaseResource(&PpRegistryDeviceResource); 05129 KeLeaveCriticalRegion(); 05130 RtlFreeUnicodeString(&guidString); 05131 05132 clean0: 05133 return status; 05134 }

NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaces IN CONST GUID *  InterfaceClassGuid,
IN PDEVICE_OBJECT PhysicalDeviceObject  OPTIONAL,
IN ULONG  Flags,
OUT PWSTR *  SymbolicLinkList
 

Definition at line 3419 of file pnpioapi.c.

References ASSERT_PDO, FALSE, _DEVICE_NODE::InstancePath, IopGetDeviceInterfaces(), NTSTATUS(), NULL, and PAGED_CODE.

Referenced by IopCreateArcNames(), and IoRegisterPlugPlayNotification().

03428 : 03429 03430 This API allows a WDM driver to get a list of paths that represent all 03431 device interfaces registered for the specified interface class. 03432 03433 Parameters: 03434 03435 InterfaceClassGuid - Supplies a pointer to a GUID representing the interface class 03436 for whom a list of members is to be retrieved 03437 03438 PhysicalDeviceObject - Optionally, supplies a pointer to the PDO for whom 03439 interfaces of the specified class are to be re-trieved. If this parameter 03440 is not supplied, then all interface devices (regardless of what physical 03441 device exposes them) will be returned. 03442 03443 Flags - Supplies flags that modify the behavior of list retrieval. 03444 The following flags are presently defined: 03445 03446 DEVICE_INTERFACE_INCLUDE_NONACTIVE -- If this flag is specified, then all 03447 device interfaces, whether currently active or not, will be returned 03448 (potentially filtered based on the PhysicalDeviceObject, if specified). 03449 03450 SymbolicLinkList - Supplies the address of a character pointer, that on 03451 success will contain a multi-sz list of \DosDevices\ symbolic link 03452 names that provide the requested functionality. The caller is 03453 responsible for freeing the memory via ExFreePool 03454 03455 Return Value: 03456 03457 Status code that indicates whether or not the function was successful. 03458 03459 --*/ 03460 03461 { 03462 NTSTATUS status; 03463 PUNICODE_STRING pDeviceName = NULL; 03464 PDEVICE_NODE pDeviceNode; 03465 03466 PAGED_CODE(); 03467 03468 // 03469 // Check we have a PDO and if so extract the instance path from it 03470 // 03471 03472 if (ARGUMENT_PRESENT(PhysicalDeviceObject)) { 03473 03474 ASSERT_PDO(PhysicalDeviceObject); 03475 pDeviceNode = (PDEVICE_NODE) PhysicalDeviceObject->DeviceObjectExtension->DeviceNode; 03476 pDeviceName = &pDeviceNode->InstancePath; 03477 } 03478 03479 status = IopGetDeviceInterfaces(InterfaceClassGuid, 03480 pDeviceName, 03481 Flags, 03482 FALSE, 03483 SymbolicLinkList, 03484 NULL 03485 ); 03486 return status; 03487 }

NTKERNELAPI NTSTATUS IoGetDeviceProperty IN PDEVICE_OBJECT  DeviceObject,
IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
IN ULONG  BufferLength,
OUT PVOID  PropertyBuffer,
OUT PULONG  ResultLength
 

Definition at line 373 of file pnpioapi.c.

References _DEVICE_CAPABILITIES::Address, ASSERT, ASSERT_PDO, _DEVICE_NODE::ChildBusNumber, _DEVICE_NODE::ChildBusTypeIndex, _DEVICE_NODE::ChildInterfaceType, _BUS_TYPE_GUID_LIST::Count, DevicePropertyAddress, DevicePropertyBootConfiguration, DevicePropertyBootConfigurationTranslated, DevicePropertyBusNumber, DevicePropertyBusTypeGuid, DevicePropertyClassGuid, DevicePropertyClassName, DevicePropertyCompatibleIDs, DevicePropertyDeviceDescription, DevicePropertyDriverKeyName, DevicePropertyEnumeratorName, DevicePropertyFriendlyName, DevicePropertyHardwareID, DevicePropertyLegacyBusType, DevicePropertyLocationInformation, DevicePropertyManufacturer, DevicePropertyPhysicalDeviceObjectName, DevicePropertyUINumber, ExAcquireResourceExclusive, ExAllocatePool, ExFreePool(), ExReleaseResource, _BUS_TYPE_GUID_LIST::Guid, _DEVICE_NODE::InstancePath, IopBusTypeGuidList, IopDeviceObjectToDeviceInstance(), IopGetRegistryValue(), IopOpenRegistryKeyEx(), IopQueryDeviceCapabilities(), KeEnterCriticalRegion, KeLeaveCriticalRegion, KEY_VALUE_DATA, L, NT_SUCCESS, NTSTATUS(), NULL, ObQueryNameString(), PAGED_CODE, PagedPool, PpRegistryDeviceResource, RtlInitUnicodeString(), and TRUE.

Referenced by ArbQueryConflict(), IoGetDmaAdapter(), and IopProcessSetInterfaceState().

00383 : 00384 00385 This routine lets drivers query the registry properties associated with the 00386 specified device. 00387 00388 Parameters: 00389 00390 DeviceObject - Supplies the device object whoes registry property is to be 00391 returned. This device object should be the one created by 00392 a bus driver. 00393 00394 DeviceProperty - Specifies what device property to get. 00395 00396 BufferLength - Specifies the length, in byte, of the PropertyBuffer. 00397 00398 PropertyBuffer - Supplies a pointer to a buffer to receive property data. 00399 00400 ResultLength - Supplies a pointer to a variable to receive the size of the 00401 property data returned. 00402 00403 ReturnValue: 00404 00405 Status code that indicates whether or not the function was successful. If 00406 PropertyBuffer is not big enough to hold requested data, STATUS_BUFFER_TOO_SMALL 00407 will be returned and ResultLength will be set to the number of bytes actually 00408 required. 00409 00410 --*/ 00411 00412 { 00413 PDEVICE_NODE deviceNode; 00414 DEVICE_CAPABILITIES capabilities; 00415 NTSTATUS status; 00416 HANDLE handle; 00417 PWSTR valueName, keyName = NULL; 00418 PKEY_VALUE_FULL_INFORMATION keyValueInformation; 00419 ULONG valueType; 00420 ULONG length; 00421 POBJECT_NAME_INFORMATION deviceObjectName; 00422 PWSTR deviceInstanceName; 00423 PWCHAR enumeratorNameEnd; 00424 00425 PAGED_CODE(); 00426 00427 ASSERT_PDO(DeviceObject); 00428 00429 // 00430 // Initialize out parameters 00431 // 00432 00433 *ResultLength = 0; 00434 00435 // 00436 // Map Device Property to registry value name and value type. 00437 // 00438 00439 switch (DeviceProperty) { 00440 00441 case DevicePropertyDeviceDescription: 00442 valueName = REGSTR_VALUE_DEVICE_DESC; 00443 valueType = REG_SZ; 00444 break; 00445 00446 case DevicePropertyHardwareID: 00447 valueName = REGSTR_VAL_HARDWAREID; 00448 valueType = REG_MULTI_SZ; 00449 break; 00450 00451 case DevicePropertyCompatibleIDs: 00452 valueName = REGSTR_VAL_COMPATIBLEIDS; 00453 valueType = REG_MULTI_SZ; 00454 break; 00455 00456 case DevicePropertyBootConfiguration: 00457 keyName = REGSTR_KEY_LOG_CONF; 00458 valueName = REGSTR_VAL_BOOTCONFIG; 00459 valueType = REG_RESOURCE_LIST; 00460 break; 00461 00462 case DevicePropertyBootConfigurationTranslated: 00463 // 00464 // BUGBUG(andrewth) - support this! 00465 // 00466 return STATUS_NOT_SUPPORTED; 00467 break; 00468 00469 case DevicePropertyClassName: 00470 valueName = REGSTR_VALUE_CLASS; 00471 valueType = REG_SZ; 00472 break; 00473 00474 case DevicePropertyClassGuid: 00475 valueName = REGSTR_VALUE_CLASSGUID; 00476 valueType = REG_SZ; 00477 break; 00478 00479 case DevicePropertyDriverKeyName: 00480 valueName = REGSTR_VALUE_DRIVER; 00481 valueType = REG_SZ; 00482 break; 00483 00484 case DevicePropertyManufacturer: 00485 valueName = REGSTR_VAL_MFG; 00486 valueType = REG_SZ; 00487 break; 00488 00489 case DevicePropertyFriendlyName: 00490 valueName = REGSTR_VALUE_FRIENDLYNAME; 00491 valueType = REG_SZ; 00492 break; 00493 00494 case DevicePropertyLocationInformation: 00495 valueName = REGSTR_VAL_LOCATION_INFORMATION; 00496 valueType = REG_SZ; 00497 break; 00498 00499 case DevicePropertyUINumber: 00500 valueName = REGSTR_VAL_UI_NUMBER; 00501 valueType = REG_DWORD; 00502 break; 00503 00504 case DevicePropertyPhysicalDeviceObjectName: 00505 00506 ASSERT (0 == (1 & BufferLength)); // had better be an even length 00507 00508 // 00509 // Create a buffer for the Obj manager. 00510 // 00511 length = BufferLength + sizeof (OBJECT_NAME_INFORMATION); 00512 00513 deviceObjectName = (POBJECT_NAME_INFORMATION) 00514 ExAllocatePool(PagedPool, length); 00515 00516 if (NULL == deviceObjectName) { 00517 return STATUS_INSUFFICIENT_RESOURCES; 00518 } 00519 00520 status = ObQueryNameString (DeviceObject, 00521 deviceObjectName, 00522 length, 00523 ResultLength); 00524 00525 if (STATUS_INFO_LENGTH_MISMATCH == status) { 00526 status = STATUS_BUFFER_TOO_SMALL; 00527 } 00528 00529 if (NT_SUCCESS (status)) { 00530 00531 if (deviceObjectName->Name.Length == 0) { 00532 00533 // 00534 // PDO has no NAME, probably it's been deleted 00535 // 00536 *ResultLength = 0; 00537 00538 } else { 00539 00540 *ResultLength = deviceObjectName->Name.Length + sizeof(UNICODE_NULL); 00541 if (*ResultLength > BufferLength) { 00542 status = STATUS_BUFFER_TOO_SMALL; 00543 } else { 00544 00545 RtlCopyMemory(PropertyBuffer, 00546 deviceObjectName->Name.Buffer, 00547 deviceObjectName->Name.Length); 00548 *(PWCHAR) (((PUCHAR) PropertyBuffer) + deviceObjectName->Name.Length) = L'\0'; 00549 } 00550 } 00551 } else { 00552 *ResultLength -= sizeof(OBJECT_NAME_INFORMATION); 00553 } 00554 00555 ExFreePool (deviceObjectName); 00556 return status; 00557 00558 00559 case DevicePropertyBusTypeGuid: 00560 00561 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00562 if (deviceNode->ChildBusTypeIndex != 0xffff 00563 && deviceNode->ChildBusTypeIndex < IopBusTypeGuidList->Count) { 00564 00565 *ResultLength = sizeof(GUID); 00566 00567 if(*ResultLength <= BufferLength) { 00568 00569 RtlCopyMemory(PropertyBuffer, 00570 &(IopBusTypeGuidList->Guid[deviceNode->ChildBusTypeIndex]), 00571 sizeof(GUID)); 00572 00573 status = STATUS_SUCCESS; 00574 00575 } else { 00576 00577 status = STATUS_BUFFER_TOO_SMALL; 00578 00579 } 00580 00581 } else { 00582 status = STATUS_OBJECT_NAME_NOT_FOUND; 00583 } 00584 00585 return status; 00586 00587 case DevicePropertyLegacyBusType: 00588 00589 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00590 if (deviceNode->ChildInterfaceType != InterfaceTypeUndefined) { 00591 00592 *ResultLength = sizeof(INTERFACE_TYPE); 00593 00594 if(*ResultLength <= BufferLength) { 00595 00596 *(PINTERFACE_TYPE)PropertyBuffer = deviceNode->ChildInterfaceType; 00597 status = STATUS_SUCCESS; 00598 00599 } else { 00600 status = STATUS_BUFFER_TOO_SMALL; 00601 } 00602 00603 } else { 00604 status = STATUS_OBJECT_NAME_NOT_FOUND; 00605 } 00606 00607 return status; 00608 00609 case DevicePropertyBusNumber: 00610 00611 // 00612 // Retrieve the property from the parent's devnode field. 00613 // 00614 00615 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00616 if ((deviceNode->ChildBusNumber & 0x80000000) != 0x80000000) { 00617 00618 *ResultLength = sizeof(ULONG); 00619 00620 if(*ResultLength <= BufferLength) { 00621 00622 *(PULONG)PropertyBuffer = deviceNode->ChildBusNumber; 00623 status = STATUS_SUCCESS; 00624 00625 } else { 00626 status = STATUS_BUFFER_TOO_SMALL; 00627 } 00628 00629 } else { 00630 status = STATUS_OBJECT_NAME_NOT_FOUND; 00631 } 00632 00633 return status; 00634 00635 case DevicePropertyEnumeratorName: 00636 00637 ASSERT (0 == (1 & BufferLength)); // had better be an even length 00638 00639 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00640 deviceInstanceName = deviceNode->InstancePath.Buffer; 00641 00642 // 00643 // There should always be a string here, except for (possibly) 00644 // HTREE\Root\0, but no one should ever be calling us with that PDO 00645 // anyway. 00646 // 00647 ASSERT (deviceInstanceName); 00648 00649 // 00650 // We know we're going to find a separator character (\) in the string, 00651 // so the fact that unicode strings may not be null-terminated isn't 00652 // a problem. 00653 // 00654 enumeratorNameEnd = wcschr(deviceInstanceName, OBJ_NAME_PATH_SEPARATOR); 00655 ASSERT (enumeratorNameEnd); 00656 00657 // 00658 // Compute required length, minus null terminating character. 00659 // 00660 length = (ULONG)((PUCHAR)enumeratorNameEnd - (PUCHAR)deviceInstanceName); 00661 00662 // 00663 // Store required length in caller-supplied OUT parameter. 00664 // 00665 *ResultLength = length + sizeof(UNICODE_NULL); 00666 00667 if(*ResultLength > BufferLength) { 00668 status = STATUS_BUFFER_TOO_SMALL; 00669 } else { 00670 memcpy((PUCHAR)PropertyBuffer, (PUCHAR)deviceInstanceName, length); 00671 *(PWCHAR)((PUCHAR)PropertyBuffer + length) = UNICODE_NULL; 00672 status = STATUS_SUCCESS; 00673 } 00674 00675 return status; 00676 00677 case DevicePropertyAddress: 00678 00679 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 00680 00681 status = IopQueryDeviceCapabilities(deviceNode, &capabilities); 00682 00683 if (NT_SUCCESS(status) && (capabilities.Address != 0xFFFFFFFF)) { 00684 00685 *ResultLength = sizeof(ULONG); 00686 00687 if(*ResultLength <= BufferLength) { 00688 00689 *(PULONG)PropertyBuffer = capabilities.Address; 00690 status = STATUS_SUCCESS; 00691 00692 } else { 00693 status = STATUS_BUFFER_TOO_SMALL; 00694 } 00695 00696 } else { 00697 status = STATUS_OBJECT_NAME_NOT_FOUND; 00698 } 00699 00700 return status; 00701 00702 default: 00703 status = STATUS_INVALID_PARAMETER_2; 00704 goto clean0; 00705 } 00706 00707 // 00708 // Enter critical section and acquire a lock on the registry. Both these 00709 // mechanisms are required to prevent deadlock in the case where an APC 00710 // routine calls this routine after the registry resource has been claimed 00711 // in this case it would wait blocking this thread so the registry would 00712 // never be released -> deadlock. Critical sectioning the registry manipulatio 00713 // portion solves this problem 00714 // 00715 00716 KeEnterCriticalRegion(); 00717 ExAcquireResourceExclusive(&PpRegistryDeviceResource, TRUE); 00718 00719 // 00720 // Based on the PDO specified by caller, find the handle of its device 00721 // instance registry key. 00722 // 00723 00724 status = IopDeviceObjectToDeviceInstance(DeviceObject, &handle, KEY_READ); 00725 if (!NT_SUCCESS(status)) { 00726 goto clean1; 00727 } 00728 00729 // 00730 // If the data is stored in a subkey then open this key and close the old one 00731 // 00732 00733 if (keyName) { 00734 HANDLE subKeyHandle; 00735 UNICODE_STRING unicodeKey; 00736 00737 RtlInitUnicodeString(&unicodeKey, keyName); 00738 status = IopOpenRegistryKeyEx( &subKeyHandle, 00739 handle, 00740 &unicodeKey, 00741 KEY_READ 00742 ); 00743 00744 if(NT_SUCCESS(status)){ 00745 ZwClose(handle); 00746 handle = subKeyHandle; 00747 } else { 00748 goto clean2; 00749 } 00750 00751 } 00752 00753 // 00754 // Read the registry value of the desired value name 00755 // 00756 00757 status = IopGetRegistryValue (handle, 00758 valueName, 00759 &keyValueInformation); 00760 00761 00762 // 00763 // We have finished using the registry so clean up and release our resources 00764 // 00765 00766 clean2: 00767 ZwClose(handle); 00768 clean1: 00769 ExReleaseResource(&PpRegistryDeviceResource); 00770 KeLeaveCriticalRegion(); 00771 00772 // 00773 // If we have been sucessful finding the info hand it back to the caller 00774 // 00775 00776 if (NT_SUCCESS(status)) { 00777 00778 // 00779 // Return the length of the data (or the required length if the buffer is too small) 00780 // 00781 00782 *ResultLength = keyValueInformation->DataLength; 00783 00784 // 00785 // Check that the buffer we have been given is big enough and that the value returned is 00786 // of the correct registry type 00787 // 00788 00789 if (keyValueInformation->DataLength <= BufferLength) { 00790 if (keyValueInformation->Type == valueType) { 00791 RtlCopyMemory(PropertyBuffer, 00792 KEY_VALUE_DATA(keyValueInformation), 00793 keyValueInformation->DataLength); 00794 00795 } else { 00796 status = STATUS_INVALID_PARAMETER_2; 00797 } 00798 } else { 00799 status = STATUS_BUFFER_TOO_SMALL; 00800 } 00801 00802 ExFreePool(keyValueInformation); 00803 } 00804 00805 clean0: 00806 return status; 00807 }

NTKERNELAPI VOID IoInvalidateDeviceRelations IN PDEVICE_OBJECT  DeviceObject,
IN DEVICE_RELATION_TYPE  Type
 

NTKERNELAPI VOID IoInvalidateDeviceState IN PDEVICE_OBJECT  PhysicalDeviceObject  ) 
 

Definition at line 6281 of file pnpioapi.c.

References ASSERT_PDO, DNF_REMOVE_PENDING_CLOSES, DNF_STARTED, _DEVICE_NODE::Flags, IopInvalidateDeviceStateWorker(), IopQueueDeviceWorkItem(), and NULL.

06287 : 06288 06289 This API will cause the PnP manager to send the specified PDO an IRP_MN_QUERY_PNP_DEVICE_STATE 06290 IRP. 06291 06292 Parameters: 06293 06294 PhysicalDeviceObject - Provides a pointer to the PDO who's state is to be invalidated. 06295 06296 Return Value: 06297 06298 none. 06299 06300 --*/ 06301 { 06302 PDEVICE_NODE deviceNode; 06303 06304 ASSERT_PDO(PhysicalDeviceObject); 06305 06306 // 06307 // If the call was made before PnP completes device enumeration 06308 // we can safely ignore it. PnP manager will do it without 06309 // driver's request. If the device was already removed or surprised 06310 // removed then ignore it as well since this is only valid for started 06311 // devices. 06312 // 06313 06314 deviceNode = (PDEVICE_NODE)PhysicalDeviceObject->DeviceObjectExtension->DeviceNode; 06315 06316 if ((deviceNode->Flags & (DNF_STARTED | DNF_REMOVE_PENDING_CLOSES)) != DNF_STARTED) { 06317 return; 06318 } 06319 06320 IopQueueDeviceWorkItem( PhysicalDeviceObject, 06321 IopInvalidateDeviceStateWorker, 06322 NULL); 06323 }

NTKERNELAPI NTSTATUS IoOpenDeviceInterfaceRegistryKey IN PUNICODE_STRING  SymbolicLinkName,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  DeviceInterfaceKey
 

Definition at line 3624 of file pnpioapi.c.

References ExAcquireResourceExclusive, ExReleaseResource, IopCreateRegistryKeyEx(), IopDeviceInterfaceKeysFromSymbolicLink(), KeEnterCriticalRegion, KeLeaveCriticalRegion, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PpRegistryDeviceResource, and TRUE.

03632 : 03633 03634 This routine will open the registry key where the data associated with a 03635 specific device interface can be stored. 03636 03637 Parameters: 03638 03639 SymbolicLinkName - Supplies a pointer to the symbolic link name which was 03640 returned by IoRegisterDeviceInterface when the device class was registered. 03641 03642 DesiredAccess - Supplies the access privileges to the key the caller wants. 03643 03644 DeviceInterfaceKey - Supplies a pointer to a handle which on success will 03645 contain the handle to the requested registry key. 03646 03647 Return Value: 03648 03649 Status code that indicates whether or not the function was successful. 03650 03651 --*/ 03652 03653 { 03654 NTSTATUS status; 03655 HANDLE hKey; 03656 UNICODE_STRING unicodeString; 03657 03658 PAGED_CODE(); 03659 03660 // 03661 // Enter critical section and acquire a lock on the registry. Both these 03662 // mechanisms are required to prevent deadlock in the case where an APC 03663 // routine calls this routine after the registry resource has been claimed 03664 // in this case it would wait blocking this thread so the registry would 03665 // never be released -> deadlock. Critical sectioning the registry manipulation 03666 // portion solves this problem 03667 // 03668 03669 KeEnterCriticalRegion(); 03670 ExAcquireResourceExclusive(&PpRegistryDeviceResource, TRUE); 03671 03672 // 03673 // Open the interface device key 03674 // 03675 03676 status = IopDeviceInterfaceKeysFromSymbolicLink(SymbolicLinkName, 03677 KEY_READ, 03678 NULL, 03679 NULL, 03680 &hKey 03681 ); 03682 if(!NT_SUCCESS(status)) { 03683 goto clean0; 03684 } 03685 03686 // 03687 // Open the "Device Parameters" subkey. 03688 // 03689 03690 PiWstrToUnicodeString(&unicodeString, REGSTR_KEY_DEVICEPARAMETERS); 03691 status = IopCreateRegistryKeyEx( DeviceInterfaceKey, 03692 hKey, 03693 &unicodeString, 03694 DesiredAccess, 03695 REG_OPTION_NON_VOLATILE, 03696 NULL 03697 ); 03698 ZwClose(hKey); 03699 03700 clean0: 03701 ExReleaseResource(&PpRegistryDeviceResource); 03702 KeLeaveCriticalRegion(); 03703 03704 return status; 03705 }

NTKERNELAPI NTSTATUS IoOpenDeviceRegistryKey IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  DevInstKeyType,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  DevInstRegKey
 

Definition at line 810 of file pnpioapi.c.

References ASSERT, ExAcquireResourceExclusive, ExAllocatePool, ExFreePool(), ExReleaseResource, _DEVICE_NODE::InstancePath, IopCreateRegistryKeyEx(), IopDeviceObjectToDeviceInstance(), IopGetRegistryValue(), IopOpenDeviceParametersSubkey(), IopOpenRegistryKeyEx(), KeEnterCriticalRegion, KeLeaveCriticalRegion, KEY_VALUE_DATA, MAX_RESTPATH_BUF_LEN, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, PATH_CONTROL_CLASS, PATH_CURRENTCONTROLSET, PATH_CURRENTCONTROLSET_HW_PROFILE_CURRENT, PATH_ENUM, PLUGPLAY_REGKEY_CURRENT_HWPROFILE, PLUGPLAY_REGKEY_DEVICE, PLUGPLAY_REGKEY_DRIVER, PpRegistryDeviceResource, RtlAppendUnicodeStringToString(), RtlAppendUnicodeToString(), and TRUE.

00819 : 00820 00821 This routine returns a handle to an opened registry key that the driver 00822 may use to store/retrieve configuration information specific to a particular 00823 device instance. 00824 00825 The driver must call ZwClose to close the handle returned from this api 00826 when access is no longer required. 00827 00828 Parameters: 00829 00830 DeviceObject - Supples the device object of the physical device instance to 00831 open a registry storage key for. Normally it is a device object 00832 created by the hal bus extender. 00833 00834 DevInstKeyType - Supplies flags specifying which storage key associated with 00835 the device instance is to be opened. May be a combination of 00836 the following value: 00837 00838 PLUGPLAY_REGKEY_DEVICE - Open a key for storing device specific 00839 (driver-independent) information relating to the device instance. 00840 The flag may not be specified with PLUGPLAY_REGKEY_DRIVER. 00841 00842 PLUGPLAY_REGKEY_DRIVER - Open a key for storing driver-specific 00843 information relating to the device instance, This flag may 00844 not be specified with PLUGPLAY_REGKEY_DEVICE. 00845 00846 PLUGPLAY_REGKEY_CURRENT_HWPROFILE - If this flag is specified, 00847 then a key in the current hardware profile branch will be 00848 opened for the specified storage type. This allows the driver 00849 to access configuration information that is hardware profile 00850 specific. 00851 00852 DesiredAccess - Specifies the access mask for the key to be opened. 00853 00854 DevInstRegKey - Supplies the address of a variable that receives a handle to the 00855 opened key for the specified registry storage location. 00856 00857 Return Value: 00858 00859 Status code that indicates whether or not the function was successful. 00860 00861 --*/ 00862 00863 { 00864 00865 NTSTATUS status, appendStatus; 00866 HANDLE hBasePath; 00867 UNICODE_STRING unicodeBasePath, unicodeRestPath; 00868 00869 PAGED_CODE(); 00870 00871 // 00872 // Until SCSIPORT stops passing non PDOs allow the system to boot. 00873 // 00874 // ASSERT_PDO(PhysicalDeviceObject); 00875 // 00876 00877 // 00878 // Initialise out parameters 00879 // 00880 00881 *DevInstRegKey = NULL; 00882 00883 // 00884 // Allocate a buffer to build the RestPath string in 00885 // 00886 00887 if(!(unicodeRestPath.Buffer = ExAllocatePool(PagedPool, MAX_RESTPATH_BUF_LEN))) { 00888 status = STATUS_INSUFFICIENT_RESOURCES; 00889 goto clean0; 00890 } 00891 00892 unicodeRestPath.Length=0; 00893 unicodeRestPath.MaximumLength=MAX_RESTPATH_BUF_LEN; 00894 00895 // 00896 // Select the base path to the CurrentControlSet based on if we are dealing with 00897 // a hardware profile or not 00898 // 00899 00900 if(DevInstKeyType & PLUGPLAY_REGKEY_CURRENT_HWPROFILE) { 00901 PiWstrToUnicodeString(&unicodeBasePath, PATH_CURRENTCONTROLSET_HW_PROFILE_CURRENT); 00902 00903 } else { 00904 PiWstrToUnicodeString(&unicodeBasePath, PATH_CURRENTCONTROLSET); 00905 } 00906 00907 // 00908 // Enter critical section and acquire a lock on the registry. Both these 00909 // mechanisms are required to prevent deadlock in the case where an APC 00910 // routine calls this routine after the registry resource has been claimed 00911 // in this case it would wait blocking this thread so the registry would 00912 // never be released -> deadlock. Critical sectioning the registry manipulation 00913 // portion solves this problem 00914 // 00915 00916 KeEnterCriticalRegion(); 00917 ExAcquireResourceExclusive(&PpRegistryDeviceResource, TRUE); 00918 00919 // 00920 // Open the base registry key 00921 // 00922 00923 status = IopOpenRegistryKeyEx( &hBasePath, 00924 NULL, 00925 &unicodeBasePath, 00926 KEY_READ 00927 ); 00928 00929 if(!NT_SUCCESS(status)) { 00930 goto clean1; 00931 } 00932 00933 // 00934 // Build the RestPath string 00935 // 00936 00937 switch (DevInstKeyType) { 00938 00939 case PLUGPLAY_REGKEY_DEVICE: 00940 case PLUGPLAY_REGKEY_DEVICE + PLUGPLAY_REGKEY_CURRENT_HWPROFILE: 00941 { 00942 PDEVICE_NODE pDeviceNode; 00943 00944 // 00945 // Initialise the rest path with Enum\ 00946 // 00947 00948 appendStatus = RtlAppendUnicodeToString(&unicodeRestPath, PATH_ENUM); 00949 ASSERT(NT_SUCCESS( appendStatus )); 00950 // 00951 // Get the Enumerator\DeviceID\InstanceID path from the DeviceNode 00952 // 00953 00954 pDeviceNode = (PDEVICE_NODE) PhysicalDeviceObject->DeviceObjectExtension->DeviceNode; 00955 00956 // 00957 // Ensure this is a PDO and not an FDO (only PDO's have a DeviceNode) 00958 // 00959 00960 if (pDeviceNode) { 00961 appendStatus = RtlAppendUnicodeStringToString(&unicodeRestPath, &(pDeviceNode->InstancePath)); 00962 ASSERT(NT_SUCCESS( appendStatus )); 00963 } else { 00964 status = STATUS_INVALID_DEVICE_REQUEST; 00965 } 00966 00967 break; 00968 } 00969 00970 case PLUGPLAY_REGKEY_DRIVER: 00971 case PLUGPLAY_REGKEY_DRIVER + PLUGPLAY_REGKEY_CURRENT_HWPROFILE: 00972 { 00973 00974 HANDLE hDeviceKey; 00975 PKEY_VALUE_FULL_INFORMATION pDriverKeyInfo; 00976 00977 // 00978 // Initialise the rest path with Control\Class\ 00979 // 00980 00981 appendStatus = RtlAppendUnicodeToString(&unicodeRestPath, PATH_CONTROL_CLASS); 00982 ASSERT(NT_SUCCESS( appendStatus )); 00983 00984 // 00985 // Open the device instance key for this device 00986 // 00987 00988 status = IopDeviceObjectToDeviceInstance(PhysicalDeviceObject, &hDeviceKey, KEY_READ); 00989 00990 if(!NT_SUCCESS(status)){ 00991 goto clean1; 00992 } 00993 00994 // 00995 // See if we have a driver value 00996 // 00997 00998 status = IopGetRegistryValue(hDeviceKey, REGSTR_VALUE_DRIVER, &pDriverKeyInfo ); 00999 01000 if(NT_SUCCESS(status)){ 01001 01002 if(pDriverKeyInfo->Type == REG_SZ) { 01003 01004 // 01005 // Append <DevInstClass><ClassInstanceOrdinal> 01006 // 01007 01008 appendStatus = RtlAppendUnicodeToString(&unicodeRestPath, (PWSTR) KEY_VALUE_DATA(pDriverKeyInfo)); 01009 ASSERT(NT_SUCCESS( appendStatus )); 01010 01011 } else { 01012 // 01013 // We have a driver key with a non REG_SZ type - something is wrong - blame the PDO! 01014 // 01015 01016 status = STATUS_INVALID_PARAMETER_1; 01017 } 01018 01019 ExFreePool(pDriverKeyInfo); 01020 } 01021 01022 ZwClose(hDeviceKey); 01023 01024 break; 01025 } 01026 default: 01027 status = STATUS_INVALID_PARAMETER_3; 01028 goto clean2; 01029 } 01030 01031 01032 // 01033 // If we succeeded in building the rest path then open the key and hand it back to the caller 01034 // 01035 01036 if (NT_SUCCESS(status)){ 01037 if (DevInstKeyType == PLUGPLAY_REGKEY_DEVICE) { 01038 01039 status = IopOpenDeviceParametersSubkey(DevInstRegKey, 01040 hBasePath, 01041 &unicodeRestPath, 01042 DesiredAccess); 01043 } else { 01044 01045 status = IopCreateRegistryKeyEx( DevInstRegKey, 01046 hBasePath, 01047 &unicodeRestPath, 01048 DesiredAccess, 01049 REG_OPTION_NON_VOLATILE, 01050 NULL 01051 ); 01052 } 01053 } 01054 01055 // 01056 // Free up resources 01057 // 01058 01059 clean2: 01060 ZwClose(hBasePath); 01061 clean1: 01062 ExReleaseResource(&PpRegistryDeviceResource); 01063 KeLeaveCriticalRegion(); 01064 ExFreePool(unicodeRestPath.Buffer); 01065 clean0: 01066 return status; 01067 01068 }

ULONG IoPnPDeliverServicePowerNotification ULONG  PwrNotification,
BOOLEAN  Synchronous
 

Definition at line 9221 of file pnpioapi.c.

References ASSERT, ExAllocatePool, Executive, ExFreePool(), FALSE, IoRaiseInformationalHardError(), KeInitializeEvent, KernelMode, KeWaitForSingleObject(), MAX_VETO_NAME_LENGTH, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, and PpSetPowerEvent().

Referenced by xxxSendMessageBSM().

09225 { 09226 09227 NTSTATUS status = STATUS_SUCCESS; 09228 KEVENT completionEvent; 09229 NTSTATUS completionStatus=STATUS_SUCCESS; 09230 PNP_VETO_TYPE vetoType = PNP_VetoTypeUnknown; 09231 UNICODE_STRING vetoName; 09232 09233 PAGED_CODE(); 09234 09235 #define MAX_VETO_NAME_LENGTH 512 //From Revent.c make it common 09236 09237 if (Synchronous) { 09238 09239 09240 09241 vetoName.Buffer = ExAllocatePool (PagedPool,MAX_VETO_NAME_LENGTH*sizeof (WCHAR)); 09242 09243 if (vetoName.Buffer) { 09244 vetoName.MaximumLength = MAX_VETO_NAME_LENGTH; 09245 }else { 09246 vetoName.MaximumLength = 0; 09247 } 09248 vetoName.Length = 0; 09249 09250 KeInitializeEvent(&completionEvent, NotificationEvent, FALSE); 09251 09252 status = PpSetPowerEvent( 09253 PwrNotification, 09254 &completionEvent, 09255 &completionStatus, 09256 &vetoType,&vetoName 09257 ); 09258 09259 if (NT_SUCCESS(status)) { 09260 09261 KeWaitForSingleObject( &completionEvent, Executive, KernelMode, FALSE, NULL ); 09262 status = completionStatus; 09263 09264 if (vetoType == PNP_VetoWindowsService) { 09265 IoRaiseInformationalHardError (STATUS_DRIVER_FAILED_SLEEP,&vetoName,NULL); 09266 } 09267 09268 } 09269 if (vetoName.Buffer) { 09270 ExFreePool (vetoName.Buffer); 09271 } 09272 09273 } else { 09274 status = PpSetPowerEvent( 09275 PwrNotification, 09276 NULL, 09277 NULL, 09278 NULL, 09279 NULL 09280 ); 09281 } 09282 09283 ASSERT ((completionStatus == STATUS_SUCCESS) || 09284 (completionStatus == STATUS_UNSUCCESSFUL)); 09285 // 09286 // The private code in Win32k that calls this, assumes that 0 is failure, !0 is success 09287 // 09288 09289 return (completionStatus != STATUS_UNSUCCESSFUL); 09290 09291 }

NTKERNELAPI NTSTATUS NTAPI IoRegisterDeviceInterface IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN CONST GUID *  InterfaceClassGuid,
IN PUNICODE_STRING  ReferenceString,
OPTIONAL OUT PUNICODE_STRING  SymbolicLinkName
 

NTKERNELAPI NTSTATUS IoRegisterPlugPlayNotification IN IO_NOTIFICATION_EVENT_CATEGORY  EventCategory,
IN ULONG  EventCategoryFlags,
IN PVOID EventCategoryData  OPTIONAL,
IN PDRIVER_OBJECT  DriverObject,
IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE  CallbackRoutine,
IN PVOID  Context,
OUT PVOID *  NotificationEntry
 

Definition at line 7495 of file pnpioapi.c.

References ASSERT, _SETUP_NOTIFY_DATA::Callback, _HWPROFILE_NOTIFY_ENTRY::Callback, _TARGET_DEVICE_NOTIFY_ENTRY::Callback, _DEVICE_CLASS_NOTIFY_ENTRY::Callback, _NOTIFICATION_CALLBACK_PARAM_BLOCK::Callout, _DEVICE_CLASS_NOTIFY_ENTRY::ClassGuid, _SETUP_NOTIFY_DATA::Context, _HWPROFILE_NOTIFY_ENTRY::Context, _TARGET_DEVICE_NOTIFY_ENTRY::Context, _DEVICE_CLASS_NOTIFY_ENTRY::Context, _NOTIFICATION_CALLBACK_PARAM_BLOCK::Context, DbgPrint, DEVICE_CLASS_NOTIFY_ENTRY, _SETUP_NOTIFY_DATA::DriverObject, _HWPROFILE_NOTIFY_ENTRY::DriverObject, _TARGET_DEVICE_NOTIFY_ENTRY::DriverObject, _DEVICE_CLASS_NOTIFY_ENTRY::DriverObject, _DEVICE_INTERFACE_CHANGE_NOTIFICATION::Event, _SETUP_NOTIFY_DATA::EventCategory, _HWPROFILE_NOTIFY_ENTRY::EventCategory, _TARGET_DEVICE_NOTIFY_ENTRY::EventCategory, _DEVICE_CLASS_NOTIFY_ENTRY::EventCategory, EventCategoryDeviceInterfaceChange, EventCategoryHardwareProfileChange, EventCategoryReserved, EventCategoryTargetDeviceChange, ExAllocatePool, ExFreePool(), FALSE, _TARGET_DEVICE_NOTIFY_ENTRY::FileObject, HWPROFILE_NOTIFY_ENTRY, _DEVICE_INTERFACE_CHANGE_NOTIFICATION::InterfaceClassGuid, IoDriverObjectType, IoGetDeviceInterfaces(), IopAcquireNotifyLock, IopDeferredRegistrationList, IopDeferredRegistrationLock, IopDeviceClassNotifyList, IopDeviceClassNotifyLock, IopGetRelatedTargetDevice(), IopHashGuid, IopHwProfileNotifyLock, IopPnPHydraCallback(), IopProfileNotifyList, IopReferenceNotify(), IopReleaseNotifyLock, IopSetupNotifyData, IopTargetDeviceNotifyLock, KeGetCurrentThread, KernelMode, _SETUP_NOTIFY_DATA::ListEntry, _SETUP_NOTIFY_DATA::Lock, _HWPROFILE_NOTIFY_ENTRY::Lock, _TARGET_DEVICE_NOTIFY_ENTRY::Lock, _DEVICE_CLASS_NOTIFY_ENTRY::Lock, MmDispatchWin32Callout(), _NOTIFICATION_CALLBACK_PARAM_BLOCK::NotificationStructure, _DEFERRED_REGISTRATION_ENTRY::NotifyEntry, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObjectByPointer(), PAGED_CODE, PagedPool, PDEFERRED_REGISTRATION_ENTRY, _DEVICE_NODE::PhysicalDeviceObject, _TARGET_DEVICE_NOTIFY_ENTRY::PhysicalDeviceObject, PiNotificationInProgress, PiNotificationInProgressLock, PKWIN32_CALLOUT, PNP_NOTIFICATION_VERSION, PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, _SETUP_NOTIFY_DATA::RefCount, _HWPROFILE_NOTIFY_ENTRY::RefCount, _TARGET_DEVICE_NOTIFY_ENTRY::RefCount, _DEVICE_CLASS_NOTIFY_ENTRY::RefCount, RtlInitUnicodeString(), SETUP_NOTIFY_DATA, _DEVICE_INTERFACE_CHANGE_NOTIFICATION::Size, _DEVICE_INTERFACE_CHANGE_NOTIFICATION::SymbolicLinkName, TARGET_DEVICE_NOTIFY_ENTRY, _DEVICE_NODE::TargetDeviceNotify, TRUE, _SETUP_NOTIFY_DATA::Unregistered, _HWPROFILE_NOTIFY_ENTRY::Unregistered, _TARGET_DEVICE_NOTIFY_ENTRY::Unregistered, _DEVICE_CLASS_NOTIFY_ENTRY::Unregistered, and _DEVICE_INTERFACE_CHANGE_NOTIFICATION::Version.

Referenced by DeviceClassCDROMNotify(), RegisterForDeviceChangeNotifications(), and xxxRegisterForDeviceClassNotifications().

07506 : 07507 07508 IoRegisterPlugPlayNotification provides a mechanism by which WDM drivers may 07509 receive notification (via callback) for a variety of Plug&Play events. 07510 07511 Arguments: 07512 07513 EventCategory - Specifies the event category being registered for. WDM drivers 07514 may currently register for hard-ware profile changes, device class changes 07515 (instance arrivals and removals), and target device changes (query-removal, 07516 cancel-removal, removal-complete, as well as 3rd-party extensible events). 07517 07518 EventCategoryFlags - Supplies flags that modify the behavior of event registration. 07519 There is a separate group of flags defined for each event category. Presently, 07520 only the interface device change event category has any flags defined: 07521 07522 DEVICE_CLASS_NOTIFY_FOR_EXISTING_DEVICES -- Drivers wishing to retrieve a 07523 complete list of all interface devices presently available, and keep 07524 the list up-to-date (i.e., receive notification of interface device 07525 arrivals and removals), may specify this flag. This will cause the 07526 PnP manager to immediately notify the driver about every currently-existing 07527 device of the specified interface class. 07528 07529 EventCategoryData - Used to 'filter' events of the desired category based on the 07530 supplied criteria. Not all event categories will use this parameter. The 07531 event categories presently defined use this information as fol-lows: 07532 07533 EventCategoryHardwareProfileChange -- this parameter is unused, and should be NULL. 07534 EventCategoryDeviceClassChange -- LPGUID representing the interface class of interest 07535 EventCategoryTargetDeviceChange -- PFILE_OBJECT of interest 07536 07537 DriverObject - The caller must supply a reference to its driver object (obtained via 07538 ObReferenceObject), to prevent the driver from being unloaded while registered for 07539 notification. The PnP Manager will dereference the driver object when the driver 07540 unregisters for notification via IoUnregisterPlugPlayNotification). 07541 07542 CallbackRoutine - Entry point within the driver that the PnP manager should call 07543 whenever an applicable PnP event occurs. The entry point must have the 07544 following prototype: 07545 07546 typedef 07547 NTSTATUS 07548 (*PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) ( 07549 IN PVOID NotificationStructure, 07550 IN PVOID Context 07551 ); 07552 07553 where NotificationStructure contains information about the event. Each event 07554 GUID within an event category may potentially have its own notification structure 07555 format, but the buffer must al-ways begin with a PLUGPLAY_NOTIFICATION_HEADER, 07556 which indicates the size and ver-sion of the structure, as well as the GUID for 07557 the event. 07558 07559 The Context parameter provides the callback with the same context data that the 07560 caller passed in during registration. 07561 07562 Context - Points to the context data passed to the callback upon event notification. 07563 07564 NotificationEntry - Upon success, receives a handle representing the notification 07565 registration. This handle may be used to unregister for notification via 07566 IoUnregisterPlugPlayNotification. 07567 07568 --*/ 07569 { 07570 07571 NTSTATUS status = STATUS_SUCCESS; 07572 #if DBG 07573 ULONG originalApcDisable; 07574 #endif 07575 07576 PAGED_CODE(); 07577 07578 ASSERT(NotificationEntry); 07579 07580 // 07581 // Initialize out parameters 07582 // 07583 07584 *NotificationEntry = NULL; 07585 07586 // 07587 // Reference the driver object so it doesn't go away while we still have 07588 // a pointer outstanding 07589 // 07590 status = ObReferenceObjectByPointer(DriverObject, 07591 0, 07592 IoDriverObjectType, 07593 KernelMode 07594 ); 07595 07596 if (!NT_SUCCESS(status)) { 07597 return status; 07598 } 07599 07600 switch (EventCategory) { 07601 07602 case EventCategoryReserved: 07603 { 07604 07605 PSETUP_NOTIFY_DATA setupData; 07606 07607 // 07608 // Allocate space for the setup data 07609 // 07610 07611 setupData = ExAllocatePool(PagedPool, sizeof(SETUP_NOTIFY_DATA)); 07612 if (!setupData) { 07613 status = STATUS_INSUFFICIENT_RESOURCES; 07614 goto clean0; 07615 } 07616 07617 // 07618 // Store the required information 07619 // 07620 InitializeListHead(&(setupData->ListEntry)); 07621 setupData->EventCategory = EventCategory; 07622 setupData->Callback = CallbackRoutine; 07623 setupData->Context = Context; 07624 setupData->RefCount = 1; 07625 setupData->Unregistered = FALSE; 07626 setupData->Lock = NULL; 07627 setupData->DriverObject = DriverObject; 07628 07629 // 07630 // Activate the notifications 07631 // 07632 07633 IopSetupNotifyData = setupData; 07634 07635 // 07636 // Explicitly NULL out the returned entry as you can *NOT* unregister 07637 // for setup notifications 07638 // 07639 07640 *NotificationEntry = NULL; 07641 07642 break; 07643 07644 } 07645 07646 case EventCategoryHardwareProfileChange: 07647 { 07648 PHWPROFILE_NOTIFY_ENTRY entry; 07649 07650 // 07651 // new entry 07652 // 07653 entry =ExAllocatePool (PagedPool,sizeof (HWPROFILE_NOTIFY_ENTRY)); 07654 if (!entry) { 07655 status = STATUS_INSUFFICIENT_RESOURCES; 07656 goto clean0; 07657 } 07658 07659 // 07660 // grab the fields 07661 // 07662 07663 entry->EventCategory = EventCategory; 07664 entry->Callback = CallbackRoutine; 07665 entry->Context = Context; 07666 entry->RefCount = 1; 07667 entry->Unregistered = FALSE; 07668 entry->Lock = &IopHwProfileNotifyLock; 07669 entry->DriverObject = DriverObject; 07670 07671 ExAcquireFastMutex(&PiNotificationInProgressLock); 07672 if (PiNotificationInProgress) { 07673 // 07674 // If a notification is in progress, mark the entry as 07675 // Unregistered until after the current notification is 07676 // complete. 07677 // 07678 07679 PDEFERRED_REGISTRATION_ENTRY deferredNode; 07680 07681 deferredNode = ExAllocatePool(PagedPool, sizeof(DEFERRED_REGISTRATION_ENTRY)); 07682 if (!deferredNode) { 07683 ExReleaseFastMutex(&PiNotificationInProgressLock); 07684 status = STATUS_INSUFFICIENT_RESOURCES; 07685 goto clean0; 07686 } 07687 07688 deferredNode->NotifyEntry = (PNOTIFY_ENTRY_HEADER)entry; 07689 07690 // 07691 // Consider this entry unregistered during the current 07692 // notification 07693 // 07694 entry->Unregistered = TRUE; 07695 07696 // 07697 // Reference the entry so that it doesn't go away until it has 07698 // been removed from the deferred registration list 07699 // 07700 IopReferenceNotify((PNOTIFY_ENTRY_HEADER)entry); 07701 07702 // 07703 // Add this entry to the deferred registration list 07704 // 07705 IopAcquireNotifyLock(&IopDeferredRegistrationLock); 07706 InsertTailList(&IopDeferredRegistrationList, (PLIST_ENTRY)deferredNode); 07707 IopReleaseNotifyLock(&IopDeferredRegistrationLock); 07708 } else { 07709 // 07710 // If there is currently no notification in progress, the deferred 07711 // registration list must be empty. 07712 // 07713 ASSERT(IsListEmpty(&IopDeferredRegistrationList)); 07714 } 07715 ExReleaseFastMutex(&PiNotificationInProgressLock); 07716 07717 // 07718 // Lock the list, insert the new entry, and unlock it. 07719 // 07720 07721 IopAcquireNotifyLock(&IopHwProfileNotifyLock); 07722 InsertTailList(&IopProfileNotifyList, (PLIST_ENTRY)entry); 07723 IopReleaseNotifyLock(&IopHwProfileNotifyLock); 07724 07725 *NotificationEntry = entry; 07726 07727 break; 07728 } 07729 case EventCategoryTargetDeviceChange: 07730 { 07731 PTARGET_DEVICE_NOTIFY_ENTRY entry; 07732 IO_STACK_LOCATION irpSp; 07733 PDEVICE_NODE deviceNode; 07734 07735 ASSERT(EventCategoryData); 07736 07737 // 07738 // Allocate a new list entry 07739 // 07740 07741 entry = ExAllocatePool(PagedPool, sizeof(TARGET_DEVICE_NOTIFY_ENTRY)); 07742 if (!entry) { 07743 status = STATUS_INSUFFICIENT_RESOURCES; 07744 goto clean0; 07745 } 07746 07747 // 07748 // Retrieve the device object associated with this file handle. 07749 // 07750 status = IopGetRelatedTargetDevice((PFILE_OBJECT)EventCategoryData, 07751 &deviceNode); 07752 if (!NT_SUCCESS(status)) { 07753 ExFreePool(entry); 07754 goto clean0; 07755 } 07756 07757 // 07758 // Fill out the entry 07759 // 07760 07761 entry->EventCategory = EventCategory; 07762 entry->Callback = CallbackRoutine; 07763 entry->Context = Context; 07764 entry->DriverObject = DriverObject; 07765 entry->RefCount = 1; 07766 entry->Unregistered = FALSE; 07767 entry->Lock = &IopTargetDeviceNotifyLock; 07768 entry->FileObject = (PFILE_OBJECT)EventCategoryData; 07769 07770 // 07771 // The PDO associated with the devnode we got back from 07772 // IopGetRelatedTargetDevice has already been referenced by that 07773 // routine. Store this reference away in the notification entry, 07774 // so we can deref it later when the notification entry is unregistered. 07775 // 07776 07777 ASSERT(deviceNode->PhysicalDeviceObject); 07778 entry->PhysicalDeviceObject = deviceNode->PhysicalDeviceObject; 07779 07780 ExAcquireFastMutex(&PiNotificationInProgressLock); 07781 if (PiNotificationInProgress) { 07782 // 07783 // If a notification is in progress, mark the entry as 07784 // Unregistered until after the current notification is 07785 // complete. 07786 // 07787 07788 PDEFERRED_REGISTRATION_ENTRY deferredNode; 07789 07790 deferredNode = ExAllocatePool(PagedPool, sizeof(DEFERRED_REGISTRATION_ENTRY)); 07791 if (!deferredNode) { 07792 ExReleaseFastMutex(&PiNotificationInProgressLock); 07793 status = STATUS_INSUFFICIENT_RESOURCES; 07794 goto clean0; 07795 } 07796 07797 deferredNode->NotifyEntry = (PNOTIFY_ENTRY_HEADER)entry; 07798 07799 // 07800 // Consider this entry unregistered during the current 07801 // notification 07802 // 07803 entry->Unregistered = TRUE; 07804 07805 // 07806 // Reference the entry so that it doesn't go away until it has 07807 // been removed from the deferred registration list 07808 // 07809 IopReferenceNotify((PNOTIFY_ENTRY_HEADER)entry); 07810 07811 // 07812 // Add this entry to the deferred registration list 07813 // 07814 IopAcquireNotifyLock(&IopDeferredRegistrationLock); 07815 InsertTailList(&IopDeferredRegistrationList, (PLIST_ENTRY)deferredNode); 07816 IopReleaseNotifyLock(&IopDeferredRegistrationLock); 07817 } else { 07818 // 07819 // If there is currently no notification in progress, the deferred 07820 // registration list must be empty. 07821 // 07822 ASSERT(IsListEmpty(&IopDeferredRegistrationList)); 07823 } 07824 ExReleaseFastMutex(&PiNotificationInProgressLock); 07825 07826 // 07827 // Lock the list, insert the new entry, and unlock it. 07828 // 07829 07830 IopAcquireNotifyLock(&IopTargetDeviceNotifyLock); 07831 InsertTailList(&deviceNode->TargetDeviceNotify, (PLIST_ENTRY)entry); 07832 IopReleaseNotifyLock(&IopTargetDeviceNotifyLock); 07833 07834 *NotificationEntry = entry; 07835 break; 07836 } 07837 07838 case EventCategoryDeviceInterfaceChange: 07839 { 07840 PDEVICE_CLASS_NOTIFY_ENTRY entry; 07841 07842 ASSERT(EventCategoryData); 07843 07844 // 07845 // Allocate a new list entry 07846 // 07847 07848 entry = ExAllocatePool(PagedPool, sizeof(DEVICE_CLASS_NOTIFY_ENTRY)); 07849 if (!entry) { 07850 status = STATUS_INSUFFICIENT_RESOURCES; 07851 goto clean0; 07852 } 07853 07854 // 07855 // Fill out the entry 07856 // 07857 07858 entry->EventCategory = EventCategory; 07859 entry->Callback = CallbackRoutine; 07860 entry->Context = Context; 07861 entry->ClassGuid = *((LPGUID) EventCategoryData); 07862 entry->RefCount = 1; 07863 entry->Unregistered = FALSE; 07864 entry->Lock = &IopDeviceClassNotifyLock; 07865 entry->DriverObject = DriverObject; 07866 07867 ExAcquireFastMutex(&PiNotificationInProgressLock); 07868 if (PiNotificationInProgress) { 07869 // 07870 // If a notification is in progress, mark the entry as 07871 // Unregistered until after the current notification is 07872 // complete. 07873 // 07874 07875 PDEFERRED_REGISTRATION_ENTRY deferredNode; 07876 07877 deferredNode = ExAllocatePool(PagedPool, sizeof(DEFERRED_REGISTRATION_ENTRY)); 07878 if (!deferredNode) { 07879 ExReleaseFastMutex(&PiNotificationInProgressLock); 07880 status = STATUS_INSUFFICIENT_RESOURCES; 07881 goto clean0; 07882 } 07883 07884 deferredNode->NotifyEntry = (PNOTIFY_ENTRY_HEADER)entry; 07885 07886 // 07887 // Consider this entry unregistered during the current 07888 // notification 07889 // 07890 entry->Unregistered = TRUE; 07891 07892 // 07893 // Reference the entry so that it doesn't go away until it has 07894 // been removed from the deferred registration list 07895 // 07896 IopReferenceNotify((PNOTIFY_ENTRY_HEADER)entry); 07897 07898 // 07899 // Add this entry to the deferred registration list 07900 // 07901 IopAcquireNotifyLock(&IopDeferredRegistrationLock); 07902 InsertTailList(&IopDeferredRegistrationList, (PLIST_ENTRY)deferredNode); 07903 IopReleaseNotifyLock(&IopDeferredRegistrationLock); 07904 } else { 07905 // 07906 // If there is currently no notification in progress, the deferred 07907 // registration list must be empty. 07908 // 07909 ASSERT(IsListEmpty(&IopDeferredRegistrationList)); 07910 } 07911 ExReleaseFastMutex(&PiNotificationInProgressLock); 07912 07913 // 07914 // Lock the list 07915 // 07916 07917 IopAcquireNotifyLock(&IopDeviceClassNotifyLock); 07918 07919 // 07920 // Insert it at the tail 07921 // 07922 07923 InsertTailList( (PLIST_ENTRY) &(IopDeviceClassNotifyList[ IopHashGuid(&(entry->ClassGuid)) ]), 07924 (PLIST_ENTRY) entry 07925 ); 07926 07927 // 07928 // Unlock the list 07929 // 07930 07931 IopReleaseNotifyLock(&IopDeviceClassNotifyLock); 07932 07933 // 07934 // See if we need to notify for all the device classes already present 07935 // 07936 07937 if (EventCategoryFlags & PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES) { 07938 07939 PWCHAR pSymbolicLinks, pCurrent; 07940 DEVICE_INTERFACE_CHANGE_NOTIFICATION notification; 07941 UNICODE_STRING unicodeString; 07942 07943 // 07944 // Fill in the notification structure 07945 // 07946 07947 notification.Version = PNP_NOTIFICATION_VERSION; 07948 notification.Size = sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION); 07949 notification.Event = GUID_DEVICE_INTERFACE_ARRIVAL; 07950 notification.InterfaceClassGuid = entry->ClassGuid; 07951 07952 // 07953 // Get the list of all the devices of this function class that are 07954 // already in the system 07955 // 07956 07957 status = IoGetDeviceInterfaces(&(entry->ClassGuid), 07958 NULL, 07959 0, 07960 &pSymbolicLinks 07961 ); 07962 if (!NT_SUCCESS(status)) { 07963 // 07964 // No buffer will have been returned so just return status 07965 // 07966 goto clean0; 07967 } 07968 07969 // 07970 // Callback for each device currently in the system 07971 // 07972 07973 pCurrent = pSymbolicLinks; 07974 while(*pCurrent != UNICODE_NULL) { 07975 NOTIFICATION_CALLBACK_PARAM_BLOCK callparams; 07976 ULONG Console=0; 07977 07978 RtlInitUnicodeString(&unicodeString, pCurrent); 07979 notification.SymbolicLinkName = &unicodeString; 07980 07981 #if DBG 07982 originalApcDisable = KeGetCurrentThread()->KernelApcDisable; 07983 #endif 07984 // 07985 // Call back on the registered notification routine 07986 // 07987 callparams.Callout=(*CallbackRoutine); 07988 callparams.NotificationStructure=&notification; 07989 callparams.Context=Context; 07990 07991 07992 // 07993 // Dispatch this function via the memory manager. 07994 // Win32K is a driver that can have multiple copies. If Hydra 07995 // is running, the Mem. manager will check if the callback exists 07996 // in "per session" space. If that is the case, it will attach to the 07997 // console (hence the 3rd param of PULONG containing 0) session and deliver 07998 // it. If either Hydra is not running, or the callback is outside session space 07999 // then the callback is called directly. 08000 // 08001 MmDispatchWin32Callout ((PKWIN32_CALLOUT)callparams.Callout,&IopPnPHydraCallback,&callparams,&Console); 08002 08003 #if DBG 08004 if (originalApcDisable != KeGetCurrentThread()->KernelApcDisable) { 08005 DbgPrint("IoRegisterPlugPlayNotification: Driver %Z, notification handler @ 0x%p returned with different KernelApcDisable = %d, original = %d\n", 08006 &entry->DriverObject->DriverName, entry->Callback, KeGetCurrentThread()->KernelApcDisable, originalApcDisable); 08007 DbgBreakPoint(); 08008 } 08009 #endif 08010 08011 pCurrent += (unicodeString.Length / sizeof(WCHAR)) + 1; 08012 08013 } 08014 08015 ExFreePool(pSymbolicLinks); 08016 08017 } 08018 08019 *NotificationEntry = entry; 08020 } 08021 08022 break; 08023 } 08024 08025 clean0: 08026 08027 if (!NT_SUCCESS(status)) { 08028 ObDereferenceObject(DriverObject); 08029 } 08030 08031 return status; 08032 }

NTKERNELAPI NTSTATUS IoReportDetectedDevice IN PDRIVER_OBJECT  DriverObject,
IN INTERFACE_TYPE  LegacyBusType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PCM_RESOURCE_LIST  ResourceList,
IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements  OPTIONAL,
IN BOOLEAN  ResourceAssigned,
IN OUT PDEVICE_OBJECT DeviceObject
 

Definition at line 1548 of file pnpioapi.c.

References ArbiterRequestLegacyReported, ASSERT, BusNumber, CmRegistryMachineSystemCurrentControlSetEnumName, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_ADDED, DNF_ENUMERATED, DNF_HAS_PROBLEM, DNF_MADEUP, DNF_NEED_ENUMERATION_ONLY, DNF_NEED_QUERY_IDS, DNF_NO_RESOURCE_REQUIRED, DNF_PROCESSED, DNF_STARTED, DO_BUS_ENUMERATED_DEVICE, DRVO_BUILTIN_DRIVER, ExAcquireResourceShared, ExAllocatePool, ExFreePool(), exit, ExReleaseResource, FALSE, _DEVICE_NODE::Flags, _DEVICE_OBJECT::Flags, _DEVICE_NODE::InstancePath, IoCreateDevice(), IoDeleteDevice(), IopAllocateDeviceNode(), IopConcatenateUnicodeStrings(), IopCreateRegistryKeyEx(), IopDeleteLegacyKey(), IopDetermineResourceListSize(), IopDeviceObjectFromDeviceInstance(), IopDeviceObjectToDeviceInstance(), IopDoDeferredSetInterfaceState(), IopDoesDevNodeHaveProblem, IopDuplicateDetection(), IopInsertTreeDeviceNode(), IopIsReportedAlready(), IopNotifySetupDeviceArrival(), IoPnpDriverObject, IopNumberDeviceNodes, IopOpenRegistryKeyEx(), IopReleaseDeviceResources(), IopRootDeviceNode, IopSetDevNodeProblem, IopWriteAllocatedResourcesToRegistry(), IoReportResourceUsageInternal(), KeEnterCriticalRegion, KeLeaveCriticalRegion, KeQueryTickCount(), L, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObject, PAGED_CODE, PagedPool, _DEVICE_NODE::PhysicalDeviceObject, PpCreateLegacyDeviceIds(), PpDeviceRegistration(), PpRegistryDeviceResource, _DEVICE_NODE::Problem, RtlInitUnicodeString(), _DEVICE_NODE::ServiceName, TITLE_INDEX_VALUE, TRUE, and USHORT.

01561 : 01562 01563 PnP device drivers call this API to report any device detected. This routine 01564 creates a Physical Device object, reference the Physical Device object and 01565 returns back to the callers. Once the detected device is reported, the Pnp manager 01566 considers the device has been fully controlled by the reporting drivers. Thus it 01567 will not invoke AddDevice entry and send StartDevice irp to the driver. 01568 01569 The driver needs to report the resources it used to detect this device such that 01570 pnp manager can perform duplicates detection on this device. 01571 01572 The caller must dereference the DeviceObject once it no longer needs it. 01573 01574 Parameters: 01575 01576 DriverObject - Supplies the driver object of the driver who detected 01577 this device. 01578 01579 ResourceList - Supplies a pointer to the resource list which the driver used 01580 to detect the device. 01581 01582 ResourceRequirements - supplies a pointer to the resource requirements list 01583 for the detected device. This is optional. 01584 01585 ResourceAssigned - if TRUE, the driver already called IoReportResourceUsage or 01586 IoAssignResource to get the ownership of the resources. Otherwise, 01587 the PnP manager will call IoReportResourceUsage to allocate the 01588 resources for the driver. 01589 01590 DeviceObject - if NULL, this routine will create a PDO and return it thru this variable. 01591 Otherwise, a PDO is already created and this routine will simply use the supplied 01592 PDO. 01593 01594 Return Value: 01595 01596 Status code that indicates whether or not the function was successful. 01597 01598 01599 --*/ 01600 01601 { 01602 WCHAR buffer[60]; 01603 NTSTATUS status; 01604 UNICODE_STRING deviceName, instanceName, unicodeName, *serviceName, driverName; 01605 PDEVICE_NODE deviceNode; 01606 ULONG length, i = 0, disposition, tmpValue, listSize = 0; 01607 HANDLE handle, handle1, logConfHandle, controlHandle, hTreeHandle, enumHandle; 01608 PCM_RESOURCE_LIST cmResource; 01609 PWSTR p; 01610 LARGE_INTEGER tickCount; 01611 PDEVICE_OBJECT deviceObject; 01612 BOOLEAN newlyCreated = FALSE; 01613 01614 PAGED_CODE(); 01615 01616 if (*DeviceObject) { 01617 01618 deviceObject = *DeviceObject; 01619 01620 // 01621 // The PDO is already known. simply handle the resourcelist and resreq list. 01622 // This is a hack for NDIS drivers. 01623 // 01624 deviceNode = (PDEVICE_NODE)(*DeviceObject)->DeviceObjectExtension->DeviceNode; 01625 if (!deviceNode) { 01626 return STATUS_NO_SUCH_DEVICE; 01627 } 01628 01629 KeEnterCriticalRegion(); 01630 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 01631 01632 // 01633 // Write ResourceList and ResReq list to the device instance 01634 // 01635 01636 status = IopDeviceObjectToDeviceInstance (*DeviceObject, 01637 &handle, 01638 KEY_ALL_ACCESS 01639 ); 01640 if (!NT_SUCCESS(status)) { 01641 ExReleaseResource(&PpRegistryDeviceResource); 01642 KeLeaveCriticalRegion(); 01643 return status; 01644 } 01645 if (ResourceAssigned) { 01646 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_NO_RESOURCE_AT_INIT); 01647 tmpValue = 1; 01648 ZwSetValueKey(handle, 01649 &unicodeName, 01650 TITLE_INDEX_VALUE, 01651 REG_DWORD, 01652 &tmpValue, 01653 sizeof(tmpValue) 01654 ); 01655 } 01656 RtlInitUnicodeString(&unicodeName, REGSTR_KEY_LOG_CONF); 01657 status = IopCreateRegistryKeyEx( &logConfHandle, 01658 handle, 01659 &unicodeName, 01660 KEY_ALL_ACCESS, 01661 REG_OPTION_NON_VOLATILE, 01662 NULL 01663 ); 01664 ZwClose(handle); 01665 if (NT_SUCCESS(status)) { 01666 01667 // 01668 // Write the ResourceList and and ResourceRequirements to the logconf key under 01669 // device instance key. 01670 // 01671 01672 if (ResourceList) { 01673 RtlInitUnicodeString(&unicodeName, REGSTR_VAL_BOOTCONFIG); 01674 ZwSetValueKey( 01675 logConfHandle, 01676 &unicodeName, 01677 TITLE_INDEX_VALUE, 01678 REG_RESOURCE_LIST, 01679 ResourceList, 01680 listSize = IopDetermineResourceListSize(ResourceList) 01681 ); 01682 } 01683 if (ResourceRequirements) { 01684 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_BASIC_CONFIG_VECTOR); 01685 ZwSetValueKey( 01686 logConfHandle, 01687 &unicodeName, 01688 TITLE_INDEX_VALUE, 01689 REG_RESOURCE_REQUIREMENTS_LIST, 01690 ResourceRequirements, 01691 ResourceRequirements->ListSize 01692 ); 01693 } 01694 ZwClose(logConfHandle); 01695 } 01696 ExReleaseResource(&PpRegistryDeviceResource); 01697 KeLeaveCriticalRegion(); 01698 if (NT_SUCCESS(status)) { 01699 goto checkResource; 01700 } else { 01701 return status; 01702 } 01703 } 01704 01705 // 01706 // Normal case: *DeviceObject is NULL 01707 // 01708 01709 *DeviceObject = NULL; 01710 serviceName = &DriverObject->DriverExtension->ServiceKeyName; 01711 01712 // 01713 // Special handling for driver object created thru IoCreateDriver. 01714 // When a builtin driver calls IoReportDetectedDevice, the ServiceKeyName of 01715 // the driver object is set to \Driver\DriverName. To create a detected device 01716 // instance key, we will take only the DriverName. 01717 // 01718 01719 if (DriverObject->Flags & DRVO_BUILTIN_DRIVER) { 01720 p = serviceName->Buffer + (serviceName->Length / sizeof(WCHAR)) - 1; 01721 driverName.Length = 0; 01722 while (*p != '\\' && (p != serviceName->Buffer)) { 01723 p--; 01724 driverName.Length += sizeof(WCHAR); 01725 } 01726 if (p == serviceName->Buffer) { 01727 return STATUS_UNSUCCESSFUL; 01728 } else { 01729 p++; 01730 driverName.Buffer = p; 01731 driverName.MaximumLength = driverName.Length + sizeof(WCHAR); 01732 } 01733 } else { 01734 01735 // 01736 // Before doing anything first perform duplicate detection 01737 // 01738 01739 status = IopDuplicateDetection( 01740 LegacyBusType, 01741 BusNumber, 01742 SlotNumber, 01743 &deviceNode 01744 ); 01745 01746 if (NT_SUCCESS(status) && deviceNode) { 01747 deviceObject = deviceNode->PhysicalDeviceObject; 01748 if ((deviceNode->Flags & DNF_ADDED) || 01749 (IopDoesDevNodeHaveProblem(deviceNode) && 01750 deviceNode->Problem != CM_PROB_NOT_CONFIGURED && 01751 deviceNode->Problem != CM_PROB_REINSTALL && 01752 deviceNode->Problem != CM_PROB_FAILED_INSTALL)) { 01753 01754 // 01755 // BUGBUG: This assumption may not be true. 01756 // 01757 01758 ObDereferenceObject(deviceObject); 01759 01760 return STATUS_NO_SUCH_DEVICE; 01761 } 01762 01763 deviceNode->Flags &= ~DNF_HAS_PROBLEM; 01764 deviceNode->Problem = 0; 01765 01766 IopDeleteLegacyKey(DriverObject); 01767 goto checkResource; 01768 } 01769 01770 } 01771 01772 // 01773 // Create a PDO and its DeviceNode 01774 // 01775 01776 // 01777 // Madeup a name for the device object. 01778 // 01779 01780 KeQueryTickCount(&tickCount); 01781 length = _snwprintf(buffer, sizeof(buffer) / sizeof(WCHAR), L"\\Device\\%04u%x", IopNumberDeviceNodes, tickCount.LowPart); 01782 deviceName.MaximumLength = sizeof(buffer); 01783 deviceName.Length = (USHORT)(length * sizeof(WCHAR)); 01784 deviceName.Buffer = buffer; \ 01785 01786 status = IoCreateDevice( IoPnpDriverObject, 01787 sizeof(IOPNP_DEVICE_EXTENSION), 01788 &deviceName, 01789 FILE_DEVICE_CONTROLLER, 01790 0, 01791 FALSE, 01792 &deviceObject ); 01793 01794 if (NT_SUCCESS(status)) { 01795 deviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE; // Mark this is a PDO 01796 deviceNode = IopAllocateDeviceNode(deviceObject); 01797 if (deviceNode) { 01798 01799 // 01800 // First delete the Legacy_DriverName key and subkeys from Enum\Root, if exits. 01801 // 01802 01803 if (!(DriverObject->Flags & DRVO_BUILTIN_DRIVER)) { 01804 IopDeleteLegacyKey(DriverObject); 01805 } 01806 01807 // 01808 // Create the compatible id list we'll use for this made-up device. 01809 // 01810 01811 status = PpCreateLegacyDeviceIds( 01812 deviceObject, 01813 ((DriverObject->Flags & DRVO_BUILTIN_DRIVER) ? 01814 &driverName : serviceName), 01815 ResourceList); 01816 01817 if(!NT_SUCCESS(status)) { 01818 goto exit; 01819 } 01820 01821 // 01822 // Create/Open a registry key for the device instance and 01823 // write the addr of the device object to registry 01824 // 01825 01826 if (DriverObject->Flags & DRVO_BUILTIN_DRIVER) { 01827 length = _snwprintf(buffer, sizeof(buffer) / sizeof(WCHAR), L"ROOT\\%s", driverName.Buffer); 01828 } else { 01829 length = _snwprintf(buffer, sizeof(buffer) / sizeof(WCHAR), L"ROOT\\%s", serviceName->Buffer); 01830 } 01831 deviceName.MaximumLength = sizeof(buffer); 01832 ASSERT(length <= sizeof(buffer) - 10); 01833 deviceName.Length = (USHORT)(length * sizeof(WCHAR)); 01834 deviceName.Buffer = buffer; 01835 01836 KeEnterCriticalRegion(); 01837 ExAcquireResourceShared(&PpRegistryDeviceResource, TRUE); 01838 01839 status = IopOpenRegistryKeyEx( &enumHandle, 01840 NULL, 01841 &CmRegistryMachineSystemCurrentControlSetEnumName, 01842 KEY_ALL_ACCESS 01843 ); 01844 if (!NT_SUCCESS(status)) { 01845 goto exit; 01846 } 01847 01848 status = IopCreateRegistryKeyEx( &handle1, 01849 enumHandle, 01850 &deviceName, 01851 KEY_ALL_ACCESS, 01852 REG_OPTION_NON_VOLATILE, 01853 &disposition 01854 ); 01855 01856 if (NT_SUCCESS(status)) { 01857 deviceName.Buffer[deviceName.Length / sizeof(WCHAR)] = 01858 OBJ_NAME_PATH_SEPARATOR; 01859 deviceName.Length += sizeof(WCHAR); 01860 if (disposition != REG_CREATED_NEW_KEY) { 01861 while (TRUE) { 01862 PiUlongToInstanceKeyUnicodeString(&instanceName, 01863 buffer + deviceName.Length / sizeof(WCHAR), 01864 sizeof(buffer) - deviceName.Length, 01865 i 01866 ); 01867 status = IopCreateRegistryKeyEx( &handle, 01868 handle1, 01869 &instanceName, 01870 KEY_ALL_ACCESS, 01871 REG_OPTION_NON_VOLATILE, 01872 &disposition 01873 ); 01874 if (NT_SUCCESS(status)) { 01875 if (disposition == REG_CREATED_NEW_KEY) { 01876 ZwClose(handle1); 01877 break; 01878 } else { 01879 if (IopIsReportedAlready(handle, serviceName, ResourceList)) { 01880 01881 // 01882 // Write the reported resources to registry in case the irq changed 01883 // 01884 01885 RtlInitUnicodeString(&unicodeName, REGSTR_KEY_LOG_CONF); 01886 status = IopCreateRegistryKeyEx( &logConfHandle, 01887 handle, 01888 &unicodeName, 01889 KEY_ALL_ACCESS, 01890 REG_OPTION_NON_VOLATILE, 01891 NULL 01892 ); 01893 if (NT_SUCCESS(status)) { 01894 01895 // 01896 // Write the ResourceList and and ResourceRequirements to the device instance key 01897 // 01898 01899 if (ResourceList) { 01900 RtlInitUnicodeString(&unicodeName, REGSTR_VAL_BOOTCONFIG); 01901 ZwSetValueKey( 01902 logConfHandle, 01903 &unicodeName, 01904 TITLE_INDEX_VALUE, 01905 REG_RESOURCE_LIST, 01906 ResourceList, 01907 listSize = IopDetermineResourceListSize(ResourceList) 01908 ); 01909 } 01910 if (ResourceRequirements) { 01911 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_BASIC_CONFIG_VECTOR); 01912 ZwSetValueKey( 01913 logConfHandle, 01914 &unicodeName, 01915 TITLE_INDEX_VALUE, 01916 REG_RESOURCE_REQUIREMENTS_LIST, 01917 ResourceRequirements, 01918 ResourceRequirements->ListSize 01919 ); 01920 } 01921 ZwClose(logConfHandle); 01922 } 01923 01924 ExReleaseResource(&PpRegistryDeviceResource); 01925 KeLeaveCriticalRegion(); 01926 IoDeleteDevice(deviceObject); 01927 ZwClose(handle1); 01928 deviceObject = IopDeviceObjectFromDeviceInstance ( 01929 handle, NULL); // Add a reference 01930 ZwClose(handle); 01931 ZwClose(enumHandle); 01932 ASSERT(deviceObject); 01933 if (deviceObject == NULL) { 01934 status = STATUS_UNSUCCESSFUL; 01935 return status; 01936 } 01937 deviceNode = (PDEVICE_NODE) 01938 deviceObject->DeviceObjectExtension->DeviceNode; 01939 goto checkResource; 01940 } else { 01941 i++; 01942 ZwClose(handle); 01943 continue; 01944 } 01945 } 01946 } else { 01947 ZwClose(handle1); 01948 ZwClose(enumHandle); 01949 goto exit; 01950 } 01951 } 01952 } else { 01953 01954 // 01955 // This is a new device key. So, instance is 0. Create it. 01956 // 01957 01958 PiUlongToInstanceKeyUnicodeString(&instanceName, 01959 buffer + deviceName.Length / sizeof(WCHAR), 01960 sizeof(buffer) - deviceName.Length, 01961 i 01962 ); 01963 status = IopCreateRegistryKeyEx( &handle, 01964 handle1, 01965 &instanceName, 01966 KEY_ALL_ACCESS, 01967 REG_OPTION_NON_VOLATILE, 01968 &disposition 01969 ); 01970 ZwClose(handle1); 01971 if (!NT_SUCCESS(status)) { 01972 ZwClose(enumHandle); 01973 goto exit; 01974 } 01975 ASSERT(disposition == REG_CREATED_NEW_KEY); 01976 } 01977 } else { 01978 ZwClose(enumHandle); 01979 goto exit; 01980 } 01981 01982 deviceName.Length += instanceName.Length; 01983 ASSERT(disposition == REG_CREATED_NEW_KEY); 01984 newlyCreated = TRUE; 01985 01986 // 01987 // Initialize new device instance registry key 01988 // 01989 01990 if (ResourceAssigned) { 01991 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_NO_RESOURCE_AT_INIT); 01992 tmpValue = 1; 01993 ZwSetValueKey(handle, 01994 &unicodeName, 01995 TITLE_INDEX_VALUE, 01996 REG_DWORD, 01997 &tmpValue, 01998 sizeof(tmpValue) 01999 ); 02000 } 02001 RtlInitUnicodeString(&unicodeName, REGSTR_KEY_LOG_CONF); 02002 logConfHandle = NULL; 02003 status = IopCreateRegistryKeyEx( &logConfHandle, 02004 handle, 02005 &unicodeName, 02006 KEY_ALL_ACCESS, 02007 REG_OPTION_NON_VOLATILE, 02008 NULL 02009 ); 02010 02011 ASSERT(status == STATUS_SUCCESS); 02012 02013 if (NT_SUCCESS(status)) { 02014 02015 // 02016 // Write the ResourceList and and ResourceRequirements to the logconf key under 02017 // device instance key. 02018 // 02019 02020 if (ResourceList) { 02021 RtlInitUnicodeString(&unicodeName, REGSTR_VAL_BOOTCONFIG); 02022 ZwSetValueKey( 02023 logConfHandle, 02024 &unicodeName, 02025 TITLE_INDEX_VALUE, 02026 REG_RESOURCE_LIST, 02027 ResourceList, 02028 listSize = IopDetermineResourceListSize(ResourceList) 02029 ); 02030 } 02031 if (ResourceRequirements) { 02032 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_BASIC_CONFIG_VECTOR); 02033 ZwSetValueKey( 02034 logConfHandle, 02035 &unicodeName, 02036 TITLE_INDEX_VALUE, 02037 REG_RESOURCE_REQUIREMENTS_LIST, 02038 ResourceRequirements, 02039 ResourceRequirements->ListSize 02040 ); 02041 } 02042 //ZwClose(logConfHandle); 02043 } 02044 02045 RtlInitUnicodeString(&unicodeName, REGSTR_VALUE_CONFIG_FLAGS); 02046 tmpValue = CONFIGFLAG_FINISH_INSTALL; 02047 ZwSetValueKey(handle, 02048 &unicodeName, 02049 TITLE_INDEX_VALUE, 02050 REG_DWORD, 02051 &tmpValue, 02052 sizeof(tmpValue) 02053 ); 02054 02055 PiWstrToUnicodeString(&unicodeName, REGSTR_VALUE_LEGACY); 02056 tmpValue = 0; 02057 ZwSetValueKey( 02058 handle, 02059 &unicodeName, 02060 TITLE_INDEX_VALUE, 02061 REG_DWORD, 02062 &tmpValue, 02063 sizeof(ULONG) 02064 ); 02065 02066 RtlInitUnicodeString(&unicodeName, REGSTR_KEY_CONTROL); 02067 controlHandle = NULL; 02068 IopCreateRegistryKeyEx( &controlHandle, 02069 handle, 02070 &unicodeName, 02071 KEY_ALL_ACCESS, 02072 REG_OPTION_VOLATILE, 02073 NULL 02074 ); 02075 02076 ASSERT(status == STATUS_SUCCESS); 02077 02078 if (NT_SUCCESS(status)) { 02079 02080 // 02081 // Write DeviceObject reference ... 02082 // 02083 02084 PiWstrToUnicodeString(&unicodeName, REGSTR_VALUE_DEVICE_REFERENCE); 02085 status = ZwSetValueKey(controlHandle, 02086 &unicodeName, 02087 TITLE_INDEX_VALUE, 02088 REG_DWORD, 02089 (PULONG_PTR)&deviceObject, 02090 sizeof(ULONG_PTR) 02091 ); 02092 PiWstrToUnicodeString(&unicodeName, REGSTR_VALUE_DEVICE_REPORTED); 02093 tmpValue = 1; 02094 status = ZwSetValueKey(controlHandle, 02095 &unicodeName, 02096 TITLE_INDEX_VALUE, 02097 REG_DWORD, 02098 &tmpValue, 02099 sizeof(ULONG) 02100 ); 02101 status = ZwSetValueKey(handle, 02102 &unicodeName, 02103 TITLE_INDEX_VALUE, 02104 REG_DWORD, 02105 &tmpValue, 02106 sizeof(ULONG) 02107 ); 02108 02109 //ZwClose(controlHandle); 02110 } 02111 02112 ZwClose(enumHandle); 02113 02114 // 02115 // Create Service value name and set it to the calling driver's service 02116 // key name. 02117 // 02118 02119 PiWstrToUnicodeString(&unicodeName, REGSTR_VALUE_SERVICE); 02120 p = (PWSTR)ExAllocatePool(PagedPool, serviceName->Length + sizeof(UNICODE_NULL)); 02121 if (!p) { 02122 goto CleanupRegistry; 02123 } 02124 RtlMoveMemory(p, serviceName->Buffer, serviceName->Length); 02125 p[serviceName->Length / sizeof (WCHAR)] = UNICODE_NULL; 02126 ZwSetValueKey( 02127 handle, 02128 &unicodeName, 02129 TITLE_INDEX_VALUE, 02130 REG_SZ, 02131 p, 02132 serviceName->Length + sizeof(UNICODE_NULL) 02133 ); 02134 if (DriverObject->Flags & DRVO_BUILTIN_DRIVER) { 02135 deviceNode->ServiceName = *serviceName; 02136 } else { 02137 ExFreePool(p); 02138 } 02139 02140 ExReleaseResource(&PpRegistryDeviceResource); 02141 KeLeaveCriticalRegion(); 02142 //ZwClose(logConfHandle); 02143 //ZwClose(controlHandle); 02144 //ZwClose(handle); 02145 02146 // 02147 // Register the device for the driver and save the device 02148 // instance path in device node. 02149 // 02150 02151 if (!(DriverObject->Flags & DRVO_BUILTIN_DRIVER)) { 02152 PpDeviceRegistration( &deviceName, 02153 TRUE, 02154 &deviceNode->ServiceName 02155 ); 02156 } 02157 02158 IopConcatenateUnicodeStrings(&deviceNode->InstancePath, &deviceName, NULL); 02159 02160 deviceNode->Flags = DNF_MADEUP + DNF_ENUMERATED + DNF_PROCESSED; 02161 02162 IopInsertTreeDeviceNode(IopRootDeviceNode, deviceNode); 02163 02164 // 02165 // Add a reference to the DeviceObject for ourself 02166 // 02167 02168 ObReferenceObject(deviceObject); 02169 02170 IopNotifySetupDeviceArrival(deviceObject, NULL, FALSE); 02171 02172 goto checkResource; 02173 } else { 02174 IoDeleteDevice(deviceObject); 02175 status = STATUS_INSUFFICIENT_RESOURCES; 02176 } 02177 } 02178 return status; 02179 checkResource: 02180 02181 02182 // 02183 // At this point the *DeviceObject is established. Check if we need to report resources for 02184 // the detected device. If we failed to 02185 // 02186 02187 if (ResourceAssigned) { 02188 //ASSERT(deviceNode->ResourceList == NULL); // make sure we have not reported resources yet. 02189 02190 // 02191 // If the driver specifies it already has acquired the resource. We will put a flag 02192 // in the device instance path to not to allocate resources at boot time. The Driver 02193 // may do detection and report it again. 02194 // 02195 02196 deviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; // do not need resources for this boot. 02197 if (ResourceList) { 02198 02199 // 02200 // Write the resource list to the reported device instance key. 02201 // 02202 02203 listSize = IopDetermineResourceListSize(ResourceList); 02204 IopWriteAllocatedResourcesToRegistry (deviceNode, ResourceList, listSize); 02205 } 02206 } else { 02207 BOOLEAN conflict; 02208 02209 if (ResourceList && ResourceList->Count && ResourceList->List[0].PartialResourceList.Count) { 02210 if (listSize == 0) { 02211 listSize = IopDetermineResourceListSize(ResourceList); 02212 } 02213 cmResource = (PCM_RESOURCE_LIST) ExAllocatePool(PagedPool, listSize); 02214 if (cmResource) { 02215 RtlCopyMemory(cmResource, ResourceList, listSize); 02216 RtlInitUnicodeString(&unicodeName, PNPMGR_STR_PNP_MANAGER); 02217 status = IoReportResourceUsageInternal( 02218 ArbiterRequestLegacyReported, 02219 &unicodeName, // DriverClassName OPTIONAL, 02220 IoPnpDriverObject, // DriverObject, 02221 NULL, // DriverList OPTIONAL, 02222 0, // DriverListSize OPTIONAL, 02223 deviceNode->PhysicalDeviceObject, 02224 // DeviceObject OPTIONAL, 02225 cmResource, // DeviceList OPTIONAL, 02226 listSize, // DeviceListSize OPTIONAL, 02227 FALSE, // OverrideConflict, 02228 &conflict // ConflictDetected 02229 ); 02230 ExFreePool(cmResource); 02231 if (!NT_SUCCESS(status) || conflict) { 02232 status = STATUS_CONFLICTING_ADDRESSES; 02233 IopSetDevNodeProblem(deviceNode, CM_PROB_NORMAL_CONFLICT); 02234 } 02235 } else { 02236 status = STATUS_INSUFFICIENT_RESOURCES; 02237 IopSetDevNodeProblem(deviceNode, CM_PROB_OUT_OF_MEMORY); 02238 } 02239 } else { 02240 ASSERT(ResourceRequirements == NULL); 02241 deviceNode->Flags |= DNF_NO_RESOURCE_REQUIRED; // do not need resources for this boot. 02242 } 02243 } 02244 02245 if (NT_SUCCESS(status)) { 02246 02247 IopDoDeferredSetInterfaceState(deviceNode); 02248 02249 deviceNode->Flags |= DNF_STARTED | DNF_ADDED | DNF_NEED_ENUMERATION_ONLY | DNF_NEED_QUERY_IDS; 02250 *DeviceObject = deviceObject; 02251 if (newlyCreated) { 02252 if (controlHandle) { 02253 ZwClose(controlHandle); 02254 } 02255 if (logConfHandle) { 02256 ZwClose(logConfHandle); 02257 } 02258 ZwClose(handle); 02259 } 02260 return status; 02261 02262 } 02263 CleanupRegistry: 02264 IopReleaseDeviceResources(deviceNode, FALSE); 02265 if (newlyCreated) { 02266 IoDeleteDevice(deviceObject); 02267 if (controlHandle) { 02268 ZwDeleteKey(controlHandle); 02269 } 02270 if (logConfHandle) { 02271 ZwDeleteKey(logConfHandle); 02272 } 02273 if (handle) { 02274 ZwDeleteKey(handle); 02275 } 02276 } 02277 return status; 02278 exit: 02279 ExReleaseResource(&PpRegistryDeviceResource); 02280 KeLeaveCriticalRegion(); 02281 IoDeleteDevice(*DeviceObject); 02282 return status; 02283 }

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

Definition at line 297 of file report.c.

References ArbiterRequestPnpDetected, DNF_LEGACY_RESOURCE_DEVICENODE, FALSE, IoReportResourceUsageInternal(), KeBugCheckEx(), NULL, and PNP_ERR_INVALID_PDO.

00309 : 00310 00311 This routine will automatically search through the configuration 00312 registry for resource conflicts between resources requested by a device 00313 and the resources already claimed by previously installed drivers. The 00314 contents of the DriverList and the DeviceList will be matched against 00315 all the other resource list stored in the registry to determine 00316 conflicts. 00317 00318 The function may be called more than once for a given device or driver. 00319 If a new resource list is given, the previous resource list stored in 00320 the registry will be replaced by the new list. 00321 00322 Note, this function is for the drivers acquiring resources for detection. 00323 00324 Arguments: 00325 00326 DriverObject - Pointer to the driver's driver object. 00327 00328 DriverList - Optional pointer to the driver's resource list. 00329 00330 DriverListSize - Optional value determining the size of the driver's 00331 resource list. 00332 00333 DeviceObject - Optional pointer to driver's device object. 00334 00335 DeviceList - Optional pointer to the device's resource list. 00336 00337 DriverListSize - Optional value determining the size of the device's 00338 resource list. 00339 00340 ConflictDetected - Supplies a pointer to a boolean that is set to TRUE 00341 if the resource list conflicts with an already existing resource 00342 list in the configuration registry. 00343 00344 Return Value: 00345 00346 The status returned is the final completion status of the operation. 00347 00348 --*/ 00349 00350 { 00351 // 00352 // Sanity check that the caller did not pass in a PnP PDO. 00353 // 00354 00355 if (DeviceObject) { 00356 00357 if ( DeviceObject->DeviceObjectExtension->DeviceNode && 00358 !(((PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) { 00359 00360 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, PNP_ERR_INVALID_PDO, (ULONG_PTR)DeviceObject, 0, 0); 00361 00362 } 00363 00364 } 00365 00366 return IoReportResourceUsageInternal( ArbiterRequestPnpDetected, 00367 NULL, 00368 DriverObject, 00369 DriverList, 00370 DriverListSize, 00371 DeviceObject, 00372 DeviceList, 00373 DeviceListSize, 00374 FALSE, 00375 ConflictDetected); 00376 }

NTKERNELAPI NTSTATUS IoReportTargetDeviceChange IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PVOID  NotificationStructure
 

Definition at line 6017 of file pnpioapi.c.

References ASSERT, ASSERT_PDO, DbgPrint, _TARGET_DEVICE_CUSTOM_NOTIFICATION::Event, Executive, FALSE, _TARGET_DEVICE_CUSTOM_NOTIFICATION::FileObject, IopCompareGuid, KeInitializeEvent, KernelMode, KeWaitForSingleObject(), _TARGET_DEVICE_CUSTOM_NOTIFICATION::NameBufferOffset, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PpSetCustomTargetEvent(), and _TARGET_DEVICE_CUSTOM_NOTIFICATION::Size.

Referenced by FsRtlNotifyVolumeEvent(), and NtSetVolumeInformationFile().

06024 : 06025 06026 This routine may be used to give notification of 3rd-party target device 06027 change events. This API will notify every driver that has registered for 06028 notification on a file object associated with PhysicalDeviceObject about 06029 the event indicated in the NotificationStructure. 06030 06031 Parameters: 06032 06033 PhysicalDeviceObject - Provides a pointer to the PDO that the change begin 06034 reported is associated with. 06035 06036 NotificationStructure - Provides a pointer to the notification structure to be 06037 sent to all parties registered for notifications about changes to 06038 PhysicalDeviceObject. 06039 06040 Return Value: 06041 06042 Status code that indicates whether or not the function was successful. 06043 06044 Note: 06045 06046 This API may only be used to report non-PnP target device changes. In particular, 06047 it will fail if it's called with the NotificationStructure->Event field set to 06048 GUID_TARGET_DEVICE_QUERY_REMOVE, GUID_TARGET_DEVICE_REMOVE_CANCELLED, or 06049 GUID_TARGET_DEVICE_REMOVE_COMPLETE. 06050 06051 --*/ 06052 { 06053 06054 NTSTATUS status = STATUS_SUCCESS; 06055 KEVENT completionEvent; 06056 NTSTATUS completionStatus; 06057 PTARGET_DEVICE_CUSTOM_NOTIFICATION notifyStruct; 06058 LONG dataSize; 06059 06060 PAGED_CODE(); 06061 06062 notifyStruct = (PTARGET_DEVICE_CUSTOM_NOTIFICATION)NotificationStructure; 06063 06064 ASSERT(notifyStruct); 06065 06066 ASSERT_PDO(PhysicalDeviceObject); 06067 06068 ASSERT(NULL == notifyStruct->FileObject); 06069 06070 06071 if (IopCompareGuid(&notifyStruct->Event, &GUID_TARGET_DEVICE_QUERY_REMOVE) || 06072 IopCompareGuid(&notifyStruct->Event, &GUID_TARGET_DEVICE_REMOVE_CANCELLED) || 06073 IopCompareGuid(&notifyStruct->Event, &GUID_TARGET_DEVICE_REMOVE_COMPLETE)) { 06074 06075 // 06076 // Passed in an illegal value 06077 // 06078 06079 #if DBG 06080 DbgPrint("Illegal Event type passed as custom notification\n"); 06081 #endif 06082 return STATUS_INVALID_DEVICE_REQUEST; 06083 06084 } 06085 06086 if (notifyStruct->Size < FIELD_OFFSET(TARGET_DEVICE_CUSTOM_NOTIFICATION, CustomDataBuffer)) { 06087 06088 return STATUS_INVALID_DEVICE_REQUEST; 06089 } 06090 06091 dataSize = notifyStruct->Size - FIELD_OFFSET(TARGET_DEVICE_CUSTOM_NOTIFICATION, CustomDataBuffer); 06092 06093 if (notifyStruct->NameBufferOffset != -1 && notifyStruct->NameBufferOffset > dataSize) { 06094 06095 return STATUS_INVALID_DEVICE_REQUEST; 06096 } 06097 06098 KeInitializeEvent(&completionEvent, NotificationEvent, FALSE); 06099 06100 status = PpSetCustomTargetEvent( PhysicalDeviceObject, 06101 &completionEvent, 06102 &completionStatus, 06103 NULL, 06104 NULL, 06105 notifyStruct); 06106 06107 if (NT_SUCCESS(status)) { 06108 06109 KeWaitForSingleObject( &completionEvent, Executive, KernelMode, FALSE, NULL ); 06110 06111 status = completionStatus; 06112 } 06113 06114 return status; 06115 }

NTKERNELAPI NTSTATUS IoReportTargetDeviceChangeAsynchronous IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PVOID  NotificationStructure,
IN PDEVICE_CHANGE_COMPLETE_CALLBACK  Callback,
OPTIONAL IN PVOID Context  OPTIONAL
 

NTKERNELAPI VOID IoRequestDeviceEject IN PDEVICE_OBJECT  PhysicalDeviceObject  ) 
 

NTKERNELAPI NTSTATUS IoSetDeviceInterfaceState IN PUNICODE_STRING  SymbolicLinkName,
IN BOOLEAN  Enable
 

Definition at line 3563 of file pnpioapi.c.

References ExAcquireResourceExclusive, ExReleaseResource, IopProcessSetInterfaceState(), KeEnterCriticalRegion, KeLeaveCriticalRegion, NT_SUCCESS, NTSTATUS(), PAGED_CODE, PpRegistryDeviceResource, and TRUE.

Referenced by IopUnregisterDeviceInterface().

03570 : 03571 03572 This DDI allows a device class to activate and deactivate an association 03573 previously registered using IoRegisterDeviceInterface 03574 03575 Parameters: 03576 03577 SymbolicLinkName - Supplies a pointer to the symbolic link name which was 03578 returned by IoRegisterDeviceInterface when the interface was registered, 03579 or as returned by IoGetDeviceInterfaces. 03580 03581 Enable - If TRUE (non-zero), the interface will be enabled. If FALSE, it 03582 will be disabled. 03583 03584 Return Value: 03585 03586 Status code that indicates whether or not the function was successful. 03587 03588 --*/ 03589 03590 { 03591 NTSTATUS status; 03592 03593 PAGED_CODE(); 03594 03595 // 03596 // Enter critical section and acquire a lock on the registry. Both these 03597 // mechanisms are required to prevent deadlock in the case where an APC 03598 // routine calls this routine after the registry resource has been claimed 03599 // in this case it would wait blocking this thread so the registry would 03600 // never be released -> deadlock. Critical sectioning the registry manipulation 03601 // portion solves this problem 03602 // 03603 03604 KeEnterCriticalRegion(); 03605 ExAcquireResourceExclusive(&PpRegistryDeviceResource, TRUE); 03606 03607 status = IopProcessSetInterfaceState(SymbolicLinkName, Enable, TRUE); 03608 03609 ExReleaseResource(&PpRegistryDeviceResource); 03610 KeLeaveCriticalRegion(); 03611 03612 if (!NT_SUCCESS(status) && !Enable) { 03613 // 03614 // If we failed to disable an interface (most likely because the 03615 // interface keys have already been deleted) report success. 03616 // 03617 status = STATUS_SUCCESS; 03618 } 03619 03620 return status; 03621 }

NTKERNELAPI NTSTATUS IoSynchronousInvalidateDeviceRelations PDEVICE_OBJECT  DeviceObject,
DEVICE_RELATION_TYPE  Type
 

Definition at line 1291 of file pnpioapi.c.

References ASSERT_PDO, BusRelations, _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, DNF_STARTED, EjectionRelations, Executive, FALSE, _DEVICE_NODE::Flags, IopRequestDeviceAction(), KeInitializeEvent, KernelMode, KeWaitForSingleObject(), NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PnPInitialized, PoInvalidateDevicePowerRelations(), PowerRelations, and ReenumerateDeviceTree.

01298 : 01299 01300 This API notifies the system that changes have occurred in the device 01301 relations of the specified type for the supplied DeviceObject. All 01302 cached information concerning the relationships must be invalidated, 01303 and if needed re-obtained via IRP_MN_QUERY_DEVICE_RELATIONS. 01304 01305 This routine performs device enumeration synchronously. 01306 Note, A driver can NOT call this IO api while processing pnp irps AND 01307 A driver can NOT call this api from any system thread except the system 01308 threads created by the driver itself. 01309 01310 Parameters: 01311 01312 DeviceObject - the PDEVICE_OBJECT for which the specified relation type 01313 information has been invalidated. This pointer is valid 01314 for the duration of the call. 01315 01316 Type - specifies the type of the relation being invalidated. 01317 01318 ReturnValue: 01319 01320 Status code that indicates whether or not the function was successful. 01321 01322 --*/ 01323 01324 { 01325 PDEVICE_NODE deviceNode; 01326 NTSTATUS status = STATUS_SUCCESS; 01327 KEVENT completionEvent; 01328 01329 PAGED_CODE(); 01330 01331 ASSERT_PDO(DeviceObject); 01332 01333 switch (Type) { 01334 case BusRelations: 01335 01336 if (PnPInitialized) { 01337 01338 deviceNode = (PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode; 01339 01340 if (deviceNode->Flags & DNF_STARTED) { 01341 01342 KeInitializeEvent( &completionEvent, NotificationEvent, FALSE ); 01343 01344 status = IopRequestDeviceAction( DeviceObject, 01345 ReenumerateDeviceTree, 01346 &completionEvent, 01347 NULL ); 01348 01349 if (NT_SUCCESS(status)) { 01350 01351 status = KeWaitForSingleObject( &completionEvent, 01352 Executive, 01353 KernelMode, 01354 FALSE, 01355 NULL); 01356 } 01357 } else { 01358 status = STATUS_UNSUCCESSFUL; 01359 } 01360 } else { 01361 // 01362 // BUGBUG - This check may be too much. For now ... 01363 // 01364 01365 status = STATUS_UNSUCCESSFUL; // BUGBUG- better status code 01366 } 01367 01368 01369 break; 01370 01371 case EjectionRelations: 01372 01373 // 01374 // For Ejection relation change, we will ignore it. We don't keep track 01375 // the Ejection relation. We will query the Ejection relation only when 01376 // we are requested to eject a device. 01377 // 01378 01379 status = STATUS_NOT_SUPPORTED; 01380 break; 01381 01382 case PowerRelations: 01383 01384 01385 // 01386 // Call off to Po code, which will do the right thing 01387 // 01388 PoInvalidateDevicePowerRelations(DeviceObject); 01389 break; 01390 } 01391 return status; 01392 }

NTKERNELAPI NTSTATUS IoUnregisterPlugPlayNotification IN PVOID  NotificationEntry  ) 
 

Definition at line 5829 of file pnpioapi.c.

References ASSERT, ExFreePool(), FALSE, IopAcquireNotifyLock, IopDeferredRegistrationList, IopDeferredRegistrationLock, IopDereferenceNotify(), IopReleaseNotifyLock, _NOTIFY_ENTRY_HEADER::Lock, _DEFERRED_REGISTRATION_ENTRY::NotifyEntry, PAGED_CODE, PDEFERRED_REGISTRATION_ENTRY, PiNotificationInProgress, PiNotificationInProgressLock, TRUE, and _NOTIFY_ENTRY_HEADER::Unregistered.

Referenced by DeviceCDROMNotify(), and UnregisterForDeviceChangeNotifications().

05835 : 05836 05837 This routine unregisters a notification previously registered via 05838 IoRegisterPlugPlayNotification. A driver cannot be unloaded until it has 05839 unregistered all of its notification handles. 05840 05841 Parameters: 05842 05843 NotificationEntry - This provices the cookie returned by IoRegisterPlugPlayNotification 05844 which identifies the registration in question. 05845 05846 Return Value: 05847 05848 Status code that indicates whether or not the function was successful. 05849 05850 --*/ 05851 05852 { 05853 PNOTIFY_ENTRY_HEADER entry; 05854 PFAST_MUTEX lock; 05855 BOOLEAN wasDeferred = FALSE; 05856 05857 PAGED_CODE(); 05858 05859 ASSERT(NotificationEntry); 05860 05861 entry = (PNOTIFY_ENTRY_HEADER)NotificationEntry; 05862 05863 lock = entry->Lock; 05864 05865 ExAcquireFastMutex(&PiNotificationInProgressLock); 05866 if (PiNotificationInProgress) { 05867 // 05868 // Before unregistering the entry, we need to make sure that it's not sitting 05869 // around in the deferred registration list. 05870 // 05871 IopAcquireNotifyLock(&IopDeferredRegistrationLock); 05872 05873 if (!IsListEmpty(&IopDeferredRegistrationList)) { 05874 05875 PLIST_ENTRY link; 05876 PDEFERRED_REGISTRATION_ENTRY deferredNode; 05877 05878 link = IopDeferredRegistrationList.Flink; 05879 deferredNode = (PDEFERRED_REGISTRATION_ENTRY)link; 05880 05881 while (link != (PLIST_ENTRY)&IopDeferredRegistrationList) { 05882 ASSERT(deferredNode->NotifyEntry->Unregistered); 05883 if (deferredNode->NotifyEntry == entry) { 05884 wasDeferred = TRUE; 05885 if (lock) { 05886 IopAcquireNotifyLock(lock); 05887 } 05888 link = link->Flink; 05889 RemoveEntryList((PLIST_ENTRY)deferredNode); 05890 IopDereferenceNotify((PNOTIFY_ENTRY_HEADER)deferredNode->NotifyEntry); 05891 if (lock) { 05892 IopReleaseNotifyLock(lock); 05893 } 05894 ExFreePool(deferredNode); 05895 deferredNode = (PDEFERRED_REGISTRATION_ENTRY)link; 05896 } else { 05897 link = link->Flink; 05898 deferredNode = (PDEFERRED_REGISTRATION_ENTRY)link; 05899 } 05900 } 05901 } 05902 05903 IopReleaseNotifyLock(&IopDeferredRegistrationLock); 05904 } else { 05905 // 05906 // If there is currently no notification in progress, the deferred 05907 // registration list must be empty. 05908 // 05909 ASSERT(IsListEmpty(&IopDeferredRegistrationList)); 05910 } 05911 ExReleaseFastMutex(&PiNotificationInProgressLock); 05912 05913 // 05914 // Acquire lock 05915 // 05916 if (lock) { 05917 IopAcquireNotifyLock(lock); 05918 } 05919 05920 ASSERT(wasDeferred == entry->Unregistered); 05921 05922 if (!entry->Unregistered || wasDeferred) { 05923 // 05924 // Dereference the entry if it is currently registered, or had its 05925 // registration pending completion of the notification in progress. 05926 // 05927 05928 // 05929 // Mark the entry as unregistered so we don't notify on it 05930 // 05931 05932 entry->Unregistered = TRUE; 05933 05934 // 05935 // Dereference it thus deleting if no longer required 05936 // 05937 05938 IopDereferenceNotify(entry); 05939 } 05940 05941 // 05942 // Release the lock 05943 // 05944 05945 if (lock) { 05946 IopReleaseNotifyLock(lock); 05947 } 05948 05949 return STATUS_SUCCESS; 05950 05951 }

NTKERNELAPI NTSTATUS PpDeviceRegistration IN PUNICODE_STRING  DeviceInstancePath,
IN BOOLEAN  Add,
IN PUNICODE_STRING ServiceKeyName  OPTIONAL
 

Referenced by IopCreateMadeupNode(), IopInitializeDeviceInstanceKey(), IopNotifySetupDevices(), IopProcessNewDeviceNode(), and IoReportDetectedDevice().

NTSTATUS PpInitializeNotification VOID   ) 
 

Referenced by IopInitializePlugPlayServices().

NTKERNELAPI BOOLEAN PpInitSystem VOID   ) 
 

NTSTATUS PpNotifyUserModeRemovalSafe IN PDEVICE_OBJECT  DeviceObject  ) 
 

Referenced by IopEjectDevice().

NTSTATUS PpSetCustomTargetEvent IN PDEVICE_OBJECT  DeviceObject,
IN PKEVENT SyncEvent  OPTIONAL,
OUT PULONG Result  OPTIONAL,
IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback  OPTIONAL,
IN PVOID Context  OPTIONAL,
IN PTARGET_DEVICE_CUSTOM_NOTIFICATION  NotificationStructure
 

Referenced by IopReportTargetDeviceChangeAsyncWorker(), and IoReportTargetDeviceChange().

NTSTATUS PpSetDeviceClassChange IN CONST GUID *  EventGuid,
IN CONST GUID *  ClassGuid,
IN PUNICODE_STRING  SymbolicLinkName
 

Referenced by IopProcessSetInterfaceState().

NTSTATUS PpSetDeviceRemovalSafe IN PDEVICE_OBJECT  DeviceObject,
IN PKEVENT SyncEvent  OPTIONAL,
OUT PULONG Result  OPTIONAL
 

Referenced by IopProcessCompletedEject().

NTSTATUS PpSetHwProfileChangeEvent IN CONST GUID *  EventGuid,
IN PKEVENT CompletionEvent  OPTIONAL,
OUT PNTSTATUS CompletionStatus  OPTIONAL,
OUT PPNP_VETO_TYPE VetoType  OPTIONAL,
OUT PUNICODE_STRING VetoName  OPTIONAL
 

Referenced by IopRequestHwProfileChangeNotification().

VOID PpSetPlugPlayEvent IN CONST GUID *  EventGuid,
IN PDEVICE_OBJECT  DeviceObject
 

Referenced by IopEnumerateDevice(), and IopProcessNewDeviceNode().

NTSTATUS PpSetPowerEvent IN ULONG  EventCode,
IN PKEVENT CompletionEvent  OPTIONAL,
OUT PNTSTATUS CompletionStatus  OPTIONAL,
OUT PPNP_VETO_TYPE VetoType  OPTIONAL,
OUT PUNICODE_STRING VetoName  OPTIONAL
 

Referenced by IoPnPDeliverServicePowerNotification().

NTSTATUS PpSetPowerVetoEvent IN POWER_ACTION  VetoedPowerOperation,
IN PKEVENT CompletionEvent  OPTIONAL,
OUT PNTSTATUS CompletionStatus  OPTIONAL,
IN PDEVICE_OBJECT  DeviceObject,
IN PNP_VETO_TYPE  VetoType,
IN PUNICODE_STRING VetoName  OPTIONAL
 

Referenced by IoNotifyPowerOperationVetoed().

NTSTATUS PpSetTargetDeviceRemove IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  KernelInitiated,
IN BOOLEAN  NoRestart,
IN BOOLEAN  DoEject,
IN ULONG  Problem,
IN PKEVENT SyncEvent  OPTIONAL,
OUT PULONG Result  OPTIONAL,
OUT PPNP_VETO_TYPE VetoType  OPTIONAL,
OUT PUNICODE_STRING VetoName  OPTIONAL
 

Referenced by IopRequestDeviceEjectWorker(), IopRequestDeviceRemoval(), and IopStartDevice().

VOID PpShutdownSystem IN BOOLEAN  Reboot,
IN ULONG  Phase,
IN OUT PVOID *  Context
 

NTSTATUS PpSynchronizeDeviceEventQueue VOID   ) 
 

Referenced by IopDeviceActionWorker(), and IopProcessStartDevices().


Variable Documentation

PDRIVER_OBJECT IoPnpDriverObject
 

Definition at line 37 of file pnp.h.

Referenced by IopFindLegacyDeviceNode(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IopLegacyResourceAllocation(), IopPnPDriverEntry(), IopReleaseDeviceResources(), IopRemoveLegacyDeviceNode(), and IoReportDetectedDevice().

ERESOURCE PpRegistryDeviceResource
 

Definition at line 36 of file pnp.h.

Referenced by IoGetDeviceInterfaceAlias(), IoGetDeviceProperty(), IoOpenDeviceInterfaceRegistryKey(), IoOpenDeviceRegistryKey(), IopCreateMadeupNode(), IopDeleteLegacyKey(), IopDeleteLockedDeviceNode(), IopDeviceActionWorker(), IopDeviceInterfaceKeysFromSymbolicLink(), IopDoDeferredSetInterfaceState(), IopDriverLoadingFailed(), IopGetDeviceInterfaces(), IopGetDriverDeviceList(), IopGetRootDevices(), IopIsFirmwareDisabled(), IopMakeGloballyUniqueId(), IopPrepareDriverLoading(), IopProcessNewDeviceNode(), IopRegisterDeviceInterface(), IopReleaseDeviceResources(), IopStartAndEnumerateDevice(), IopUnlockDeviceRemovalRelations(), IopUnregisterDeviceInterface(), IopWriteAllocatedResourcesToRegistry(), IoReportDetectedDevice(), and IoSetDeviceInterfaceState().


Generated on Sat May 15 19:45:09 2004 for test by doxygen 1.3.7