ReactOS 0.4.16-dev-303-g11d5cb8
fxdeviceapi.cpp File Reference
#include "coreprivshared.hpp"
#include "fxiotarget.hpp"
Include dependency graph for fxdeviceapi.cpp:

Go to the source code of this file.

Classes

struct  FxOffsetAndName
 

Macros

#define OFFSET_AND_NAME(type, offset)   { #offset, FIELD_OFFSET(type, offset) }
 

Functions

 __drv_maxIRQL (DISPATCH_LEVEL) WDFDRIVER STDCALL WDFEXPORT(WdfDeviceGetDriver)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
 FxObjectHandleGetPtr (GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice)
 
return pDevice GetDriver () -> GetHandle()
 
 FxObjectHandleGetPtr (GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE_BASE,(PVOID *) &pDeviceBase)
 
 if (pTarget !=NULL)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) WDFIOTARGET STDCALL WDFEXPORT(WdfDeviceGetSelfIoTarget)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
 
_Must_inspect_result_ __drv_maxIRQL (PASSIVE_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfDeviceRetrieveDeviceName)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
 FxObjectHandleGetPtrAndGlobals (GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice, &pFxDriverGlobals)
 
 if (!NT_SUCCESS(status))
 
 FxObjectHandleGetPtr (pFxDriverGlobals, String, FX_TYPE_STRING,(PVOID *) &pString)
 
 if (pDevice->m_DeviceName.Buffer !=NULL)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGPNP, "Device name for WDFDEVICE 0x%p is NULL. Possibly incorrect " "device handle was passed, %!STATUS!", Device, status)
 
deviceObject SetObject (pDevice->GetDeviceObject())
 
deviceObject SetCharacteristics (DeviceCharacteristics|FILE_DEVICE_SECURE_OPEN)
 
return deviceObject GetCharacteristics ()
 
deviceObject SetObject (pDeviceBase->GetDeviceObject())
 
return deviceObject GetAlignmentRequirement ()
 
deviceObject SetAlignmentRequirement (AlignmentRequirement)
 
return pDevice GetDevicePnpState ()
 
return pDevice GetDevicePowerState ()
 
return pDevice GetDevicePowerPolicyState ()
 
 FxPointerNotNull (pFxDriverGlobals, Settings)
 
 if (pDevice->m_PkgPnp->IsPowerPolicyOwner()==FALSE)
 
 if (Settings->Size !=sizeof(WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS) &&Settings->Size !=sizeof(WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_9) &&Settings->Size !=sizeof(WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_7))
 
else if (Settings->DxState< PowerDeviceD1||Settings->DxState > PowerDeviceMaximum||Settings->IdleCaps< IdleCannotWakeFromS0||Settings->IdleCaps > IdleUsbSelectiveSuspend||Settings->UserControlOfIdleSettings< IdleDoNotAllowUserControl||Settings->UserControlOfIdleSettings > IdleAllowUserControl||Settings->Enabled< WdfFalse||Settings->Enabled > WdfUseDefault)
 
 if (Settings->Size > sizeof(WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_7))
 
 if (Settings->Size > sizeof(WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_9))
 
return pDevice m_PkgPnp PowerPolicySetS0IdleSettings (Settings)
 
else if (Settings->DxState< PowerDeviceD1||Settings->DxState > PowerDeviceMaximum||Settings->UserControlOfWakeSettings< WakeDoNotAllowUserControl||Settings->UserControlOfWakeSettings > WakeAllowUserControl||Settings->Enabled< WdfFalse||Settings->Enabled > WdfUseDefault)
 
return pDevice m_PkgPnp PowerPolicySetSxWakeSettings (Settings, armForWakeIfChildrenAreArmedForWake, indicateChildWakeOnParentWake)
 
 FxPointerNotNull (pFxDriverGlobals, Key)
 
_Must_inspect_result_ _IRQL_requires_max_ (PASSIVE_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfDeviceOpenDevicemapKey)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
 Queries information details about a security descriptor.
 
 if (KeyName->Length==0)
 
 if (pKey==NULL)
 
pKey SetDeviceBase (pDevice)
 
 if (NT_SUCCESS(status))
 
 FxPointerNotNull (pFxDriverGlobals, DeviceState)
 
 if (DeviceState->Size !=sizeof(WDF_DEVICE_STATE))
 
pDevice m_PkgPnp GetPnpState (DeviceState)
 
 for (i=0;i< ARRAY_SIZE(offsets);i++)
 
pDevice m_PkgPnp SetPnpState (DeviceState)
 
pDevice InvalidateDeviceState ()
 
 FxPointerNotNull (pFxDriverGlobals, DeviceInit)
 
 FxPointerNotNull (pFxDriverGlobals, *DeviceInit)
 
 FxPointerNotNull (pFxDriverGlobals, Device)
 
 if ((*DeviceInit) ->CreatedDevice !=NULL)
 
 if ((*DeviceInit) ->Security.Sddl !=NULL||(*DeviceInit) ->Security.DeviceClassSet)
 
 if ((*DeviceInit) ->RequiresSelfIoTarget)
 
 FxPointerNotNull (pFxDriverGlobals, SymbolicLinkName)
 
 if (pDevice->m_SymbolicLinkName.Buffer !=NULL)
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG __out_bcount_full (BufferLength) PVOID PropertyBuffer
 
 FxPointerNotNull (pFxDriverGlobals, ResultLength)
 
 if (BufferLength > 0)
 
 if (pDevice->IsLegacy())
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGDEVICE, "exit WDFDEVICE %p, Property %d, %!STATUS!", Device, DeviceProperty, status)
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __drv_strictTypeMatch (__drv_typeExpr) POOL_TYPE PoolType
 
 FxPointerNotNull (pFxDriverGlobals, PropertyMemory)
 
 FxVerifierCheckNxPoolType (pFxDriverGlobals, PoolType, pFxDriverGlobals->Tag)
 
 if (Stoppable)
 
 if (FailedAction< WdfDeviceFailedAttemptRestart||FailedAction > WdfDeviceFailedNoRestart)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_INFORMATION, TRACINGDEVICE, "WDFDEVICE %p, !devobj %p SetFailed %!WDF_DEVICE_FAILED_ACTION!", Device, pDevice->GetDeviceObject(), FailedAction)
 
pDevice m_PkgPnp SetDeviceFailed (FailedAction)
 
__inline NTSTATUS StopIdleWorker (__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDEVICE Device, __in BOOLEAN WaitForD0, __in PVOID Tag, __in LONG Line, __in PSTR File)
 
__inline VOID ResumeIdleWorker (__in PWDF_DRIVER_GLOBALS DriverGlobals, __in WDFDEVICE Device, __in PVOID Tag, __in LONG Line, __in PSTR File)
 
_Must_inspect_result_ __drv_when (WaitForD0==0, __drv_maxIRQL(DISPATCH_LEVEL)) __drv_when(WaitForD0 !=0
 
 ResumeIdleWorker (DriverGlobals, Device, NULL, 0, NULL)
 
 ResumeIdleWorker (DriverGlobals, Device, Tag, Line, File)
 
 FxPointerNotNull (pFxDriverGlobals, PnpCapabilities)
 
 if (PnpCapabilities->Size !=sizeof(WDF_DEVICE_PNP_CAPABILITIES))
 
 FxPointerNotNull (pFxDriverGlobals, PowerCapabilities)
 
 if (PowerCapabilities->Size !=sizeof(WDF_DEVICE_POWER_CAPABILITIES))
 
_Must_inspect_result_ __in WDFDEVICE __in WDFQUEUE __in __drv_strictTypeMatch (__drv_typeCond) WDF_REQUEST_TYPE RequestType)
 
 if (pFxIoQueue==NULL)
 
 return (WDFQUEUE) pFxIoQueue -> GetObjectHandle()
 
 FxObjectHandleGetPtr (pFxDriverGlobals, Device, FX_TYPE_DEVICE,(PVOID *) &pDevice)
 
 FxObjectHandleGetPtr (pFxDriverGlobals, Request, FX_TYPE_REQUEST,(PVOID *) &pRequest)
 
return pDevice m_PkgIo EnqueueRequest (pDevice, pRequest)
 
return pDevice m_PkgPnp GetSystemPowerAction ()
 
_Must_inspect_result_ _IRQL_requires_max_ (APC_LEVEL) WDFAPI NTSTATUS STDCALL WDFEXPORT(WdfDeviceQueryPropertyEx)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
 Probes and locks virtual pages in memory for the specified process.
 
 FxPointerNotNull (pFxDriverGlobals, DeviceProperty)
 
 if (DeviceProperty->Size !=sizeof(WDF_DEVICE_PROPERTY_DATA))
 
 FxPointerNotNull (pFxDriverGlobals, RequiredSize)
 
 FxPointerNotNull (pFxDriverGlobals, Type)
 
 if (BufferLength !=0 &&PropertyBuffer==NULL)
 
 if (BufferLength==0 &&PropertyBuffer !=NULL)
 
 switch (MajorFunction)
 
 if (Driver !=NULL)
 
 FxPointerNotNull (pFxDriverGlobals, EvtDeviceWdmIrpDispatch)
 
_Must_inspect_result_ NTSTATUS FX_VF_FUNCTION() VerifyWdfDeviceWdmDispatchIrpToIoQueue (_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ FxDevice *device, _In_ MdIrp Irp, _In_ FxIoQueue *queue, _In_ ULONG Flags)
 

Variables

__in WDFDEVICE Device
 
FxDevicepDevice = NULL
 
FxIoTargetpTarget = pDeviceBase->GetDefaultIoTarget()
 
FxDeviceBasepDeviceBase
 
return NULL
 
_Must_inspect_result_ __in WDFDEVICE __in WDFSTRING String
 
PFX_DRIVER_GLOBALS pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals)
 
FxStringpString
 
NTSTATUS status = FxVerifierCheckIrqlLevel(pFxDriverGlobals, PASSIVE_LEVEL)
 
 else
 
__in WDFDEVICE __in ULONG DeviceCharacteristics
 
MxDeviceObject deviceObject
 
__in WDFDEVICE __in ULONG AlignmentRequirement
 
_Must_inspect_result_ __in WDFDEVICE __in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
 
BOOLEAN armForWakeIfChildrenAreArmedForWake
 
BOOLEAN indicateChildWakeOnParentWake
 
_Must_inspect_result_ __in WDFDEVICE __in ULONG DeviceInstanceKeyType
 
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK DesiredAccess
 
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES KeyAttributes
 
_Must_inspect_result_ __in WDFDEVICE __in ULONG __in ACCESS_MASK __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFKEY * Key
 
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
 
FxRegKeypKey = NULL
 
WDFKEY keyHandle
 
__in WDFDEVICE __out PWDF_DEVICE_STATE DeviceState
 
ULONG i
 
static const FxOffsetAndName offsets []
 
_Must_inspect_result_ __inout PWDFDEVICE_INITDeviceInit
 
_Must_inspect_result_ __inout PWDFDEVICE_INIT __in_opt PWDF_OBJECT_ATTRIBUTES DeviceAttributes
 
_Must_inspect_result_ __in WDFDEVICE __in PCUNICODE_STRING SymbolicLinkName
 
FxAutoString pdoName
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY DeviceProperty
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG BufferLength
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in ULONG __out PULONG ResultLength
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes
 
_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY * PropertyMemory
 
__in WDFDEVICE __in BOOLEAN Stoppable
 
 return
 
__in WDFDEVICE __in WDF_DEVICE_FAILED_ACTION FailedAction
 
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN WaitForD0
 
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID Tag
 
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID __in LONG Line
 
_Must_inspect_result_ __in WDFDEVICE __in BOOLEAN __in_opt PVOID __in LONG __in PSTR File
 
__in WDFDEVICE __in PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities
 
__in WDFDEVICE __in PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
 
_Must_inspect_result_ __in WDFDEVICE __in WDFQUEUE Queue
 
FxPkgIopPkgIo = NULL
 
FxIoQueuepFxIoQueue = NULL
 
FxDevicepFxDevice
 
_Must_inspect_result_ __in WDFDEVICE __in WDFREQUEST Request
 
FxRequestpRequest
 
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
 
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
 
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG _Out_ PDEVPROPTYPE Type
 
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ _Strict_type_match_ POOL_TYPE PoolType
 
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER Driver
 
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR MajorFunction
 
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch
 
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH _In_opt_ WDFCONTEXT DriverContext
 
FxCxDeviceInfopCxDeviceInfo = NULL
 
ULONG deviceFlags
 
exit __pad0__
 

Macro Definition Documentation

◆ OFFSET_AND_NAME

#define OFFSET_AND_NAME (   type,
  offset 
)    { #offset, FIELD_OFFSET(type, offset) }

Definition at line 37 of file fxdeviceapi.cpp.

Function Documentation

◆ __drv_maxIRQL() [1/2]

__drv_maxIRQL ( DISPATCH_LEVEL  )

◆ __drv_maxIRQL() [2/2]

_Must_inspect_result_ __drv_maxIRQL ( PASSIVE_LEVEL  )

◆ __drv_strictTypeMatch() [1/2]

_Must_inspect_result_ __in WDFDEVICE __in WDFQUEUE __in __drv_strictTypeMatch ( __drv_typeCond  )

Definition at line 1773 of file fxdeviceapi.cpp.

1802{
1803 DDI_ENTRY();
1804
1809
1810 pDevice = NULL;
1811 pFxIoQueue = NULL;
1812
1814 Device,
1816 (PVOID *) &pDevice,
1818
1826 "Invalid RequestType %!WDF_REQUEST_TYPE!, %!STATUS!",
1828 return status;
1829 }
1830
1831 //
1832 // Validate the Queue handle
1833 //
1835 Queue,
1837 (PVOID*)&pFxIoQueue);
1838
1839 if (pDevice != pFxIoQueue->GetDevice()) {
1841
1844 "Input WDFQUEUE 0x%p doesn't belong to the WDFDEVICE 0x%p, %!STATUS!",
1845 Queue, Device, status);
1846
1847 return status;
1848 }
1849
1850 if (pDevice->IsLegacy()) {
1851 //
1852 // This is a controldevice. Make sure the create is called after the device
1853 // is initialized and ready to accept I/O.
1854 //
1856 if ((deviceObject.GetFlags() & DO_DEVICE_INITIALIZING) == 0x0) {
1857
1861 "Queue cannot be configured for automatic dispatching"
1862 " after WdfControlDeviceFinishInitializing"
1863 "is called on the WDFDEVICE %p is called %!STATUS!",
1864 Device,
1865 status);
1866 return status;
1867 }
1868 }
1869 else {
1870 //
1871 // This is either FDO or PDO. Make sure it's not started yet.
1872 //
1877 "Queue cannot be configured for automatic dispatching"
1878 "after the WDFDEVICE %p is started, %!STATUS!",
1879 Device, status);
1880 return status;
1881 }
1882 }
1883
1886 }
1887 else {
1889 }
1890
1891 return status;
1892}
LONG NTSTATUS
Definition: precomp.h:26
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
__inline WDF_DEVICE_PNP_STATE GetDevicePnpState()
Definition: fxdevice.hpp:1149
__inline CfxDevice * GetDevice(VOID)
Definition: fxioqueue.hpp:773
_Must_inspect_result_ NTSTATUS ConfigureForwarding(__in FxIoQueue *FxQueue)
_Must_inspect_result_ NTSTATUS ConfigureForwarding(__inout FxIoQueue *TargetQueue, __in WDF_REQUEST_TYPE RequestType)
Definition: fxpkgio.cpp:910
ULONG GetFlags(VOID)
#define TRACINGIO
Definition: dbgtrace.h:66
#define TRACINGPNP
Definition: dbgtrace.h:67
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGPNP, "Device name for WDFDEVICE 0x%p is NULL. Possibly incorrect " "device handle was passed, %!STATUS!", Device, status)
return NULL
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice)
NTSTATUS status
MxDeviceObject deviceObject
FxIoQueue * pFxIoQueue
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *) &pDevice, &pFxDriverGlobals)
FxDevice * pDevice
Definition: fxdeviceapi.cpp:71
PFX_DRIVER_GLOBALS pFxDriverGlobals
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
@ FX_TYPE_DEVICE
Definition: fxtypes.h:47
@ FX_TYPE_QUEUE
Definition: fxtypes.h:48
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225
@ WdfRequestTypeDeviceControlInternal
Definition: wdfdevice.h:518
@ WdfRequestTypeCreate
Definition: wdfdevice.h:503
@ WdfRequestTypeWrite
Definition: wdfdevice.h:507
@ WdfRequestTypeRead
Definition: wdfdevice.h:506
@ WdfRequestTypeDeviceControl
Definition: wdfdevice.h:517
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFQUEUE _In_ _Strict_type_match_ WDF_REQUEST_TYPE RequestType
Definition: wdfdevice.h:4233

◆ __drv_strictTypeMatch() [2/2]

_Must_inspect_result_ __in WDFDEVICE __in DEVICE_REGISTRY_PROPERTY __in __drv_strictTypeMatch ( __drv_typeExpr  )

◆ __drv_when()

_Must_inspect_result_ __drv_when ( WaitForD0  = = 0,
__drv_maxIRQL(DISPATCH_LEVEL  
)
pure virtual

◆ __out_bcount_full()

◆ _IRQL_requires_max_() [1/3]

_Must_inspect_result_ _IRQL_requires_max_ ( APC_LEVEL  )

Probes and locks virtual pages in memory for the specified process.

Parameters
[in,out]MemoryDescriptorListMemory Descriptor List (MDL) containing the buffer to be probed and locked.
[in]ProcessThe process for which the buffer should be probed and locked.
[in]AccessModeAccess mode for probing the pages. Can be KernelMode or UserMode.
[in]LockOperationThe type of the probing and locking operation. Can be IoReadAccess, IoWriteAccess or IoModifyAccess.
Returns
Nothing.
See also
MmProbeAndLockPages
Remarks
Must be called at IRQL <= APC_LEVEL

Probes and locks virtual pages in memory for the specified process.

Frees previously reserved amount of memory in system virtual address space.

Parameters
[in]NumberOfBytesSize, in bytes, of memory to reserve.
[in]PoolTagPool Tag identifying the buffer. Usually consists from 4 characters in reversed order.
Returns
A pointer to the 1st memory block of the reserved buffer in case of success, NULL otherwise.
Remarks
Must be called at IRQL <= APC_LEVEL
Parameters
[in]BaseAddressA pointer to the 1st memory block of the reserved buffer.
[in]PoolTagPool Tag identifying the buffer. Usually consists from 4 characters in reversed order.
Returns
Nothing.
See also
MmAllocateMappingAddress
Remarks
Must be called at IRQL <= APC_LEVEL

Definition at line 37 of file cddata.c.

254{
255 THREAD_CONTEXT ThreadContext = {0};
256 PIRP_CONTEXT IrpContext = NULL;
258
259#ifdef CD_SANITY
260 PVOID PreviousTopLevel;
261#endif
262
264
265#if DBG
266
267 KIRQL SaveIrql = KeGetCurrentIrql();
268
269#endif
270
272
274
276
277#ifdef CD_SANITY
278 PreviousTopLevel = IoGetTopLevelIrp();
279#endif
280
281 //
282 // Loop until this request has been completed or posted.
283 //
284
285 do {
286
287 //
288 // Use a try-except to handle the exception cases.
289 //
290
291 _SEH2_TRY {
292
293 //
294 // If the IrpContext is NULL then this is the first pass through
295 // this loop.
296 //
297
298 if (IrpContext == NULL) {
299
300 //
301 // Decide if this request is waitable an allocate the IrpContext.
302 // If the file object in the stack location is NULL then this
303 // is a mount which is always waitable. Otherwise we look at
304 // the file object flags.
305 //
306
308
309 Wait = TRUE;
310
311 } else {
312
313 Wait = CanFsdWait( Irp );
314 }
315
316 IrpContext = CdCreateIrpContext( Irp, Wait );
317
318 //
319 // Update the thread context information.
320 //
321
322 CdSetThreadContext( IrpContext, &ThreadContext );
323
324#ifdef CD_SANITY
325 NT_ASSERT( !CdTestTopLevel ||
326 SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327#endif
328
329 //
330 // Otherwise cleanup the IrpContext for the retry.
331 //
332
333 } else {
334
335 //
336 // Set the MORE_PROCESSING flag to make sure the IrpContext
337 // isn't inadvertently deleted here. Then cleanup the
338 // IrpContext to perform the retry.
339 //
340
341 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342 CdCleanupIrpContext( IrpContext, FALSE );
343 }
344
345 //
346 // Case on the major irp code.
347 //
348
349 switch (IrpContext->MajorFunction) {
350
351 case IRP_MJ_CREATE :
352
353 Status = CdCommonCreate( IrpContext, Irp );
354 break;
355
356 case IRP_MJ_CLOSE :
357
358 Status = CdCommonClose( IrpContext, Irp );
359 break;
360
361 case IRP_MJ_READ :
362
363 //
364 // If this is an Mdl complete request, don't go through
365 // common read.
366 //
367
368 if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369
370 Status = CdCompleteMdl( IrpContext, Irp );
371
372 } else {
373
374 Status = CdCommonRead( IrpContext, Irp );
375 }
376
377 break;
378
379 case IRP_MJ_WRITE :
380
381 Status = CdCommonWrite( IrpContext, Irp );
382 break;
383
385
386 Status = CdCommonQueryInfo( IrpContext, Irp );
387 break;
388
390
391 Status = CdCommonSetInfo( IrpContext, Irp );
392 break;
393
395
396 Status = CdCommonQueryVolInfo( IrpContext, Irp );
397 break;
398
400
401 Status = CdCommonDirControl( IrpContext, Irp );
402 break;
403
405
406 Status = CdCommonFsControl( IrpContext, Irp );
407 break;
408
410
411 Status = CdCommonDevControl( IrpContext, Irp );
412 break;
413
415
416 Status = CdCommonLockControl( IrpContext, Irp );
417 break;
418
419 case IRP_MJ_CLEANUP :
420
421 Status = CdCommonCleanup( IrpContext, Irp );
422 break;
423
424 case IRP_MJ_PNP :
425
426 Status = CdCommonPnp( IrpContext, Irp );
427 break;
428
429 case IRP_MJ_SHUTDOWN :
430
431 Status = CdCommonShutdown( IrpContext, Irp );
432 break;
433
434 default :
435
437 CdCompleteRequest( IrpContext, Irp, Status );
438 }
439
441
442 Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443 } _SEH2_END;
444
445 } while (Status == STATUS_CANT_WAIT);
446
447#ifdef CD_SANITY
448 NT_ASSERT( !CdTestTopLevel ||
449 (PreviousTopLevel == IoGetTopLevelIrp()) );
450#endif
451
453
454 NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455
456 return Status;
457}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP
#define NT_ASSERT
Definition: rtlfuncs.h:3327

◆ _IRQL_requires_max_() [2/3]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 347 of file common.c.

3587{
3589 BOOLEAN requestSent = FALSE;
3590
3591 BOOLEAN shouldRetry = TRUE;
3592 PCDB cdb = (PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593 ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594 ULONG retryCount = 1;
3595
3596 // reset some fields.
3597 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598 status = PowerContextReuseRequest(DeviceExtension);
3599 RequestClearSendTime(DeviceExtension->PowerContext.PowerRequest);
3600
3601 if (!NT_SUCCESS(status))
3602 {
3603 return status;
3604 }
3605
3606 // set proper timeout value and max retry count.
3607 switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3608 {
3612 break;
3613
3615 // Case of issuing SYNC CACHE command. Do not use power irp timeout remaining time in this case
3616 // as we want to give best try on SYNC CACHE command.
3617 retryCount = MAXIMUM_RETRIES;
3618 timeoutValue = DeviceExtension->TimeOutValue;
3619 break;
3620
3622 {
3623 // Case of issuing STOP UNIT command
3624 // As "Imme" bit is set to '1', this command should be completed in short time.
3625 // This command is at low importance, failure of this command has very small impact.
3626 ULONG secondsRemaining = 0;
3627
3628#if (WINVER >= 0x0601)
3629 // this API is introduced in Windows7
3630 PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3631#endif
3632
3633 if (secondsRemaining == 0)
3634 {
3635 // not able to retrieve remaining time from PoQueryWatchdogTime API, use default values.
3636 retryCount = MAXIMUM_RETRIES;
3637 timeoutValue = SCSI_CDROM_TIMEOUT;
3638 }
3639 else
3640 {
3641 // plan to leave about 30 seconds to lower level drivers if possible.
3642 if (secondsRemaining >= 32)
3643 {
3644 retryCount = (secondsRemaining - 30)/SCSI_CDROM_TIMEOUT + 1;
3645 timeoutValue = SCSI_CDROM_TIMEOUT;
3646
3647 if (retryCount > MAXIMUM_RETRIES)
3648 {
3649 retryCount = MAXIMUM_RETRIES;
3650 }
3651
3652 if (retryCount == 1)
3653 {
3654 timeoutValue = secondsRemaining - 30;
3655 }
3656 }
3657 else
3658 {
3659 // issue the command with minimal timeout value and do not retry on it.
3660 retryCount = 1;
3661 timeoutValue = 2;
3662 }
3663 }
3664 }
3665 break;
3666 default:
3667 NT_ASSERT( FALSE );
3669 return status;
3670 }
3671
3672 DeviceExtension->PowerContext.RetryCount = retryCount;
3673
3674 // issue command.
3675 while (shouldRetry)
3676 {
3677
3678 // set SRB fields.
3679 DeviceExtension->PowerContext.Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
3684
3685 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
3686 DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3687
3688 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceInitial)
3689 {
3690 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_LOCK_QUEUE;
3691 }
3692 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceLocked)
3693 {
3694 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_QUIESCE_DEVICE;
3695 }
3696 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3697 {
3698 // Case of issuing SYNC CACHE command.
3699 DeviceExtension->PowerContext.Srb.CdbLength = 10;
3700 cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
3701 }
3702 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceFlushed)
3703 {
3704 // Case of issuing STOP UNIT command.
3705 DeviceExtension->PowerContext.Srb.CdbLength = 6;
3706 cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
3707 cdb->START_STOP.Start = 0;
3708 cdb->START_STOP.Immediate = 1;
3709 }
3710 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceStopped)
3711 {
3712 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
3713 }
3714
3715 // Set up completion routine and context if requested
3717 {
3718 WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3720 Context);
3721 }
3722
3723 status = RequestSend(DeviceExtension,
3724 DeviceExtension->PowerContext.PowerRequest,
3725 DeviceExtension->IoTarget,
3727 &requestSent);
3728
3729 if (requestSent)
3730 {
3731 if ((CompletionRoutine == NULL) &&
3732 (SRB_STATUS(DeviceExtension->PowerContext.Srb.SrbStatus) != SRB_STATUS_SUCCESS))
3733 {
3734 TracePrint((TRACE_LEVEL_ERROR,
3735 TRACE_FLAG_POWER,
3736 "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737 DeviceExtension->PowerContext.PowerRequest,
3738 (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced) ? "SYNC CACHE" : "STOP UNIT",
3739 &DeviceExtension->PowerContext.Srb,
3740 DeviceExtension->PowerContext.Srb.SrbStatus));
3741
3742 NT_ASSERT(!(TEST_FLAG(DeviceExtension->PowerContext.Srb.SrbStatus, SRB_STATUS_QUEUE_FROZEN)));
3743
3744 shouldRetry = RequestSenseInfoInterpret(DeviceExtension,
3745 DeviceExtension->PowerContext.PowerRequest,
3746 &(DeviceExtension->PowerContext.Srb),
3747 retryCount - DeviceExtension->PowerContext.RetryCount,
3748 &status,
3749 &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3750
3751 if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3752 {
3753 shouldRetry = FALSE;
3754 }
3755 }
3756 else
3757 {
3758 // succeeded, do not need to retry.
3759 shouldRetry = FALSE;
3760 }
3761
3762 }
3763 else
3764 {
3765 // request failed to be sent
3766 shouldRetry = FALSE;
3767 }
3768
3769 if (shouldRetry)
3770 {
3772 t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3774
3775 status = PowerContextReuseRequest(DeviceExtension);
3776 if (!NT_SUCCESS(status))
3777 {
3778 shouldRetry = FALSE;
3779 }
3780 }
3781 }
3782
3783 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3784 {
3785 // record SYNC CACHE command completion time stamp.
3786 KeQueryTickCount(&DeviceExtension->PowerContext.Step1CompleteTime);
3787 }
3788
3789 return status;
3790}
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
#define SCSI_CDROM_TIMEOUT
Definition: cdrom.h:680
BOOLEAN RequestSenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2467
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
@ PowerDownDeviceStopped
Definition: cdrom.h:412
@ PowerDownDeviceQuiesced
Definition: cdrom.h:410
@ PowerDownDeviceInitial
Definition: cdrom.h:408
@ PowerDownDeviceLocked
Definition: cdrom.h:409
@ PowerDownDeviceFlushed
Definition: cdrom.h:411
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
Definition: common.c:111
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:402
#define SRB_FUNCTION_LOCK_QUEUE
Definition: srb.h:332
#define SRB_FUNCTION_UNLOCK_QUEUE
Definition: srb.h:333
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:410
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:397
#define SRB_STATUS(Status)
Definition: srb.h:389
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:386
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:404
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
GLdouble GLdouble t
Definition: gl.h:2047
#define KernelMode
Definition: asm.h:34
#define SRB_FLAGS_D3_PROCESSING
Definition: srb.h:165
#define SRB_FUNCTION_QUIESCE_DEVICE
Definition: srb.h:99
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
uint32_t ULONG
Definition: typedefs.h:59
Definition: cdrw_hw.h:28
struct _CDB::_START_STOP START_STOP
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
Definition: wdfrequest.h:109
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

◆ _IRQL_requires_max_() [3/3]

_Must_inspect_result_ _IRQL_requires_max_ ( PASSIVE_LEVEL  )

Queries information details about a security descriptor.

Computes the quota size of a security descriptor.

Assigns a security descriptor for a new object.

An extended function that assigns a security descriptor for a new object.

Frees a security descriptor.

An extended function that sets new information data to a security descriptor.

Modifies some information data about a security descriptor.

Parameters
[in]SecurityInformationSecurity information details to be queried from a security descriptor.
[out]SecurityDescriptorThe returned security descriptor with security information data.
[in,out]LengthThe returned length of a security descriptor.
[in,out]ObjectsSecurityDescriptorThe returned object security descriptor.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the specific information about the security descriptor has been queried. STATUS_BUFFER_TOO_SMALL is returned if the buffer size is too small to contain the queried info about the security descriptor.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
See SeSetSecurityDescriptorInfoEx.
Parameters
[in]ObjectIf specified, the function will use this arbitrary object that points to an object security descriptor.
[in]SecurityInformationSecurity information details to be set.
[in]SecurityDescriptorA security descriptor where its info is to be changed.
[in,out]ObjectsSecurityDescriptorThe returned pointer to security descriptor objects.
[in]AutoInheritFlagsFlags bitmask inheritation, influencing how the security descriptor can be inherited and if it can be in the first place.
[in]PoolTypePool type for the new security descriptor to allocate.
[in]GenericMappingThe generic mapping of access rights masks.
Returns
Returns STATUS_SUCCESS if the operations have been completed without problems and that new info has been set to the security descriptor. STATUS_NO_SECURITY_ON_OBJECT is returned if the object does not have a security descriptor. STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the new security descriptor with new info set has failed.
Parameters
[in]SecurityDescriptorA security descriptor to be freed from memory.
Returns
Returns STATUS_SUCCESS.
Parameters
[in]_ParentDescriptorA security descriptor of the parent object that is being created.
[in]_ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]ObjectTypeThe type of the new object.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]AutoInheritFlagsAutomatic inheritance flags that influence how access control entries within ACLs from security descriptors are inherited.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
Returns STATUS_SUCCESS if the operations have been completed successfully and that the security descriptor has been assigned to the new object. STATUS_NO_TOKEN is returned if the caller hasn't supplied a valid argument to a security subject context. STATUS_INVALID_OWNER is returned if the caller hasn't supplied a parent descriptor that belongs to the main user (owner). STATUS_INVALID_PRIMARY_GROUP is returned by the same reason as with the previous NTSTATUS code. The two NTSTATUS codes are returned if the calling thread stated that the owner and/or group is defaulted to the parent descriptor (SEF_DEFAULT_OWNER_FROM_PARENT and/or SEF_DEFAULT_GROUP_FROM_PARENT respectively). STATUS_INSUFFICIENT_RESOURCES is returned if memory pool allocation for the descriptor buffer has failed. A failure NTSTATUS is returned otherwise.
Parameters
[in]ParentDescriptorA security descriptor of the parent object that is being created.
[in]ExplicitDescriptorAn explicit security descriptor that is applied to a new object.
[out]NewDescriptorThe new allocated security descriptor.
[in]IsDirectoryObjectSet this to TRUE if the newly created object is a directory object, otherwise set this to FALSE.
[in]SubjectContextSecurity subject context of the new object.
[in]GenericMappingGeneric mapping of access mask rights.
[in]PoolTypeThis parameter is unused.
Returns
See SeAssignSecurityEx.
Parameters
[in]SecurityDescriptorA security descriptor.
[out]QuotaInfoSizeThe returned quota size of the given security descriptor to the caller. The function may return 0 to this parameter if the descriptor doesn't have a group or a discretionary access control list (DACL) even.
Returns
Returns STATUS_SUCCESS if the quota size of a security descriptor has been computed successfully. STATUS_UNKNOWN_REVISION is returned if the security descriptor has an invalid revision.

Definition at line 923 of file Messaging.c.

75{
76 PFLT_SERVER_PORT_OBJECT PortObject;
78
79 /* The caller must allow at least one connection */
80 if (MaxConnections == 0)
81 {
83 }
84
85 /* The request must be for a kernel handle */
86 if (!(ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE))
87 {
89 }
90
91 /*
92 * Get rundown protection on the target to stop the owner
93 * from unloading whilst this port object is open. It gets
94 * removed in the FltpServerPortClose callback
95 */
97 if (!NT_SUCCESS(Status))
98 {
99 return Status;
100 }
101
102 /* Create the server port object for this filter */
107 NULL,
109 0,
110 0,
111 (PVOID *)&PortObject);
112 if (NT_SUCCESS(Status))
113 {
114 /* Zero out the struct */
115 RtlZeroMemory(PortObject, sizeof(FLT_SERVER_PORT_OBJECT));
116
117 /* Increment the ref count on the target filter */
119
120 /* Setup the filter port object */
121 PortObject->Filter = Filter;
125 PortObject->Cookie = ServerPortCookie;
126 PortObject->MaxConnections = MaxConnections;
127
128 /* Insert the object */
129 Status = ObInsertObject(PortObject,
130 NULL,
132 0,
133 NULL,
135 if (NT_SUCCESS(Status))
136 {
137 /* Lock the connection list */
139
140 /* Add the new port object to the connection list and increment the count */
143
144 /* Unlock the connection list*/
146 }
147 }
148
149 if (!NT_SUCCESS(Status))
150 {
151 /* Allow the filter to be cleaned up */
153 }
154
155 return Status;
156}
static const INTERNET_PORT ServerPort
Definition: CWebService.cpp:11
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1877
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1875
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1874
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1876
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static LONG MaxConnections
#define FILE_READ_DATA
Definition: nt_native.h:628
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2935
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1039
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121
LIST_ENTRY mList
Definition: fltmgrint.h:56
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ DoTraceLevelMessage() [1/3]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_ERROR  ,
TRACINGPNP  ,
"Device name for WDFDEVICE 0x%p is NULL. Possibly incorrect " "device handle was  passed,
%!STATUS!"  ,
Device  ,
status   
)

◆ DoTraceLevelMessage() [2/3]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_INFORMATION  ,
TRACINGDEVICE  ,
"WDFDEVICE %  p,
!devobj %p SetFailed %!WDF_DEVICE_FAILED_ACTION!"  ,
Device  ,
pDevice->  GetDeviceObject(),
FailedAction   
)

◆ DoTraceLevelMessage() [3/3]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGDEVICE  ,
"exit WDFDEVICE %  p,
Property d,
%!STATUS!"  ,
Device  ,
DeviceProperty  ,
status   
)

◆ EnqueueRequest()

return pDevice m_PkgIo EnqueueRequest ( pDevice  ,
pRequest   
)

◆ for()

for ( )

Definition at line 827 of file fxdeviceapi.cpp.

827 {
829
830 //
831 // This check makes prefast happy
832 //
833 if (offsets[i].Offset + sizeof(WDF_TRI_STATE) > sizeof(*DeviceState)) {
834 return;
835 }
836
838 offsets[i].Offset);
839
840 switch (value) {
841 case WdfFalse:
842 case WdfTrue:
843 case WdfUseDefault:
844 break;
845
846 default:
849 "WDFDEVICE 0x%p DeviceState WDF_TRI_STATE %s value out of range, "
850 "value is %d", Device, offsets[i].Name, value);
852
853 return; // STATUS_INVALID_PARAMETER
854 }
855 }
#define TRACINGDEVICE
Definition: dbgtrace.h:58
static const FxOffsetAndName offsets[]
ULONG i
FxVerifierDbgBreakPoint(pFxDriverGlobals)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: pdh_main.c:94
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
_In_ WDFDEVICE _Out_ PWDF_DEVICE_STATE DeviceState
Definition: wdfdevice.h:1999
@ WdfTrue
Definition: wdftypes.h:88
@ WdfUseDefault
Definition: wdftypes.h:89
@ WdfFalse
Definition: wdftypes.h:87
enum _WDF_TRI_STATE WDF_TRI_STATE

◆ FxObjectHandleGetPtr() [1/5]

FxObjectHandleGetPtr ( GetFxDriverGlobals(DriverGlobals ,
Device  ,
FX_TYPE_DEVICE  ,
(PVOID *) &  pDevice 
)

Referenced by __drv_strictTypeMatch(), and if().

◆ FxObjectHandleGetPtr() [2/5]

FxObjectHandleGetPtr ( GetFxDriverGlobals(DriverGlobals ,
Device  ,
FX_TYPE_DEVICE_BASE  ,
(PVOID *) &  pDeviceBase 
)

◆ FxObjectHandleGetPtr() [3/5]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
Device  ,
FX_TYPE_DEVICE  ,
(PVOID *) &  pDevice 
)

◆ FxObjectHandleGetPtr() [4/5]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
Request  ,
FX_TYPE_REQUEST  ,
(PVOID *) &  pRequest 
)

◆ FxObjectHandleGetPtr() [5/5]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
String  ,
FX_TYPE_STRING  ,
(PVOID *) &  pString 
)

◆ FxObjectHandleGetPtrAndGlobals()

FxObjectHandleGetPtrAndGlobals ( GetFxDriverGlobals(DriverGlobals ,
Device  ,
FX_TYPE_DEVICE  ,
(PVOID *) &  pDevice,
pFxDriverGlobals 
)

◆ FxPointerNotNull() [1/15]

FxPointerNotNull ( pFxDriverGlobals  ,
DeviceInit 
)

◆ FxPointerNotNull() [2/15]

FxPointerNotNull ( pFxDriverGlobals  ,
Device   
)

◆ FxPointerNotNull() [3/15]

FxPointerNotNull ( pFxDriverGlobals  ,
DeviceInit   
)

◆ FxPointerNotNull() [4/15]

FxPointerNotNull ( pFxDriverGlobals  ,
DeviceProperty   
)

◆ FxPointerNotNull() [5/15]

FxPointerNotNull ( pFxDriverGlobals  ,
DeviceState   
)

◆ FxPointerNotNull() [6/15]

FxPointerNotNull ( pFxDriverGlobals  ,
EvtDeviceWdmIrpDispatch   
)

◆ FxPointerNotNull() [7/15]

FxPointerNotNull ( pFxDriverGlobals  ,
Key   
)

◆ FxPointerNotNull() [8/15]

FxPointerNotNull ( pFxDriverGlobals  ,
PnpCapabilities   
)

◆ FxPointerNotNull() [9/15]

FxPointerNotNull ( pFxDriverGlobals  ,
PowerCapabilities   
)

◆ FxPointerNotNull() [10/15]

FxPointerNotNull ( pFxDriverGlobals  ,
PropertyMemory   
)

◆ FxPointerNotNull() [11/15]

FxPointerNotNull ( pFxDriverGlobals  ,
RequiredSize   
)

◆ FxPointerNotNull() [12/15]

FxPointerNotNull ( pFxDriverGlobals  ,
ResultLength   
)

◆ FxPointerNotNull() [13/15]

FxPointerNotNull ( pFxDriverGlobals  ,
Settings   
)

◆ FxPointerNotNull() [14/15]

FxPointerNotNull ( pFxDriverGlobals  ,
SymbolicLinkName   
)

◆ FxPointerNotNull() [15/15]

FxPointerNotNull ( pFxDriverGlobals  ,
Type   
)

◆ FxVerifierCheckNxPoolType()

FxVerifierCheckNxPoolType ( pFxDriverGlobals  ,
PoolType  ,
pFxDriverGlobals->  Tag 
)

◆ GetAlignmentRequirement()

return deviceObject GetAlignmentRequirement ( )

◆ GetCharacteristics()

return deviceObject GetCharacteristics ( )

Referenced by DECLARE_INTERFACE_().

◆ GetDevicePnpState()

return pDevice GetDevicePnpState ( )

◆ GetDevicePowerPolicyState()

return pDevice GetDevicePowerPolicyState ( )

◆ GetDevicePowerState()

return pDevice GetDevicePowerState ( )

◆ GetDriver()

◆ GetPnpState()

pDevice m_PkgPnp GetPnpState ( DeviceState  )

◆ GetSystemPowerAction()

return pDevice m_PkgPnp GetSystemPowerAction ( )

◆ if() [1/28]

if ( NT_SUCCESSstatus)

Definition at line 190 of file fxdeviceapi.cpp.

190 {
191 return status;
192 }

◆ if() [2/28]

if ( *DeviceInit->CreatedDevice !  = NULL)

Definition at line 918 of file fxdeviceapi.cpp.

918 {
919 //
920 // Already created the device!
921 //
923 "WDFDEVICE 0x%p already created"
924 "STATUS_INVALID_DEVICE_STATE",
925 Device);
926
928 }

◆ if() [3/28]

if ( *DeviceInit->  RequiresSelfIoTarget)

Definition at line 953 of file fxdeviceapi.cpp.

953 {
954 if ((*DeviceInit)->InitType != FxDeviceInitTypeFdo) {
958 "Client called WdfDeviceInitAllowSelfTarget. Self "
959 "IO Targets are supported only for FDOs, %!STATUS!", status);
960 return status;
961 }
962 }
@ FxDeviceInitTypeFdo

◆ if() [4/28]

if ( *DeviceInit->Security.Sddl !  = NULL || (*DeviceInit)->Security.DeviceClassSet)

Definition at line 934 of file fxdeviceapi.cpp.

934 {
935 if ((*DeviceInit)->HasName()) {
936 //
937 // Driver writer specified a name, all is good
938 //
939 DO_NOTHING();
940 }
941 else {
943
946 "Device init: has device class or SDDL set, but does not have "
947 "a name, %!STATUS!", status);
948
949 return status;
950 }
951 }
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define STATUS_INVALID_SECURITY_DESCR
Definition: ntstatus.h:357

◆ if() [5/28]

if ( BufferLength = 0 && PropertyBuffer == NULL)

Definition at line 2189 of file fxdeviceapi.cpp.

2189 {
2192 "Property buffer size is non-zero, while the buffer is NULL"
2193 ", %!STATUS!", status);
2194 return status;
2195 }

◆ if() [6/28]

if ( BufferLength  ,
 
)

Definition at line 1092 of file fxdeviceapi.cpp.

1092 {
1094 }
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4437

◆ if() [7/28]

if ( BufferLength  = = 0 && PropertyBuffer != NULL)

Definition at line 2197 of file fxdeviceapi.cpp.

2197 {
2200 "Property buffer size is zero, while the buffer is non-NULL"
2201 ", %!STATUS!", status);
2202 return status;
2203 }

◆ if() [8/28]

Definition at line 2171 of file fxdeviceapi.cpp.

2171 {
2174 "PropertyData size (%d) incorrect, expected %d, %!STATUS!",
2175 DeviceProperty->Size,
2177 return status;
2178 }
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3769

◆ if() [9/28]

Definition at line 768 of file fxdeviceapi.cpp.

768 {
771 "WDFDEVICE 0x%p DeviceState Size %d, expected %d",
772 Device, DeviceState->Size, sizeof(WDF_DEVICE_STATE));
773
775
776 return; // STATUS_INFO_LENGTH_MISMATCH;
777 }

◆ if() [10/28]

if ( Driver = NULL)

Definition at line 2532 of file fxdeviceapi.cpp.

2532 {
2534
2536 Driver,
2538 (PVOID*)&pDriver);
2539
2540 //
2541 // Find the driver's cx info if it's not the main driver for this device.
2542 // cx struct info can be NULL if cx acts as client driver.
2543 //
2545 }
FxCxDeviceInfo * GetCxDeviceInfo(__in FxDriver *CxDriver)
Definition: fxdevice.hpp:1560
FxCxDeviceInfo * pCxDeviceInfo
FxDriver * pDriver
@ FX_TYPE_DRIVER
Definition: fxtypes.h:46
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83

◆ if() [11/28]

if ( FailedAction< WdfDeviceFailedAttemptRestart||FailedAction WdfDeviceFailedNoRestart)

Definition at line 1281 of file fxdeviceapi.cpp.

1282 {
1285 "Invalid FailedAction %d", FailedAction);
1287 return;
1288 }
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_In_ WDFDEVICE _In_ WDF_DEVICE_FAILED_ACTION FailedAction
Definition: wdfdevice.h:3975

◆ if() [12/28]

if ( KeyName->  Length = = 0)

Definition at line 691 of file fxdeviceapi.cpp.

691 {
695 "The subkey cannot be of length zero, %!STATUS!", status);
696 return status;
697 }

◆ if() [13/28]

if ( NT_SUCCESS(status )

Definition at line 724 of file fxdeviceapi.cpp.

724 {
725
727 KeyName,
729 pKey);
730 if (NT_SUCCESS(status)) {
731 *Key = keyHandle;
732 }
733 }
_Must_inspect_result_ NTSTATUS OpenDevicemapKeyWorker(_In_ PFX_DRIVER_GLOBALS pFxDriverGlobals, _In_ PCUNICODE_STRING KeyName, _In_ ACCESS_MASK DesiredAccess, _In_ FxRegKey *pKey)
Definition: fxdevicekm.cpp:995
FxRegKey * pKey
WDFKEY keyHandle
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

◆ if() [14/28]

if ( pDevice->  IsLegacy())

Definition at line 1101 of file fxdeviceapi.cpp.

1101 {
1103
1105 "WDFDEVICE 0x%p is not a PnP device %!STATUS!",
1106 Device, status);
1107
1108 return status;
1109 }

◆ if() [15/28]

if ( pDevice->m_DeviceName.Buffer !  = NULL)

Definition at line 199 of file fxdeviceapi.cpp.

199 {
201 }
UNICODE_STRING m_DeviceName
Definition: fxdevice.hpp:578
_Must_inspect_result_ NTSTATUS Assign(__in PCWSTR SourceString)
Definition: fxstring.cpp:57
FxString * pString

◆ if() [16/28]

if ( pDevice->m_PkgPnp->  IsPowerPolicyOwner() = FALSE)

Definition at line 410 of file fxdeviceapi.cpp.

410 {
412
415 "Device 0x%p is not the power policy owner, caller cannot set S0"
416 " idle settings %!STATUS!", Device, status);
417
418 return status;
419 }

◆ if() [17/28]

if ( pDevice->m_SymbolicLinkName.Buffer !  = NULL)

Definition at line 1023 of file fxdeviceapi.cpp.

1023 {
1025
1028 "WDFDEVICE %p already has a symbolic link associated with it, %!STATUS!",
1029 Device, status);
1030
1031 return status;
1032 }

◆ if() [18/28]

if ( pFxIoQueue  = NULL)

Definition at line 1946 of file fxdeviceapi.cpp.

1946 {
1948 "No default Queue configured "
1949 "for Device 0x%p", Device);
1950 return NULL;
1951 }
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28

◆ if() [19/28]

if ( pKey  = NULL)

Definition at line 713 of file fxdeviceapi.cpp.

713 {
717 "Unable to allocate memory for WDFKEY object, %!STATUS!", status);
718 return status;
719 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

◆ if() [20/28]

Definition at line 1548 of file fxdeviceapi.cpp.

1548 {
1551 "WDFDEVICE 0x%p PnpCapabilities Size %d, expected %d",
1554
1555 return; // STATUS_INFO_LENGTH_MISMATCH;
1556 }
_In_ WDFDEVICE _In_ PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities
Definition: wdfdevice.h:3857

◆ if() [21/28]

Definition at line 1643 of file fxdeviceapi.cpp.

1643 {
1644
1647 "WDFDEVICE 0x%p PowerCapabilities Size %d, expected %d",
1650
1652
1653 return; // STATUS_INFO_LENGTH_MISMATCH;
1654 }
_In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
Definition: wdfdevice.h:3886

◆ if() [22/28]

if ( pTarget = NULL)

Definition at line 107 of file fxdeviceapi.cpp.

107 {
108 return pTarget->GetHandle();
109 }
WDFIOTARGET GetHandle(VOID)
Definition: fxiotarget.hpp:307
FxIoTarget * pTarget
Definition: fxdeviceapi.cpp:97

◆ if() [23/28]

else if ( Settings->DxState< PowerDeviceD1||Settings->  DxState,
PowerDeviceMaximum||Settings->IdleCaps< IdleCannotWakeFromS0||Settings->  IdleCaps,
IdleUsbSelectiveSuspend||Settings->UserControlOfIdleSettings< IdleDoNotAllowUserControl||Settings->  UserControlOfIdleSettings,
IdleAllowUserControl||Settings->Enabled< WdfFalse||Settings->  Enabled,
WdfUseDefault   
)

Definition at line 435 of file fxdeviceapi.cpp.

442 {
443
447 "a field (DxState, IdleCaps, Enabled, or UserControlOfIdleSettings)"
448 " is out range, %!STATUS!", status);
449 return status;
450 }

◆ if() [24/28]

else if ( Settings->DxState< PowerDeviceD1||Settings->  DxState,
PowerDeviceMaximum||Settings->UserControlOfWakeSettings< WakeDoNotAllowUserControl||Settings->  UserControlOfWakeSettings,
WakeAllowUserControl||Settings->Enabled< WdfFalse||Settings->  Enabled,
WdfUseDefault   
)

Definition at line 549 of file fxdeviceapi.cpp.

554 {
555
559 "a field (DxState, Enabled, or UserControlOfIdleSettings) is out "
560 "range, %!STATUS!", status);
561 return status;
562 }

◆ if() [25/28]

Definition at line 424 of file fxdeviceapi.cpp.

426 {
430 "Expected Settings Size %d, got %d, %!STATUS!",
432 status);
433 return status;
434 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595

◆ if() [26/28]

Definition at line 456 of file fxdeviceapi.cpp.

456 {
457 if (Settings->PowerUpIdleDeviceOnSystemWake < WdfFalse ||
458 Settings->PowerUpIdleDeviceOnSystemWake > WdfUseDefault) {
459
463 "value of field PowerUpIdleDeviceOnSystemWake is out of range,"
464 " %!STATUS!", status);
465 return status;
466 }
467 else if (Settings->IdleCaps != IdleCannotWakeFromS0 &&
468 Settings->PowerUpIdleDeviceOnSystemWake != WdfUseDefault) {
469
473 "value of field PowerUpIdleDeviceOnSystemWake should be set only when"
474 " IdleCaps is IdleCannotWakeFromS0, %!STATUS!", status);
475 return status;
476 }
477 }
@ IdleCannotWakeFromS0
Definition: wdfdevice.h:400

◆ if() [27/28]

Definition at line 482 of file fxdeviceapi.cpp.

482 {
483 if (Settings->IdleTimeoutType > SystemManagedIdleTimeoutWithHint) {
487 "WDFDEVICE %p, value of field IdleTimeoutType is out of range,"
488 " %!STATUS!", Device, status);
489 return status;
490 }
491 }
@ SystemManagedIdleTimeoutWithHint
Definition: wdfdevice.h:1245

◆ if() [28/28]

if ( Stoppable  )

Definition at line 1242 of file fxdeviceapi.cpp.

1242 {
1243 //
1244 // Stoppable means that query stop / query remove can succeed.
1245 // This means m_DeviceStopCount == 0 (eventually if there are nested
1246 // calls to this function).
1247 //
1250 }
#define InterlockedDecrement
Definition: armddk.h:52
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
ULONG m_DeviceStopCount
Definition: fxpkgpnp.hpp:4146
#define ASSERT(a)
Definition: mode.c:44
int32_t * PLONG
Definition: typedefs.h:58

◆ InvalidateDeviceState()

pDevice InvalidateDeviceState ( )

◆ PowerPolicySetS0IdleSettings()

return pDevice m_PkgPnp PowerPolicySetS0IdleSettings ( Settings  )

◆ PowerPolicySetSxWakeSettings()

return pDevice m_PkgPnp PowerPolicySetSxWakeSettings ( Settings  ,
armForWakeIfChildrenAreArmedForWake  ,
indicateChildWakeOnParentWake   
)

◆ ResumeIdleWorker() [1/3]

__inline VOID ResumeIdleWorker ( __in PWDF_DRIVER_GLOBALS  DriverGlobals,
__in WDFDEVICE  Device,
__in PVOID  Tag,
__in LONG  Line,
__in PSTR  File 
)

Definition at line 1355 of file fxdeviceapi.cpp.

1367{
1370
1372 Device,
1374 (PVOID *) &pDevice,
1376
1380 "WdfDeviceResumeIdle does nothing if you are not the power "
1381 "policy owner for the stack");
1382 return;
1383 }
1384
1386}
Definition: File.h:16
BOOLEAN IsPowerPolicyOwner(VOID)
Definition: fxpkgpnp.hpp:3612
VOID __inline PowerDereference(__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3498
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065

◆ ResumeIdleWorker() [2/3]

ResumeIdleWorker ( DriverGlobals  ,
Device  ,
NULL  ,
,
NULL   
)

◆ ResumeIdleWorker() [3/3]

ResumeIdleWorker ( DriverGlobals  ,
Device  ,
Tag  ,
Line  ,
File   
)

◆ return()

return ( WDFQUEUE  ) -> GetObjectHandle()

◆ SetAlignmentRequirement()

deviceObject SetAlignmentRequirement ( AlignmentRequirement  )

◆ SetCharacteristics()

deviceObject SetCharacteristics ( DeviceCharacteristics FILE_DEVICE_SECURE_OPEN)

◆ SetDeviceBase()

◆ SetDeviceFailed()

pDevice m_PkgPnp SetDeviceFailed ( FailedAction  )

◆ SetObject() [1/2]

deviceObject SetObject ( pDevice->  GetDeviceObject())

◆ SetObject() [2/2]

deviceObject SetObject ( pDeviceBase->  GetDeviceObject())

◆ SetPnpState()

pDevice m_PkgPnp SetPnpState ( DeviceState  )

◆ StopIdleWorker()

__inline NTSTATUS StopIdleWorker ( __in PWDF_DRIVER_GLOBALS  DriverGlobals,
__in WDFDEVICE  Device,
__in BOOLEAN  WaitForD0,
__in PVOID  Tag,
__in LONG  Line,
__in PSTR  File 
)

Definition at line 1300 of file fxdeviceapi.cpp.

1314{
1318
1320 Device,
1322 (PVOID *) &pDevice,
1324
1325 if (WaitForD0) {
1328 if (!NT_SUCCESS(status)) {
1329 return status;
1330 }
1331 }
1332
1333
1338 "WDFDEVICE %p WdfDeviceStopIdle does nothing if you are not the power "
1339 "policy owner for the stack, %!STATUS!", Device, status);
1340 return status;
1341 }
1342
1344
1347 "WDFDEVICE %p WdfDeviceStopIdle, WaitForD0 %d %!STATUS!",
1349
1350 return status;
1351}
_Must_inspect_result_ NTSTATUS __inline PowerReference(__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3486
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4006

◆ switch()

switch ( MajorFunction  )

Definition at line 2512 of file fxdeviceapi.cpp.

2512 {
2513 case IRP_MJ_WRITE:
2514 case IRP_MJ_READ:
2516#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2518#endif
2519 break;
2520 default:
2524 "Invalid MajorFunction provided %!IRPMJ!, %!STATUS!",
2526 goto exit;
2527 }
#define exit(n)
Definition: config.h:202
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IRP_MJ_INTERNAL_DEVICE_CONTROL

◆ VerifyWdfDeviceWdmDispatchIrpToIoQueue()

_Must_inspect_result_ NTSTATUS FX_VF_FUNCTION() VerifyWdfDeviceWdmDispatchIrpToIoQueue ( _In_ PFX_DRIVER_GLOBALS  FxDriverGlobals,
_In_ FxDevice device,
_In_ MdIrp  Irp,
_In_ FxIoQueue queue,
_In_ ULONG  Flags 
)

Definition at line 2608 of file fxdeviceapi.cpp.

2615{
2617 UCHAR majorFunction, minorFunction;
2618 FxIrp fxIrp(Irp);
2619
2621
2623 minorFunction = fxIrp.GetMinorFunction();
2624
2626 FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
2627 "WDFDEVICE 0x%p !devobj 0x%p %!IRPMJ!, IRP_MN %x, IRP 0x%p",
2628 device->GetHandle(), device->GetDeviceObject(),
2629 majorFunction, minorFunction, Irp);
2630
2631 //
2632 // Validate Flags. For UMDF, this field is reserved and must be zero.
2633 //
2634#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
2636#else
2638#endif
2641 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2642 "Flags 0x%x are invalid, %!STATUS!",
2643 Flags, status);
2644 FxVerifierDbgBreakPoint(FxDriverGlobals);
2645 goto Done;
2646 }
2647
2648 //
2649 // Only read/writes/ctrls/internal_ctrls IRPs are allowed, i.e., the I/O request set.
2650 //
2651 if (device->GetDispatchPackage(majorFunction) != device->m_PkgIo) {
2654 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2655 "Only Read/Write/Control/Internal-Control IRPs can be "
2656 "forwarded to I/O Queue 0x%p, Irp 0x%p, %!IRPMJ!, "
2657 "IRP_MN %x, Device 0x%p, %!STATUS!",
2658 queue->GetHandle(), Irp, majorFunction, minorFunction,
2659 device->GetObjectHandle(), status);
2660 FxVerifierDbgBreakPoint(FxDriverGlobals);
2661 goto Done;
2662 }
2663
2664 //
2665 // Make sure queue can handle the request.
2666 //
2667 if (FALSE == queue->IsIoEventHandlerRegistered(
2669
2672 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2673 "I/O Queue 0x%p cannot handle Irp 0x%p, %!IRPMJ!, "
2674 "IRP_MN %x, Device 0x%p, %!STATUS!",
2675 queue->GetHandle(), Irp, majorFunction, minorFunction,
2676 device->GetObjectHandle(), status);
2677 FxVerifierDbgBreakPoint(FxDriverGlobals);
2678 goto Done;
2679 }
2680
2681 if (device->m_ParentDevice == queue->GetDevice()) {
2682 //
2683 // Send to parent device's queue validation.
2684 //
2685 if (device->m_ParentDevice == NULL) {
2688 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2689 "No parent device for Device 0x%p, %!STATUS!",
2690 device->GetObjectHandle(), status);
2691 FxVerifierDbgBreakPoint(FxDriverGlobals);
2692 goto Done;
2693 }
2694
2695 //
2696 // Make sure the child device is a PDO
2697 //
2698 ASSERT(device->IsPdo());
2699
2700 //
2701 // Check if the WdfPdoInitSetForwardRequestToParent was called to
2702 // increase the StackSize of the child Device to include the stack
2703 // size of the parent Device
2704 //
2705 if (device->IsPnp() &&
2706 device->GetPdoPkg()->m_AllowForwardRequestToParent == FALSE) {
2709 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2710 "WdfPdoInitSetForwardRequestToParent not called on "
2711 "Device 0x%p, %!STATUS!",
2712 device->GetObjectHandle(), status);
2713 FxVerifierDbgBreakPoint(FxDriverGlobals);
2714 goto Done;
2715 }
2716 }
2717 else {
2718 //
2719 // Send to current device's queue validation.
2720 //
2721 if (device != queue->GetDevice()) {
2724 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
2725 "Cannot forward a request to "
2726 "a different Device 0x%p, %!STATUS!",
2727 queue->GetDevice()->GetObjectHandle(), status);
2728 FxVerifierDbgBreakPoint(FxDriverGlobals);
2729 goto Done;
2730 }
2731 }
2732
2733Done:
2734 return status;
2735}
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
Definition: _queue.h:67
#define FX_DISPATCH_IRP_TO_IO_QUEUE_FLAGS_MASK
Definition: fxdevice.hpp:93
FxIrp fxIrp(Irp)
UCHAR majorFunction
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: devices.h:37
@ WDF_DISPATCH_IRP_TO_IO_QUEUE_NO_FLAGS
Definition: wdfdevice.h:435
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define PAGED_CODE_LOCKED()
Definition: kefuncs.h:1417
unsigned char UCHAR
Definition: xmlstorage.h:181

Variable Documentation

◆ __pad0__

exit __pad0__

Definition at line 2602 of file fxdeviceapi.cpp.

◆ AlignmentRequirement

Initial value:

Definition at line 299 of file fxdeviceapi.cpp.

◆ armForWakeIfChildrenAreArmedForWake

armForWakeIfChildrenAreArmedForWake
Initial value:
=
Settings->ArmForWakeIfChildrenAreArmedForWake :
struct _WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_V1_5 WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_V1_5

Definition at line 514 of file fxdeviceapi.cpp.

◆ BufferLength

◆ DesiredAccess

◆ Device

Initial value:

Definition at line 51 of file fxdeviceapi.cpp.

◆ DeviceAttributes

◆ DeviceCharacteristics

Initial value:

Definition at line 222 of file fxdeviceapi.cpp.

◆ deviceFlags

ULONG deviceFlags

Definition at line 2497 of file fxdeviceapi.cpp.

◆ DeviceInit

◆ DeviceInstanceKeyType

◆ deviceObject

◆ DeviceProperty

◆ DeviceState

Initial value:

Definition at line 752 of file fxdeviceapi.cpp.

◆ Driver

Definition at line 2452 of file fxdeviceapi.cpp.

◆ DriverContext

◆ else

else
Initial value:

Definition at line 202 of file fxdeviceapi.cpp.

◆ EvtDeviceWdmIrpDispatch

_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch

Definition at line 2456 of file fxdeviceapi.cpp.

Referenced by FxPkgIo::ConfigureDynamicDispatching().

◆ FailedAction

Initial value:

Definition at line 1267 of file fxdeviceapi.cpp.

◆ File

Initial value:

Definition at line 1433 of file fxdeviceapi.cpp.

◆ i

ULONG i

Definition at line 798 of file fxdeviceapi.cpp.

◆ indicateChildWakeOnParentWake

indicateChildWakeOnParentWake
Initial value:
=
Settings->IndicateChildWakeOnParentWake :

Definition at line 515 of file fxdeviceapi.cpp.

◆ Key

* Key
Initial value:

Definition at line 608 of file fxdeviceapi.cpp.

◆ KeyAttributes

◆ keyHandle

WDFKEY keyHandle

Definition at line 674 of file fxdeviceapi.cpp.

Referenced by FxDevice::_OpenKey(), and if().

◆ KeyName

◆ Line

Definition at line 1431 of file fxdeviceapi.cpp.

◆ MajorFunction

Definition at line 2454 of file fxdeviceapi.cpp.

◆ NULL

return NULL

◆ offsets

◆ pCxDeviceInfo

pCxDeviceInfo = NULL

Definition at line 2496 of file fxdeviceapi.cpp.

Referenced by if().

◆ pDevice

pDevice = NULL

Definition at line 71 of file fxdeviceapi.cpp.

Referenced by __drv_strictTypeMatch(), if(), ResumeIdleWorker(), and StopIdleWorker().

◆ pDeviceBase

FxDeviceBase* pDeviceBase

Definition at line 98 of file fxdeviceapi.cpp.

◆ pdoName

FxAutoString pdoName

Definition at line 991 of file fxdeviceapi.cpp.

Referenced by FxDevice::CreateSymbolicLink().

◆ pFxDevice

FxDevice* pFxDevice

Definition at line 1925 of file fxdeviceapi.cpp.

◆ pFxDriverGlobals

◆ pFxIoQueue

pFxIoQueue = NULL

Definition at line 1924 of file fxdeviceapi.cpp.

Referenced by __drv_strictTypeMatch().

◆ pKey

◆ PnpCapabilities

Initial value:

Definition at line 1503 of file fxdeviceapi.cpp.

◆ PoolType

◆ PowerCapabilities

Initial value:

Definition at line 1601 of file fxdeviceapi.cpp.

◆ pPkgIo

pPkgIo = NULL

Definition at line 1923 of file fxdeviceapi.cpp.

Referenced by FxPkgGeneral::OnCleanup().

◆ pRequest

FxRequest* pRequest

Definition at line 2001 of file fxdeviceapi.cpp.

◆ PropertyBuffer

◆ PropertyMemory

Initial value:

Definition at line 1144 of file fxdeviceapi.cpp.

◆ PropertyMemoryAttributes

◆ pString

◆ pTarget

◆ Queue

_Must_inspect_result_ __in WDFDEVICE __in WDFQUEUE Queue

Definition at line 1771 of file fxdeviceapi.cpp.

◆ Request

_Must_inspect_result_ __in WDFDEVICE __in WDFREQUEST Request
Initial value:

Definition at line 1966 of file fxdeviceapi.cpp.

◆ RequiredSize

◆ ResultLength

◆ return

return

Definition at line 1255 of file fxdeviceapi.cpp.

◆ Settings

◆ status

◆ Stoppable

Initial value:

Definition at line 1230 of file fxdeviceapi.cpp.

◆ String

_Must_inspect_result_ __in WDFDEVICE __in WDFSTRING String
Initial value:

Definition at line 173 of file fxdeviceapi.cpp.

◆ SymbolicLinkName

Initial value:

Definition at line 985 of file fxdeviceapi.cpp.

◆ Tag

__in WDFDEVICE __in_opt PVOID Tag

Definition at line 1429 of file fxdeviceapi.cpp.

◆ Type

◆ WaitForD0

Initial value:

Definition at line 1399 of file fxdeviceapi.cpp.