ReactOS 0.4.15-dev-8102-g108db8f
mxlockum.h
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5ModuleName:
6
7 MxLockUm.h
8
9Abstract:
10
11 User mode implementation of lock
12 class defined in MxLock.h
13
14Author:
15
16
17
18Revision History:
19
20
21
22--*/
23
24#pragma once
25
26typedef struct {
30} MdLock;
31
32#include "DbgMacros.h"
33#include "MxLock.h"
34
35__inline
37 )
38{
40
41 m_Lock.Initialized = false;
43
45}
46
47__inline
48VOID
50 )
51{
52 BOOL ret;
53
55
57
58 //
59 // InitializeCriticalSectionAndSpinCount always returns TRUE on Vista+
60 // Assert this contract on checked builds using DBGFLAG macro.
61 //
62 if (ret) {
63 m_Lock.Initialized = true;
65 }
66
68}
69
70
71__inline
72VOID
73#pragma prefast(suppress:__WARNING_UNMATCHED_DECL_ANNO, "Can't apply kernel mode annotations.");
74MxLockNoDynam::Acquire(
76 )
77{
79
81
82 DWORD threadId = GetCurrentThreadId();
83
84 if (threadId == m_Lock.OwnerThreadId) {
85 Mx::MxAssertMsg("Recursive acquision of the lock is not allowed", FALSE);
86 }
87
88 m_Lock.OwnerThreadId = threadId;
89
91}
92
93__inline
96 VOID
97 )
98{
99 BOOLEAN acquired;
100
102
104
105 if (acquired) {
106 DWORD threadId = GetCurrentThreadId();
107
108 if (threadId == m_Lock.OwnerThreadId) {
109 Mx::MxAssertMsg("Recursive acquision of the lock is not allowed", FALSE);
110 }
111
112 m_Lock.OwnerThreadId = threadId;
113 }
114
115 return acquired;
116}
117
118__inline
119VOID
120#pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
121MxLockNoDynam::AcquireAtDpcLevel(
122 )
123{
125
126 KIRQL dontCare;
127
128 Acquire(&dontCare);
129}
130
131__inline
132VOID
133#pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
134MxLockNoDynam::Release(
136 )
137{
139
141
143
145}
146
147__inline
148VOID
149#pragma prefast(suppress:__WARNING_UNMATCHED_DEFN, "Can't apply kernel mode annotations.");
150MxLockNoDynam::ReleaseFromDpcLevel(
151 )
152{
154
156}
157
158__inline
159VOID
161 )
162{
164
166 m_Lock.Initialized = false;
167
169}
170
171__inline
173 )
174{
175 //
176 // PLEASE NOTE: shared code must not rely of d'tor uninitializing the
177 // lock. d'tor may not be invoked if the event is used in a structure
178 // which is allocated/deallocated using MxPoolAllocate/Free instead of
179 // new/delete
180 //
181
182 if (m_Lock.Initialized) {
183 this->Uninitialize();
184 }
185}
unsigned char BOOLEAN
_In_ BOOLEAN Release
Definition: cdrom.h:920
MdLock m_Lock
Definition: mxlock.h:40
CHECK_RETURN_IF_USER_MODE __inline BOOLEAN TryToAcquire(VOID)
Definition: mxlockum.h:95
__inline VOID Uninitialize()
Definition: mxlockkm.h:104
__inline VOID Initialize()
Definition: mxlockkm.h:43
__inline MxLock()
Definition: mxlockkm.h:33
__inline ~MxLock()
Definition: mxlockkm.h:111
static __inline VOID MxAssertMsg(__in LPSTR Message, __in BOOLEAN Condition)
Definition: mxgeneralkm.h:176
static __inline VOID MxAssert(__in BOOLEAN Condition)
Definition: mxgeneralkm.h:165
#define __out
Definition: dbghelp.h:62
#define ASSERT_DBGFLAG_INITIALIZED
Definition: dbgmacros.h:58
#define SET_DBGFLAG_INITIALIZED
Definition: dbgmacros.h:59
#define CLEAR_DBGFLAG_INITIALIZED
Definition: dbgmacros.h:60
#define ASSERT_DBGFLAG_NOT_INITIALIZED
Definition: dbgmacros.h:61
#define FALSE
Definition: types.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
UCHAR KIRQL
Definition: env_spec_w32.h:591
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BOOLEAN
Definition: pedump.c:73
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
bool Initialized
Definition: mxlockum.h:28
DWORD OwnerThreadId
Definition: mxlockum.h:29
CRITICAL_SECTION Lock
Definition: mxlockum.h:27
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765
int ret
BOOL WINAPI TryEnterCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778