ReactOS  0.4.15-dev-3451-gf606fec
fxuserobjectapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxUserObjectApi.cpp
8 
9 Abstract:
10 
11  This modules implements the C API's for the FxUserObject.
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 --*/
24 
25 #include "fxobjectpch.hpp"
26 
27 #include "fxuserobject.hpp"
28 
29 // Tracing support
30 extern "C" {
31 #if defined(EVENT_TRACING)
32 #include "FxUserObjectApi.tmh"
33 #endif
34 }
35 
36 
37 extern "C" {
38 
42 STDCALL
43 WDFEXPORT(WdfObjectCreate)(
44  __in
46  __in_opt
48  __out
50  )
51 
52 /*++
53 
54 Routine Description:
55 
56  This creates a general WDF object for use by the device driver.
57 
58  It participates in general framework object contracts in that it:
59 
60  - Has a handle and a reference count
61  - Has Cleanup and Destroy callbacks
62  - Supports driver context memory and type
63  - Can have child objects
64  - Can optionally have a parent object and automatically delete with it
65 
66  It is intended to allow a WDF device driver to use this object to
67  create its own structures that can participate in frameworks lifetime
68  management.
69 
70  The device driver can use the objects context memory and type to
71  represent its own internal data structures, and can further assign
72  device driver specific resources and release them by registering
73  for EvtObjectCleanup, and EvtObjectDestroy callbacks.
74 
75  The object may be deleted by using the WdfObjectDelete API.
76 
77  Since the object is represented by a frameworks handle, it can be
78  reference counted, and validated.
79 
80  Class drivers may use this object to define framework object handles
81  for their types.
82 
83 Arguments:
84 
85  Attributes - WDF_OBJECT_ATTRIBUTES to define a parent object, context memory,
86  Cleanup and Destroy handlers.
87 
88 Return Value:
89 
90  NTSTATUS
91 
92 --*/
93 
94 {
95  DDI_ENTRY();
96 
101 
102  pUserObject = NULL;
104 
105  //
106  // Get the parent's globals if it is present
107  //
109  Attributes))) {
110  FxObject* pParent;
111 
113  Attributes->ParentObject,
115  (PVOID*)&pParent,
117  }
118 
120 
122  Attributes,
124  );
126  return status;
127  }
128 
129  //
130  // Create the FxObject.
131  //
135  *Object = handle;
136 
139  "Created UserObject Handle 0x%p",
140  handle);
141  }
142 
143  return status;
144 }
145 
146 } // extern "C" the entire file
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
NTSTATUS status
#define __in_opt
Definition: dbghelp.h:38
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
LONG NTSTATUS
Definition: precomp.h:26
WDFOBJECT handle
DriverGlobals
FxPointerNotNull(pFxDriverGlobals, Object)
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
FxUserObject * pUserObject
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define __out
Definition: dbghelp.h:62
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFOBJECT * Object
#define STDCALL
Definition: wdf.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline WDFOBJECT GetHandle(VOID)
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out FxUserObject **Object)
FxObject * pParent
Definition: fxdpcapi.cpp:86
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
#define TRACINGUSEROBJECT
Definition: dbgtrace.h:64
_Must_inspect_result_ __drv_maxIRQL(DISPATCH_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfObjectCreate)(__in PWDF_DRIVER_GLOBALS DriverGlobals
PFX_DRIVER_GLOBALS pFxDriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define __in
Definition: dbghelp.h:35
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97