18a978a17SVictor Perevertkin /*++
28a978a17SVictor Perevertkin
38a978a17SVictor Perevertkin Copyright (c) Microsoft Corporation
48a978a17SVictor Perevertkin
58a978a17SVictor Perevertkin ModuleName:
68a978a17SVictor Perevertkin
78a978a17SVictor Perevertkin MxGeneralKm.h
88a978a17SVictor Perevertkin
98a978a17SVictor Perevertkin Abstract:
108a978a17SVictor Perevertkin
118a978a17SVictor Perevertkin Kernel mode implementation for general OS
128a978a17SVictor Perevertkin functions defined in MxGeneral.h
138a978a17SVictor Perevertkin
148a978a17SVictor Perevertkin Author:
158a978a17SVictor Perevertkin
168a978a17SVictor Perevertkin
178a978a17SVictor Perevertkin
188a978a17SVictor Perevertkin Revision History:
198a978a17SVictor Perevertkin
208a978a17SVictor Perevertkin
218a978a17SVictor Perevertkin
228a978a17SVictor Perevertkin --*/
238a978a17SVictor Perevertkin
248a978a17SVictor Perevertkin #pragma once
258a978a17SVictor Perevertkin
268a978a17SVictor Perevertkin #define MAKE_MX_FUNC_NAME(x) L##x
278a978a17SVictor Perevertkin typedef LPCWSTR MxFuncName;
288a978a17SVictor Perevertkin typedef PKTHREAD MxThread;
298a978a17SVictor Perevertkin typedef PETHREAD MdEThread;
308a978a17SVictor Perevertkin typedef PDEVICE_OBJECT MdDeviceObject;
318a978a17SVictor Perevertkin typedef PDRIVER_OBJECT MdDriverObject;
328a978a17SVictor Perevertkin typedef PFILE_OBJECT MdFileObject;
338a978a17SVictor Perevertkin typedef PIO_REMOVE_LOCK MdRemoveLock;
348a978a17SVictor Perevertkin typedef PCALLBACK_OBJECT MdCallbackObject;
358a978a17SVictor Perevertkin typedef CALLBACK_FUNCTION MdCallbackFunctionType, *MdCallbackFunction;
368a978a17SVictor Perevertkin typedef PKINTERRUPT MdInterrupt;
378a978a17SVictor Perevertkin typedef KSERVICE_ROUTINE MdInterruptServiceRoutineType, *MdInterruptServiceRoutine;
388a978a17SVictor Perevertkin typedef KSYNCHRONIZE_ROUTINE MdInterruptSynchronizeRoutineType, *MdInterruptSynchronizeRoutine;
398a978a17SVictor Perevertkin
40*1f377076SVictor Perevertkin #include "mxgeneral.h"
418a978a17SVictor Perevertkin #include <ntstrsafe.h>
428a978a17SVictor Perevertkin
438a978a17SVictor Perevertkin __inline
448a978a17SVictor Perevertkin BOOLEAN
IsUM()458a978a17SVictor Perevertkin Mx::IsUM(
468a978a17SVictor Perevertkin )
478a978a17SVictor Perevertkin {
488a978a17SVictor Perevertkin return FALSE;
498a978a17SVictor Perevertkin }
508a978a17SVictor Perevertkin
518a978a17SVictor Perevertkin __inline
528a978a17SVictor Perevertkin BOOLEAN
IsKM()538a978a17SVictor Perevertkin Mx::IsKM(
548a978a17SVictor Perevertkin )
558a978a17SVictor Perevertkin {
568a978a17SVictor Perevertkin return TRUE;
578a978a17SVictor Perevertkin }
588a978a17SVictor Perevertkin
598a978a17SVictor Perevertkin __inline
608a978a17SVictor Perevertkin MxThread
MxGetCurrentThread()618a978a17SVictor Perevertkin Mx::MxGetCurrentThread(
628a978a17SVictor Perevertkin )
638a978a17SVictor Perevertkin {
648a978a17SVictor Perevertkin return KeGetCurrentThread();
658a978a17SVictor Perevertkin }
668a978a17SVictor Perevertkin
678a978a17SVictor Perevertkin __inline
688a978a17SVictor Perevertkin MdEThread
GetCurrentEThread()698a978a17SVictor Perevertkin Mx::GetCurrentEThread(
708a978a17SVictor Perevertkin )
718a978a17SVictor Perevertkin {
728a978a17SVictor Perevertkin return PsGetCurrentThread();
738a978a17SVictor Perevertkin }
748a978a17SVictor Perevertkin
758a978a17SVictor Perevertkin __inline
768a978a17SVictor Perevertkin NTSTATUS
MxTerminateCurrentThread(__in NTSTATUS Status)778a978a17SVictor Perevertkin Mx::MxTerminateCurrentThread(
788a978a17SVictor Perevertkin __in NTSTATUS Status
798a978a17SVictor Perevertkin )
808a978a17SVictor Perevertkin {
818a978a17SVictor Perevertkin return PsTerminateSystemThread(Status);
828a978a17SVictor Perevertkin }
838a978a17SVictor Perevertkin
848a978a17SVictor Perevertkin __inline
858a978a17SVictor Perevertkin KIRQL
MxGetCurrentIrql()868a978a17SVictor Perevertkin Mx::MxGetCurrentIrql(
878a978a17SVictor Perevertkin )
888a978a17SVictor Perevertkin {
898a978a17SVictor Perevertkin return KeGetCurrentIrql();
908a978a17SVictor Perevertkin }
918a978a17SVictor Perevertkin
928a978a17SVictor Perevertkin __drv_maxIRQL(HIGH_LEVEL)
__drv_raisesIRQL(NewIrql)938a978a17SVictor Perevertkin __drv_raisesIRQL(NewIrql)
948a978a17SVictor Perevertkin __inline
958a978a17SVictor Perevertkin VOID
968a978a17SVictor Perevertkin Mx::MxRaiseIrql(
978a978a17SVictor Perevertkin __in KIRQL NewIrql,
988a978a17SVictor Perevertkin __out __deref __drv_savesIRQL PKIRQL OldIrql
998a978a17SVictor Perevertkin )
1008a978a17SVictor Perevertkin {
1018a978a17SVictor Perevertkin KeRaiseIrql(NewIrql, OldIrql);
1028a978a17SVictor Perevertkin }
1038a978a17SVictor Perevertkin
__drv_maxIRQL(HIGH_LEVEL)1048a978a17SVictor Perevertkin __drv_maxIRQL(HIGH_LEVEL)
1058a978a17SVictor Perevertkin __inline
1068a978a17SVictor Perevertkin VOID
1078a978a17SVictor Perevertkin Mx::MxLowerIrql(
1088a978a17SVictor Perevertkin __in __drv_restoresIRQL __drv_nonConstant KIRQL NewIrql
1098a978a17SVictor Perevertkin )
1108a978a17SVictor Perevertkin {
1118a978a17SVictor Perevertkin KeLowerIrql(NewIrql);
1128a978a17SVictor Perevertkin }
1138a978a17SVictor Perevertkin
1148a978a17SVictor Perevertkin __inline
1158a978a17SVictor Perevertkin VOID
MxQueryTickCount(__out PLARGE_INTEGER TickCount)1168a978a17SVictor Perevertkin Mx::MxQueryTickCount(
1178a978a17SVictor Perevertkin __out PLARGE_INTEGER TickCount
1188a978a17SVictor Perevertkin )
1198a978a17SVictor Perevertkin {
1208a978a17SVictor Perevertkin KeQueryTickCount(TickCount);
1218a978a17SVictor Perevertkin }
1228a978a17SVictor Perevertkin
1238a978a17SVictor Perevertkin __inline
1248a978a17SVictor Perevertkin ULONG
MxQueryTimeIncrement()1258a978a17SVictor Perevertkin Mx::MxQueryTimeIncrement(
1268a978a17SVictor Perevertkin )
1278a978a17SVictor Perevertkin {
1288a978a17SVictor Perevertkin return KeQueryTimeIncrement();
1298a978a17SVictor Perevertkin }
1308a978a17SVictor Perevertkin
1318a978a17SVictor Perevertkin __inline
1328a978a17SVictor Perevertkin VOID
MxBugCheckEx(__in ULONG BugCheckCode,__in ULONG_PTR BugCheckParameter1,__in ULONG_PTR BugCheckParameter2,__in ULONG_PTR BugCheckParameter3,__in ULONG_PTR BugCheckParameter4)1338a978a17SVictor Perevertkin Mx::MxBugCheckEx(
1348a978a17SVictor Perevertkin __in ULONG BugCheckCode,
1358a978a17SVictor Perevertkin __in ULONG_PTR BugCheckParameter1,
1368a978a17SVictor Perevertkin __in ULONG_PTR BugCheckParameter2,
1378a978a17SVictor Perevertkin __in ULONG_PTR BugCheckParameter3,
1388a978a17SVictor Perevertkin __in ULONG_PTR BugCheckParameter4
1398a978a17SVictor Perevertkin )
1408a978a17SVictor Perevertkin {
141*1f377076SVictor Perevertkin #ifdef _MSC_VER
1428a978a17SVictor Perevertkin #pragma prefast(suppress:__WARNING_USE_OTHER_FUNCTION, "KeBugCheckEx is the intent.");
143*1f377076SVictor Perevertkin #endif
1448a978a17SVictor Perevertkin KeBugCheckEx(
1458a978a17SVictor Perevertkin BugCheckCode,
1468a978a17SVictor Perevertkin BugCheckParameter1,
1478a978a17SVictor Perevertkin BugCheckParameter2,
1488a978a17SVictor Perevertkin BugCheckParameter3,
1498a978a17SVictor Perevertkin BugCheckParameter4
1508a978a17SVictor Perevertkin );
151*1f377076SVictor Perevertkin
152*1f377076SVictor Perevertkin UNREACHABLE;
1538a978a17SVictor Perevertkin }
1548a978a17SVictor Perevertkin
1558a978a17SVictor Perevertkin __inline
1568a978a17SVictor Perevertkin VOID
MxDbgBreakPoint()1578a978a17SVictor Perevertkin Mx::MxDbgBreakPoint(
1588a978a17SVictor Perevertkin )
1598a978a17SVictor Perevertkin {
1608a978a17SVictor Perevertkin DbgBreakPoint();
1618a978a17SVictor Perevertkin }
1628a978a17SVictor Perevertkin
1638a978a17SVictor Perevertkin __inline
1648a978a17SVictor Perevertkin VOID
MxAssert(__in BOOLEAN Condition)1658a978a17SVictor Perevertkin Mx::MxAssert(
1668a978a17SVictor Perevertkin __in BOOLEAN Condition
1678a978a17SVictor Perevertkin )
1688a978a17SVictor Perevertkin {
1698a978a17SVictor Perevertkin UNREFERENCED_PARAMETER(Condition);
1708a978a17SVictor Perevertkin
1718a978a17SVictor Perevertkin ASSERT(Condition); //this get defined as RtlAssert
1728a978a17SVictor Perevertkin }
1738a978a17SVictor Perevertkin
1748a978a17SVictor Perevertkin __inline
1758a978a17SVictor Perevertkin VOID
MxAssertMsg(__in LPSTR Message,__in BOOLEAN Condition)1768a978a17SVictor Perevertkin Mx::MxAssertMsg(
1778a978a17SVictor Perevertkin __in LPSTR Message,
1788a978a17SVictor Perevertkin __in BOOLEAN Condition
1798a978a17SVictor Perevertkin )
1808a978a17SVictor Perevertkin {
1818a978a17SVictor Perevertkin UNREFERENCED_PARAMETER(Message);
1828a978a17SVictor Perevertkin UNREFERENCED_PARAMETER(Condition);
1838a978a17SVictor Perevertkin
184*1f377076SVictor Perevertkin ASSERT(Condition);
185*1f377076SVictor Perevertkin
186*1f377076SVictor Perevertkin // ASSERTMSG(Message, Condition); TODO: wtf
1878a978a17SVictor Perevertkin }
1888a978a17SVictor Perevertkin
_Acquires_lock_(_Global_critical_region_)1898a978a17SVictor Perevertkin _Acquires_lock_(_Global_critical_region_)
1908a978a17SVictor Perevertkin __inline
1918a978a17SVictor Perevertkin VOID
1928a978a17SVictor Perevertkin Mx::MxEnterCriticalRegion(
1938a978a17SVictor Perevertkin )
1948a978a17SVictor Perevertkin {
1958a978a17SVictor Perevertkin KeEnterCriticalRegion();
1968a978a17SVictor Perevertkin }
1978a978a17SVictor Perevertkin
_Releases_lock_(_Global_critical_region_)1988a978a17SVictor Perevertkin _Releases_lock_(_Global_critical_region_)
1998a978a17SVictor Perevertkin __inline
2008a978a17SVictor Perevertkin VOID
2018a978a17SVictor Perevertkin Mx::MxLeaveCriticalRegion(
2028a978a17SVictor Perevertkin )
2038a978a17SVictor Perevertkin {
2048a978a17SVictor Perevertkin KeLeaveCriticalRegion();
2058a978a17SVictor Perevertkin }
2068a978a17SVictor Perevertkin
2078a978a17SVictor Perevertkin __inline
2088a978a17SVictor Perevertkin VOID
MxDelayExecutionThread(__in KPROCESSOR_MODE WaitMode,__in BOOLEAN Alertable,__in PLARGE_INTEGER Interval)2098a978a17SVictor Perevertkin Mx::MxDelayExecutionThread(
2108a978a17SVictor Perevertkin __in KPROCESSOR_MODE WaitMode,
2118a978a17SVictor Perevertkin __in BOOLEAN Alertable,
2128a978a17SVictor Perevertkin __in PLARGE_INTEGER Interval
2138a978a17SVictor Perevertkin )
2148a978a17SVictor Perevertkin {
2158a978a17SVictor Perevertkin ASSERTMSG("Interval must be relative\n", Interval->QuadPart <= 0);
2168a978a17SVictor Perevertkin
2178a978a17SVictor Perevertkin KeDelayExecutionThread(
2188a978a17SVictor Perevertkin WaitMode,
2198a978a17SVictor Perevertkin Alertable,
2208a978a17SVictor Perevertkin Interval
2218a978a17SVictor Perevertkin );
2228a978a17SVictor Perevertkin }
2238a978a17SVictor Perevertkin
2248a978a17SVictor Perevertkin __inline
2258a978a17SVictor Perevertkin PVOID
MxGetSystemRoutineAddress(__in MxFuncName FuncName)2268a978a17SVictor Perevertkin Mx::MxGetSystemRoutineAddress(
2278a978a17SVictor Perevertkin __in MxFuncName FuncName
2288a978a17SVictor Perevertkin )
2298a978a17SVictor Perevertkin {
2308a978a17SVictor Perevertkin UNICODE_STRING funcName;
2318a978a17SVictor Perevertkin
2328a978a17SVictor Perevertkin RtlInitUnicodeString(&funcName, FuncName);
2338a978a17SVictor Perevertkin return MmGetSystemRoutineAddress(&funcName);
2348a978a17SVictor Perevertkin }
2358a978a17SVictor Perevertkin
2368a978a17SVictor Perevertkin __inline
2378a978a17SVictor Perevertkin VOID
MxReferenceObject(__in PVOID Object)2388a978a17SVictor Perevertkin Mx::MxReferenceObject(
2398a978a17SVictor Perevertkin __in PVOID Object
2408a978a17SVictor Perevertkin )
2418a978a17SVictor Perevertkin {
2428a978a17SVictor Perevertkin ObReferenceObject(Object);
2438a978a17SVictor Perevertkin }
2448a978a17SVictor Perevertkin
2458a978a17SVictor Perevertkin __inline
2468a978a17SVictor Perevertkin VOID
MxDereferenceObject(__in PVOID Object)2478a978a17SVictor Perevertkin Mx::MxDereferenceObject(
2488a978a17SVictor Perevertkin __in PVOID Object
2498a978a17SVictor Perevertkin )
2508a978a17SVictor Perevertkin {
2518a978a17SVictor Perevertkin ObDereferenceObject(Object);
2528a978a17SVictor Perevertkin }
2538a978a17SVictor Perevertkin
2548a978a17SVictor Perevertkin __inline
2558a978a17SVictor Perevertkin VOID
MxInitializeRemoveLock(__in MdRemoveLock Lock,__in ULONG AllocateTag,__in ULONG MaxLockedMinutes,__in ULONG HighWatermark)2568a978a17SVictor Perevertkin Mx::MxInitializeRemoveLock(
2578a978a17SVictor Perevertkin __in MdRemoveLock Lock,
2588a978a17SVictor Perevertkin __in ULONG AllocateTag,
2598a978a17SVictor Perevertkin __in ULONG MaxLockedMinutes,
2608a978a17SVictor Perevertkin __in ULONG HighWatermark
2618a978a17SVictor Perevertkin )
2628a978a17SVictor Perevertkin {
2638a978a17SVictor Perevertkin IoInitializeRemoveLock(Lock, AllocateTag, MaxLockedMinutes, HighWatermark);
2648a978a17SVictor Perevertkin }
2658a978a17SVictor Perevertkin
2668a978a17SVictor Perevertkin __inline
2678a978a17SVictor Perevertkin NTSTATUS
MxAcquireRemoveLock(__in MdRemoveLock RemoveLock,__in_opt PVOID Tag)2688a978a17SVictor Perevertkin Mx::MxAcquireRemoveLock(
2698a978a17SVictor Perevertkin __in MdRemoveLock RemoveLock,
2708a978a17SVictor Perevertkin __in_opt PVOID Tag
2718a978a17SVictor Perevertkin )
2728a978a17SVictor Perevertkin {
2738a978a17SVictor Perevertkin return IoAcquireRemoveLock(RemoveLock, Tag);
2748a978a17SVictor Perevertkin }
2758a978a17SVictor Perevertkin
2768a978a17SVictor Perevertkin __inline
2778a978a17SVictor Perevertkin VOID
MxReleaseRemoveLock(__in MdRemoveLock RemoveLock,__in PVOID Tag)2788a978a17SVictor Perevertkin Mx::MxReleaseRemoveLock(
2798a978a17SVictor Perevertkin __in MdRemoveLock RemoveLock,
2808a978a17SVictor Perevertkin __in PVOID Tag
2818a978a17SVictor Perevertkin )
2828a978a17SVictor Perevertkin {
2838a978a17SVictor Perevertkin IoReleaseRemoveLock(RemoveLock, Tag);
2848a978a17SVictor Perevertkin }
2858a978a17SVictor Perevertkin
2868a978a17SVictor Perevertkin __inline
2878a978a17SVictor Perevertkin VOID
MxReleaseRemoveLockAndWait(__in MdRemoveLock RemoveLock,__in PVOID Tag)2888a978a17SVictor Perevertkin Mx::MxReleaseRemoveLockAndWait(
2898a978a17SVictor Perevertkin __in MdRemoveLock RemoveLock,
2908a978a17SVictor Perevertkin __in PVOID Tag
2918a978a17SVictor Perevertkin )
2928a978a17SVictor Perevertkin {
2938a978a17SVictor Perevertkin IoReleaseRemoveLockAndWait(RemoveLock, Tag);
2948a978a17SVictor Perevertkin }
2958a978a17SVictor Perevertkin
2968a978a17SVictor Perevertkin __inline
2978a978a17SVictor Perevertkin BOOLEAN
MxHasEnoughRemainingThreadStack(VOID)2988a978a17SVictor Perevertkin Mx::MxHasEnoughRemainingThreadStack(
2998a978a17SVictor Perevertkin VOID
3008a978a17SVictor Perevertkin )
3018a978a17SVictor Perevertkin {
3028a978a17SVictor Perevertkin return (IoGetRemainingStackSize() < KERNEL_STACK_SIZE/2) ? FALSE : TRUE;
3038a978a17SVictor Perevertkin }
3048a978a17SVictor Perevertkin
3058a978a17SVictor Perevertkin _Releases_lock_(_Global_cancel_spin_lock_)
__drv_requiresIRQL(DISPATCH_LEVEL)3068a978a17SVictor Perevertkin __drv_requiresIRQL(DISPATCH_LEVEL)
3078a978a17SVictor Perevertkin __inline
3088a978a17SVictor Perevertkin VOID
3098a978a17SVictor Perevertkin Mx::ReleaseCancelSpinLock(
3108a978a17SVictor Perevertkin __in __drv_restoresIRQL __drv_useCancelIRQL KIRQL Irql
3118a978a17SVictor Perevertkin )
3128a978a17SVictor Perevertkin {
3138a978a17SVictor Perevertkin IoReleaseCancelSpinLock(Irql);
3148a978a17SVictor Perevertkin }
3158a978a17SVictor Perevertkin
3168a978a17SVictor Perevertkin __inline
3178a978a17SVictor Perevertkin NTSTATUS
CreateCallback(__out PCALLBACK_OBJECT * CallbackObject,__in POBJECT_ATTRIBUTES ObjectAttributes,__in BOOLEAN Create,__in BOOLEAN AllowMultipleCallbacks)3188a978a17SVictor Perevertkin Mx::CreateCallback(
3198a978a17SVictor Perevertkin __out PCALLBACK_OBJECT *CallbackObject,
3208a978a17SVictor Perevertkin __in POBJECT_ATTRIBUTES ObjectAttributes,
3218a978a17SVictor Perevertkin __in BOOLEAN Create,
3228a978a17SVictor Perevertkin __in BOOLEAN AllowMultipleCallbacks
3238a978a17SVictor Perevertkin )
3248a978a17SVictor Perevertkin {
3258a978a17SVictor Perevertkin return ExCreateCallback(
3268a978a17SVictor Perevertkin CallbackObject,
3278a978a17SVictor Perevertkin ObjectAttributes,
3288a978a17SVictor Perevertkin Create,
3298a978a17SVictor Perevertkin AllowMultipleCallbacks);
3308a978a17SVictor Perevertkin }
3318a978a17SVictor Perevertkin
3328a978a17SVictor Perevertkin __inline
3338a978a17SVictor Perevertkin PVOID
RegisterCallback(__in PCALLBACK_OBJECT CallbackObject,__in MdCallbackFunction CallbackFunction,__in PVOID CallbackContext)3348a978a17SVictor Perevertkin Mx::RegisterCallback(
3358a978a17SVictor Perevertkin __in PCALLBACK_OBJECT CallbackObject,
3368a978a17SVictor Perevertkin __in MdCallbackFunction CallbackFunction,
3378a978a17SVictor Perevertkin __in PVOID CallbackContext
3388a978a17SVictor Perevertkin )
3398a978a17SVictor Perevertkin {
3408a978a17SVictor Perevertkin return ExRegisterCallback(
3418a978a17SVictor Perevertkin CallbackObject,
3428a978a17SVictor Perevertkin CallbackFunction,
3438a978a17SVictor Perevertkin CallbackContext);
3448a978a17SVictor Perevertkin }
3458a978a17SVictor Perevertkin
3468a978a17SVictor Perevertkin __inline
3478a978a17SVictor Perevertkin VOID
UnregisterCallback(__in PVOID CbRegistration)3488a978a17SVictor Perevertkin Mx::UnregisterCallback(
3498a978a17SVictor Perevertkin __in PVOID CbRegistration
3508a978a17SVictor Perevertkin )
3518a978a17SVictor Perevertkin {
3528a978a17SVictor Perevertkin ExUnregisterCallback(CbRegistration);
3538a978a17SVictor Perevertkin }
3548a978a17SVictor Perevertkin
3558a978a17SVictor Perevertkin __inline
3568a978a17SVictor Perevertkin VOID
MxUnlockPages(__in PMDL Mdl)3578a978a17SVictor Perevertkin Mx::MxUnlockPages(
3588a978a17SVictor Perevertkin __in PMDL Mdl
3598a978a17SVictor Perevertkin )
3608a978a17SVictor Perevertkin {
3618a978a17SVictor Perevertkin MmUnlockPages(Mdl);
3628a978a17SVictor Perevertkin }
3638a978a17SVictor Perevertkin
3648a978a17SVictor Perevertkin __inline
3658a978a17SVictor Perevertkin PVOID
MxGetSystemAddressForMdlSafe(__inout PMDL Mdl,__in ULONG Priority)3668a978a17SVictor Perevertkin Mx::MxGetSystemAddressForMdlSafe(
3678a978a17SVictor Perevertkin __inout PMDL Mdl,
3688a978a17SVictor Perevertkin __in ULONG Priority
3698a978a17SVictor Perevertkin )
3708a978a17SVictor Perevertkin {
3718a978a17SVictor Perevertkin return MmGetSystemAddressForMdlSafe(Mdl, Priority);
3728a978a17SVictor Perevertkin }
3738a978a17SVictor Perevertkin
3748a978a17SVictor Perevertkin __inline
3758a978a17SVictor Perevertkin VOID
MxBuildMdlForNonPagedPool(__inout PMDL Mdl)3768a978a17SVictor Perevertkin Mx::MxBuildMdlForNonPagedPool(
3778a978a17SVictor Perevertkin __inout PMDL Mdl
3788a978a17SVictor Perevertkin )
3798a978a17SVictor Perevertkin {
3808a978a17SVictor Perevertkin MmBuildMdlForNonPagedPool(Mdl);
3818a978a17SVictor Perevertkin }
3828a978a17SVictor Perevertkin
3838a978a17SVictor Perevertkin __inline
3848a978a17SVictor Perevertkin PVOID
MxGetDriverObjectExtension(__in PDRIVER_OBJECT DriverObject,__in PVOID ClientIdentificationAddress)3858a978a17SVictor Perevertkin Mx::MxGetDriverObjectExtension(
3868a978a17SVictor Perevertkin __in PDRIVER_OBJECT DriverObject,
3878a978a17SVictor Perevertkin __in PVOID ClientIdentificationAddress
3888a978a17SVictor Perevertkin )
3898a978a17SVictor Perevertkin {
3908a978a17SVictor Perevertkin return IoGetDriverObjectExtension(DriverObject,
3918a978a17SVictor Perevertkin ClientIdentificationAddress);
3928a978a17SVictor Perevertkin }
3938a978a17SVictor Perevertkin
3948a978a17SVictor Perevertkin __inline
3958a978a17SVictor Perevertkin NTSTATUS
3968a978a17SVictor Perevertkin Mx::MxAllocateDriverObjectExtension(
3978a978a17SVictor Perevertkin _In_ MdDriverObject DriverObject,
3988a978a17SVictor Perevertkin _In_ PVOID ClientIdentificationAddress,
3998a978a17SVictor Perevertkin _In_ ULONG DriverObjectExtensionSize,
4008a978a17SVictor Perevertkin // When successful, this always allocates already-aliased memory.
4018a978a17SVictor Perevertkin _Post_ _At_(*DriverObjectExtension, _When_(return==0,
4028a978a17SVictor Perevertkin __drv_aliasesMem __drv_allocatesMem(Mem) _Post_notnull_))
4038a978a17SVictor Perevertkin _When_(return == 0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize))
4048a978a17SVictor Perevertkin PVOID *DriverObjectExtension
4058a978a17SVictor Perevertkin )
4068a978a17SVictor Perevertkin {
4078a978a17SVictor Perevertkin return IoAllocateDriverObjectExtension(DriverObject,
4088a978a17SVictor Perevertkin ClientIdentificationAddress,
4098a978a17SVictor Perevertkin DriverObjectExtensionSize,
4108a978a17SVictor Perevertkin DriverObjectExtension);
4118a978a17SVictor Perevertkin }
4128a978a17SVictor Perevertkin
4138a978a17SVictor Perevertkin __inline
4148a978a17SVictor Perevertkin MdDeviceObject
MxGetAttachedDeviceReference(__in PDEVICE_OBJECT DriverObject)4158a978a17SVictor Perevertkin Mx::MxGetAttachedDeviceReference(
4168a978a17SVictor Perevertkin __in PDEVICE_OBJECT DriverObject
4178a978a17SVictor Perevertkin )
4188a978a17SVictor Perevertkin {
4198a978a17SVictor Perevertkin return IoGetAttachedDeviceReference(DriverObject);
4208a978a17SVictor Perevertkin }
4218a978a17SVictor Perevertkin
4228a978a17SVictor Perevertkin __inline
4238a978a17SVictor Perevertkin VOID
MxDeleteSymbolicLink(__in PUNICODE_STRING Value)4248a978a17SVictor Perevertkin Mx::MxDeleteSymbolicLink(
4258a978a17SVictor Perevertkin __in PUNICODE_STRING Value
4268a978a17SVictor Perevertkin )
4278a978a17SVictor Perevertkin {
4288a978a17SVictor Perevertkin IoDeleteSymbolicLink(Value);
4298a978a17SVictor Perevertkin }
4308a978a17SVictor Perevertkin
4318a978a17SVictor Perevertkin __inline
4328a978a17SVictor Perevertkin VOID
MxDeleteNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST LookasideList)4338a978a17SVictor Perevertkin Mx::MxDeleteNPagedLookasideList(
4348a978a17SVictor Perevertkin _In_ PNPAGED_LOOKASIDE_LIST LookasideList
4358a978a17SVictor Perevertkin )
4368a978a17SVictor Perevertkin {
4378a978a17SVictor Perevertkin ExDeleteNPagedLookasideList(LookasideList);
4388a978a17SVictor Perevertkin }
4398a978a17SVictor Perevertkin
4408a978a17SVictor Perevertkin __inline
4418a978a17SVictor Perevertkin VOID
MxDeletePagedLookasideList(_In_ PPAGED_LOOKASIDE_LIST LookasideList)4428a978a17SVictor Perevertkin Mx::MxDeletePagedLookasideList(
4438a978a17SVictor Perevertkin _In_ PPAGED_LOOKASIDE_LIST LookasideList
4448a978a17SVictor Perevertkin )
4458a978a17SVictor Perevertkin {
4468a978a17SVictor Perevertkin ExDeletePagedLookasideList(LookasideList);
4478a978a17SVictor Perevertkin }
4488a978a17SVictor Perevertkin
4498a978a17SVictor Perevertkin __inline
4508a978a17SVictor Perevertkin VOID
MxInitializeNPagedLookasideList(_Out_ PNPAGED_LOOKASIDE_LIST Lookaside,_In_opt_ PALLOCATE_FUNCTION Allocate,_In_opt_ PFREE_FUNCTION Free,_In_ ULONG Flags,_In_ SIZE_T Size,_In_ ULONG Tag,_In_ USHORT Depth)4518a978a17SVictor Perevertkin Mx::MxInitializeNPagedLookasideList(
4528a978a17SVictor Perevertkin _Out_ PNPAGED_LOOKASIDE_LIST Lookaside,
4538a978a17SVictor Perevertkin _In_opt_ PALLOCATE_FUNCTION Allocate,
4548a978a17SVictor Perevertkin _In_opt_ PFREE_FUNCTION Free,
4558a978a17SVictor Perevertkin _In_ ULONG Flags,
4568a978a17SVictor Perevertkin _In_ SIZE_T Size,
4578a978a17SVictor Perevertkin _In_ ULONG Tag,
4588a978a17SVictor Perevertkin _In_ USHORT Depth
4598a978a17SVictor Perevertkin )
4608a978a17SVictor Perevertkin {
4618a978a17SVictor Perevertkin ExInitializeNPagedLookasideList(Lookaside,
4628a978a17SVictor Perevertkin Allocate,
4638a978a17SVictor Perevertkin Free,
4648a978a17SVictor Perevertkin Flags,
4658a978a17SVictor Perevertkin Size,
4668a978a17SVictor Perevertkin Tag,
4678a978a17SVictor Perevertkin Depth);
4688a978a17SVictor Perevertkin }
4698a978a17SVictor Perevertkin
4708a978a17SVictor Perevertkin __inline
4718a978a17SVictor Perevertkin VOID
MxInitializePagedLookasideList(_Out_ PPAGED_LOOKASIDE_LIST Lookaside,_In_opt_ PALLOCATE_FUNCTION Allocate,_In_opt_ PFREE_FUNCTION Free,_In_ ULONG Flags,_In_ SIZE_T Size,_In_ ULONG Tag,_In_ USHORT Depth)4728a978a17SVictor Perevertkin Mx::MxInitializePagedLookasideList(
4738a978a17SVictor Perevertkin _Out_ PPAGED_LOOKASIDE_LIST Lookaside,
4748a978a17SVictor Perevertkin _In_opt_ PALLOCATE_FUNCTION Allocate,
4758a978a17SVictor Perevertkin _In_opt_ PFREE_FUNCTION Free,
4768a978a17SVictor Perevertkin _In_ ULONG Flags,
4778a978a17SVictor Perevertkin _In_ SIZE_T Size,
4788a978a17SVictor Perevertkin _In_ ULONG Tag,
4798a978a17SVictor Perevertkin _In_ USHORT Depth
4808a978a17SVictor Perevertkin )
4818a978a17SVictor Perevertkin {
4828a978a17SVictor Perevertkin ExInitializePagedLookasideList(Lookaside,
4838a978a17SVictor Perevertkin Allocate,
4848a978a17SVictor Perevertkin Free,
4858a978a17SVictor Perevertkin Flags,
4868a978a17SVictor Perevertkin Size,
4878a978a17SVictor Perevertkin Tag,
4888a978a17SVictor Perevertkin Depth);
4898a978a17SVictor Perevertkin }
4908a978a17SVictor Perevertkin
4918a978a17SVictor Perevertkin __inline
4928a978a17SVictor Perevertkin VOID
MxDeleteDevice(_In_ MdDeviceObject Device)4938a978a17SVictor Perevertkin Mx::MxDeleteDevice(
4948a978a17SVictor Perevertkin _In_ MdDeviceObject Device
4958a978a17SVictor Perevertkin )
4968a978a17SVictor Perevertkin {
4978a978a17SVictor Perevertkin IoDeleteDevice(Device);
4988a978a17SVictor Perevertkin }
4998a978a17SVictor Perevertkin
5008a978a17SVictor Perevertkin __inline
5018a978a17SVictor Perevertkin VOID
MxDetachDevice(_Inout_ MdDeviceObject Device)5028a978a17SVictor Perevertkin Mx::MxDetachDevice(
5038a978a17SVictor Perevertkin _Inout_ MdDeviceObject Device
5048a978a17SVictor Perevertkin )
5058a978a17SVictor Perevertkin {
5068a978a17SVictor Perevertkin IoDetachDevice(Device);
5078a978a17SVictor Perevertkin }
5088a978a17SVictor Perevertkin
5098a978a17SVictor Perevertkin __inline
5108a978a17SVictor Perevertkin MdDeviceObject
MxAttachDeviceToDeviceStack(_In_ MdDeviceObject SourceDevice,_In_ MdDeviceObject TargetDevice)5118a978a17SVictor Perevertkin Mx::MxAttachDeviceToDeviceStack(
5128a978a17SVictor Perevertkin _In_ MdDeviceObject SourceDevice,
5138a978a17SVictor Perevertkin _In_ MdDeviceObject TargetDevice
5148a978a17SVictor Perevertkin )
5158a978a17SVictor Perevertkin {
5168a978a17SVictor Perevertkin return IoAttachDeviceToDeviceStack(SourceDevice, TargetDevice);
5178a978a17SVictor Perevertkin }
5188a978a17SVictor Perevertkin
5198a978a17SVictor Perevertkin __inline
5208a978a17SVictor Perevertkin NTSTATUS
MxCreateDeviceSecure(_In_ PDRIVER_OBJECT DriverObject,_In_ ULONG DeviceExtensionSize,_In_opt_ PUNICODE_STRING DeviceName,_In_ DEVICE_TYPE DeviceType,_In_ ULONG DeviceCharacteristics,_In_ BOOLEAN Exclusive,_In_ PCUNICODE_STRING DefaultSDDLString,_In_opt_ LPCGUID DeviceClassGuid,_Out_ MdDeviceObject * DeviceObject)5218a978a17SVictor Perevertkin Mx::MxCreateDeviceSecure(
5228a978a17SVictor Perevertkin _In_ PDRIVER_OBJECT DriverObject,
5238a978a17SVictor Perevertkin _In_ ULONG DeviceExtensionSize,
5248a978a17SVictor Perevertkin _In_opt_ PUNICODE_STRING DeviceName,
5258a978a17SVictor Perevertkin _In_ DEVICE_TYPE DeviceType,
5268a978a17SVictor Perevertkin _In_ ULONG DeviceCharacteristics,
5278a978a17SVictor Perevertkin _In_ BOOLEAN Exclusive,
5288a978a17SVictor Perevertkin _In_ PCUNICODE_STRING DefaultSDDLString,
5298a978a17SVictor Perevertkin _In_opt_ LPCGUID DeviceClassGuid,
5308a978a17SVictor Perevertkin _Out_ MdDeviceObject *DeviceObject
5318a978a17SVictor Perevertkin )
5328a978a17SVictor Perevertkin {
533*1f377076SVictor Perevertkin #ifndef __REACTOS__ // we don't have wdmsec.lib
5348a978a17SVictor Perevertkin return IoCreateDeviceSecure(DriverObject,
5358a978a17SVictor Perevertkin DeviceExtensionSize,
5368a978a17SVictor Perevertkin DeviceName,
5378a978a17SVictor Perevertkin DeviceType,
5388a978a17SVictor Perevertkin DeviceCharacteristics,
5398a978a17SVictor Perevertkin Exclusive,
5408a978a17SVictor Perevertkin DefaultSDDLString,
5418a978a17SVictor Perevertkin DeviceClassGuid,
5428a978a17SVictor Perevertkin DeviceObject);
543*1f377076SVictor Perevertkin #else
544*1f377076SVictor Perevertkin return IoCreateDevice(
545*1f377076SVictor Perevertkin DriverObject,
546*1f377076SVictor Perevertkin DeviceExtensionSize,
547*1f377076SVictor Perevertkin DeviceName,
548*1f377076SVictor Perevertkin DeviceType,
549*1f377076SVictor Perevertkin DeviceCharacteristics,
550*1f377076SVictor Perevertkin Exclusive,
551*1f377076SVictor Perevertkin DeviceObject);
552*1f377076SVictor Perevertkin #endif
5538a978a17SVictor Perevertkin }
5548a978a17SVictor Perevertkin
5558a978a17SVictor Perevertkin __inline
5568a978a17SVictor Perevertkin NTSTATUS
MxCreateDevice(_In_ PDRIVER_OBJECT DriverObject,_In_ ULONG DeviceExtensionSize,_In_opt_ PUNICODE_STRING DeviceName,_In_ DEVICE_TYPE DeviceType,_In_ ULONG DeviceCharacteristics,_In_ BOOLEAN Exclusive,_Out_ MdDeviceObject * DeviceObject)5578a978a17SVictor Perevertkin Mx::MxCreateDevice(
5588a978a17SVictor Perevertkin _In_ PDRIVER_OBJECT DriverObject,
5598a978a17SVictor Perevertkin _In_ ULONG DeviceExtensionSize,
5608a978a17SVictor Perevertkin _In_opt_ PUNICODE_STRING DeviceName,
5618a978a17SVictor Perevertkin _In_ DEVICE_TYPE DeviceType,
5628a978a17SVictor Perevertkin _In_ ULONG DeviceCharacteristics,
5638a978a17SVictor Perevertkin _In_ BOOLEAN Exclusive,
5648a978a17SVictor Perevertkin _Out_ MdDeviceObject *DeviceObject
5658a978a17SVictor Perevertkin )
5668a978a17SVictor Perevertkin {
5678a978a17SVictor Perevertkin return IoCreateDevice(DriverObject,
5688a978a17SVictor Perevertkin DeviceExtensionSize,
5698a978a17SVictor Perevertkin DeviceName,
5708a978a17SVictor Perevertkin DeviceType,
5718a978a17SVictor Perevertkin DeviceCharacteristics,
5728a978a17SVictor Perevertkin Exclusive,
5738a978a17SVictor Perevertkin DeviceObject);
5748a978a17SVictor Perevertkin
5758a978a17SVictor Perevertkin }
5768a978a17SVictor Perevertkin
5778a978a17SVictor Perevertkin __inline
5788a978a17SVictor Perevertkin NTSTATUS
MxCreateSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName,_In_ PUNICODE_STRING DeviceName)5798a978a17SVictor Perevertkin Mx::MxCreateSymbolicLink(
5808a978a17SVictor Perevertkin _In_ PUNICODE_STRING SymbolicLinkName,
5818a978a17SVictor Perevertkin _In_ PUNICODE_STRING DeviceName
5828a978a17SVictor Perevertkin )
5838a978a17SVictor Perevertkin {
5848a978a17SVictor Perevertkin return IoCreateSymbolicLink(SymbolicLinkName, DeviceName);
5858a978a17SVictor Perevertkin }
5868a978a17SVictor Perevertkin
5878a978a17SVictor Perevertkin __inline
5888a978a17SVictor Perevertkin VOID
MxFlushQueuedDpcs()5898a978a17SVictor Perevertkin Mx::MxFlushQueuedDpcs(
5908a978a17SVictor Perevertkin )
5918a978a17SVictor Perevertkin {
5928a978a17SVictor Perevertkin KeFlushQueuedDpcs();
5938a978a17SVictor Perevertkin }
5948a978a17SVictor Perevertkin
5958a978a17SVictor Perevertkin __inline
5968a978a17SVictor Perevertkin NTSTATUS
MxOpenKey(_Out_ PHANDLE KeyHandle,_In_ ACCESS_MASK DesiredAccess,_In_ POBJECT_ATTRIBUTES ObjectAttributes)5978a978a17SVictor Perevertkin Mx::MxOpenKey(
5988a978a17SVictor Perevertkin _Out_ PHANDLE KeyHandle,
5998a978a17SVictor Perevertkin _In_ ACCESS_MASK DesiredAccess,
6008a978a17SVictor Perevertkin _In_ POBJECT_ATTRIBUTES ObjectAttributes
6018a978a17SVictor Perevertkin )
6028a978a17SVictor Perevertkin {
6038a978a17SVictor Perevertkin return ZwOpenKey(KeyHandle, DesiredAccess, ObjectAttributes);
6048a978a17SVictor Perevertkin }
6058a978a17SVictor Perevertkin
6068a978a17SVictor Perevertkin __inline
6078a978a17SVictor Perevertkin NTSTATUS
MxSetDeviceInterfaceState(_In_ PUNICODE_STRING SymbolicLinkName,_In_ BOOLEAN Enable)6088a978a17SVictor Perevertkin Mx::MxSetDeviceInterfaceState(
6098a978a17SVictor Perevertkin _In_ PUNICODE_STRING SymbolicLinkName,
6108a978a17SVictor Perevertkin _In_ BOOLEAN Enable
6118a978a17SVictor Perevertkin )
6128a978a17SVictor Perevertkin {
6138a978a17SVictor Perevertkin return IoSetDeviceInterfaceState(SymbolicLinkName, Enable);
6148a978a17SVictor Perevertkin }
6158a978a17SVictor Perevertkin
6168a978a17SVictor Perevertkin
6178a978a17SVictor Perevertkin __inline
6188a978a17SVictor Perevertkin NTSTATUS
MxRegisterDeviceInterface(_In_ PDEVICE_OBJECT PhysicalDeviceObject,_In_ const GUID * InterfaceClassGuid,_In_opt_ PUNICODE_STRING ReferenceString,_Out_ PUNICODE_STRING SymbolicLinkName)6198a978a17SVictor Perevertkin Mx::MxRegisterDeviceInterface(
6208a978a17SVictor Perevertkin _In_ PDEVICE_OBJECT PhysicalDeviceObject,
6218a978a17SVictor Perevertkin _In_ const GUID *InterfaceClassGuid,
6228a978a17SVictor Perevertkin _In_opt_ PUNICODE_STRING ReferenceString,
6238a978a17SVictor Perevertkin _Out_ PUNICODE_STRING SymbolicLinkName
6248a978a17SVictor Perevertkin )
6258a978a17SVictor Perevertkin {
6268a978a17SVictor Perevertkin return IoRegisterDeviceInterface(PhysicalDeviceObject,
6278a978a17SVictor Perevertkin InterfaceClassGuid,
6288a978a17SVictor Perevertkin ReferenceString,
6298a978a17SVictor Perevertkin SymbolicLinkName);
6308a978a17SVictor Perevertkin }
6318a978a17SVictor Perevertkin
6328a978a17SVictor Perevertkin __inline
6338a978a17SVictor Perevertkin NTSTATUS
MxDeleteKey(_In_ HANDLE KeyHandle)6348a978a17SVictor Perevertkin Mx::MxDeleteKey(
6358a978a17SVictor Perevertkin _In_ HANDLE KeyHandle
6368a978a17SVictor Perevertkin )
6378a978a17SVictor Perevertkin {
6388a978a17SVictor Perevertkin return ZwDeleteKey(KeyHandle);
6398a978a17SVictor Perevertkin }
6408a978a17SVictor Perevertkin
6418a978a17SVictor Perevertkin __inline
6428a978a17SVictor Perevertkin VOID
MxInitializeMdl(_In_ PMDL MemoryDescriptorList,_In_ PVOID BaseVa,_In_ SIZE_T Length)6438a978a17SVictor Perevertkin Mx::MxInitializeMdl(
6448a978a17SVictor Perevertkin _In_ PMDL MemoryDescriptorList,
6458a978a17SVictor Perevertkin _In_ PVOID BaseVa,
6468a978a17SVictor Perevertkin _In_ SIZE_T Length
6478a978a17SVictor Perevertkin )
6488a978a17SVictor Perevertkin {
6498a978a17SVictor Perevertkin MmInitializeMdl(MemoryDescriptorList, BaseVa, Length);
6508a978a17SVictor Perevertkin }
6518a978a17SVictor Perevertkin
6528a978a17SVictor Perevertkin __inline
6538a978a17SVictor Perevertkin PVOID
MxGetMdlVirtualAddress(_In_ PMDL Mdl)6548a978a17SVictor Perevertkin Mx::MxGetMdlVirtualAddress(
6558a978a17SVictor Perevertkin _In_ PMDL Mdl
6568a978a17SVictor Perevertkin )
6578a978a17SVictor Perevertkin {
6588a978a17SVictor Perevertkin return MmGetMdlVirtualAddress(Mdl);
6598a978a17SVictor Perevertkin }
6608a978a17SVictor Perevertkin
6618a978a17SVictor Perevertkin __inline
6628a978a17SVictor Perevertkin VOID
MxBuildPartialMdl(_In_ PMDL SourceMdl,_Inout_ PMDL TargetMdl,_In_ PVOID VirtualAddress,_In_ ULONG Length)6638a978a17SVictor Perevertkin Mx::MxBuildPartialMdl(
6648a978a17SVictor Perevertkin _In_ PMDL SourceMdl,
6658a978a17SVictor Perevertkin _Inout_ PMDL TargetMdl,
6668a978a17SVictor Perevertkin _In_ PVOID VirtualAddress,
6678a978a17SVictor Perevertkin _In_ ULONG Length
6688a978a17SVictor Perevertkin )
6698a978a17SVictor Perevertkin {
6708a978a17SVictor Perevertkin IoBuildPartialMdl(SourceMdl,
6718a978a17SVictor Perevertkin TargetMdl,
6728a978a17SVictor Perevertkin VirtualAddress,
6738a978a17SVictor Perevertkin Length
6748a978a17SVictor Perevertkin );
6758a978a17SVictor Perevertkin }
6768a978a17SVictor Perevertkin
6778a978a17SVictor Perevertkin __inline
6788a978a17SVictor Perevertkin VOID
MxQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)6798a978a17SVictor Perevertkin Mx::MxQuerySystemTime(
6808a978a17SVictor Perevertkin _Out_ PLARGE_INTEGER CurrentTime
6818a978a17SVictor Perevertkin )
6828a978a17SVictor Perevertkin {
6838a978a17SVictor Perevertkin KeQuerySystemTime(CurrentTime);
6848a978a17SVictor Perevertkin }
6858a978a17SVictor Perevertkin
6868a978a17SVictor Perevertkin __inline
6878a978a17SVictor Perevertkin NTSTATUS
MxSetValueKey(_In_ HANDLE KeyHandle,_In_ PUNICODE_STRING ValueName,_In_opt_ ULONG TitleIndex,_In_ ULONG Type,_In_opt_ PVOID Data,_In_ ULONG DataSize)6888a978a17SVictor Perevertkin Mx::MxSetValueKey(
6898a978a17SVictor Perevertkin _In_ HANDLE KeyHandle,
6908a978a17SVictor Perevertkin _In_ PUNICODE_STRING ValueName,
6918a978a17SVictor Perevertkin _In_opt_ ULONG TitleIndex,
6928a978a17SVictor Perevertkin _In_ ULONG Type,
6938a978a17SVictor Perevertkin _In_opt_ PVOID Data,
6948a978a17SVictor Perevertkin _In_ ULONG DataSize
6958a978a17SVictor Perevertkin )
6968a978a17SVictor Perevertkin {
6978a978a17SVictor Perevertkin return ZwSetValueKey(KeyHandle,
6988a978a17SVictor Perevertkin ValueName,
6998a978a17SVictor Perevertkin TitleIndex,
7008a978a17SVictor Perevertkin Type,
7018a978a17SVictor Perevertkin Data,
7028a978a17SVictor Perevertkin DataSize
7038a978a17SVictor Perevertkin );
7048a978a17SVictor Perevertkin }
7058a978a17SVictor Perevertkin
7068a978a17SVictor Perevertkin __inline
7078a978a17SVictor Perevertkin NTSTATUS
MxQueryValueKey(_In_ HANDLE KeyHandle,_In_ PUNICODE_STRING ValueName,_In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,_Out_opt_ PVOID KeyValueInformation,_In_ ULONG Length,_Out_ PULONG ResultLength)7088a978a17SVictor Perevertkin Mx::MxQueryValueKey(
7098a978a17SVictor Perevertkin _In_ HANDLE KeyHandle,
7108a978a17SVictor Perevertkin _In_ PUNICODE_STRING ValueName,
7118a978a17SVictor Perevertkin _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
7128a978a17SVictor Perevertkin _Out_opt_ PVOID KeyValueInformation,
7138a978a17SVictor Perevertkin _In_ ULONG Length,
7148a978a17SVictor Perevertkin _Out_ PULONG ResultLength
7158a978a17SVictor Perevertkin )
7168a978a17SVictor Perevertkin {
7178a978a17SVictor Perevertkin return ZwQueryValueKey(KeyHandle,
7188a978a17SVictor Perevertkin ValueName,
7198a978a17SVictor Perevertkin KeyValueInformationClass,
7208a978a17SVictor Perevertkin KeyValueInformation,
7218a978a17SVictor Perevertkin Length,
7228a978a17SVictor Perevertkin ResultLength
7238a978a17SVictor Perevertkin );
7248a978a17SVictor Perevertkin }
7258a978a17SVictor Perevertkin
7268a978a17SVictor Perevertkin __inline
7278a978a17SVictor Perevertkin NTSTATUS
MxReferenceObjectByHandle(__in HANDLE Handle,__in ACCESS_MASK DesiredAccess,__in_opt POBJECT_TYPE ObjectType,__in KPROCESSOR_MODE AccessMode,__out PVOID * Object,__out_opt POBJECT_HANDLE_INFORMATION HandleInformation)7288a978a17SVictor Perevertkin Mx::MxReferenceObjectByHandle(
7298a978a17SVictor Perevertkin __in HANDLE Handle,
7308a978a17SVictor Perevertkin __in ACCESS_MASK DesiredAccess,
7318a978a17SVictor Perevertkin __in_opt POBJECT_TYPE ObjectType,
7328a978a17SVictor Perevertkin __in KPROCESSOR_MODE AccessMode,
7338a978a17SVictor Perevertkin __out PVOID *Object,
7348a978a17SVictor Perevertkin __out_opt POBJECT_HANDLE_INFORMATION HandleInformation
7358a978a17SVictor Perevertkin )
7368a978a17SVictor Perevertkin {
7378a978a17SVictor Perevertkin return ObReferenceObjectByHandle(
7388a978a17SVictor Perevertkin Handle,
7398a978a17SVictor Perevertkin DesiredAccess,
7408a978a17SVictor Perevertkin ObjectType,
7418a978a17SVictor Perevertkin AccessMode,
7428a978a17SVictor Perevertkin Object,
7438a978a17SVictor Perevertkin HandleInformation);
7448a978a17SVictor Perevertkin }
7458a978a17SVictor Perevertkin
7468a978a17SVictor Perevertkin __inline
7478a978a17SVictor Perevertkin NTSTATUS
MxUnRegisterPlugPlayNotification(__in __drv_freesMem (Pool)PVOID NotificationEntry)7488a978a17SVictor Perevertkin Mx::MxUnRegisterPlugPlayNotification(
7498a978a17SVictor Perevertkin __in __drv_freesMem(Pool) PVOID NotificationEntry
7508a978a17SVictor Perevertkin )
7518a978a17SVictor Perevertkin {
7528a978a17SVictor Perevertkin return IoUnregisterPlugPlayNotification(NotificationEntry);
7538a978a17SVictor Perevertkin }
7548a978a17SVictor Perevertkin
7558a978a17SVictor Perevertkin
7568a978a17SVictor Perevertkin __inline
7578a978a17SVictor Perevertkin NTSTATUS
MxClose(__in HANDLE Handle)7588a978a17SVictor Perevertkin Mx::MxClose(
7598a978a17SVictor Perevertkin __in HANDLE Handle
7608a978a17SVictor Perevertkin )
7618a978a17SVictor Perevertkin {
7628a978a17SVictor Perevertkin return ZwClose(Handle);
7638a978a17SVictor Perevertkin }
7648a978a17SVictor Perevertkin
7658a978a17SVictor Perevertkin __inline
7668a978a17SVictor Perevertkin KIRQL
MxAcquireInterruptSpinLock(_Inout_ PKINTERRUPT Interrupt)7678a978a17SVictor Perevertkin Mx::MxAcquireInterruptSpinLock(
7688a978a17SVictor Perevertkin _Inout_ PKINTERRUPT Interrupt
7698a978a17SVictor Perevertkin )
7708a978a17SVictor Perevertkin {
7718a978a17SVictor Perevertkin return KeAcquireInterruptSpinLock(Interrupt);
7728a978a17SVictor Perevertkin }
7738a978a17SVictor Perevertkin
7748a978a17SVictor Perevertkin __inline
7758a978a17SVictor Perevertkin VOID
MxReleaseInterruptSpinLock(_Inout_ PKINTERRUPT Interrupt,_In_ KIRQL OldIrql)7768a978a17SVictor Perevertkin Mx::MxReleaseInterruptSpinLock(
7778a978a17SVictor Perevertkin _Inout_ PKINTERRUPT Interrupt,
7788a978a17SVictor Perevertkin _In_ KIRQL OldIrql
7798a978a17SVictor Perevertkin )
7808a978a17SVictor Perevertkin {
7818a978a17SVictor Perevertkin KeReleaseInterruptSpinLock(Interrupt, OldIrql);
7828a978a17SVictor Perevertkin }
7838a978a17SVictor Perevertkin
7848a978a17SVictor Perevertkin __inline
7858a978a17SVictor Perevertkin BOOLEAN
MxInsertQueueDpc(__inout PRKDPC Dpc,__in_opt PVOID SystemArgument1,__in_opt PVOID SystemArgument2)7868a978a17SVictor Perevertkin Mx::MxInsertQueueDpc(
7878a978a17SVictor Perevertkin __inout PRKDPC Dpc,
7888a978a17SVictor Perevertkin __in_opt PVOID SystemArgument1,
7898a978a17SVictor Perevertkin __in_opt PVOID SystemArgument2
7908a978a17SVictor Perevertkin )
7918a978a17SVictor Perevertkin {
7928a978a17SVictor Perevertkin return KeInsertQueueDpc(Dpc, SystemArgument1, SystemArgument2);
7938a978a17SVictor Perevertkin }
7948a978a17SVictor Perevertkin
7958a978a17SVictor Perevertkin
796