mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 15:02:01 +00:00
[WDF] Add Windows Driver Framework files
Takern from Microsoft GitHub repo:
d9c6040fe9
Licensed under MIT
This commit is contained in:
parent
545df81502
commit
8a978a179f
475 changed files with 285099 additions and 0 deletions
208
sdk/lib/drivers/wdf/kmdf/inc/private/fx.hpp
Normal file
208
sdk/lib/drivers/wdf/kmdf/inc/private/fx.hpp
Normal file
|
@ -0,0 +1,208 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Module Name:
|
||||
|
||||
Fx.hpp
|
||||
|
||||
Abstract:
|
||||
|
||||
This is the main driver framework include file.
|
||||
|
||||
Author:
|
||||
WDF team
|
||||
|
||||
Environment:
|
||||
|
||||
kernel mode only
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _FX_H
|
||||
#define _FX_H
|
||||
|
||||
extern "C" {
|
||||
#include "mx.h"
|
||||
}
|
||||
|
||||
#include "FxMacros.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "wdf.h"
|
||||
#include "wdmsec.h"
|
||||
#include "wdmguid.h"
|
||||
|
||||
#include "wdfdevicepri.h"
|
||||
#include "wdfiotargetpri.h"
|
||||
#include "wdfcx.h"
|
||||
#include "wdfldr.h"
|
||||
|
||||
#include <FxDynamicsWrapper.h>
|
||||
|
||||
#include "wdf10.h"
|
||||
#include "wdf11.h"
|
||||
#include "wdf15.h"
|
||||
#include "wdf17.h"
|
||||
#include "wdf19.h"
|
||||
#include "wdf111.h"
|
||||
#include "wdf113.h"
|
||||
#include "wdf115.h"
|
||||
}
|
||||
|
||||
#define KMDF_ONLY_CODE_PATH_ASSERT()
|
||||
|
||||
// Integer overflow functions
|
||||
#include "ntintsafe.h"
|
||||
|
||||
#include "FxForward.hpp"
|
||||
|
||||
//KMDF defines for shared type names
|
||||
#include "FxTypeDefsKm.hpp"
|
||||
|
||||
#include "fxwmicompat.h"
|
||||
#include "fxtrace.h"
|
||||
#include "fxtypes.h"
|
||||
#include "fxrequestcontexttypes.h"
|
||||
#include "fxpool.h"
|
||||
#include "FxGlobalsKM.h"
|
||||
#include "FxPoolInlines.hpp"
|
||||
#include "fxverifier.h"
|
||||
#include "fxverifierkm.h"
|
||||
#include "FxMdl.h"
|
||||
#include "FxProbeAndLock.h"
|
||||
|
||||
#include "FxPerfTraceKm.hpp"
|
||||
#include "DriverFrameworks-KernelMode-KmEvents.h"
|
||||
|
||||
#include <NtStrSafe.h>
|
||||
|
||||
#include "FxStump.hpp"
|
||||
|
||||
#include "FxRequestBuffer.hpp"
|
||||
|
||||
#include "FxTagTracker.hpp"
|
||||
|
||||
// internal locks
|
||||
#include "FxVerifierLock.hpp"
|
||||
#include "FxLock.hpp"
|
||||
|
||||
// base objects
|
||||
#include "fxobject.hpp"
|
||||
#include "FxPagedObject.hpp"
|
||||
#include "FxNonPagedObject.hpp"
|
||||
|
||||
#include "fxhandle.h"
|
||||
|
||||
// external locks
|
||||
#include "FxWaitLock.hpp"
|
||||
#include "FxSpinLock.hpp"
|
||||
|
||||
// utitilty classes and functions
|
||||
#include "FxTransactionedList.hpp"
|
||||
#include "FxRelatedDeviceList.hpp"
|
||||
#include "FxDisposeList.hpp"
|
||||
#include "FxCollection.hpp"
|
||||
#include "StringUtil.hpp"
|
||||
|
||||
// abstract classes
|
||||
#include "IFxHasCallbacks.hpp"
|
||||
|
||||
// callback delegation and locking
|
||||
#include "FxSystemThread.hpp"
|
||||
#include "FxSystemWorkItem.hpp"
|
||||
#include "FxCallbackLock.hpp"
|
||||
#include "FxCallbackSpinLock.hpp"
|
||||
#include "FxCallbackMutexLock.hpp"
|
||||
#include "FxCallback.hpp"
|
||||
#include "FxSystemThread.hpp"
|
||||
|
||||
#include "IFxMemory.hpp"
|
||||
#include "FxLookasideList.hpp"
|
||||
#include "FxNPagedLookasideList.hpp"
|
||||
#include "FxPagedLookasideList.hpp"
|
||||
#include "FxMemoryObject.hpp"
|
||||
#include "FxMemoryBuffer.hpp"
|
||||
#include "FxMemoryBufferFromPool.hpp"
|
||||
#include "FxMemoryBufferPreallocated.hpp"
|
||||
#include "FxMemoryBufferFromLookaside.hpp"
|
||||
#include "FxRequestMemory.hpp"
|
||||
#include "FxRegKey.hpp"
|
||||
#include "FxAutoRegistry.hpp"
|
||||
#include "FxAutoString.hpp"
|
||||
#include "FxString.hpp"
|
||||
|
||||
#include "FxValidateFunctions.hpp"
|
||||
#include "FxRequestValidateFunctions.hpp"
|
||||
|
||||
#include "FxResource.hpp"
|
||||
#include "FxRelatedDevice.hpp"
|
||||
#include "FxDeviceInterface.hpp"
|
||||
#include "FxQueryInterface.hpp"
|
||||
#include "FxDeviceText.hpp"
|
||||
|
||||
#include "FxIrp.hpp"
|
||||
#include "FxDriver.hpp"
|
||||
|
||||
// generic package interface
|
||||
#include "FxPackage.hpp"
|
||||
#include "FxPkgGeneral.hpp"
|
||||
#include "FxDefaultIrpHandler.hpp"
|
||||
#include "FxPkgPnp.hpp"
|
||||
#include "FxWatchDog.hpp"
|
||||
|
||||
// Device support
|
||||
#include "FxChildList.hpp"
|
||||
#include "FxCxDeviceInfo.hpp"
|
||||
#include "FxDevice.hpp"
|
||||
|
||||
#include "FxPkgIo.hpp"
|
||||
|
||||
#include "FxDeviceToMxInterface.hpp"
|
||||
|
||||
#include "FxIrpQueue.hpp"
|
||||
#include "FxRequestContext.hpp"
|
||||
#include "FxRequestCallbacks.hpp"
|
||||
#include "FxRequestBase.hpp"
|
||||
#include "FxRequest.hpp"
|
||||
#include "FxSyncRequest.hpp"
|
||||
|
||||
// specialized irp handlers (ie packages)
|
||||
#include "FxPkgFdo.hpp"
|
||||
#include "FxPkgPdo.hpp"
|
||||
#include "FxWmiIrpHandler.hpp"
|
||||
#include "FxWmiProvider.hpp"
|
||||
#include "FxWmiInstance.hpp"
|
||||
|
||||
// queus for read, write, (internal) IOCTL
|
||||
#include "FxIoQueue.hpp"
|
||||
#include "FxFileObject.hpp"
|
||||
#include "FxIrpPreprocessInfo.hpp"
|
||||
#include "FxIrpDynamicDispatchInfo.hpp"
|
||||
|
||||
#include "FxDpc.hpp"
|
||||
#include "FxWorkItem.hpp"
|
||||
#include "FxTimer.hpp"
|
||||
#include "FxInterruptKm.hpp"
|
||||
|
||||
// IO targets (device lower edge interface)
|
||||
#include "FxIoTarget.hpp"
|
||||
#include "FxIoTargetRemote.hpp"
|
||||
#include "FxIoTargetSelf.hpp"
|
||||
|
||||
#include "FxUsbDevice.hpp"
|
||||
#include "FxUsbInterface.hpp"
|
||||
#include "FxUsbPipe.hpp"
|
||||
|
||||
// DMA support
|
||||
#include "FxDmaEnabler.hpp"
|
||||
#include "FxDmaTransaction.hpp"
|
||||
#include "FxCommonBuffer.hpp"
|
||||
|
||||
// Triage info.
|
||||
#include "wdftriage.h"
|
||||
|
||||
#include "FxTelemetry.hpp"
|
||||
#endif // _FX_H
|
91
sdk/lib/drivers/wdf/kmdf/inc/private/fxbugcheck.h
Normal file
91
sdk/lib/drivers/wdf/kmdf/inc/private/fxbugcheck.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FxBugcheck.h
|
||||
|
||||
Abstract:
|
||||
This module contains private macros/defines for crashdumps.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef __FXBUGCHECK_H__
|
||||
#define __FXBUGCHECK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Macro for doing pointer arithmetic.
|
||||
//
|
||||
#define Add2Ptr(P,I) ((PVOID)((PUCHAR)(P) + (I)))
|
||||
|
||||
//
|
||||
// This macro takes a length & rounds it up to a multiple of the alignment
|
||||
// Alignment is given as a power of 2
|
||||
//
|
||||
#define EXP_ALIGN_UP_PTR_ON_BOUNDARY(_length, _alignment) \
|
||||
(PVOID) ((((ULONG_PTR) (_length)) + ((_alignment)-1)) & \
|
||||
~(ULONG_PTR)((_alignment) - 1))
|
||||
|
||||
//
|
||||
// Checks if 1st argument is aligned on given power of 2 boundary specified
|
||||
// by 2nd argument
|
||||
//
|
||||
#define EXP_IS_PTR_ALIGNED_ON_BOUNDARY(_pointer, _alignment) \
|
||||
((((ULONG_PTR) (_pointer)) & ((_alignment) - 1)) == 0)
|
||||
|
||||
|
||||
//
|
||||
// This macro takes a size and rounds it down to a multiple of the alignemnt.
|
||||
// Alignment doesn't need to be a power of 2.
|
||||
//
|
||||
#define EXP_ALIGN_DOWN_ON_BOUNDARY(_size, _alignment) \
|
||||
((_size) - ((_size) % _alignment))
|
||||
|
||||
//
|
||||
// Define the max data size the bugcheck callback can write. Per callback the
|
||||
// total size is around 16K on 32bit OS (32K on 64bit OS).
|
||||
//
|
||||
#ifdef _WIN64
|
||||
#define FX_MAX_DUMP_SIZE (32*1024)
|
||||
#else
|
||||
#define FX_MAX_DUMP_SIZE (16*1024)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Maximum number of CPUs supported by the driver tracker.
|
||||
//
|
||||
#define FX_DRIVER_TRACKER_MAX_CPUS 256 // Max Win7 processors.
|
||||
|
||||
//
|
||||
// The initial/increment size of the array to hold driver info.
|
||||
//
|
||||
#define FX_DUMP_DRIVER_INFO_INCREMENT 10 // # entries.
|
||||
|
||||
//
|
||||
// The max size of the array to hold the driver info. This is the max data
|
||||
// we can write into the minidump.
|
||||
//
|
||||
#define FX_MAX_DUMP_DRIVER_INFO_COUNT \
|
||||
(FX_MAX_DUMP_SIZE/sizeof(FX_DUMP_DRIVER_INFO_ENTRY))
|
||||
|
||||
//
|
||||
// During run-time we store info about the loaded drivers in an array
|
||||
// of FX_DUMP_DRIVER_INFO_ENTRY struct entries, on a crash we write the
|
||||
// entire array in the minidump for postmortem analysis.
|
||||
//
|
||||
typedef struct _FX_DUMP_DRIVER_INFO_ENTRY {
|
||||
PFX_DRIVER_GLOBALS FxDriverGlobals;
|
||||
WDF_VERSION Version;
|
||||
CHAR DriverName[WDF_DRIVER_GLOBALS_NAME_LEN];
|
||||
} FX_DUMP_DRIVER_INFO_ENTRY, *PFX_DUMP_DRIVER_INFO_ENTRY;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // __FXBUGCHECK_H__
|
161
sdk/lib/drivers/wdf/kmdf/inc/private/fxcommonbuffer.hpp
Normal file
161
sdk/lib/drivers/wdf/kmdf/inc/private/fxcommonbuffer.hpp
Normal file
|
@ -0,0 +1,161 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FxCommonBuffer.hpp
|
||||
|
||||
Abstract:
|
||||
|
||||
WDF CommonBuffer Object support
|
||||
|
||||
Environment:
|
||||
|
||||
Kernel mode only.
|
||||
|
||||
Notes:
|
||||
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _FXCOMMONBUFFER_H_
|
||||
#define _FXCOMMONBUFFER_H_
|
||||
|
||||
//
|
||||
// Calculate an "aligned" address (Logical or Virtual) per
|
||||
// a specific alignment value.
|
||||
//
|
||||
FORCEINLINE
|
||||
PVOID
|
||||
FX_ALIGN_VIRTUAL_ADDRESS(
|
||||
__in PVOID VA,
|
||||
__in size_t AlignTo
|
||||
)
|
||||
{
|
||||
return (PVOID)(((ULONG_PTR)VA + AlignTo) & ~AlignTo);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
ULONGLONG
|
||||
FX_ALIGN_LOGICAL_ADDRESS(
|
||||
__in PHYSICAL_ADDRESS LA,
|
||||
__in size_t AlignTo
|
||||
)
|
||||
{
|
||||
return (LA.QuadPart + AlignTo) & ~((ULONGLONG)AlignTo);
|
||||
}
|
||||
|
||||
//
|
||||
// Declare the FxCommonBuffer class
|
||||
//
|
||||
class FxCommonBuffer : public FxNonPagedObject {
|
||||
|
||||
public:
|
||||
|
||||
FxCommonBuffer(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
|
||||
__in FxDmaEnabler * pDmaEnabler
|
||||
);
|
||||
|
||||
virtual
|
||||
BOOLEAN
|
||||
Dispose(
|
||||
VOID
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
AllocateCommonBuffer(
|
||||
__in size_t Length
|
||||
);
|
||||
|
||||
VOID
|
||||
FreeCommonBuffer(
|
||||
VOID
|
||||
);
|
||||
|
||||
__forceinline
|
||||
PHYSICAL_ADDRESS
|
||||
GetAlignedLogicalAddress(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return m_BufferAlignedLA;
|
||||
}
|
||||
|
||||
__forceinline
|
||||
PVOID
|
||||
GetAlignedVirtualAddress(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return m_BufferAlignedVA;
|
||||
}
|
||||
|
||||
__forceinline
|
||||
size_t
|
||||
GetLength(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return m_Length;
|
||||
}
|
||||
|
||||
__forceinline
|
||||
VOID
|
||||
SetAlignment(
|
||||
__in ULONG Alignment
|
||||
)
|
||||
{
|
||||
m_Alignment = Alignment;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
// Unaligned virtual address
|
||||
//
|
||||
PVOID m_BufferRawVA;
|
||||
|
||||
//
|
||||
// Aligned virtual address
|
||||
//
|
||||
PVOID m_BufferAlignedVA;
|
||||
|
||||
//
|
||||
// Aligned logical address
|
||||
//
|
||||
PHYSICAL_ADDRESS m_BufferAlignedLA;
|
||||
|
||||
//
|
||||
// Unaligned logical address
|
||||
//
|
||||
PHYSICAL_ADDRESS m_BufferRawLA;
|
||||
|
||||
//
|
||||
// Pointer to the DMA enabler
|
||||
//
|
||||
FxDmaEnabler * m_DmaEnabler;
|
||||
|
||||
//
|
||||
// Length specified by the caller
|
||||
//
|
||||
size_t m_Length;
|
||||
|
||||
//
|
||||
// Actual length used to allocate buffer after adding the alignement
|
||||
// value.
|
||||
//
|
||||
size_t m_RawLength;
|
||||
|
||||
//
|
||||
// Alignment of the allocated buffer.
|
||||
//
|
||||
size_t m_Alignment;
|
||||
|
||||
};
|
||||
|
||||
#endif // _FXCOMMONBUFFER_H_
|
1559
sdk/lib/drivers/wdf/kmdf/inc/private/fxdmatransaction.hpp
Normal file
1559
sdk/lib/drivers/wdf/kmdf/inc/private/fxdmatransaction.hpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,168 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FxDmaTransactionCallbacks.h
|
||||
|
||||
Abstract:
|
||||
|
||||
This module implements the FxDmaTransaction object callbacks
|
||||
|
||||
Environment:
|
||||
|
||||
kernel mode only
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _FXDMATRANSACTIONCALLBACKS_H
|
||||
#define _FXDMATRANSACTIONCALLBACKS_H
|
||||
|
||||
//
|
||||
// FxDmaTransactionProgramDma or FxDmaTransactionReserveDma callback delegate
|
||||
// These are mutually exclusive callbacks and are packed together in
|
||||
// the callback structure (C++ won't allow two classes with constructors
|
||||
// to be together in a union, so the containing class can't do the
|
||||
// packing)
|
||||
//
|
||||
class FxDmaTransactionProgramOrReserveDma : public FxCallback {
|
||||
|
||||
public:
|
||||
union {
|
||||
PFN_WDF_PROGRAM_DMA ProgramDma;
|
||||
PFN_WDF_RESERVE_DMA ReserveDma;
|
||||
} Method;
|
||||
|
||||
FxDmaTransactionProgramOrReserveDma(
|
||||
VOID
|
||||
) :
|
||||
FxCallback()
|
||||
{
|
||||
Method.ProgramDma = NULL;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
InvokeProgramDma(
|
||||
__in WDFDMATRANSACTION Transaction,
|
||||
__in WDFDEVICE Device,
|
||||
__in PVOID Context,
|
||||
__in WDF_DMA_DIRECTION Direction,
|
||||
__in PSCATTER_GATHER_LIST SgList
|
||||
)
|
||||
{
|
||||
if (Method.ProgramDma) {
|
||||
BOOLEAN cc;
|
||||
|
||||
CallbackStart();
|
||||
cc = Method.ProgramDma( Transaction,
|
||||
Device,
|
||||
Context,
|
||||
Direction,
|
||||
SgList );
|
||||
CallbackEnd();
|
||||
|
||||
return cc;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
InvokeReserveDma(
|
||||
__in WDFDMATRANSACTION Transaction,
|
||||
__in PVOID Context
|
||||
)
|
||||
{
|
||||
if (Method.ReserveDma) {
|
||||
CallbackStart();
|
||||
Method.ReserveDma( Transaction, Context );
|
||||
CallbackEnd();
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
Clear(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
Method.ProgramDma = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// FxDmaTransactionConfigureChannel callback delegate
|
||||
//
|
||||
|
||||
class FxDmaTransactionConfigureChannel : public FxCallback {
|
||||
|
||||
public:
|
||||
PFN_WDF_DMA_TRANSACTION_CONFIGURE_DMA_CHANNEL Method;
|
||||
|
||||
FxDmaTransactionConfigureChannel(
|
||||
VOID
|
||||
) :
|
||||
FxCallback()
|
||||
{
|
||||
Method = NULL;
|
||||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
BOOLEAN
|
||||
Invoke(
|
||||
__in WDFDMATRANSACTION DmaTransaction,
|
||||
__in WDFDEVICE Device,
|
||||
__in PVOID Context,
|
||||
__in_opt PMDL Mdl,
|
||||
__in size_t Offset,
|
||||
__in size_t Length
|
||||
)
|
||||
{
|
||||
BOOLEAN b = TRUE;
|
||||
if (Method) {
|
||||
CallbackStart();
|
||||
b = Method( DmaTransaction, Device, Context, Mdl, Offset, Length );
|
||||
CallbackEnd();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// FxDmaTransactionTransferComplete callback delegate
|
||||
//
|
||||
|
||||
class FxDmaTransactionTransferComplete : public FxCallback {
|
||||
|
||||
public:
|
||||
PFN_WDF_DMA_TRANSACTION_DMA_TRANSFER_COMPLETE Method;
|
||||
|
||||
FxDmaTransactionTransferComplete(
|
||||
VOID
|
||||
) :
|
||||
FxCallback()
|
||||
{
|
||||
Method = NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
Invoke(
|
||||
__in WDFDMATRANSACTION Transaction,
|
||||
__in WDFDEVICE Device,
|
||||
__in WDFCONTEXT Context,
|
||||
__in WDF_DMA_DIRECTION Direction,
|
||||
__in DMA_COMPLETION_STATUS Status
|
||||
)
|
||||
{
|
||||
if (Method) {
|
||||
CallbackStart();
|
||||
Method( Transaction, Device, Context, Direction, Status );
|
||||
CallbackEnd();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _FXDMATRANSACTIONCALLBACKS_H
|
201
sdk/lib/drivers/wdf/kmdf/inc/private/fxdpc.hpp
Normal file
201
sdk/lib/drivers/wdf/kmdf/inc/private/fxdpc.hpp
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FxDpc.hpp
|
||||
|
||||
Abstract:
|
||||
|
||||
This module implements a frameworks managed DPC that
|
||||
can synchrononize with driver frameworks object locks.
|
||||
|
||||
Author:
|
||||
|
||||
|
||||
|
||||
Environment:
|
||||
|
||||
kernel mode only
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _FXDPC_H_
|
||||
#define _FXDPC_H_
|
||||
|
||||
//
|
||||
// Driver Frameworks DPC Design:
|
||||
//
|
||||
// The driver frameworks provides an optional DPC wrapper object that allows
|
||||
// the creation of a reference counted DPC object that can synchronize
|
||||
// automatically with certain frameworks objects.
|
||||
//
|
||||
// This provides automatic synchronization between the DPC's execution, and the
|
||||
// frameworks objects' event callbacks into the device driver.
|
||||
//
|
||||
// The WDFDPC object is designed to be re-useable, in which it can be re-linked
|
||||
// into the DPC queue after firing.
|
||||
//
|
||||
// In many cases, the KDPC struct is embedded inside another structure that
|
||||
// represents a device command block. These device command blocks are typically
|
||||
// submitted to another device driver. So the calling driver, which is utilizing
|
||||
// the driver frameworks would not likely have an opportunity to make
|
||||
// changes to this. In order to support this, the caller can optionally supply
|
||||
// a DPC object pointer to Initialize, and the WDFDPC object will use this
|
||||
// embedded user supplied DPC object, and pass its address as the RawDpc
|
||||
// parameter to the callback function.
|
||||
//
|
||||
// If the user does not supply a DPC pointer by passing NULL, then the
|
||||
// internal DPC object is used, and RawDPC is NULL.
|
||||
//
|
||||
// Calling GetDpcPtr returns the DPC to be used, and could be
|
||||
// the caller supplied DPC, or the embedded one depending on
|
||||
// whether the caller supplied a user DPC pointer to Initialize.
|
||||
//
|
||||
// The GetDpcPtr allows linking of the WDFDPC object into various DPC
|
||||
// lists by the driver.
|
||||
//
|
||||
|
||||
class FxDpc : public FxNonPagedObject {
|
||||
|
||||
private:
|
||||
|
||||
KDPC m_Dpc;
|
||||
|
||||
//
|
||||
// This is the Framework object who is associated with the DPC
|
||||
// if supplied
|
||||
//
|
||||
FxObject* m_Object;
|
||||
|
||||
//
|
||||
// This is the callback lock for the object this DPC will
|
||||
// synchronize with
|
||||
//
|
||||
FxCallbackLock* m_CallbackLock;
|
||||
|
||||
//
|
||||
// This is the object whose reference count actually controls
|
||||
// the lifetime of the m_CallbackLock
|
||||
//
|
||||
FxObject* m_CallbackLockObject;
|
||||
|
||||
//
|
||||
// This is the user supplied callback function
|
||||
//
|
||||
PFN_WDF_DPC m_Callback;
|
||||
|
||||
// Ensures only one of either Delete or Cleanup runs down the object
|
||||
BOOLEAN m_RunningDown;
|
||||
|
||||
public:
|
||||
static
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
_Create(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
|
||||
__in PWDF_DPC_CONFIG Config,
|
||||
__in PWDF_OBJECT_ATTRIBUTES Attributes,
|
||||
__in FxObject* ParentObject,
|
||||
__out WDFDPC* Dpc
|
||||
);
|
||||
|
||||
FxDpc(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals
|
||||
);
|
||||
|
||||
virtual
|
||||
~FxDpc(
|
||||
VOID
|
||||
);
|
||||
|
||||
KDPC*
|
||||
GetDpcPtr(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return &m_Dpc;
|
||||
}
|
||||
|
||||
WDFOBJECT
|
||||
GetObject(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (m_Object != NULL) {
|
||||
return m_Object->GetObjectHandle();
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initialize the DPC using either the caller supplied DPC
|
||||
struct, or if NULL, our own internal one.
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
NTSTATUS
|
||||
|
||||
--*/
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
Initialize(
|
||||
__in PWDF_OBJECT_ATTRIBUTES Attributes,
|
||||
__in PWDF_DPC_CONFIG Config,
|
||||
__in FxObject* ParentObject,
|
||||
__out WDFDPC* Dpc
|
||||
);
|
||||
|
||||
virtual
|
||||
BOOLEAN
|
||||
Dispose(
|
||||
VOID
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
Cancel(
|
||||
__in BOOLEAN Wait
|
||||
);
|
||||
|
||||
VOID
|
||||
DpcHandler(
|
||||
__in PKDPC Dpc,
|
||||
__in PVOID SystemArgument1,
|
||||
__in PVOID SystemArgument2
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// Called from Dispose, or cleanup list to perform final flushing of any
|
||||
// outstanding DPC's and dereferencing of objects.
|
||||
//
|
||||
VOID
|
||||
FlushAndRundown(
|
||||
);
|
||||
|
||||
static
|
||||
KDEFERRED_ROUTINE
|
||||
FxDpcThunk;
|
||||
|
||||
static
|
||||
VOID
|
||||
WorkItemThunk(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PVOID Context
|
||||
);
|
||||
};
|
||||
|
||||
#endif // _FXDPC_H_
|
||||
|
6943
sdk/lib/drivers/wdf/kmdf/inc/private/fxdynamics.h
Normal file
6943
sdk/lib/drivers/wdf/kmdf/inc/private/fxdynamics.h
Normal file
File diff suppressed because it is too large
Load diff
18
sdk/lib/drivers/wdf/kmdf/inc/private/fxdynamicswrapper.h
Normal file
18
sdk/lib/drivers/wdf/kmdf/inc/private/fxdynamicswrapper.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Since #include'ing FxDymamics.h requires a bunch of headers before it, we
|
||||
// do this in one place because multiple spots in the code include this header.
|
||||
//
|
||||
|
||||
extern "C" {
|
||||
#pragma warning(disable:4200) // zero-sized array in struct/union
|
||||
#include <usbdrivr.h>
|
||||
#pragma warning(default:4200)
|
||||
|
||||
#include <wdfusb.h>
|
||||
#include <wdfminiport.h>
|
||||
#include "FxDynamics.h"
|
||||
#include "VfFxDynamics.h"
|
||||
}
|
87
sdk/lib/drivers/wdf/kmdf/inc/private/fxlibrarycommon.h
Normal file
87
sdk/lib/drivers/wdf/kmdf/inc/private/fxlibrarycommon.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
//
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
//
|
||||
#ifndef __FX_LIBRARY_COMMON_H__
|
||||
#define __FX_LIBRARY_COMMON_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
extern ULONG WdfLdrDbgPrintOn;
|
||||
extern PCHAR WdfLdrType;
|
||||
|
||||
extern WDFVERSION WdfVersion;
|
||||
|
||||
extern RTL_OSVERSIONINFOW gOsVersion;
|
||||
|
||||
#define _LIT_(a) # a
|
||||
#define LITERAL(a) _LIT_(a)
|
||||
|
||||
#define __PrintUnfiltered(...) \
|
||||
DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__);
|
||||
|
||||
#define __Print(_x_) \
|
||||
{ \
|
||||
if (WdfLdrDbgPrintOn) { \
|
||||
DbgPrintEx(DPFLTR_DEFAULT_ID, DPFLTR_ERROR_LEVEL, "%s: ", WdfLdrType); \
|
||||
__PrintUnfiltered _x_ \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WDF_ENHANCED_VERIFIER_OPTIONS_VALUE_NAME L"EnhancedVerifierOptions"
|
||||
|
||||
typedef
|
||||
NTSTATUS
|
||||
(*PFN_RTL_GET_VERSION)(
|
||||
__out PRTL_OSVERSIONINFOW VersionInformation
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxLibraryCommonCommission(
|
||||
VOID
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxLibraryCommonDecommission(
|
||||
VOID
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxLibraryCommonRegisterClient(
|
||||
__inout PWDF_BIND_INFO Info,
|
||||
__deref_out PWDF_DRIVER_GLOBALS * WdfDriverGlobals,
|
||||
__in_opt PCLIENT_INFO ClientInfo
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxLibraryCommonUnregisterClient(
|
||||
__in PWDF_BIND_INFO Info,
|
||||
__in PWDF_DRIVER_GLOBALS WdfDriverGlobals
|
||||
);
|
||||
|
||||
VOID
|
||||
GetEnhancedVerifierOptions(
|
||||
__in PCLIENT_INFO ClientInfo,
|
||||
__out PULONG Options
|
||||
);
|
||||
|
||||
VOID
|
||||
LibraryLogEvent(
|
||||
__in PDRIVER_OBJECT DriverObject,
|
||||
__in NTSTATUS ErrorCode,
|
||||
__in NTSTATUS FinalStatus,
|
||||
__in PWSTR ErrorInsertionString,
|
||||
__in_bcount(RawDataLen) PVOID RawDataBuf,
|
||||
__in USHORT RawDataLen
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __FX_LIBRARY_COMMON_H__
|
38
sdk/lib/drivers/wdf/kmdf/inc/private/fxprobeandlock.h
Normal file
38
sdk/lib/drivers/wdf/kmdf/inc/private/fxprobeandlock.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
//
|
||||
#ifndef __FXPROBEANDLOCK_H__
|
||||
#define __FXPROBEANDLOCK_H__
|
||||
|
||||
extern "C" {
|
||||
|
||||
//
|
||||
// These are defined in a C file in src\support\ProbeAndLock.c
|
||||
// to avoid C++ exception handling issues.
|
||||
//
|
||||
// They do not raise the exception beyond the C function, but
|
||||
// translate it into an NTSTATUS before returning.
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
FxProbeAndLockForRead(
|
||||
__in PMDL Mdl,
|
||||
__in KPROCESSOR_MODE AccessMode
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
FxProbeAndLockForWrite(
|
||||
__in PMDL Mdl,
|
||||
__in KPROCESSOR_MODE AccessMode
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
FxProbeAndLockWithAccess(
|
||||
__in PMDL Mdl,
|
||||
__in KPROCESSOR_MODE AccessMode,
|
||||
__in LOCK_OPERATION Operation
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif __FXPROBEANDLOCK_H__
|
161
sdk/lib/drivers/wdf/kmdf/inc/private/ifxmemory.hpp
Normal file
161
sdk/lib/drivers/wdf/kmdf/inc/private/ifxmemory.hpp
Normal file
|
@ -0,0 +1,161 @@
|
|||
//
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
//
|
||||
/*++
|
||||
|
||||
Module Name:
|
||||
|
||||
IFxMemory.hpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Abstract base class for a memory object. It is necessary to split the
|
||||
memory interface away from an FxObject derived base class so that we can
|
||||
hand out WDFMEMORY handles that are embedded within other FxObject derived
|
||||
classes without having to embed another FxObject derived class within the
|
||||
parent.
|
||||
|
||||
Author:
|
||||
|
||||
|
||||
|
||||
Environment:
|
||||
|
||||
kernel mode only
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef __IFX_MEMORY_HPP__
|
||||
#define __IFX_MEMORY_HPP__
|
||||
|
||||
// begin_wpp enum
|
||||
enum IFxMemoryFlags {
|
||||
IFxMemoryFlagReadOnly = 0x0001,
|
||||
};
|
||||
// end_wpp
|
||||
|
||||
|
||||
class IFxMemory {
|
||||
public:
|
||||
virtual
|
||||
PVOID
|
||||
GetBuffer(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
size_t
|
||||
GetBufferSize(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
PMDL
|
||||
GetMdl(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
WDFMEMORY
|
||||
GetHandle(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
//
|
||||
// Value returned is a bit field from the enum IFxMemoryFlags
|
||||
//
|
||||
virtual
|
||||
USHORT
|
||||
GetFlags(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
PFX_DRIVER_GLOBALS
|
||||
GetDriverGlobals(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
ULONG
|
||||
AddRef(
|
||||
__in PVOID Tag,
|
||||
__in LONG Line,
|
||||
__in_opt PSTR File
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
ULONG
|
||||
Release(
|
||||
__in PVOID Tag,
|
||||
__in LONG Line,
|
||||
__in_opt PSTR File
|
||||
) =0;
|
||||
|
||||
virtual
|
||||
VOID
|
||||
Delete(
|
||||
VOID
|
||||
) =0;
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
ValidateMemoryOffsets(
|
||||
__in_opt PWDFMEMORY_OFFSET Offsets
|
||||
)
|
||||
{
|
||||
NTSTATUS status;
|
||||
size_t total;
|
||||
|
||||
if (Offsets == NULL) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
status = RtlSizeTAdd(Offsets->BufferLength, Offsets->BufferOffset, &total);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (total > GetBufferSize()) {
|
||||
return STATUS_INTEGER_OVERFLOW;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
CopyFromPtr(
|
||||
__in_opt PWDFMEMORY_OFFSET DestinationOffsets,
|
||||
__in_bcount(SourceBufferLength) PVOID SourceBuffer,
|
||||
__in size_t SourceBufferLength,
|
||||
__in_opt PWDFMEMORY_OFFSET SourceOffsets
|
||||
);
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
CopyToPtr(
|
||||
__in_opt PWDFMEMORY_OFFSET SourceOffsets,
|
||||
__out_bcount(DestinationBufferLength) PVOID DestinationBuffer,
|
||||
__in size_t DestinationBufferLength,
|
||||
__in_opt PWDFMEMORY_OFFSET DestinationOffsets
|
||||
);
|
||||
|
||||
protected:
|
||||
static
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
_CopyPtrToPtr(
|
||||
__in_bcount(SourceBufferLength) PVOID SourceBuffer,
|
||||
__in size_t SourceBufferLength,
|
||||
__in_opt PWDFMEMORY_OFFSET SourceOffsets,
|
||||
__out_bcount(DestinationBufferLength) PVOID DestinationBuffer,
|
||||
__in size_t DestinationBufferLength,
|
||||
__in_opt PWDFMEMORY_OFFSET DestinationOffsets
|
||||
);
|
||||
};
|
||||
|
||||
#endif // __IFX_MEMORY_HPP__
|
6484
sdk/lib/drivers/wdf/kmdf/inc/private/vffxdynamics.h
Normal file
6484
sdk/lib/drivers/wdf/kmdf/inc/private/vffxdynamics.h
Normal file
File diff suppressed because it is too large
Load diff
2173
sdk/lib/drivers/wdf/kmdf/inc/private/wdf10.h
Normal file
2173
sdk/lib/drivers/wdf/kmdf/inc/private/wdf10.h
Normal file
File diff suppressed because it is too large
Load diff
2203
sdk/lib/drivers/wdf/kmdf/inc/private/wdf11.h
Normal file
2203
sdk/lib/drivers/wdf/kmdf/inc/private/wdf11.h
Normal file
File diff suppressed because it is too large
Load diff
2896
sdk/lib/drivers/wdf/kmdf/inc/private/wdf111.h
Normal file
2896
sdk/lib/drivers/wdf/kmdf/inc/private/wdf111.h
Normal file
File diff suppressed because it is too large
Load diff
3064
sdk/lib/drivers/wdf/kmdf/inc/private/wdf113.h
Normal file
3064
sdk/lib/drivers/wdf/kmdf/inc/private/wdf113.h
Normal file
File diff suppressed because it is too large
Load diff
3079
sdk/lib/drivers/wdf/kmdf/inc/private/wdf115.h
Normal file
3079
sdk/lib/drivers/wdf/kmdf/inc/private/wdf115.h
Normal file
File diff suppressed because it is too large
Load diff
2209
sdk/lib/drivers/wdf/kmdf/inc/private/wdf15.h
Normal file
2209
sdk/lib/drivers/wdf/kmdf/inc/private/wdf15.h
Normal file
File diff suppressed because it is too large
Load diff
2228
sdk/lib/drivers/wdf/kmdf/inc/private/wdf17.h
Normal file
2228
sdk/lib/drivers/wdf/kmdf/inc/private/wdf17.h
Normal file
File diff suppressed because it is too large
Load diff
2410
sdk/lib/drivers/wdf/kmdf/inc/private/wdf19.h
Normal file
2410
sdk/lib/drivers/wdf/kmdf/inc/private/wdf19.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue