32#if defined(EVENT_TRACING)
34#include "FxPkgPdo.tmh"
41 _PnpQueryRemoveDevice,
43 _PnpCancelRemoveDevice,
48 _PnpQueryDeviceRelations,
50 _PnpQueryCapabilities,
52 _PnpQueryResourceRequirements,
54 _PnpFilterResourceRequirements,
63 _PnpQueryPnpDeviceState,
64 _PnpQueryBusInformation,
65 _PnpDeviceUsageNotification,
72 _DispatchPowerSequence,
204 size_t cbLength, cbStrLength;
225 cbLength +=
pPdo->DeviceID->ByteLength(
TRUE);
228 cbLength +=
pPdo->InstanceID->ByteLength(
TRUE);
231 cbLength +=
pPdo->ContainerID->ByteLength(
TRUE);
243 "DeviceInit %p could not allocate string for device IDs "
263 cbStrLength =
pPdo->DeviceID->ByteLength(
FALSE);
266 pPdo->DeviceID->Buffer(),
281 cbStrLength =
pPdo->InstanceID->ByteLength(
FALSE);
284 pPdo->InstanceID->Buffer(),
299 cbStrLength =
pPdo->ContainerID->ByteLength(
FALSE);
302 pPdo->ContainerID->Buffer(),
379 return Irp->GetStatus();
462 type =
Irp->GetParameterQDRType();
492 if (pDeviceRelations !=
NULL) {
499 pDeviceRelations->
Count = 1;
511 "WDFDEVICE %p failing TargetDeviceRelations, %!STATUS!",
588 pDeviceCapabilities =
Irp->GetParameterDeviceCapabilities();
594 ASSERT(pDeviceCapabilities->Version == 1);
596 if ((pDeviceCapabilities->Version == 1) &&
620 Irp->MarkIrpPending();
645 &parentStackCapabilities);
648#pragma prefast(suppress:__WARNING_POTENTIAL_BUFFER_OVERFLOW_HIGH_PRIORITY, "prefast is confused")
686#pragma prefast(suppress:__WARNING_POTENTIAL_BUFFER_OVERFLOW_HIGH_PRIORITY, "Esp:675")
687 ReportedCaps->DeviceState[
i] = ParentCaps->DeviceState[
i];
693 ReportedCaps->DeviceState[
i] =
state;
703 SET_PNP_CAP(pnpCaps, ReportedCaps, EjectSupported);
717 ReportedCaps->SilentInstall =
TRUE;
720 SET_PNP_CAP(pnpCaps, ReportedCaps, SurpriseRemovalOK);
721 SET_PNP_CAP(pnpCaps, ReportedCaps, HardwareDisabled);
732 ReportedCaps->RawDeviceOK =
TRUE;
742 ReportedCaps->SystemWake = ParentCaps->SystemWake;
753 ReportedCaps->DeviceWake = ParentCaps->DeviceWake;
763 ReportedCaps->D1Latency = 0;
770 ReportedCaps->D2Latency = 0;
803 &parentCapabilities);
806#pragma prefast(suppress:__WARNING_POTENTIAL_BUFFER_OVERFLOW_HIGH_PRIORITY, "prefast is confused")
890 localeId =
Irp->GetParameterQueryDeviceTextLocaleId();
908 if (pDeviceTextObject ==
NULL) {
913 if (pDeviceTextObject !=
NULL) {
918 switch (
Irp->GetParameterQueryDeviceTextType()) {
931 if (pInformation !=
NULL) {
956 "WDFDEVICE %p failing Query Device Text, type %d, %!STATUS!",
958 Irp->GetParameterQueryDeviceTextType(),
status);
1010 "Event allocation failed while processing eject for WDFDEVICE %p,"
1088 "PDO WDFDEVICE %p !devobj %p marked missing as a result of eject",
1094 "Failed to mark PDO WDFDEVICE %p !devobj %p missing after eject %!STATUS!",
1109 "waiting on event %p for device to finish scanning",
1127 "Eject failed since driver's EvtDeviceEject returned %!STATUS!",
status);
1132 "EvtDeviceEject returned an invalid status STATUS_NOT_SUPPORTED");
1247 "Removing entry reference %p on FxPkgPnp %p",
1273 ASSERT(!
"This should only be implemented for FDOs.");
1345 lock =
Irp->GetParameterSetLockLock();
1377 queryIdType =
Irp->GetParameterQueryIdType();
1379 switch (queryIdType) {
1463 "WDFDEVICE %p does not have a string for PnP query IdType "
1464 "%!BUS_QUERY_ID_TYPE!, %!STATUS!",
1471 "WDFDEVICE %p could not alloc string for PnP query IdType "
1472 "%!BUS_QUERY_ID_TYPE!, %!STATUS!",
1506 "Entering QueryPnpDeviceState handler");
1508 pnpDeviceState = ((
FxPkgPdo*)
This)->HandleQueryPnpDeviceState(
1515 "WDFDEVICE 0x%p !devobj 0x%p returning PNP_DEVICE_STATE 0x%d IRP 0x%p",
1516 This->GetDevice()->GetHandle(),
1517 This->GetDevice()->GetDeviceObject(),
1522 "Exiting QueryPnpDeviceState handler");
1647 if (GracefulRemove) {
1718 return Irp->GetStatus();
1721 if (
Irp->GetParameterQueryInterfaceVersion() == 1 &&
1722 Irp->GetParameterQueryInterfaceSize() >=
sizeof(*
pInterface)) {
1725 Irp->GetParameterQueryInterfaceInterface();
1847 "Could not allocate ejection device list for PDO WDFDEVICE %p",
1868 if (pRelated ==
NULL) {
VOID ReenumerateEntry(__inout FxDeviceDescriptionEntry *Entry)
MxEvent * GetScanEvent(VOID)
_Must_inspect_result_ NTSTATUS UpdateAsMissing(__in PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Description)
WDFDEVICE __inline GetHandle(VOID)
MdDeviceObject __inline GetDeviceObject(VOID)
VOID DeleteSymbolicLink(VOID)
__inline FxPkgFdo * GetFdoPkg(VOID)
static VOID STDCALL _InterfaceDereferenceNoOp(__in_opt PVOID Context)
CfxDevice * m_ParentDevice
static FxDevice * GetFxDevice(__in MdDeviceObject DeviceObject)
MdRemoveLock GetRemoveLock(VOID)
__inline FxPkgPdo * GetPdoPkg(VOID)
static VOID STDCALL _InterfaceReferenceNoOp(__in_opt PVOID Context)
__inline BOOLEAN IsFdo(VOID)
PDEVICE_CAPABILITIES GetParameterDeviceCapabilities()
PVOID GetContext(__in ULONG Index)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
VOID DeleteFromFailedCreate(VOID)
FxChildList * m_StaticDeviceList
FxPowerDeviceEnableWakeAtBus m_DeviceEnableWakeAtBus
SINGLE_LIST_ENTRY m_DeviceTextHead
virtual BOOLEAN PnpSendStartDeviceDownTheStackOverload(VOID)
virtual WDF_DEVICE_PNP_STATE PnpEventEjectHardwareOverload(VOID)
virtual VOID DeleteSymbolicLinkOverload(__in BOOLEAN GracefulRemove)
virtual VOID PnpEventSurpriseRemovePendingOverload(VOID)
virtual WDF_DEVICE_PNP_STATE PnpGetPostRemoveState(VOID)
virtual _Must_inspect_result_ NTSTATUS ProcessRemoveDeviceOverload(__inout FxIrp *Irp)
BOOLEAN m_AddedToStaticList
static _Must_inspect_result_ NTSTATUS _PnpSurpriseRemoval(__inout FxPkgPnp *This, __inout FxIrp *Irp)
static VOID STDCALL _RemoveAndReenumerateSelf(__in PVOID Context)
VOID HandleQueryCapabilities(__inout PDEVICE_CAPABILITIES ReportedCaps, __in PDEVICE_CAPABILITIES ParentCaps)
static _Must_inspect_result_ NTSTATUS _PnpQueryDeviceText(__inout FxPkgPnp *This, __inout FxIrp *Irp)
virtual _Must_inspect_result_ NTSTATUS SendIrpSynchronously(__in FxIrp *Irp)
static _Must_inspect_result_ NTSTATUS _PnpEject(__inout FxPkgPnp *This, __inout FxIrp *Irp)
virtual VOID FinishInitialize(__in PWDFDEVICE_INIT DeviceInit)
_Must_inspect_result_ NTSTATUS HandleQueryInterfaceForReenumerate(__in FxIrp *Irp, __out PBOOLEAN CompleteRequest)
FxPowerDeviceDisableWakeAtBus m_DeviceDisableWakeAtBus
static const PFN_PNP_POWER_CALLBACK m_PdoPowerFunctionTable[IRP_MN_QUERY_POWER+1]
FxRelatedDeviceList * m_EjectionDeviceList
static VOID STDCALL _QueryCapsWorkItem(__in MdDeviceObject DeviceObject, __in PVOID Context)
virtual WDF_DEVICE_PNP_STATE PnpEventPdoRemovedOverload(VOID)
VOID RemoveEjectionDevice(__in MdDeviceObject DependentDevice)
virtual _Must_inspect_result_ NTSTATUS FireAndForgetIrp(__inout FxIrp *Irp)
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
FxPnpDeviceSetLock m_DeviceSetLock
static _Must_inspect_result_ NTSTATUS _PnpQueryPnpDeviceState(__inout FxPkgPnp *This, __inout FxIrp *Irp)
static _Must_inspect_result_ NTSTATUS _PnpQueryInterface(IN FxPkgPnp *This, IN FxIrp *Irp)
static _Must_inspect_result_ NTSTATUS _PnpSetLock(__inout FxPkgPnp *This, __inout FxIrp *Irp)
static _Must_inspect_result_ NTSTATUS _PnpQueryBusInformation(__inout FxPkgPnp *This, __inout FxIrp *Irp)
static _Must_inspect_result_ NTSTATUS _PnpQueryDeviceRelations(__in FxPkgPnp *This, __inout FxIrp *Irp)
FxPnpDeviceResourceRequirementsQuery m_DeviceResourceRequirementsQuery
virtual _Must_inspect_result_ NTSTATUS QueryForPowerThread(VOID)
FxChildList * m_OwningChildList
FxPkgPdo(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device)
FxDeviceDescriptionEntry * m_Description
VOID RegisterCallbacks(__in PWDF_PDO_EVENT_CALLBACKS DispatchTable)
static _Must_inspect_result_ NTSTATUS _PnpQueryCapabilities(__inout FxPkgPnp *This, __inout FxIrp *Irp)
virtual WDF_DEVICE_PNP_STATE PnpEventFdoRemovedOverload(VOID)
FxPnpDeviceEject m_DeviceEject
_Must_inspect_result_ NTSTATUS AddEjectionDevice(__in MdDeviceObject DependentDevice)
BOOLEAN m_EnableWakeAtBusInvoked
FxPnpDeviceResourcesQuery m_DeviceResourcesQuery
virtual _Must_inspect_result_ NTSTATUS AskParentToRemoveAndReenumerate(VOID)
FxPnpDeviceReportedMissing m_DeviceReportedMissing
static _Must_inspect_result_ NTSTATUS _PnpCompleteIrp(__in FxPkgPnp *This, __inout FxIrp *Irp)
_Must_inspect_result_ NTSTATUS PnpQueryCapabilities(__inout FxIrp *Irp)
VOID ClearEjectionDevicesList(VOID)
MxEvent * m_DeviceEjectProcessed
virtual WDF_DEVICE_PNP_STATE PnpEventCheckForDevicePresenceOverload(VOID)
static const PFN_PNP_POWER_CALLBACK m_PdoPnpFunctionTable[IRP_MN_SURPRISE_REMOVAL+1]
static _Must_inspect_result_ NTSTATUS _PnpQueryId(__inout FxPkgPnp *This, __inout FxIrp *Irp)
_Must_inspect_result_ NTSTATUS PnpQueryDeviceRelations(__inout FxIrp *Irp)
_Must_inspect_result_ NTSTATUS HandleQueryBusInformation(__inout FxIrp *Irp)
_Must_inspect_result_ NTSTATUS CreatePowerThread(VOID)
virtual _Must_inspect_result_ NTSTATUS Initialize(__in PWDFDEVICE_INIT DeviceInit)
MxEvent * m_DeviceRemoveProcessed
_Must_inspect_result_ NTSTATUS HandleQueryDeviceRelations(__inout FxIrp *Irp, __inout FxRelatedDeviceList *List)
VOID SetPendingPnpIrpStatus(__in NTSTATUS Status)
MdIrp ClearPendingPnpIrp(VOID)
virtual VOID PnpEventSurpriseRemovePendingOverload(VOID)
LONG GetPnpCapsInternal(VOID)
VOID CleanupStateMachines(__in BOOLEAN ClenaupPnp)
_Must_inspect_result_ NTSTATUS HandleQueryBusRelations(__inout FxIrp *Irp)
SharedPowerData m_SharedPower
VOID PnpEventRemovedCommonCode(VOID)
VOID PnpProcessEvent(__in FxPnpEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
NTSTATUS CompletePowerRequest(__inout FxIrp *Irp, __in NTSTATUS Status)
FxRelatedDeviceList * m_RemovalDeviceList
VOID SetPendingPnpIrp(__inout FxIrp *Irp, __in BOOLEAN MarkIrpPending=TRUE)
NTSTATUS CompletePnpRequest(__inout FxIrp *Irp, __in NTSTATUS Status)
static DEVICE_POWER_STATE _GetPowerCapState(__in ULONG Index, __in ULONG State)
virtual VOID FinishInitialize(__inout PWDFDEVICE_INIT DeviceInit)
_Must_inspect_result_ NTSTATUS PnpSurpriseRemoval(__inout FxIrp *Irp)
PFN_WDF_DEVICE_EJECT m_Method
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDEVICE Device)
PFN_WDF_DEVICE_REPORTED_MISSING m_Method
PFN_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY m_Method
PFN_WDF_DEVICE_RESOURCES_QUERY m_Method
PFN_WDF_DEVICE_SET_LOCK m_Method
PFN_WDF_DEVICE_DISABLE_WAKE_AT_BUS m_Method
PFN_WDF_DEVICE_ENABLE_WAKE_AT_BUS m_Method
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
MxEvent * GetSelfPointer(VOID)
static __inline PVOID MxAllocatePoolWithTag(__in POOL_TYPE PoolType, __in SIZE_T NumberOfBytes, __in ULONG Tag)
__inline MdWorkItem GetWorkItem()
__inline VOID Enqueue(__in PMX_WORKITEM_ROUTINE Callback, __in PVOID Context)
static __inline VOID _Free(__in MdWorkItem Item)
_Must_inspect_result_ __inline NTSTATUS Allocate(__in MdDeviceObject DeviceObject, __in_opt PVOID ThreadPoolEnv=NULL)
static __inline VOID MxReleaseRemoveLockAndWait(__in MdRemoveLock RemoveLock, __in PVOID Tag)
static __inline BOOLEAN MxHasEnoughRemainingThreadStack(VOID)
static __inline VOID MxAssert(__in BOOLEAN Condition)
static __inline VOID MxReferenceObject(__in PVOID Object)
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxDeviceText * pDeviceText
FxVerifierDbgBreakPoint(pFxDriverGlobals)
FxDeviceText * FindObjectForGivenLocale(__in PSINGLE_LIST_ENTRY Head, __in LCID LocaleId)
_Must_inspect_result_ NTSTATUS(* PFN_PNP_POWER_CALLBACK)(__inout FxPkgPnp *This, __inout FxIrp *Irp)
@ FxPnpCapSilentInstallUseDefault
@ FxPnpCapSilentInstallMask
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
GLuint GLuint GLsizei GLenum type
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
#define _Must_inspect_result_
#define IRP_MN_SURPRISE_REMOVAL
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
#define STATUS_INVALID_BUFFER_SIZE
#define SET_POWER_CAP(caps, pCaps, FieldName)
#define SET_PNP_CAP(caps, pCaps, FieldName)
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
PWSTR FxCopyMultiSz(__out LPWSTR Buffer, __in FxCollectionInternal *StringCollection)
size_t FxCalculateTotalMultiSzStringSize(__in __nullnullterminated PCWSTR MultiSz)
size_t FxCalculateTotalStringSize(__in FxCollectionInternal *StringCollection, __in BOOLEAN Verify=FALSE, __out_opt PBOOLEAN ContainsOnlyStrings=NULL)
VOID ProcessDeviceRemoved(VOID)
VOID DeviceSurpriseRemoved(VOID)
BOOLEAN IsDeviceReportedMissing(VOID)
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER GetId(VOID)
BOOLEAN IsDeviceRemoved(VOID)
FxChildList * GetParentList(VOID)
PWCHAR m_LocationInformation
static FxDeviceText * _FromEntry(__in PSINGLE_LIST_ENTRY Entry)
static void _CleanupList(__inout PSINGLE_LIST_ENTRY Head)
SINGLE_LIST_ENTRY DeviceText
PDEVICE_OBJECT Objects[1]
PINTERFACE_REFERENCE InterfaceReference
PINTERFACE_DEREFERENCE InterfaceDereference
struct _SINGLE_LIST_ENTRY * Next
DEVICE_CAPABILITIES DeviceCaps
_Must_inspect_result_ NTSTATUS GetStackCapabilities(__in PFX_DRIVER_GLOBALS DriverGlobals, __in MxDeviceObject *DeviceInStack, __in_opt PD3COLD_SUPPORT_INTERFACE D3ColdInterface, __out PSTACK_DEVICE_CAPABILITIES Capabilities)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_ WDFDEVICE Device
_In_ PWDFDEVICE_INIT DeviceInit
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
_In_ PDEVICE_OBJECT DeviceObject
@ WdfDevStatePnpEjectedWaitingForRemove
@ WdfDevStatePnpPdoRemoved
@ WdfDevStatePnpRemovedPdoWait
@ WdfDevStatePnpCheckForDevicePresence
@ WdfDevStatePnpEjectFailed
_Must_inspect_result_ _In_ WDFDEVICE _In_ PDEVICE_OBJECT DependentDevice
enum _WDF_DEVICE_PNP_STATE WDF_DEVICE_PNP_STATE
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
enum _BUS_QUERY_ID_TYPE BUS_QUERY_ID_TYPE
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
struct _REENUMERATE_SELF_INTERFACE_STANDARD * PREENUMERATE_SELF_INTERFACE_STANDARD
@ DeviceTextLocationInformation
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_POWER