ReactOS  0.4.15-dev-2487-g7b27e7c
mxgeneralum.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7  MxGeneralUm.h
8 
9 Abstract:
10 
11  User 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) x
27 
28 
29 
30 
31 
32 
33 
34 
35 #define REMOVE_LOCK_RELEASE_TIMEOUT_IN_SECONDS 45
36 
40  __inout PTP_WAIT Wait,
41  __in TP_WAIT_RESULT WaitResult
42  );
43 
45 
46 typedef
47 BOOLEAN
50  );
51 
53 
55 
56 typedef
57 VOID
62  );
63 
65 
66 //
67 // Define PnP notification event categories
68 //
69 
76 
77 #include "MxGeneral.h"
78 
79 __inline
80 BOOLEAN
81 Mx::IsUM(
82  )
83 {
84  return TRUE;
85 }
86 
87 __inline
88 BOOLEAN
89 Mx::IsKM(
90  )
91 {
92  return FALSE;
93 }
94 
95 __inline
98  )
99 {
100  //
101  // We can't use GetCurrentThread as it returns a pseudo handle
102  // which would have same numeric value for different threads
103  // We could use DuplicateHandle to get real handle but that has the
104  // following problems:
105  // 1) It returns different handle values for the same thread
106  // if called again without closing handle.
107  // 2) Makes the caller call CloseHandle making it inconvenient to
108  // call this function just to get an identifier for the thread
109  // 3) More expensive than GetCurrentThreadId
110  //
111  // Since framework uses the thread only for comparison, logging
112  // purposes GetCurrentThreadId works well.
113  // It is cast to PVOID to match the pointer type PKTHREAD otherwise
114  // trace functions complain of data type mismatch
115  //
116 
117  return (PVOID) ::GetCurrentThreadId();
118 }
119 
120 __inline
121 MdEThread
123  )
124 {
125  //
126  // See comments in MxGetCurrentThread.
127  //
128  return (PVOID) MxGetCurrentThread();
129 }
130 
131 __inline
132 NTSTATUS
135  )
136 {
137  #pragma prefast(suppress:__WARNING_USINGTERMINATETHREAD, "TerminateThread is the intent.");
139  DWORD err = GetLastError();
140  return WinErrorToNtStatus(err);
141  }
142  return STATUS_SUCCESS;
143 }
144 
145 __inline
146 KIRQL
148  )
149 {
150  return PASSIVE_LEVEL;
151 }
152 
153 __inline
154 VOID
155 #pragma prefast(suppress:__WARNING_UNMATCHED_DECL_ANNO, "Can't apply kernel mode annotations.");
156 Mx::MxRaiseIrql(
159  )
160 {
163 
164  DO_NOTHING();
165 }
166 
167 __inline
168 VOID
169 #pragma prefast(suppress:__WARNING_UNMATCHED_DECL_ANNO, "Can't apply kernel mode annotations.");
170 Mx::MxLowerIrql(
172  )
173 {
175 
176  DO_NOTHING();
177 }
178 
179 __inline
180 VOID
182  __out PLARGE_INTEGER TickCount
183  )
184 {
185  TickCount->QuadPart = GetTickCount();
186 }
187 
188 __inline
189 ULONG
191  )
192 {
193  //
194  // The way to get absolute time is TickCount * TimeIncrement.
195  // In UM, TickCount is expressed in miliseconds, so this
196  // conversion ensures that absolute time is expressed
197  // in 100ns units as it is in KM.
198  //
199  return 1000 * 10;
200 }
201 
202 __inline
203 VOID
205  )
206 {
207  DebugBreak();
208 }
209 
210 __inline
211 VOID
214  )
215 {
216  if (!Condition)
217  {
218 
219 
220 
221  DebugBreak();
222  }
223 }
224 
225 __inline
226 VOID
230  )
231 {
233 
234  if (!Condition)
235  {
236 
237 
238 
239  DebugBreak();
240  }
241 }
242 
243 __inline
244 VOID
245 #pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
246 Mx::MxEnterCriticalRegion(
247  )
248 {
249 
250 
251 
252 
253 
254  // DO_NOTHING();
255 }
256 
257 __inline
258 VOID
259 #pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
260 Mx::MxLeaveCriticalRegion(
261  )
262 {
263 
264 
265 
266 
267 
268  // DO_NOTHING();
269 }
270 
271 __inline
272 VOID
274  __in KPROCESSOR_MODE WaitMode,
277  )
278 {
279  UNREFERENCED_PARAMETER(WaitMode);
280  ASSERTMSG("Interval must be relative\n", Interval->QuadPart <= 0);
281 
282  LARGE_INTEGER intervalMillisecond;
283 
284  //
285  // This function uses KeDelayExecutionThread's contract, where relative
286  // intervals are negative numbers expressed in 100ns units. We must
287  // flip the sign and convert to ms units before calling SleepEx.
288  //
289  intervalMillisecond.QuadPart = -1 * Interval->QuadPart;
290  intervalMillisecond.QuadPart /= 10 * 1000;
291 
292  SleepEx((DWORD)intervalMillisecond.QuadPart, Alertable);
293 }
294 
295 __inline
296 PVOID
299  )
300 /*++
301 Description:
302 
303  This function is meant to be called only by mode agnostic code
304  System routine is assumed to be in ntdll.dll.
305 
306  This is because system routines (Rtl*) that can be used both
307  in kernel mode as well as user mode reside in ntdll.dll.
308  Kernel32.dll contains the user mode only Win32 API.
309 
310 Arguments:
311 
312  MxFuncName FuncName -
313 
314 Return Value:
315 
316  NTSTATUS Status code.
317 --*/
318 {
319  HMODULE hMod;
320 
321  hMod = GetModuleHandleW(L"ntdll.dll");
322 
323  return GetProcAddress(hMod, FuncName);
324 }
325 
326 __inline
327 VOID
330  )
331 {
333 
334 
335 
336 
337 
338 
339  // DO_NOTHING();
340 }
341 
342 __inline
343 VOID
346  )
347 {
349 
350 
351 
352 
353 
354 
355  // DO_NOTHING();
356 }
357 
358 __inline
359 VOID
365  )
366 {
370 
371  ZeroMemory(Lock, sizeof(*Lock));
372  Lock->IoCount = 1;
373  Lock->Removed = FALSE;
374  Lock->RemoveEvent = NULL;
375  Lock->ReleaseRemLockAndWaitStatus = (DWORD)-1;
376 }
377 
378 __inline
379 NTSTATUS
381  __in MdRemoveLock RemoveLock,
383  )
384 {
386  LONG lockValue;
388 
389  lockValue = InterlockedIncrement(&RemoveLock->IoCount);
390 
391  ASSERT(lockValue > 0);
392 
393  if (! RemoveLock->Removed) {
394  return STATUS_SUCCESS;
395  }
396  else {
397  if (0 == InterlockedDecrement(&RemoveLock->IoCount)) {
398  if (! SetEvent(RemoveLock->RemoveEvent)) {
400  0, 0, 0, 0);
401  }
402  }
404  }
405 
406  return status;
407 }
408 
409 __inline
410 VOID
412  __in MdRemoveLock RemoveLock,
413  __in PVOID Tag
414  )
415 {
417  LONG lockValue;
418 
419  lockValue = InterlockedDecrement(&RemoveLock->IoCount);
420 
421  ASSERT(0 <= lockValue);
422 
423  if (0 == lockValue) {
424  ASSERT (RemoveLock->Removed);
425 
426  //
427  // The device needs to be removed. Signal the remove event
428  // that it's safe to go ahead.
429  //
430  if (! SetEvent(RemoveLock->RemoveEvent)) {
432  0, 0, 0, 0);
433  }
434  }
435 }
436 
437 __inline
438 VOID
440  __in MdRemoveLock RemoveLock,
441  __in PVOID Tag
442  )
443 {
445  LONG ioCount;
446  DWORD retVal = ERROR_SUCCESS;
447 
448  RemoveLock->Removed = TRUE;
449 
450  ioCount = InterlockedDecrement (&RemoveLock->IoCount);
451  ASSERT(0 < ioCount);
452 
453  if (0 < InterlockedDecrement (&RemoveLock->IoCount)) {
454  retVal = WaitForSingleObject(RemoveLock->RemoveEvent,
456  ASSERT(retVal == WAIT_OBJECT_0);
457  }
458 
459  // This only serves as a debugging aid.
460  RemoveLock->ReleaseRemLockAndWaitStatus = retVal;
461 }
462 
463 __inline
464 BOOLEAN
466  VOID
467  )
468 {
469 
470 
471 
472 
473  //
474  // Thread stack is not so scarce in UM so return TRUE always
475  //
476  return TRUE;
477 }
478 
479 __inline
480 VOID
481 #pragma prefast(suppress:__WARNING_UNMATCHED_DECL_ANNO, "Can't apply kernel mode annotations.");
482 Mx::ReleaseCancelSpinLock(
483  __in KIRQL Irql
484  )
485 {
487 
488  //
489  // UMDF Host doesn't have cancel spinlock equivalent concept so do nothing.
490  //
491  DO_NOTHING();
492 }
493 
494 __inline
495 NTSTATUS
497  __out PCALLBACK_OBJECT *CallbackObject,
501  )
502 {
503  UNREFERENCED_PARAMETER(CallbackObject);
507 
508  return STATUS_UNSUCCESSFUL;
509 }
510 
511 __inline
512 PVOID
514  __in PCALLBACK_OBJECT CallbackObject,
517  )
518 {
519  UNREFERENCED_PARAMETER(CallbackObject);
522 
523  ASSERTMSG("Not implemented for UMDF\n", FALSE);
524 
525  return NULL;
526 }
527 
528 __inline
529 VOID
531  __in PVOID CbRegistration
532  )
533 {
534  UNREFERENCED_PARAMETER(CbRegistration);
535 
536  ASSERTMSG("Not implemented for UMDF\n", FALSE);
537 }
538 
539 __inline
540 VOID
542  __in PMDL Mdl
543  )
544 {
546 
547  ASSERTMSG("Not implemented for UMDF\n", FALSE);
548 }
549 
550 __inline
551 PVOID
553  __inout PMDL Mdl,
555  )
556 {
559 
560  ASSERTMSG("Not implemented for UMDF\n", FALSE);
561 
562  return NULL;
563 }
564 
565 __inline
566 VOID
569  )
570 {
572 
573  ASSERTMSG("Not implemented for UMDF\n", FALSE);
574 }
575 
576 __inline
577 PVOID
581  )
582 {
585 
586  ASSERTMSG("Not implemented for UMDF\n", FALSE);
587 
588  return NULL;
589 }
590 
591 __inline
592 NTSTATUS
596  _In_ ULONG DriverObjectExtensionSize,
597  // When successful, this always allocates already-aliased memory.
598  _Post_ _At_(*DriverObjectExtension, _When_(return==0,
600  _When_(return == 0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize))
601  PVOID *DriverObjectExtension
602  )
603 {
606  UNREFERENCED_PARAMETER(DriverObjectExtensionSize);
607  UNREFERENCED_PARAMETER(DriverObjectExtension);
608 
609  ASSERTMSG("Not implemented for UMDF\n", FALSE);
610 
611  return STATUS_UNSUCCESSFUL;
612 }
613 
614 __inline
618  )
619 {
621 
622  ASSERTMSG("Not implemented for UMDF\n", FALSE);
623 
624  return NULL;
625 }
626 
627 __inline
628 VOID
631  )
632 {
634 
635  ASSERTMSG("Not implemented for UMDF\n", FALSE);
636 }
637 
638 __inline
639 VOID
642  )
643 {
645 }
646 
647 __inline
648 VOID
651  )
652 {
654 
655  ASSERTMSG("Not implemented for UMDF\n", FALSE);
656 }
657 
658 __inline
659 VOID
662  _In_opt_ PALLOCATE_FUNCTION Allocate,
663  _In_opt_ PFREE_FUNCTION Free,
664  _In_ ULONG Flags,
665  _In_ SIZE_T Size,
666  _In_ ULONG Tag,
668  )
669 {
670 
678 
679  //ASSERTMSG("Not implemented for UMDF\n", FALSE);
680 
681 }
682 
683 __inline
684 VOID
687  _In_opt_ PALLOCATE_FUNCTION Allocate,
688  _In_opt_ PFREE_FUNCTION Free,
689  _In_ ULONG Flags,
690  _In_ SIZE_T Size,
691  _In_ ULONG Tag,
693  )
694 {
695 
703 
704  //ASSERTMSG("Not implemented for UMDF\n", FALSE);
705 
706 }
707 
708 __inline
709 VOID
712  )
713 {
715 
716 
717 
718 
719  //
720  // Host's device stack object holds the only reference to the host devices.
721  // The infrastructure controls the device object's lifetime.
722  //
723  DO_NOTHING();
724 }
725 
726 __inline
727 NTSTATUS
730  _In_ ULONG DeviceExtensionSize,
735  _In_ PCUNICODE_STRING DefaultSDDLString,
738  )
739 {
741  UNREFERENCED_PARAMETER(DeviceExtensionSize);
746  UNREFERENCED_PARAMETER(DefaultSDDLString);
749 
750  ASSERTMSG("Not implemented for UMDF\n", FALSE);
751 
752  return STATUS_SUCCESS;
753 }
754 
755 __inline
760  )
761 {
762 
765 
766  ASSERTMSG("Not implemented for UMDF\n", FALSE);
767 
768  return NULL;
769 }
770 
771 __inline
772 NTSTATUS
775  _In_ ULONG DeviceExtensionSize,
781  )
782 {
784  UNREFERENCED_PARAMETER(DeviceExtensionSize);
790 
791  ASSERTMSG("Not implemented for UMDF\n", FALSE);
792 
793  return STATUS_SUCCESS;
794 
795 }
796 
797 __inline
798 NTSTATUS
802  )
803 {
806 
807  ASSERTMSG("Not implemented for UMDF\n", FALSE);
808 
809  return STATUS_NOT_IMPLEMENTED;
810 }
811 
812 __inline
813 VOID
815  )
816 {
817  //
818  // Not supported for UMDF
819  //
820 }
821 
822 __inline
823 NTSTATUS
828  )
829 {
833 
834  ASSERTMSG("Not implemented for UMDF\n", FALSE);
835 
836  return STATUS_NOT_IMPLEMENTED;
837 }
838 
839 __inline
840 NTSTATUS
844  )
845 {
848 
849  ASSERTMSG("Not implemented for UMDF\n", FALSE);
850 
851  return STATUS_NOT_IMPLEMENTED;
852 }
853 
854 
855 __inline
856 NTSTATUS
862  )
863 {
868 
869  ASSERTMSG("Not implemented for UMDF\n", FALSE);
870 
871  return STATUS_NOT_IMPLEMENTED;
872 }
873 
874 __inline
875 NTSTATUS
878  )
879 
880 {
882 
883  ASSERTMSG("Not implemented for UMDF\n", FALSE);
884 
885  return STATUS_NOT_IMPLEMENTED;
886 }
887 
888 __inline
889 VOID
892  _In_ PVOID BaseVa,
894  )
895 {
897  UNREFERENCED_PARAMETER(BaseVa);
899 
900  ASSERTMSG("Not implemented for UMDF\n", FALSE);
901 
902 }
903 
904 __inline
905 PVOID
907  _In_ PMDL Mdl
908  )
909 {
911 
912  ASSERTMSG("Not implemented for UMDF\n", FALSE);
913 
914  return NULL;
915 }
916 
917 __inline
918 VOID
920  _In_ PMDL SourceMdl,
924  )
925 {
926  UNREFERENCED_PARAMETER(SourceMdl);
930 
931  ASSERTMSG("Not implemented for UMDF\n", FALSE);
932 }
933 
934 __inline
935 VOID
937  _Out_ PLARGE_INTEGER CurrentTime
938  )
939 {
940  UNREFERENCED_PARAMETER(CurrentTime);
941 
942  ASSERTMSG("Not implemented for UMDF\n", FALSE);
943 }
944 
945 __inline
946 NTSTATUS
951  _In_ ULONG Type,
954  )
955 {
962 
963  ASSERTMSG("Not implemented for UMDF\n", FALSE);
964 
965  return STATUS_NOT_IMPLEMENTED;
966 }
967 
968 __inline
969 NTSTATUS
974  _Out_opt_ PVOID KeyValueInformation,
975  _In_ ULONG Length,
977 )
978 {
982  UNREFERENCED_PARAMETER(KeyValueInformation);
985 
986  ASSERTMSG("Not implemented for UMDF\n", FALSE);
987 
988  return STATUS_NOT_IMPLEMENTED;
989 }
990 
991 __inline
992 NTSTATUS
995  )
996 {
998 
999  ASSERTMSG("Not implemented for UMDF\n", FALSE);
1000 
1001  return STATUS_NOT_IMPLEMENTED;
1002 }
1003 
1004 __inline
1005 NTSTATUS
1007  __in HANDLE Handle,
1011  __out PVOID *Object,
1013  )
1014 {
1021 
1022  ASSERTMSG("Not implemented for UMDF\n", FALSE);
1023 
1024  return STATUS_NOT_IMPLEMENTED;
1025 }
1026 
1027 __inline
1028 NTSTATUS
1029 Mx::MxClose(
1031  )
1032 {
1034 
1035  return STATUS_SUCCESS;
1036 }
1037 
1038 __inline
1039 KIRQL
1042  )
1043 {
1045 
1046  ASSERTMSG("Not implemented for UMDF\n", FALSE);
1047  return PASSIVE_LEVEL;
1048 }
1049 
1050 __inline
1051 VOID
1055  )
1056 {
1059 
1060  ASSERTMSG("Not implemented for UMDF\n", FALSE);
1061 }
1062 
1063 __inline
1064 BOOLEAN
1066  __inout PRKDPC Dpc,
1069 )
1070 {
1074 
1075  ASSERTMSG("Not implemented for UMDF\n", FALSE);
1076  return FALSE;
1077 }
1078 
static __inline PVOID MxGetMdlVirtualAddress(_In_ PMDL Mdl)
Definition: mxgeneralkm.h:654
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
_Inout_ PMDL TargetMdl
Definition: iofuncs.h:728
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
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:322
_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
CALLBACK_FUNCTION MdCallbackFunctionType
Definition: mxgeneralum.h:64
#define CloseHandle
Definition: compat.h:598
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
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
_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
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:586
_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:688
static __inline VOID MxBuildMdlForNonPagedPool(__inout PMDL Mdl)
Definition: mxgeneralkm.h:376
#define __in_opt
Definition: dbghelp.h:38
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ BOOLEAN Create
Definition: pstypes.h:527
static __inline VOID MxQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)
Definition: mxgeneralkm.h:679
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
_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
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
InterruptSynchronizeRoutine * MdInterruptSynchronizeRoutine
Definition: mxgeneralum.h:52
_IO_NOTIFICATION_EVENT_CATEGORY
Definition: iotypes.h:1223
BOOLEAN InterruptSynchronizeRoutine(__in PVOID SynchronizeContext)
Definition: mxgeneralum.h:48
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
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
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1664
enum _IO_NOTIFICATION_EVENT_CATEGORY IO_NOTIFICATION_EVENT_CATEGORY
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:688
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define REMOVE_LOCK_RELEASE_TIMEOUT_IN_SECONDS
Definition: mxgeneralum.h:35
#define __inout_opt
Definition: dbghelp.h:53
char * LPSTR
Definition: xmlstorage.h:182
__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
#define DWORD
Definition: nt_native.h:44
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
#define _In_opt_
Definition: no_sal2.h:212
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
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
#define _Post_
Definition: no_sal2.h:48
UCHAR KIRQL
Definition: env_spec_w32.h:591
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
THREADPOOL_WAIT_CALLBACK * MdInterruptServiceRoutine
Definition: mxgeneralum.h:44
return STATUS_NOT_IMPLEMENTED
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
#define __out_opt
Definition: dbghelp.h:65
_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
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
static __inline MdDeviceObject MxGetAttachedDeviceReference(__in MdDeviceObject DriverObject)
Definition: mxgeneralkm.h:415
_Inout_ PMDL MemoryDescriptorList
Definition: mmfuncs.h:405
long LONG
Definition: pedump.c:60
#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
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:395
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
#define __drv_aliasesMem
Definition: btrfs_drv.h:205
_In_ WDFDEVICE _In_ ULONG DeviceCharacteristics
Definition: wdfdevice.h:2772
#define __out
Definition: dbghelp.h:62
void WINAPI DebugBreak(void)
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 _Out_
Definition: no_sal2.h:160
_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
struct _TP_CALLBACK_INSTANCE * PTP_CALLBACK_INSTANCE
Definition: winnt_old.h:4303
__drv_aliasesMem _In_ PVOID ClientIdentificationAddress
Definition: iofuncs.h:1026
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
_In_ PVOID Argument2
Definition: classpnp.h:721
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_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 _Out_opt_
Definition: no_sal2.h:214
static __inline BOOLEAN IsUM()
Definition: mxgeneralkm.h:45
#define __drv_allocatesMem(kind)
Definition: driverspecs.h:239
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
#define WAIT_OBJECT_0
Definition: winbase.h:403
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
#define ASSERT(a)
Definition: mode.c:45
static __inline PVOID MxGetSystemAddressForMdlSafe(__inout PMDL Mdl, __in ULONG Priority)
Definition: mxgeneralkm.h:366
CALLBACK_FUNCTION * MdCallbackFunction
Definition: mxgeneralkm.h:35
#define HRESULT_FROM_NT(x)
Definition: winerror.h:94
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
Definition: bufpool.h:50
Type
Definition: Type.h:6
__in PWDFDEVICE_INIT __in BOOLEAN Exclusive
unsigned long DWORD
Definition: ntddk_ex.h:95
_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 _Inout_
Definition: no_sal2.h:162
static __inline VOID MxBuildPartialMdl(_In_ PMDL SourceMdl, _Inout_ PMDL TargetMdl, _In_ PVOID VirtualAddress, _In_ ULONG Length)
Definition: mxgeneralkm.h:663
struct _CALLBACK_OBJECT * PCALLBACK_OBJECT
Definition: mxgeneralum.h:54
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define _Outptr_result_bytebuffer_(s)
Definition: no_sal2.h:288
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
#define _Post_notnull_
Definition: sal.h:701
_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
static const WCHAR L[]
Definition: oid.c:1250
#define InterlockedDecrement
Definition: armddk.h:52
static __inline NTSTATUS MxSetDeviceInterfaceState(_In_ PUNICODE_STRING SymbolicLinkName, _In_ BOOLEAN Enable)
Definition: mxgeneralkm.h:608
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: ketypes.h:687
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
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
#define err(...)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_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
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 _In_
Definition: no_sal2.h:158
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static __inline VOID MxReleaseRemoveLock(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:278
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
static __inline VOID MxFlushQueuedDpcs()
Definition: mxgeneralkm.h:589
#define InterlockedIncrement
Definition: armddk.h:53
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
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG AllocateTag
Definition: iofuncs.h:1065
#define _At_(t, a)
Definition: no_sal2.h:40
#define DEVICE_TYPE
Definition: guid.c:10
VOID THREADPOOL_WAIT_CALLBACK(__inout PTP_CALLBACK_INSTANCE Instance, __inout_opt PVOID Context, __inout PTP_WAIT Wait, __in TP_WAIT_RESULT WaitResult)
Definition: mxgeneralum.h:37
CALLBACK_FUNCTION * MdCallbackFunction
Definition: mxgeneralum.h:64
_In_ CONST GUID * InterfaceClassGuid
Definition: iofuncs.h:1134
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
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:254
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define _When_(c, a)
Definition: no_sal2.h:38
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
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
unsigned int ULONG
Definition: retypes.h:1
static __inline VOID MxDeleteDevice(_In_ MdDeviceObject Device)
Definition: mxgeneralkm.h:493
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
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
static __inline PVOID MxGetDriverObjectExtension(__in MdDriverObject DriverObject, __in PVOID ClientIdentificationAddress)
Definition: mxgeneralkm.h:385
#define GetProcAddress(x, y)
Definition: compat.h:612
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define STATUS_SUCCESS
Definition: shellext.h:65
static __inline ULONG MxQueryTimeIncrement()
Definition: mxgeneralkm.h:125
_In_ ULONG _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass
Definition: cmfuncs.h:93
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:1065
THREADPOOL_WAIT_CALLBACK MdInterruptServiceRoutineType
Definition: mxgeneralum.h:44
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
#define __in
Definition: dbghelp.h:35
InterruptSynchronizeRoutine MdInterruptSynchronizeRoutineType
Definition: mxgeneralum.h:52
static SERVICE_STATUS status
Definition: service.c:31
#define WDF_VIOLATION
Definition: mx.h:37
_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
IN PVOID Instance
Definition: pci.h:361
static __inline BOOLEAN MxInsertQueueDpc(__inout PRKDPC Dpc, __in_opt PVOID SystemArgument1, __in_opt PVOID SystemArgument2)
Definition: mxgeneralkm.h:786
enum _KEY_VALUE_INFORMATION_CLASS KEY_VALUE_INFORMATION_CLASS
Definition: reg.c:135
LONGLONG QuadPart
Definition: typedefs.h:114
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:2551
#define DO_NOTHING()
Definition: mxgeneral.h:32
Definition: ps.c:97