ReactOS  0.4.15-dev-5112-g22d8c0f
fxobjectum.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxObjectUm.cpp
8 
9 Abstract:
10 
11  User mode implementations of FxObject APIs
12 
13 Author:
14 
15 
16 Environment:
17 
18  user mode only
19 
20 Revision History:
21 
22 --*/
23 
24 #include "fxobjectpch.hpp"
25 
26 extern "C" {
27 
28 #if defined(EVENT_TRACING)
29 #include "FxObjectUm.tmh"
30 #endif
31 
32 }
33 
34 extern "C" {
35 
36 #define INITGUID
37 #include <guiddef.h>
38 
39 #include <WdfFileObject_private.h>
40 
41 //
42 // Function declarations for the WdfObjectQuery DDIs
43 //
45 WDFAPI
47 WDFEXPORT(WdfFileObjectIncrementProcessKeepAliveCount)(
48  _In_
50  _In_
51  WDFFILEOBJECT FileObject
52  );
53 
55 WDFAPI
57 WDFEXPORT(WdfFileObjectDecrementProcessKeepAliveCount)(
58  _In_
60  _In_
61  WDFFILEOBJECT FileObject
62  );
63 
64 }
65 
66 
67 extern "C" {
68 
76  PVOID QueryBuffer
77  )
78 
79 /*++
80 
81 Routine Description:
82 
83  Query the object handle for specific information
84 
85  This allows dynamic extensions to DDI's.
86 
87  Currently, it is used to allow test hooks for verification
88  which are not available in a production release.
89 
90 Arguments:
91 
92  Object - Object to query
93 
94  Guid - GUID to represent the information/DDI to query for
95 
96  QueryBufferLength - Length of QueryBuffer to return data in
97 
98  QueryBuffer - Pointer to QueryBuffer
99 
100 Returns:
101 
102  NTSTATUS
103 
104 --*/
105 
106 {
107  PFX_DRIVER_GLOBALS pFxDriverGlobals = Object->GetDriverGlobals();
108 
109  //
110  // Design Note: This interface does not look strongly typed
111  // but it is. The GUID defines a specific strongly typed
112  // contract for QueryBuffer and QueryBufferLength.
113  //
114 
115 #if DBG
116 
117  //
118  // These operations are only available on checked builds for deep unit
119  // testing, code coverage analysis, and model verification.
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133  //
134 
135  // Add code based on the GUID
136 
137  // IsEqualGUID(guid1, guid2), DEFINE_GUID, INITGUID, inc\wnet\guiddef.h
138 #endif
139 
140  if (IsEqualGUID(*Guid, GUID_WDFP_FILEOBJECT_INTERFACE)) {
141 
142  //
143  // Check the query buffer size before performing the cast
144  //
145  const ULONG RequiredBufferLength = sizeof(WDFP_FILEOBJECT_INTERFACE);
146 
147  if (QueryBufferLength < RequiredBufferLength) {
150  "Insufficient query buffer size for file object query "
151  "Required size %d, %!STATUS!",
152  RequiredBufferLength,
156  }
157 
158  if (nullptr == QueryBuffer) {
161  "NULL query buffer for file object query, %!STATUS!",
165  }
166 
167  PWDFP_FILEOBJECT_INTERFACE FileObjectInterface =
168  reinterpret_cast<PWDFP_FILEOBJECT_INTERFACE>(QueryBuffer);
169 
170  //
171  // Check the struct version (require an exact match for a private DDI)
172  //
173  if (FileObjectInterface->Size != RequiredBufferLength) {
176  "Wrong struct version provided for file object query, "
177  "%!STATUS!",
181  }
182 
183  FileObjectInterface->WdfpFileObjectIncrementProcessKeepAliveCount =
184  WDFEXPORT(WdfFileObjectIncrementProcessKeepAliveCount);
185  FileObjectInterface->WdfpFileObjectDecrementProcessKeepAliveCount =
186  WDFEXPORT(WdfFileObjectDecrementProcessKeepAliveCount);
187 
188  return STATUS_SUCCESS;
189  }
190 
191  return STATUS_NOT_FOUND;
192 }
193 
194 } // extern "C"
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PFN_WDFP_FILEOBJECT_INCREMENT_PROCESS_KEEP_ALIVE_COUNT WdfpFileObjectIncrementProcessKeepAliveCount
DriverGlobals
_In_ WDFFILEOBJECT FileObject
Definition: fxobjectum.cpp:52
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
Definition: wdfobject.h:760
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define WDFAPI
Definition: wdftypes.h:53
#define _In_
Definition: ms_sal.h:308
_IRQL_requires_max_(PASSIVE_LEVEL) WDFAPI NTSTATUS WDFEXPORT(WdfFileObjectIncrementProcessKeepAliveCount)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
Queries information details about a security descriptor.
Definition: Messaging.c:64
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define TRACINGDEVICE
Definition: dbgtrace.h:58
PFX_DRIVER_GLOBALS pFxDriverGlobals
PFN_WDFP_FILEOBJECT_DECREMENT_PROCESS_KEEP_ALIVE_COUNT WdfpFileObjectDecrementProcessKeepAliveCount
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
static _Must_inspect_result_ NTSTATUS _ObjectQuery(_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
Definition: fxobjectkm.cpp:39
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _Out_writes_bytes_(size)
Definition: ms_sal.h:350
#define CONST
Definition: pedump.c:81
FxVerifierDbgBreakPoint(pFxDriverGlobals)
struct _WDFP_FILEOBJECT_INTERFACE WDFP_FILEOBJECT_INTERFACE