Reactos
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxWaitLock.cpp
8
9Abstract:
10
11 This module implements the FxWaitLock's factory method.
12
13Author:
14
15
16Revision History:
17
18
19--*/
20
21#include "fxsupportpch.hpp"
22
23#if defined(EVENT_TRACING)
24// Tracing support
25extern "C" {
26#include "fxwaitlock.tmh"
27}
28#endif
29
30__checkReturn
31NTSTATUS
32FxWaitLock::_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