ReactOS  0.4.15-dev-2700-g4b4ffa9
mxpagedlockum.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7  MxPagedLockUm.h
8 
9 Abstract:
10 
11  User mode implementation of paged lock defined in
12  MxPagedLock.h
13 
14 Author:
15 
16 
17 
18 Revision History:
19 
20 
21 
22 --*/
23 
24 #pragma once
25 
26 typedef struct {
30 } MdPagedLock;
31 
32 #include "MxPagedLock.h"
33 
34 __inline
36  )
37 {
38  m_Lock.Initialized = false;
40 }
41 
43 __inline
46  )
47 {
49  m_Lock.Initialized = true;
50 
51  return S_OK;
52  }
53  else {
55  return WinErrorToNtStatus(err);
56  }
57 }
58 
59 __inline
60 VOID
61 #pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
62 MxPagedLockNoDynam::Acquire(
63  )
64 {
66 
67  DWORD threadId = GetCurrentThreadId();
68 
69  if (threadId == m_Lock.OwnerThreadId) {
70  Mx::MxAssertMsg("Recursive acquision of the lock is not allowed", FALSE);
71  }
72 
74 }
75 
76 __inline
77 VOID
79  )
80 {
81  MxPagedLockNoDynam::Acquire();
82 }
83 
84 __inline
85 BOOLEAN
86 #pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
87 MxPagedLockNoDynam::TryToAcquire(
88  )
89 {
91 }
92 
93 
94 __inline
95 VOID
96 #pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
98  )
99 {
100  m_Lock.OwnerThreadId = 0;
101 
103 }
104 
105 __inline
106 VOID
108  )
109 {
111 }
112 
113 __inline
114 VOID
116  )
117 {
119  m_Lock.Initialized = false;
120 }
121 
122 __inline
124  )
125 {
126  if (m_Lock.Initialized) {
127  this->Uninitialize();
128  }
129 }
MdPagedLock m_Lock
Definition: mxpagedlock.h:40
#define _Must_inspect_result_
Definition: no_sal2.h:62
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
#define TRUE
Definition: types.h:120
bool Initialized
Definition: mxpagedlockum.h:28
__inline VOID ReleaseUnsafe()
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
__inline VOID AcquireUnsafe()
Definition: mxpagedlockkm.h:78
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__inline ~MxPagedLock()
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
DWORD OwnerThreadId
Definition: mxpagedlockum.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ __inline NTSTATUS Initialize()
Definition: mxpagedlockkm.h:52
BOOL WINAPI TryEnterCriticalSection(LPCRITICAL_SECTION)
#define err(...)
static __inline VOID MxAssertMsg(__in LPSTR Message, __in BOOLEAN Condition)
Definition: mxgeneralkm.h:176
__inline MxPagedLock()
Definition: mxpagedlockkm.h:33
CRITICAL_SECTION Lock
Definition: mxpagedlockum.h:27
#define S_OK
Definition: intsafe.h:51
_In_ BOOLEAN Release
Definition: cdrom.h:920
__inline VOID Uninitialize()
FAST_MUTEX MdPagedLock
Definition: mxpagedlockkm.h:28
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)