ReactOS  0.4.15-dev-3308-g9455def
mxgeneralkm.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7  MxGeneralKm.h
8 
9 Abstract:
10 
11  Kernel mode implementation for general OS
12  functions defined in MxGeneral.h
13 
14 Author:
15 
16 
17 
18 Revision History:
19 
20 
21 
22 --*/
23 
24 #pragma once
25 
26 #define MAKE_MX_FUNC_NAME(x) L##x
39 
40 #include "mxgeneral.h"
41 #include <ntstrsafe.h>
42 
43 __inline
44 BOOLEAN
46  )
47 {
48  return FALSE;
49 }
50 
51 __inline
52 BOOLEAN
54  )
55 {
56  return TRUE;
57 }
58 
59 __inline
62  )
63 {
64  return KeGetCurrentThread();
65 }
66 
67 __inline
70  )
71 {
72  return PsGetCurrentThread();
73 }
74 
75 __inline
79  )
80 {
82 }
83 
84 __inline
85 KIRQL
87  )
88 {
89  return KeGetCurrentIrql();
90 }
91 
94 __inline
95 VOID
96 Mx::MxRaiseIrql(
99  )
100 {
102 }
103 
105 __inline
106 VOID
107 Mx::MxLowerIrql(
109  )
110 {
112 }
113 
114 __inline
115 VOID
117  __out PLARGE_INTEGER TickCount
118  )
119 {
120  KeQueryTickCount(TickCount);
121 }
122 
123 __inline
124 ULONG
126  )
127 {
128  return KeQueryTimeIncrement();
129 }
130 
131 __inline
132 VOID
134  __in ULONG BugCheckCode,
135  __in ULONG_PTR BugCheckParameter1,
136  __in ULONG_PTR BugCheckParameter2,
137  __in ULONG_PTR BugCheckParameter3,
138  __in ULONG_PTR BugCheckParameter4
139 )
140 {
141 #ifdef _MSC_VER
142  #pragma prefast(suppress:__WARNING_USE_OTHER_FUNCTION, "KeBugCheckEx is the intent.");
143 #endif
144  KeBugCheckEx(
145  BugCheckCode,
146  BugCheckParameter1,
147  BugCheckParameter2,
148  BugCheckParameter3,
149  BugCheckParameter4
150  );
151 
152  UNREACHABLE;
153 }
154 
155 __inline
156 VOID
158  )
159 {
160  DbgBreakPoint();
161 }
162 
163 __inline
164 VOID
167  )
168 {
170 
171  ASSERT(Condition); //this get defined as RtlAssert
172 }
173 
174 __inline
175 VOID
179  )
180 {
183 
184  ASSERT(Condition);
185 
186  // ASSERTMSG(Message, Condition); TODO: wtf
187 }
188 
189 _Acquires_lock_(_Global_critical_region_)
190 __inline
191 VOID
192 Mx::MxEnterCriticalRegion(
193  )
194 {
196 }
197 
198 _Releases_lock_(_Global_critical_region_)
199 __inline
200 VOID
201 Mx::MxLeaveCriticalRegion(
202  )
203 {
205 }
206 
207 __inline
208 VOID
210  __in KPROCESSOR_MODE WaitMode,
213  )
214 {
215  ASSERTMSG("Interval must be relative\n", Interval->QuadPart <= 0);
216 
218  WaitMode,
219  Alertable,
220  Interval
221  );
222 }
223 
224 __inline
225 PVOID
228  )
229 {
230  UNICODE_STRING funcName;
231 
232  RtlInitUnicodeString(&funcName, FuncName);
233  return MmGetSystemRoutineAddress(&funcName);
234 }
235 
236 __inline
237 VOID
240  )
241 {
243 }
244 
245 __inline
246 VOID
249  )
250 {
252 }
253 
254 __inline
255 VOID
261  )
262 {
264 }
265 
266 __inline
267 NTSTATUS
269  __in MdRemoveLock RemoveLock,
271  )
272 {
273  return IoAcquireRemoveLock(RemoveLock, Tag);
274 }
275 
276 __inline
277 VOID
279  __in MdRemoveLock RemoveLock,
280  __in PVOID Tag
281  )
282 {
283  IoReleaseRemoveLock(RemoveLock, Tag);
284 }
285 
286 __inline
287 VOID
289  __in MdRemoveLock RemoveLock,
290  __in PVOID Tag
291  )
292 {
293  IoReleaseRemoveLockAndWait(RemoveLock, Tag);
294 }
295 
296 __inline
297 BOOLEAN
299  VOID
300  )
301 {
302  return (IoGetRemainingStackSize() < KERNEL_STACK_SIZE/2) ? FALSE : TRUE;
303 }
304 
305 _Releases_lock_(_Global_cancel_spin_lock_)
307 __inline
308 VOID
309 Mx::ReleaseCancelSpinLock(
311  )
312 {
314 }
315 
316 __inline
317 NTSTATUS
319  __out PCALLBACK_OBJECT *CallbackObject,
323  )
324 {
325  return ExCreateCallback(
326  CallbackObject,
328  Create,
330 }
331 
332 __inline
333 PVOID
335  __in PCALLBACK_OBJECT CallbackObject,
338  )
339 {
340  return ExRegisterCallback(
341  CallbackObject,
344 }
345 
346 __inline
347 VOID
349  __in PVOID CbRegistration
350  )
351 {
352  ExUnregisterCallback(CbRegistration);
353 }
354 
355 __inline
356 VOID
358  __in PMDL Mdl
359  )
360 {
362 }
363 
364 __inline
365 PVOID
367  __inout PMDL Mdl,
369  )
370 {
372 }
373 
374 __inline
375 VOID
378  )
379 {
381 }
382 
383 __inline
384 PVOID
388  )
389 {
392 }
393 
394 __inline
395 NTSTATUS
399  _In_ ULONG DriverObjectExtensionSize,
400  // When successful, this always allocates already-aliased memory.
401  _Post_ _At_(*DriverObjectExtension, _When_(return==0,
403  _When_(return == 0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize))
404  PVOID *DriverObjectExtension
405  )
406 {
409  DriverObjectExtensionSize,
410  DriverObjectExtension);
411 }
412 
413 __inline
417  )
418 {
420 }
421 
422 __inline
423 VOID
426  )
427 {
429 }
430 
431 __inline
432 VOID
435  )
436 {
438 }
439 
440 __inline
441 VOID
444  )
445 {
447 }
448 
449 __inline
450 VOID
453  _In_opt_ PALLOCATE_FUNCTION Allocate,
454  _In_opt_ PFREE_FUNCTION Free,
455  _In_ ULONG Flags,
456  _In_ SIZE_T Size,
457  _In_ ULONG Tag,
459  )
460 {
462  Allocate,
463  Free,
464  Flags,
465  Size,
466  Tag,
467  Depth);
468 }
469 
470 __inline
471 VOID
474  _In_opt_ PALLOCATE_FUNCTION Allocate,
475  _In_opt_ PFREE_FUNCTION Free,
476  _In_ ULONG Flags,
477  _In_ SIZE_T Size,
478  _In_ ULONG Tag,
480  )
481 {
483  Allocate,
484  Free,
485  Flags,
486  Size,
487  Tag,
488  Depth);
489 }
490 
491 __inline
492 VOID
495  )
496 {
498 }
499 
500 __inline
501 VOID
504  )
505 {
507 }
508 
509 __inline
514  )
515 {
517 }
518 
519 __inline
520 NTSTATUS
523  _In_ ULONG DeviceExtensionSize,
528  _In_ PCUNICODE_STRING DefaultSDDLString,
531  )
532 {
533 #ifndef __REACTOS__ // we don't have wdmsec.lib
534  return IoCreateDeviceSecure(DriverObject,
535  DeviceExtensionSize,
536  DeviceName,
537  DeviceType,
539  Exclusive,
540  DefaultSDDLString,
542  DeviceObject);
543 #else
544  return IoCreateDevice(
545  DriverObject,
546  DeviceExtensionSize,
547  DeviceName,
548  DeviceType,
550  Exclusive,
551  DeviceObject);
552 #endif
553 }
554 
555 __inline
556 NTSTATUS
559  _In_ ULONG DeviceExtensionSize,
565 )
566 {
568  DeviceExtensionSize,
569  DeviceName,
570  DeviceType,
572  Exclusive,
573  DeviceObject);
574 
575 }
576 
577 __inline
578 NTSTATUS
582  )
583 {
585 }
586 
587 __inline
588 VOID
590  )
591 {
593 }
594 
595 __inline
596 NTSTATUS
601  )
602 {
603  return ZwOpenKey(KeyHandle, DesiredAccess, ObjectAttributes);
604 }
605 
606 __inline
607 NTSTATUS
611  )
612 {
614 }
615 
616 
617 __inline
618 NTSTATUS
624  )
625 {
630 }
631 
632 __inline
633 NTSTATUS
636  )
637 {
638  return ZwDeleteKey(KeyHandle);
639 }
640 
641 __inline
642 VOID
645  _In_ PVOID BaseVa,
647  )
648 {
650 }
651 
652 __inline
653 PVOID
655  _In_ PMDL Mdl
656  )
657 {
658  return MmGetMdlVirtualAddress(Mdl);
659 }
660 
661 __inline
662 VOID
664  _In_ PMDL SourceMdl,
668  )
669 {
670  IoBuildPartialMdl(SourceMdl,
671  TargetMdl,
673  Length
674  );
675 }
676 
677 __inline
678 VOID
680  _Out_ PLARGE_INTEGER CurrentTime
681  )
682 {
683  KeQuerySystemTime(CurrentTime);
684 }
685 
686 __inline
687 NTSTATUS
692  _In_ ULONG Type,
695  )
696 {
697  return ZwSetValueKey(KeyHandle,
698  ValueName,
699  TitleIndex,
700  Type,
701  Data,
702  DataSize
703  );
704 }
705 
706 __inline
707 NTSTATUS
712  _Out_opt_ PVOID KeyValueInformation,
713  _In_ ULONG Length,
715 )
716 {
717  return ZwQueryValueKey(KeyHandle,
718  ValueName,
720  KeyValueInformation,
721  Length,
723  );
724 }
725 
726 __inline
727 NTSTATUS
733  __out PVOID *Object,
735  )
736 {
738  Handle,
740  ObjectType,
741  AccessMode,
742  Object,
744 }
745 
746 __inline
747 NTSTATUS
750  )
751 {
753 }
754 
755 
756 __inline
757 NTSTATUS
760  )
761 {
762  return ZwClose(Handle);
763 }
764 
765 __inline
766 KIRQL
769  )
770 {
772 }
773 
774 __inline
775 VOID
779  )
780 {
782 }
783 
784 __inline
785 BOOLEAN
790 )
791 {
793 }
794 
795 
static __inline PVOID MxGetMdlVirtualAddress(_In_ PMDL Mdl)
Definition: mxgeneralkm.h:654
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
_Inout_ PMDL TargetMdl
Definition: iofuncs.h:730
static __inline NTSTATUS MxRegisterDeviceInterface(_In_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ const GUID *InterfaceClassGuid, _In_opt_ PUNICODE_STRING ReferenceString, _Out_ PUNICODE_STRING SymbolicLinkName)
Definition: mxgeneralkm.h:619
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ObjectType
Definition: metafile.c:80
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
KSYNCHRONIZE_ROUTINE * MdInterruptSynchronizeRoutine
Definition: mxgeneralkm.h:38
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:814
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
static __inline NTSTATUS MxCreateSymbolicLink(_In_ PUNICODE_STRING SymbolicLinkName, _In_ PUNICODE_STRING DeviceName)
Definition: mxgeneralkm.h:579
VOID NTAPI ExInitializePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:270
static __inline 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)
Definition: mxgeneralkm.h:728
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static ACCESS_MASK const OBJECT_ATTRIBUTES ULONG TitleIndex
Definition: reg.c:130
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:55
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:107
_Acquires_lock_(_Global_critical_region_) __inline VOID Mx
Definition: mxgeneralkm.h:189
#define _In_opt_
Definition: ms_sal.h:309
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:407
#define _Inout_
Definition: ms_sal.h:378
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1799
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
static __inline VOID MxQueryTickCount(__out PLARGE_INTEGER TickCount)
Definition: mxgeneralkm.h:116
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:690
static __inline VOID MxBuildMdlForNonPagedPool(__inout PMDL Mdl)
Definition: mxgeneralkm.h:376
#define _Out_
Definition: ms_sal.h:345
#define _At_(target, annos)
Definition: ms_sal.h:244
#define MmGetMdlVirtualAddress(_Mdl)
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IoInitializeRemoveLock(Lock, AllocateTag, MaxLockedMinutes, HighWatermark)
Definition: iofuncs.h:2833
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_In_ BOOLEAN Create
Definition: pstypes.h:527
static __inline VOID MxQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)
Definition: mxgeneralkm.h:679
#define __drv_restoresIRQL
Definition: driverspecs.h:321
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
LONG MaxLockedMinutes
Definition: lock.c:35
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:415
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725
LONG NTSTATUS
Definition: precomp.h:26
__drv_maxIRQL(HIGH_LEVEL) __drv_raisesIRQL(NewIrql) __inline VOID Mx
Definition: mxgeneralkm.h:92
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
PDEVICE_OBJECT MdDeviceObject
Definition: mxgeneralkm.h:30
static __inline KIRQL MxAcquireInterruptSpinLock(_Inout_ PKINTERRUPT Interrupt)
Definition: mxgeneralkm.h:767
static __inline NTSTATUS MxCreateDevice(_In_ MdDriverObject DriverObject, _In_ ULONG DeviceExtensionSize, _In_opt_ PUNICODE_STRING DeviceName, _In_ DEVICE_TYPE DeviceType, _In_ ULONG DeviceCharacteristics, _In_ BOOLEAN Exclusive, _Out_ MdDeviceObject *DeviceObject)
Definition: mxgeneralkm.h:557
static __inline VOID MxInitializeMdl(_In_ PMDL MemoryDescriptorList, _In_ PVOID BaseVa, _In_ SIZE_T Length)
Definition: mxgeneralkm.h:643
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1426
static __inline NTSTATUS MxUnRegisterPlugPlayNotification(__in __drv_freesMem(Pool) PVOID NotificationEntry)
Definition: mxgeneralkm.h:748
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT SourceDevice
Definition: iofuncs.h:690
#define _When_(expr, annos)
Definition: ms_sal.h:254
PFILE_OBJECT MdFileObject
Definition: mxgeneralkm.h:32
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
char * LPSTR
Definition: xmlstorage.h:182
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
__out __deref __drv_savesIRQL PKIRQL OldIrql
Definition: mxgeneral.h:98
static __inline VOID MxAssert(__in BOOLEAN Condition)
Definition: mxgeneralkm.h:165
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
KSERVICE_ROUTINE MdInterruptServiceRoutineType
Definition: mxgeneralkm.h:37
static __inline VOID UnregisterCallback(__in PVOID CbRegistration)
Definition: mxgeneralkm.h:348
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:814
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST * PNPAGED_LOOKASIDE_LIST
VOID NTAPI ExUnregisterCallback(IN PVOID CallbackRegistrationHandle)
Definition: callback.c:636
uint32_t ULONG_PTR
Definition: typedefs.h:65
static __inline 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)
Definition: mxgeneralkm.h:451
static VOID MxDetachDevice(_Inout_ MdDeviceObject Device)
Definition: mxgeneralkm.h:502
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define __out_opt
Definition: dbghelp.h:65
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
static __inline NTSTATUS MxOpenKey(_Out_ PHANDLE KeyHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
Definition: mxgeneralkm.h:597
#define FALSE
Definition: types.h:117
#define __drv_raisesIRQL(irql)
Definition: driverspecs.h:311
VOID NTAPI DbgBreakPoint(VOID)
static __inline MdDeviceObject MxGetAttachedDeviceReference(__in MdDeviceObject DriverObject)
Definition: mxgeneralkm.h:415
#define _Outptr_result_bytebuffer_(size)
Definition: ms_sal.h:472
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3514
_Inout_ PMDL MemoryDescriptorList
Definition: mmfuncs.h:405
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
VOID CALLBACK_FUNCTION(__in PVOID CallbackContext, __in_opt PVOID Argument1, __in_opt PVOID Argument2)
Definition: mxgeneralum.h:58
static __inline PVOID RegisterCallback(__in PCALLBACK_OBJECT CallbackObject, __in MdCallbackFunction CallbackFunction, __in PVOID CallbackContext)
Definition: mxgeneralkm.h:334
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:395
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
#define __drv_aliasesMem
Definition: btrfs_drv.h:205
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
Definition: wdfdevice.h:2772
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:171
#define __out
Definition: dbghelp.h:62
static __inline NTSTATUS MxDeleteKey(_In_ HANDLE KeyHandle)
Definition: mxgeneralkm.h:634
static __inline NTSTATUS MxClose(__in HANDLE Handle)
Definition: mxgeneralkm.h:758
static __inline VOID MxDeleteSymbolicLink(__in PUNICODE_STRING Link)
Definition: mxgeneralkm.h:424
unsigned char BOOLEAN
static __inline PVOID MxGetSystemRoutineAddress(__in MxFuncName FuncName)
Definition: mxgeneralkm.h:226
static __inline VOID MxDbgBreakPoint()
Definition: mxgeneralkm.h:157
_In_ POBJECT_ATTRIBUTES _In_ BOOLEAN _In_ BOOLEAN AllowMultipleCallbacks
Definition: exfuncs.h:748
static __inline NTSTATUS MxSetValueKey(_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _In_opt_ ULONG TitleIndex, _In_ ULONG Type, _In_opt_ PVOID Data, _In_ ULONG DataSize)
Definition: mxgeneralkm.h:688
#define _In_
Definition: ms_sal.h:308
VOID NTAPI ExDeletePagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:194
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
DeviceType
Definition: mmdrv.h:41
IN ULONG IN UCHAR Condition
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
__drv_aliasesMem _In_ PVOID ClientIdentificationAddress
Definition: iofuncs.h:1028
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
KIRQL OldIrql
Definition: mm.h:1502
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
static __inline MdDeviceObject MxAttachDeviceToDeviceStack(_In_ MdDeviceObject SourceDevice, _In_ MdDeviceObject TargetDevice)
Definition: mxgeneralkm.h:511
DWORD Interval
Definition: netstat.c:33
static NTSTATUS MxTerminateCurrentThread(__in NTSTATUS Status)
Definition: mxgeneralkm.h:77
Status
Definition: gdiplustypes.h:24
static __inline NTSTATUS MxAllocateDriverObjectExtension(_In_ MdDriverObject DriverObject, _In_ PVOID ClientIdentificationAddress, _In_ ULONG DriverObjectExtensionSize, _Post_ _At_(*DriverObjectExtension, _When_(return==0, __drv_aliasesMem __drv_allocatesMem(Mem) _Post_notnull_)) _When_(return==0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize)) PVOID *DriverObjectExtension)
Definition: mxgeneralkm.h:396
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
#define __drv_useCancelIRQL
Definition: driverspecs.h:331
static __inline BOOLEAN IsUM()
Definition: mxgeneralkm.h:45
#define __drv_allocatesMem(kind)
Definition: driverspecs.h:256
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define __drv_nonConstant
Definition: driverspecs.h:305
macro IMPORT Name endm macro EXPORT Name global &Name endm macro TEXTAREA section rx align endm macro DATAAREA section rw endm macro RODATAAREA section rw endm macro NESTED_ENTRY Name FuncName equ &Name PrologName equ &Name &_Prolog FuncEndName equ &Name &_end global &FuncName align func &FuncName & FuncName
Definition: kxarm.h:185
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:218
#define ASSERT(a)
Definition: mode.c:44
#define __drv_requiresIRQL(irql)
Definition: driverspecs.h:320
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
CALLBACK_FUNCTION * MdCallbackFunction
Definition: mxgeneralkm.h:35
static __inline 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)
Definition: mxgeneralkm.h:472
#define _Post_notnull_
Definition: ms_sal.h:701
#define ObDereferenceObject
Definition: obfuncs.h:203
Definition: bufpool.h:50
Type
Definition: Type.h:6
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
_In_ ACCESS_MASK _In_opt_ POBJECT_TYPE _In_ KPROCESSOR_MODE _Out_ PVOID _Out_opt_ POBJECT_HANDLE_INFORMATION HandleInformation
Definition: obfuncs.h:40
static __inline VOID MxReleaseRemoveLockAndWait(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:288
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
#define KERNEL_STACK_SIZE
static __inline VOID MxBuildPartialMdl(_In_ PMDL SourceMdl, _Inout_ PMDL TargetMdl, _In_ PVOID VirtualAddress, _In_ ULONG Length)
Definition: mxgeneralkm.h:663
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:154
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1998
CHAR Message[80]
Definition: alive.c:5
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:479
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
PDRIVER_OBJECT MdDriverObject
Definition: mxgeneralkm.h:31
static __inline NTSTATUS MxSetDeviceInterfaceState(_In_ PUNICODE_STRING SymbolicLinkName, _In_ BOOLEAN Enable)
Definition: mxgeneralkm.h:608
Definition: ketypes.h:687
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1877
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define __inout
Definition: dbghelp.h:50
static __inline VOID MxReleaseInterruptSpinLock(_Inout_ PKINTERRUPT Interrupt, _In_ KIRQL OldIrql)
Definition: mxgeneralkm.h:776
LPCWSTR MxFuncName
Definition: mxgeneralkm.h:27
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
static __inline MdEThread GetCurrentEThread()
Definition: mxgeneralkm.h:69
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
static __inline VOID MxAssertMsg(__in LPSTR Message, __in BOOLEAN Condition)
Definition: mxgeneralkm.h:176
static __inline VOID MxDeleteNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST LookasideList)
Definition: mxgeneralkm.h:433
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
static __inline NTSTATUS MxCreateDeviceSecure(_In_ MdDriverObject 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)
Definition: mxgeneralkm.h:521
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
static __inline VOID MxReleaseRemoveLock(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:278
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
_Releases_lock_(_Global_critical_region_) __inline VOID Mx
Definition: mxgeneralkm.h:198
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
static __inline VOID MxFlushQueuedDpcs()
Definition: mxgeneralkm.h:589
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
PKINTERRUPT MdInterrupt
Definition: mxgeneralkm.h:36
static __inline VOID MxInitializeRemoveLock(__in MdRemoveLock Lock, __in ULONG AllocateTag, __in ULONG MaxLockedMinutes, __in ULONG HighWatermark)
Definition: mxgeneralkm.h:256
_In_ PWDFDEVICE_INIT _In_ CONST GUID * DeviceClassGuid
Definition: wdfdevice.h:3333
static __inline VOID MxUnlockPages(__in PMDL Mdl)
Definition: mxgeneralkm.h:357
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
Definition: wdfdevice.h:3625
PIO_REMOVE_LOCK MdRemoveLock
Definition: mxgeneralkm.h:33
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG AllocateTag
Definition: iofuncs.h:1067
CALLBACK_FUNCTION MdCallbackFunctionType
Definition: mxgeneralkm.h:35
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
#define DEVICE_TYPE
Definition: guid.c:10
#define __deref
Definition: ms_sal.h:2629
#define _Out_opt_
Definition: ms_sal.h:346
_In_ CONST GUID * InterfaceClassGuid
Definition: iofuncs.h:1136
unsigned int * PULONG
Definition: retypes.h:1
#define __drv_savesIRQL
Definition: driverspecs.h:325
static DECLSPEC_NORETURN VOID MxBugCheckEx(__in ULONG BugCheckCode, __in ULONG_PTR BugCheckParameter1, __in ULONG_PTR BugCheckParameter2, __in ULONG_PTR BugCheckParameter3, __in ULONG_PTR BugCheckParameter4)
Definition: mxgeneralkm.h:133
#define __drv_freesMem(kind)
Definition: driverspecs.h:271
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define _Post_
Definition: ms_sal.h:620
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
KSERVICE_ROUTINE * MdInterruptServiceRoutine
Definition: mxgeneralkm.h:37
static __inline 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)
Definition: mxgeneralkm.h:708
_In_ HANDLE Handle
Definition: extypes.h:390
static __inline BOOLEAN MxHasEnoughRemainingThreadStack(VOID)
Definition: mxgeneralkm.h:298
PVOID NTAPI ExRegisterCallback(IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, IN PVOID CallbackContext)
Definition: callback.c:556
#define ObReferenceObject
Definition: obfuncs.h:204
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
static __inline NTSTATUS CreateCallback(__out PCALLBACK_OBJECT *CallbackObject, __in POBJECT_ATTRIBUTES ObjectAttributes, __in BOOLEAN Create, __in BOOLEAN AllowMultipleCallbacks)
Definition: mxgeneralkm.h:318
static __inline BOOLEAN IsKM()
Definition: mxgeneralkm.h:53
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNREACHABLE
PETHREAD MdEThread
Definition: mxgeneralkm.h:29
static __inline PVOID MxGetDriverObjectExtension(__in MdDriverObject DriverObject, __in PVOID ClientIdentificationAddress)
Definition: mxgeneralkm.h:385
#define IoReleaseRemoveLockAndWait(_RemoveLock, _Tag)
Definition: iofuncs.h:2774
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
static __inline ULONG MxQueryTimeIncrement()
Definition: mxgeneralkm.h:125
#define KeGetCurrentThread
Definition: hal.h:55
_In_ ULONG _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass
Definition: cmfuncs.h:93
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
static __inline VOID MxDeletePagedLookasideList(_In_ PPAGED_LOOKASIDE_LIST LookasideList)
Definition: mxgeneralkm.h:442
struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST * PPAGED_LOOKASIDE_LIST
_In_ ULONG _In_ ULONG _In_ ULONG HighWatermark
Definition: iofuncs.h:1067
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:170
PKTHREAD MxThread
Definition: mxgeneralkm.h:28
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
#define __in
Definition: dbghelp.h:35
KSYNCHRONIZE_ROUTINE MdInterruptSynchronizeRoutineType
Definition: mxgeneralkm.h:38
VOID NTAPI KeFlushQueuedDpcs(VOID)
Definition: dpc.c:919
#define IoAcquireRemoveLock(RemoveLock, Tag)
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
ULONG ACCESS_MASK
Definition: nt_native.h:40
static __inline BOOLEAN MxInsertQueueDpc(__inout PRKDPC Dpc, __in_opt PVOID SystemArgument1, __in_opt PVOID SystemArgument2)
Definition: mxgeneralkm.h:786
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
PCALLBACK_OBJECT MdCallbackObject
Definition: mxgeneralkm.h:34
enum _KEY_VALUE_INFORMATION_CLASS KEY_VALUE_INFORMATION_CLASS
Definition: reg.c:135
static __inline VOID MxDelayExecutionThread(__in KPROCESSOR_MODE WaitMode, __in BOOLEAN Alertable, __in PLARGE_INTEGER Interval)
Definition: mxgeneralkm.h:209
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3736
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
_Must_inspect_result_ _In_ LPCGUID _In_ ULONG _In_ FSRTL_ALLOCATE_ECP_FLAGS _In_opt_ PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK _Inout_ PVOID LookasideList
Definition: fltkernel.h:2550