ReactOS  0.4.15-dev-1638-gc0caa5c
wdfmemory.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation. All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9  WdfMemory.h
10 
11 Abstract:
12 
13  Contains prototypes for managing memory objects in the driver frameworks.
14 
15 Author:
16 
17 Environment:
18 
19  kernel mode only
20 
21 Revision History:
22 
23 --*/
24 
25 //
26 // NOTE: This header is generated by stubwork. Please make any
27 // modifications to the corresponding template files
28 // (.x or .y) and use stubwork to regenerate the header
29 //
30 
31 #ifndef _WDFMEMORY_H_
32 #define _WDFMEMORY_H_
33 
34 #ifndef WDF_EXTERN_C
35  #ifdef __cplusplus
36  #define WDF_EXTERN_C extern "C"
37  #define WDF_EXTERN_C_START extern "C" {
38  #define WDF_EXTERN_C_END }
39  #else
40  #define WDF_EXTERN_C
41  #define WDF_EXTERN_C_START
42  #define WDF_EXTERN_C_END
43  #endif
44 #endif
45 
47 
48 
49 
50 #if (NTDDI_VERSION >= NTDDI_WIN2K)
51 
58 
59 
60 
61 typedef struct _WDFMEMORY_OFFSET {
62  //
63  // Offset into the WDFMEMORY that the operation should start at.
64  //
65  size_t BufferOffset;
66 
67  //
68  // Number of bytes that the operation should access. If 0, the entire
69  // length of the WDFMEMORY buffer will be used in the operation or ignored
70  // depending on the API.
71  //
72  size_t BufferLength;
73 
75 
76 typedef struct _WDF_MEMORY_DESCRIPTOR {
78 
79  union {
80  struct {
82 
84  } BufferType;
85 
86  struct {
88 
90  } MdlType;
91 
92  struct {
93  WDFMEMORY Memory;
95  } HandleType;
96  } u;
97 
99 
101 VOID
104  _In_ PVOID Buffer,
106  )
107 {
109 
111  Descriptor->u.BufferType.Buffer = Buffer;
112  Descriptor->u.BufferType.Length = BufferLength;
113 }
114 
116 VOID
119  _In_ WDFMEMORY Memory,
121  )
122 {
124 
126  Descriptor->u.HandleType.Memory = Memory;
127  Descriptor->u.HandleType.Offsets = Offsets;
128 }
129 
130 
132 VOID
135  _In_ PMDL Mdl,
137  )
138 {
140 
142  Descriptor->u.MdlType.Mdl = Mdl;
143  Descriptor->u.MdlType.BufferLength = BufferLength;
144 }
145 
146 //
147 // WDF Function: WdfMemoryCreate
148 //
149 typedef
153 WDFAPI
154 NTSTATUS
155 (STDCALL *PFN_WDFMEMORYCREATE)(
156  _In_
158  _In_opt_
160  _In_
163  _In_opt_
164  ULONG PoolTag,
165  _In_
167  size_t BufferSize,
168  _Out_
169  WDFMEMORY* Memory,
171  PVOID* Buffer
172  );
173 
178 NTSTATUS
179 WdfMemoryCreate(
180  _In_opt_
182  _In_
185  _In_opt_
186  ULONG PoolTag,
187  _In_
189  size_t BufferSize,
190  _Out_
191  WDFMEMORY* Memory,
193  PVOID* Buffer
194  )
195 {
197 }
198 
199 //
200 // WDF Function: WdfMemoryCreatePreallocated
201 //
202 typedef
205 WDFAPI
206 NTSTATUS
207 (STDCALL *PFN_WDFMEMORYCREATEPREALLOCATED)(
208  _In_
210  _In_opt_
213  PVOID Buffer,
214  _In_
216  size_t BufferSize,
217  _Out_
218  WDFMEMORY* Memory
219  );
220 
224 NTSTATUS
225 WdfMemoryCreatePreallocated(
226  _In_opt_
229  PVOID Buffer,
230  _In_
232  size_t BufferSize,
233  _Out_
234  WDFMEMORY* Memory
235  )
236 {
238 }
239 
240 //
241 // WDF Function: WdfMemoryGetBuffer
242 //
243 typedef
245 WDFAPI
246 PVOID
247 (STDCALL *PFN_WDFMEMORYGETBUFFER)(
248  _In_
250  _In_
251  WDFMEMORY Memory,
252  _Out_opt_
253  size_t* BufferSize
254  );
255 
258 PVOID
259 WdfMemoryGetBuffer(
260  _In_
261  WDFMEMORY Memory,
262  _Out_opt_
263  size_t* BufferSize
264  )
265 {
266  return ((PFN_WDFMEMORYGETBUFFER) WdfFunctions[WdfMemoryGetBufferTableIndex])(WdfDriverGlobals, Memory, BufferSize);
267 }
268 
269 //
270 // WDF Function: WdfMemoryAssignBuffer
271 //
272 typedef
275 WDFAPI
276 NTSTATUS
277 (STDCALL *PFN_WDFMEMORYASSIGNBUFFER)(
278  _In_
280  _In_
281  WDFMEMORY Memory,
283  PVOID Buffer,
284  _In_
286  size_t BufferSize
287  );
288 
292 NTSTATUS
293 WdfMemoryAssignBuffer(
294  _In_
295  WDFMEMORY Memory,
297  PVOID Buffer,
298  _In_
300  size_t BufferSize
301  )
302 {
303  return ((PFN_WDFMEMORYASSIGNBUFFER) WdfFunctions[WdfMemoryAssignBufferTableIndex])(WdfDriverGlobals, Memory, Buffer, BufferSize);
304 }
305 
306 //
307 // WDF Function: WdfMemoryCopyToBuffer
308 //
309 typedef
312 WDFAPI
313 NTSTATUS
314 (STDCALL *PFN_WDFMEMORYCOPYTOBUFFER)(
315  _In_
317  _In_
318  WDFMEMORY SourceMemory,
319  _In_
320  size_t SourceOffset,
321  _Out_writes_bytes_( NumBytesToCopyTo )
322  PVOID Buffer,
323  _In_
324  _When_(NumBytesToCopyTo == 0, __drv_reportError(NumBytesToCopyTo cannot be zero))
325  size_t NumBytesToCopyTo
326  );
327 
331 NTSTATUS
332 WdfMemoryCopyToBuffer(
333  _In_
334  WDFMEMORY SourceMemory,
335  _In_
336  size_t SourceOffset,
337  _Out_writes_bytes_( NumBytesToCopyTo )
338  PVOID Buffer,
339  _In_
340  _When_(NumBytesToCopyTo == 0, __drv_reportError(NumBytesToCopyTo cannot be zero))
341  size_t NumBytesToCopyTo
342  )
343 {
344  return ((PFN_WDFMEMORYCOPYTOBUFFER) WdfFunctions[WdfMemoryCopyToBufferTableIndex])(WdfDriverGlobals, SourceMemory, SourceOffset, Buffer, NumBytesToCopyTo);
345 }
346 
347 //
348 // WDF Function: WdfMemoryCopyFromBuffer
349 //
350 typedef
353 WDFAPI
354 NTSTATUS
355 (STDCALL *PFN_WDFMEMORYCOPYFROMBUFFER)(
356  _In_
358  _In_
359  WDFMEMORY DestinationMemory,
360  _In_
361  size_t DestinationOffset,
362  _In_
363  PVOID Buffer,
364  _In_
365  _When_(NumBytesToCopyFrom == 0, __drv_reportError(NumBytesToCopyFrom cannot be zero))
366  size_t NumBytesToCopyFrom
367  );
368 
372 NTSTATUS
373 WdfMemoryCopyFromBuffer(
374  _In_
375  WDFMEMORY DestinationMemory,
376  _In_
377  size_t DestinationOffset,
378  _In_
379  PVOID Buffer,
380  _In_
381  _When_(NumBytesToCopyFrom == 0, __drv_reportError(NumBytesToCopyFrom cannot be zero))
382  size_t NumBytesToCopyFrom
383  )
384 {
385  return ((PFN_WDFMEMORYCOPYFROMBUFFER) WdfFunctions[WdfMemoryCopyFromBufferTableIndex])(WdfDriverGlobals, DestinationMemory, DestinationOffset, Buffer, NumBytesToCopyFrom);
386 }
387 
388 //
389 // WDF Function: WdfLookasideListCreate
390 //
391 typedef
395 WDFAPI
396 NTSTATUS
397 (STDCALL *PFN_WDFLOOKASIDELISTCREATE)(
398  _In_
400  _In_opt_
402  _In_
404  size_t BufferSize,
405  _In_
408  _In_opt_
410  _In_opt_
411  ULONG PoolTag,
412  _Out_
413  WDFLOOKASIDE* Lookaside
414  );
415 
420 NTSTATUS
421 WdfLookasideListCreate(
422  _In_opt_
424  _In_
426  size_t BufferSize,
427  _In_
430  _In_opt_
432  _In_opt_
433  ULONG PoolTag,
434  _Out_
435  WDFLOOKASIDE* Lookaside
436  )
437 {
439 }
440 
441 //
442 // WDF Function: WdfMemoryCreateFromLookaside
443 //
444 typedef
447 WDFAPI
448 NTSTATUS
449 (STDCALL *PFN_WDFMEMORYCREATEFROMLOOKASIDE)(
450  _In_
452  _In_
453  WDFLOOKASIDE Lookaside,
454  _Out_
455  WDFMEMORY* Memory
456  );
457 
461 NTSTATUS
462 WdfMemoryCreateFromLookaside(
463  _In_
464  WDFLOOKASIDE Lookaside,
465  _Out_
466  WDFMEMORY* Memory
467  )
468 {
469  return ((PFN_WDFMEMORYCREATEFROMLOOKASIDE) WdfFunctions[WdfMemoryCreateFromLookasideTableIndex])(WdfDriverGlobals, Lookaside, Memory);
470 }
471 
472 
473 
474 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
475 
476 
478 
479 #endif // _WDFMEMORY_H_
480 
_Must_inspect_result_ _In_ WDFMEMORY _Pre_notnull_ _Pre_writable_byte_size_(BufferSize) PVOID Buffer
Definition: wdfmemory.h:282
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define _Must_inspect_result_
Definition: no_sal2.h:62
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#define __drv_reportError(why)
Definition: driverspecs.h:302
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:407
_WDF_MEMORY_DESCRIPTOR_TYPE
Definition: wdfmemory.h:52
_Must_inspect_result_ _When_(PoolType==1||PoolType==257, _IRQL_requires_max_(APC_LEVEL)) _When_(PoolType
Definition: wdfmemory.h:151
FORCEINLINE VOID WDF_MEMORY_DESCRIPTOR_INIT_MDL(_Out_ PWDF_MEMORY_DESCRIPTOR Descriptor, _In_ PMDL Mdl, _In_ ULONG BufferLength)
Definition: wdfmemory.h:133
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t SourceOffset
Definition: wdfmemory.h:318
_Must_inspect_result_ _In_ WDFMEMORY SourceMemory
Definition: wdfmemory.h:318
struct _WDFMEMORY_OFFSET WDFMEMORY_OFFSET
DriverGlobals
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ __drv_aliasesMem PVOID Buffer
Definition: wdfmemory.h:211
struct _WDFMEMORY_OFFSET * PWDFMEMORY_OFFSET
#define _In_opt_
Definition: no_sal2.h:212
#define WdfFunctions
Definition: wdf.h:66
struct _WDF_MEMORY_DESCRIPTOR * PWDF_MEMORY_DESCRIPTOR
struct _WDF_MEMORY_DESCRIPTOR WDF_MEMORY_DESCRIPTOR
FORCEINLINE VOID WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(_Out_ PWDF_MEMORY_DESCRIPTOR Descriptor, _In_ WDFMEMORY Memory, _In_opt_ PWDFMEMORY_OFFSET Offsets)
Definition: wdfmemory.h:117
size_t BufferOffset
Definition: wdfmemory.h:65
#define WDFAPI
Definition: wdftypes.h:53
WDF_EXTERN_C_START enum _WDF_MEMORY_DESCRIPTOR_TYPE WDF_MEMORY_DESCRIPTOR_TYPE
#define __drv_aliasesMem
Definition: btrfs_drv.h:205
int zero
Definition: sehframes.cpp:29
#define _Out_
Definition: no_sal2.h:160
Definition: bufpool.h:45
FORCEINLINE VOID WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(_Out_ PWDF_MEMORY_DESCRIPTOR Descriptor, _In_ PVOID Buffer, _In_ ULONG BufferLength)
Definition: wdfmemory.h:102
void * PVOID
Definition: retypes.h:9
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY _Outptr_opt_result_bytebuffer_(BufferSize) PVOID *Buffer)
Definition: wdfmemory.h:170
#define WDF_EXTERN_C_END
Definition: wdfmemory.h:42
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t _Out_writes_bytes_(NumBytesToCopyTo) PVOID Buffer
Definition: wdfmemory.h:321
#define _Out_opt_
Definition: no_sal2.h:214
PWDF_DRIVER_GLOBALS WdfDriverGlobals
#define STDCALL
Definition: wdf.h:45
struct _WDF_MEMORY_DESCRIPTOR::@3676::@3678 MdlType
INT POOL_TYPE
Definition: typedefs.h:78
WDF_MEMORY_DESCRIPTOR_TYPE Type
Definition: wdfmemory.h:77
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:159
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES MemoryAttributes
Definition: wdfmemory.h:407
#define _Strict_type_match_
Definition: no_sal2.h:406
size_t BufferLength
Definition: wdfmemory.h:72
#define NTSTATUS
Definition: precomp.h:20
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfmemory.h:159
PWDFMEMORY_OFFSET Offsets
Definition: wdfmemory.h:94
#define _Pre_notnull_
Definition: no_sal2.h:516
#define WDF_EXTERN_C_START
Definition: wdfmemory.h:41
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define _In_
Definition: no_sal2.h:158
#define FORCEINLINE
Definition: wdftypes.h:67
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t DestinationOffset
Definition: wdfmemory.h:359
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
union _WDF_MEMORY_DESCRIPTOR::@3676 u
_Must_inspect_result_ _In_ WDFMEMORY DestinationMemory
Definition: wdfmemory.h:359
struct _WDF_MEMORY_DESCRIPTOR::@3676::@3679 HandleType
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: wdfmemory.h:159
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES LookasideAttributes
Definition: wdfmemory.h:401
#define APC_LEVEL
Definition: env_spec_w32.h:695
_Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL)) WDFAPI NTSTATUS(STDCALL *PFN_WDFMEMORYCREATE)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
Definition: wdfmemory.h:152
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
struct _WDF_MEMORY_DESCRIPTOR::@3676::@3677 BufferType
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes