ReactOS 0.4.15-dev-7953-g1f49173
fxobjectum.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxObjectUm.cpp
8
9Abstract:
10
11 User mode implementations of FxObject APIs
12
13Author:
14
15
16Environment:
17
18 user mode only
19
20Revision History:
21
22--*/
23
24#include "fxobjectpch.hpp"
25
26extern "C" {
27
28#if defined(EVENT_TRACING)
29#include "FxObjectUm.tmh"
30#endif
31
32}
33
34extern "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//
47WDFEXPORT(WdfFileObjectIncrementProcessKeepAliveCount)(
48 _In_
50 _In_
51 WDFFILEOBJECT FileObject
52 );
53
57WDFEXPORT(WdfFileObjectDecrementProcessKeepAliveCount)(
58 _In_
60 _In_
61 WDFFILEOBJECT FileObject
62 );
63
64}
65
66
67extern "C" {
68
76 PVOID QueryBuffer
77 )
78
79/*++
80
81Routine 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
90Arguments:
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
100Returns:
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
184 WDFEXPORT(WdfFileObjectIncrementProcessKeepAliveCount);
186 WDFEXPORT(WdfFileObjectDecrementProcessKeepAliveCount);
187
188 return STATUS_SUCCESS;
189 }
190
191 return STATUS_NOT_FOUND;
192}
193
194} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
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 TRACINGDEVICE
Definition: dbgtrace.h:58
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
DriverGlobals
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
_In_ WDFFILEOBJECT FileObject
Definition: fxobjectum.cpp:52
#define _Out_writes_bytes_(size)
Definition: ms_sal.h:350
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _In_
Definition: ms_sal.h:308
#define CONST
Definition: pedump.c:81
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
PFN_WDFP_FILEOBJECT_DECREMENT_PROCESS_KEEP_ALIVE_COUNT WdfpFileObjectDecrementProcessKeepAliveCount
PFN_WDFP_FILEOBJECT_INCREMENT_PROCESS_KEEP_ALIVE_COUNT WdfpFileObjectIncrementProcessKeepAliveCount
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
struct _WDFP_FILEOBJECT_INTERFACE WDFP_FILEOBJECT_INTERFACE
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
Definition: wdfobject.h:764
#define WDFAPI
Definition: wdftypes.h:53