1 
2 /*++
3 
4 Copyright (c) Microsoft. All rights reserved.
5 
6 Module Name:
7 
8     FxUserObject.hpp
9 
10 Abstract:
11 
12     This module implements the user object that device
13     driver writers can use to take advantage of the
14     driver frameworks infrastructure.
15 
16 Author:
17 
18 
19 
20 
21 Environment:
22 
23     Both kernel and user mode
24 
25 Revision History:
26 
27 
28         Made mode agnostic
29 
30 --*/
31 
32 #ifndef _FXUSEROBJECT_H_
33 #define _FXUSEROBJECT_H_
34 
35 class FxUserObject : public FxNonPagedObject {
36 
37 private:
38 
39 public:
40 
41     static
42     _Must_inspect_result_
43     NTSTATUS
44     _Create(
45         __in     PFX_DRIVER_GLOBALS FxDriverGlobals,
46         __in_opt PWDF_OBJECT_ATTRIBUTES Attributes,
47         __out    FxUserObject** Object
48         );
49 
50     FxUserObject(
51         __in PFX_DRIVER_GLOBALS FxDriverGlobals
52         );
53 
54     virtual
55     NTSTATUS
56     QueryInterface(
57         __in FxQueryInterfaceParams* Params
58         )
59     {
60         switch (Params->Type) {
61         case FX_TYPE_USEROBJECT:
62              *Params->Object = (FxUserObject*) this;
63              break;
64 
65         default:
66             return __super::QueryInterface(Params);
67         }
68 
69         return STATUS_SUCCESS;
70     }
71 
72     __inline
73     WDFOBJECT
74     GetHandle(
75         VOID
76         )
77     {
78         return (WDFOBJECT) GetObjectHandle();
79     }
80 
81 private:
82 
83 #ifdef INLINE_WRAPPER_ALLOCATION
84 #if (FX_CORE_MODE==FX_CORE_USER_MODE)
85     static
86     USHORT
87     GetWrapperSize(
88         VOID
89         );
90 
91 public:
92     FORCEINLINE
93     PVOID
94     GetCOMWrapper(
95         VOID
96         )
97     {
98         PBYTE ptr = (PBYTE) this;
99         return (ptr + (USHORT) WDF_ALIGN_SIZE_UP(sizeof(*this), MEMORY_ALLOCATION_ALIGNMENT));
100     }
101 #endif
102 #endif
103 };
104 
105 #endif // _FXUSEROBJECT_H_
106 
107