ReactOS  0.4.15-dev-2701-g34593d9
ifxmemory.hpp
Go to the documentation of this file.
1 //
2 // Copyright (C) Microsoft. All rights reserved.
3 //
4 /*++
5 
6 Module Name:
7 
8  IFxMemory.hpp
9 
10 Abstract:
11 
12  Abstract base class for a memory object. It is necessary to split the
13  memory interface away from an FxObject derived base class so that we can
14  hand out WDFMEMORY handles that are embedded within other FxObject derived
15  classes without having to embed another FxObject derived class within the
16  parent.
17 
18 Author:
19 
20 
21 
22 Environment:
23 
24  Both kernel and user mode
25 
26 Revision History:
27 
28 --*/
29 
30 #ifndef __IFX_MEMORY_HPP__
31 #define __IFX_MEMORY_HPP__
32 
33 // begin_wpp enum
36 };
37 // end_wpp
38 
39 
40 class IFxMemory {
41 public:
42  virtual
43  PVOID
44  GetBuffer(
45  VOID
46  ) =0;
47 
48  virtual
49  size_t
51  VOID
52  ) =0;
53 
54  virtual
55  PMDL
56  GetMdl(
57  VOID
58  ) =0;
59 
60  virtual
61  WDFMEMORY
62  GetHandle(
63  VOID
64  ) =0;
65 
66  //
67  // Value returned is a bit field from the enum IFxMemoryFlags
68  //
69  virtual
70  USHORT
71  GetFlags(
72  VOID
73  ) =0;
74 
75  virtual
78  VOID
79  ) =0;
80 
81  virtual
82  ULONG
83  AddRef(
84  __in PVOID Tag,
85  __in LONG Line,
87  ) =0;
88 
89  virtual
90  ULONG
91  Release(
92  __in PVOID Tag,
93  __in LONG Line,
95  ) =0;
96 
97  virtual
98  VOID
99  Delete(
100  VOID
101  ) =0;
102 
104  NTSTATUS
107  )
108  {
110  size_t total;
111 
112  if (Offsets == NULL) {
113  return STATUS_SUCCESS;
114  }
115 
116  status = RtlSizeTAdd(Offsets->BufferLength, Offsets->BufferOffset, &total);
117 
118  if (!NT_SUCCESS(status)) {
119  return status;
120  }
121 
122  if (total > GetBufferSize()) {
124  }
125 
126  return STATUS_SUCCESS;
127  }
128 
130  NTSTATUS
131  CopyFromPtr(
132  __in_opt PWDFMEMORY_OFFSET DestinationOffsets,
133  __in_bcount(SourceBufferLength) PVOID SourceBuffer,
134  __in size_t SourceBufferLength,
135  __in_opt PWDFMEMORY_OFFSET SourceOffsets
136  );
137 
139  NTSTATUS
140  CopyToPtr(
141  __in_opt PWDFMEMORY_OFFSET SourceOffsets,
142  __out_bcount(DestinationBufferLength) PVOID DestinationBuffer,
143  __in size_t DestinationBufferLength,
144  __in_opt PWDFMEMORY_OFFSET DestinationOffsets
145  );
146 
147 protected:
148  static
150  NTSTATUS
152  __in_bcount(SourceBufferLength) PVOID SourceBuffer,
153  __in size_t SourceBufferLength,
154  __in_opt PWDFMEMORY_OFFSET SourceOffsets,
155  __out_bcount(DestinationBufferLength) PVOID DestinationBuffer,
156  __in size_t DestinationBufferLength,
157  __in_opt PWDFMEMORY_OFFSET DestinationOffsets
158  );
159 };
160 
161 #endif // __IFX_MEMORY_HPP__
#define __in_bcount(x)
Definition: dbghelp.h:41
static _Must_inspect_result_ NTSTATUS _CopyPtrToPtr(__in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
_Must_inspect_result_ NTSTATUS ValidateMemoryOffsets(__in_opt PWDFMEMORY_OFFSET Offsets)
Definition: ifxmemory.hpp:105
#define _Must_inspect_result_
Definition: no_sal2.h:62
virtual VOID Delete(VOID)=0
#define __out_bcount(x)
Definition: dbghelp.h:68
#define __in_opt
Definition: dbghelp.h:38
virtual PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)=0
LONG NTSTATUS
Definition: precomp.h:26
virtual WDFMEMORY GetHandle(VOID)=0
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
long LONG
Definition: pedump.c:60
virtual PMDL GetMdl(VOID)=0
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IFxMemoryFlags
Definition: ifxmemory.hpp:34
Definition: ncftp.h:79
virtual ULONG Release(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_Must_inspect_result_ NTSTATUS CopyFromPtr(__in_opt PWDFMEMORY_OFFSET DestinationOffsets, __in_bcount(SourceBufferLength) PVOID SourceBuffer, __in size_t SourceBufferLength, __in_opt PWDFMEMORY_OFFSET SourceOffsets)
virtual USHORT GetFlags(VOID)=0
unsigned short USHORT
Definition: pedump.c:61
signed char * PSTR
Definition: retypes.h:7
#define NULL
Definition: types.h:112
size_t total
_Must_inspect_result_ NTSTATUS CopyToPtr(__in_opt PWDFMEMORY_OFFSET SourceOffsets, __out_bcount(DestinationBufferLength) PVOID DestinationBuffer, __in size_t DestinationBufferLength, __in_opt PWDFMEMORY_OFFSET DestinationOffsets)
virtual ULONG AddRef(__in PVOID Tag, __in LONG Line, __in_opt PSTR File)=0
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __in
Definition: dbghelp.h:35
static SERVICE_STATUS status
Definition: service.c:31
virtual size_t GetBufferSize(VOID)=0
virtual PVOID GetBuffer(VOID)=0
Definition: ps.c:97