ReactOS 0.4.15-dev-7934-g1dc8d80
fxwaitlockapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxWaitLockAPI.cpp
8
9Abstract:
10
11 This module implements the external APIs for FxWaitLock
12
13Author:
14
15
16
17Environment:
18
19 Both kernel and user mode
20
21Revision History:
22
23--*/
24
25#include "fxsupportpch.hpp"
26
27// extern the entire file
28extern "C" {
29
30
36WDFEXPORT(WdfWaitLockCreate)(
37 __in
41 __out
42 WDFWAITLOCK* Lock
43 )
44/*++
45
46Routine Description:
47 Creates a lock object which can be acquired at PASSIVE_LEVEL and will return
48 to the caller at PASSIVE_LEVEL once acquired.
49
50Arguments:
51 LockAttributes - generic attributes to be associated with the created lock
52
53 Lock - pointer to receive the newly created lock
54
55Return Value:
56 NTSTATUS
57
58 --*/
59{
60 DDI_ENTRY();
61
65
67 parent = NULL;
68
69 //
70 // Get the parent's globals if it is present
71 //
75 LockAttributes->ParentObject,
77 (PVOID*)&parent,
79 }
80
82
85 return status;
86 }
87
90 parent,
91 TRUE,
92 Lock);
93}
94
100WDFAPI
103 __in
105 __in
106 WDFWAITLOCK Lock,
109 )
110/*++
111
112Routine Description:
113 Attempts to acquire the lock object. If a non NULL timeout is provided, the
114 attempt to acquire the lock may fail if it cannot be acquired in the
115 specified time.
116
117Arguments:
118 Lock - the lock to acquire
119
120 Timeout - optional timeout in acquiring the lock. If calling at an IRQL >=
121 DISPATCH_LEVEL, then this parameter is not NULL (and should more
122 then likely be zero)
123
124Return Value:
125 STATUS_TIMEOUT if a timeout was provided and the lock could not be acquired
126 in the specified time, otherwise STATUS_SUCCESS
127
128 --*/
129{
130 DDI_ENTRY();
131
135
137 Lock,
139 (PVOID*) &pLock,
141
142 if (Timeout == NULL || *Timeout != 0) {
144 if (!NT_SUCCESS(status)) {
145 return status;
146 }
147
148 }
149
150 return pLock->AcquireLock(pFxDriverGlobals, Timeout);
151}
152
154VOID
155WDFAPI
157WDFEXPORT(WdfWaitLockRelease)(
158 __in
160 __in
161 WDFWAITLOCK Lock
162 )
163/*++
164
165Routine Description:
166 Releases a previously acquired wait lock
167
168Arguments:
169 Lock - the lock to release
170
171 --*/
172{
173 DDI_ENTRY();
174
177
179 Lock,
181 (PVOID*) &pLock,
183
184 pLock->ReleaseLock(pFxDriverGlobals);
185}
186
187} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in_opt FxObject *ParentObject, __in BOOLEAN AssignDriverAsDefaultParent, __out WDFWAITLOCK *LockHandle)
Definition: fxwaitlock.cpp:32
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_when(cond, annotes)
Definition: driverspecs.h:335
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ FX_TYPE_OBJECT
Definition: fxtypes.h:45
@ FX_TYPE_WAIT_LOCK
Definition: fxtypes.h:76
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
FxObject * parent
NTSTATUS status
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Lock, FX_TYPE_WAIT_LOCK,(PVOID *) &pLock, &pFxDriverGlobals)
PFX_DRIVER_GLOBALS fxDriverGlobals
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFWAITLOCK * Lock
__in WDFWAITLOCK __in_opt PLONGLONG Timeout
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES LockAttributes
FxWaitLock * pLock
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define _Must_inspect_result_
Definition: ms_sal.h:558
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:382
Definition: ps.c:97
#define STDCALL
Definition: wdf.h:45
_Must_inspect_result_ FORCEINLINE NTSTATUS WdfWaitLockAcquire(_In_ _Requires_lock_not_held_(_Curr_) WDFWAITLOCK Lock, _In_opt_ PLONGLONG Timeout)
Definition: wdfsync.h:173
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES LockAttributes
Definition: wdfsync.h:124
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
#define WDFAPI
Definition: wdftypes.h:53