1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     fxldrum.h
8 
9 Abstract:
10 
11     This is the UMDF version of wdfldr.h
12 
13 
14 --*/
15 #ifndef __FXLDRUM_H__
16 #define __FXLDRUM_H__
17 
18 #define WDF_COMPONENT_NAME(a) L#a
19 
20 typedef
21 VOID
22 (*WDFFUNC)(
23     VOID
24     );
25 
26 typedef ULONG WDF_MAJOR_VERSION;
27 typedef ULONG WDF_MINOR_VERSION;
28 typedef ULONG WDF_BUILD_NUMBER;
29 
30 //
31 // Version container
32 //
33 typedef struct _WDF_VERSION {
34     WDF_MAJOR_VERSION  Major;
35     WDF_MINOR_VERSION  Minor;
36     WDF_BUILD_NUMBER   Build;
37 } WDF_VERSION;
38 
39 //
40 // WDF bind information structure.
41 //
42 typedef struct _WDF_BIND_INFO {
43     ULONG              Size;
44     PWCHAR             Component;
45     WDF_VERSION        Version;
46     ULONG              FuncCount;
47     __field_bcount(FuncCount*sizeof(WDFFUNC)) WDFFUNC* FuncTable;
48 
49 
50 
51 
52 
53     //
54     // This field is not used in UMDF
55     //
56     PVOID              Module;
57 
58 
59 
60 } WDF_BIND_INFO, * PWDF_BIND_INFO;
61 
62 typedef PVOID WDF_COMPONENT_GLOBALS, *PWDF_COMPONENT_GLOBALS;
63 
64 typedef
65 NTSTATUS
66 (*PFNLIBRARYCOMMISSION)(
67     VOID
68     );
69 
70 typedef
71 NTSTATUS
72 (*PFNLIBRARYDECOMMISSION)(
73     VOID
74     );
75 
76 typedef
77 NTSTATUS
78 (*PFNLIBRARYREGISTERCLIENT)(
79     PWDF_BIND_INFO             Info,
80     PWDF_COMPONENT_GLOBALS   * ComponentGlobals,
81     PVOID                    * Context
82     );
83 
84 typedef
85 NTSTATUS
86 (*PFNLIBRARYUNREGISTERCLIENT)(
87     PWDF_BIND_INFO             Info,
88     PWDF_COMPONENT_GLOBALS     DriverGlobals
89     );
90 
91 
92 typedef struct _WDF_LIBRARY_INFO {
93     ULONG                             Size;
94     PFNLIBRARYCOMMISSION              LibraryCommission;
95     PFNLIBRARYDECOMMISSION            LibraryDecommission;
96     PFNLIBRARYREGISTERCLIENT          LibraryRegisterClient;
97     PFNLIBRARYUNREGISTERCLIENT        LibraryUnregisterClient;
98     WDF_VERSION                       Version;
99 } WDF_LIBRARY_INFO, *PWDF_LIBRARY_INFO;
100 
101 typedef
102 PWDF_LIBRARY_INFO
103 (*PFX_GET_LIBRARY_INFO_UM)(
104     VOID
105     );
106 
107 //
108 // Framework 2.x's driver object.
109 //
110 typedef struct _DRIVER_OBJECT_UM *PDRIVER_OBJECT_UM;
111 struct IWudfDeviceStack;
112 struct IWudfDeviceStack2;
113 struct IWudfDevice;
114 struct IWudfIrp;
115 struct IUnknown;
116 typedef enum _WDF_DEVICE_IO_BUFFER_RETRIEVAL *PWDF_DEVICE_IO_BUFFER_RETRIEVAL;
117 typedef enum RdWmiPowerAction;
118 typedef const GUID *LPCGUID;
119 typedef UINT64 WUDF_INTERFACE_CONTEXT;
120 class FxDriver;
121 
122 //
123 // Valid flags for use in the DRIVER_OBJECT_UM::Flags field.
124 //
125 enum FxDriverObjectUmFlags : USHORT {
126     DriverObjectUmFlagsLoggingEnabled = 0x1
127 };
128 
129 //
130 // Driver object's basic interface.
131 //
132 typedef
133 NTSTATUS
134 DRIVER_ADD_DEVICE_UM (
135     _In_  PDRIVER_OBJECT_UM         DriverObject,
136     _In_  PVOID                     Context,
137     _In_  IWudfDeviceStack *        DevStack,
138     _In_  LPCWSTR                   KernelDeviceName,
139     _In_opt_ HKEY                   hPdoKey,
140     _In_  LPCWSTR                   pwszServiceName,
141     _In_  LPCWSTR                   pwszDevInstanceID,
142     _In_  ULONG                     ulDriverID
143     );
144 
145 typedef DRIVER_ADD_DEVICE_UM *PFN_DRIVER_ADD_DEVICE_UM;
146 
147 typedef
148 VOID
149 DRIVER_DISPATCH_UM (
150     _In_ IWudfDevice *             DeviceObject,
151     _In_ IWudfIrp *                 Irp,
152     _In_opt_ IUnknown *             Context
153     );
154 
155 typedef DRIVER_DISPATCH_UM *PFN_DRIVER_DISPATCH_UM;
156 
157 typedef
158 VOID
159 DRIVER_UNLOAD_UM (
160     _In_ PDRIVER_OBJECT_UM          DriverObject
161     );
162 
163 typedef DRIVER_UNLOAD_UM *PFN_DRIVER_UNLOAD_UM;
164 
165 typedef struct _DRIVER_OBJECT_UM {
166     ULONG Size;
167 
168     //
169     // The following links all of the devices created by a single driver
170     // together on a list, and the Flags word provides an extensible flag
171     // location for driver objects.
172     //
173     ULONG Flags;
174 
175     //
176     // The driver name field is used by the error log thread
177     // determine the name of the driver that an I/O request is/was bound.
178     //
179     UNICODE_STRING DriverName;
180 
181     //
182     // Store FxDriver
183     //
184     FxDriver* FxDriver;
185 
186     //
187     // Host device stack. This field is only valid while initializing
188     // the driver, such as during DriverEntry, and is NULL at all other times.
189     //
190     IWudfDeviceStack2* WudfDevStack;
191 
192     //
193     // Callback environment for driver workitems.
194     //
195     TP_CALLBACK_ENVIRON ThreadPoolEnv;
196 
197     //
198     // Group that tracks thread pool callbacks.
199     //
200     PTP_CLEANUP_GROUP ThreadPoolGroup;
201 
202     //
203     // A global number that driver IFR and framework IFR can opt into
204     // using as their record ordering number. This allows the framework
205     // and driver IFR record lists to be merged and sorted before being
206     // displayed.
207     //
208     LONG IfrSequenceNumber;
209 
210     //
211     // The following section describes the entry points to this particular
212     // driver.  Note that the major function dispatch table must be the last
213     // field in the object so that it remains extensible.
214     //
215     PFN_DRIVER_ADD_DEVICE_UM AddDevice;
216     PFN_DRIVER_UNLOAD_UM DriverUnload;
217     PFN_DRIVER_DISPATCH_UM MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
218 
219 } DRIVER_OBJECT_UM;
220 
221 typedef struct _CLIENT_INFO {
222     //
223     // Size of this structure
224     //
225     ULONG              Size;
226 
227     //
228     // registry service path of client driver
229     //
230     PUNICODE_STRING    RegistryPath;
231 
232 } CLIENT_INFO, *PCLIENT_INFO;
233 
234 //
235 // Event name:  WdfCensusEvtLinkClientToCx
236 //
237 // Source:      WudfHost (UM loader)
238 //
239 // Description: Written when a client is binding to a class extension.
240 //              WdfVersionBindClass which is called from the client's stub,
241 //              will load/reference the Cx and add it to the fx library's
242 //              list of clients. The client driver's class extension list is
243 //              also updated at that time, which is when this event is written.
244 //
245 // Frequency:   Everytime a client driver binds to a class extension.
246 //
247 //
248 #define WDF_CENSUS_EVT_WRITE_LINK_CLIENT_TO_CX(TraceHandle, CxImageName, ClientImageName)        \
249             TraceLoggingWrite(TraceHandle,                                     \
250                 "WdfCensusEvtLinkClientToCx",                                  \
251                 WDF_TELEMETRY_EVT_KEYWORDS,                                    \
252                 TraceLoggingWideString(CxImageName,       "CxImageName"),      \
253                 TraceLoggingWideString(ClientImageName,   "ClientImageName"  ) \
254                 );
255 
256 #endif // __FXLDRUM_H__
257