1 /*++
2
3 Copyright (c) Microsoft Corporation
4
5 Module Name:
6
7 FxWaitLock.cpp
8
9 Abstract:
10
11 This module implements the FxWaitLock's factory method.
12
13 Author:
14
15
16 Revision History:
17
18
19 --*/
20
21 #include "fxsupportpch.hpp"
22
23 #if defined(EVENT_TRACING)
24 // Tracing support
25 extern "C" {
26 #include "fxwaitlock.tmh"
27 }
28 #endif
29
30 __checkReturn
31 NTSTATUS
_Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals,__in_opt PWDF_OBJECT_ATTRIBUTES Attributes,__in_opt FxObject * ParentObject,__in BOOLEAN AssignDriverAsDefaultParent,__out WDFWAITLOCK * LockHandle)32 FxWaitLock::_Create(
33 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
34 __in_opt PWDF_OBJECT_ATTRIBUTES Attributes,
35 __in_opt FxObject* ParentObject,
36 __in BOOLEAN AssignDriverAsDefaultParent,
37 __out WDFWAITLOCK* LockHandle
38 )
39 {
40 FxWaitLock* lock;
41 NTSTATUS status;
42
43 *LockHandle = NULL;
44
45 lock = new (FxDriverGlobals, Attributes) FxWaitLock(FxDriverGlobals);
46 if (lock == NULL) {
47 status = STATUS_INSUFFICIENT_RESOURCES;
48 DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
49 "Memory allocation failed: %!STATUS!", status);
50 return status;
51 }
52
53 status = lock->Initialize();
54 if (!NT_SUCCESS(status)) {
55 lock->DeleteFromFailedCreate();
56 DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
57 "faield to initialize wait lock: %!STATUS!", status);
58 return status;
59 }
60
61 status = lock->Commit(Attributes,
62 (WDFOBJECT*)LockHandle,
63 ParentObject,
64 AssignDriverAsDefaultParent);
65
66 if (!NT_SUCCESS(status)) {
67 lock->DeleteFromFailedCreate();
68 }
69
70 return status;
71 }
72
73
74
75