1 
2 /*++
3 
4 Copyright (c) Microsoft. All rights reserved.
5 
6 Module Name:
7 
8     FxRequestMemory.hpp
9 
10 Abstract:
11 
12     This is the memory object for FxRequest that is sized, and
13     allows checking for read/write access.
14 
15     It's reference lifetime is tied with IRP completion in
16     FxRequest.
17 
18 Author:
19 
20 
21 
22 Environment:
23 
24     Both kernel and user mode
25 
26 Revision History:
27 
28 --*/
29 
30 #ifndef _FXREQUESTMEMORY_H_
31 #define _FXREQUESTMEMORY_H_
32 
33 class FxRequestMemory : public FxMemoryBufferPreallocated {
34 public:
35 
36     // Factory function
37     static
38     NTSTATUS
39     Create(
40         __in PFX_DRIVER_GLOBALS DriverGlobals,
41         __in_opt PWDF_OBJECT_ATTRIBUTES Attributes,
42         __out FxRequestMemory** Object
43         );
44 
45     FxRequestMemory(
46         __in PFX_DRIVER_GLOBALS Globals
47         );
48 
49     // begin end FxMemoryObject
50     virtual
51     PVOID
52     GetBuffer(
53         VOID
54         );
55 
56     _Must_inspect_result_
57     virtual
58     PMDL
59     GetMdl(
60         VOID
61         );
62 
63     virtual
64     USHORT
GetFlags(VOID)65     GetFlags(
66         VOID
67         )
68     {
69         return m_Flags;
70     }
71     // end FxMemoryObject overrides
72 
73     VOID
74     SetBuffer(
75         _In_ FxRequest* Request,
76         _Pre_notnull_ _Pre_writable_byte_size_(BufferSize) PVOID      Buffer,
77         _In_ PMDL       BackingMdl,
78         _In_ size_t     BufferSize,
79         _In_ BOOLEAN    ReadOnly
80         );
81 
82     VOID
83     SetMdl(
84         __in FxRequest* Request,
85         __in PMDL       Mdl,
86         __in PVOID      MdlBuffer,
87         __in size_t     BufferSize,
88         __in BOOLEAN    ReadOnly
89         );
90 
91     _Must_inspect_result_
92     NTSTATUS
93     QueryInterface(
94         __in FxQueryInterfaceParams* Params
95         );
96 
97     ~FxRequestMemory(
98         VOID
99         );
100 
101 protected:
102     VOID
SetFlags(__in USHORT Flags)103     SetFlags(
104         __in USHORT Flags
105         )
106     {
107         m_Flags = Flags;
108     }
109 
110 protected:
111 
112     FxRequest* m_Request;
113 
114     //
115     // The m_Mdl is owned by this object and it must be freed by the this object.
116     //
117     PMDL       m_Mdl;
118 
119     USHORT m_Flags;
120 };
121 
122 #endif //  _FXREQUESTMEMORY_H_
123 
124 
125