ReactOS 0.4.15-dev-5669-g09dde2c
ATL::CAtlFileMappingBase Class Reference

#include <atlfile.h>

Inheritance diagram for ATL::CAtlFileMappingBase:
Collaboration diagram for ATL::CAtlFileMappingBase:

Public Member Functions

 CAtlFileMappingBase () throw ()
 
 ~CAtlFileMappingBase () throw ()
 
 CAtlFileMappingBase (CAtlFileMappingBase &orig)
 
CAtlFileMappingBaseoperator= (CAtlFileMappingBase &orig)
 
HRESULT CopyFrom (CAtlFileMappingBase &orig) throw ()
 
HRESULT MapFile (HANDLE hFile, SIZE_T nMappingSize=0, ULONGLONG nOffset=0, DWORD dwMappingProtection=PAGE_READONLY, DWORD dwViewDesiredAccess=FILE_MAP_READ) throw ()
 
HRESULT MapSharedMem (SIZE_T nMappingSize, LPCTSTR szName, BOOL *pbAlreadyExisted=NULL, LPSECURITY_ATTRIBUTES lpsa=NULL, DWORD dwMappingProtection=PAGE_READWRITE, DWORD dwViewDesiredAccess=FILE_MAP_ALL_ACCESS) throw ()
 
HRESULT OpenMapping (LPCTSTR szName, SIZE_T nMappingSize, ULONGLONG nOffset=0, DWORD dwViewDesiredAccess=FILE_MAP_ALL_ACCESS) throw ()
 
HRESULT Unmap () throw ()
 
voidGetData () const throw ()
 
HANDLE GetHandle () throw ()
 
SIZE_T GetMappingSize () throw ()
 

Private Attributes

voidm_pData
 
SIZE_T m_nMappingSize
 
HANDLE m_hMapping
 
ULARGE_INTEGER m_nOffset
 
DWORD m_dwViewDesiredAccess
 

Detailed Description

Definition at line 27 of file atlfile.h.

Constructor & Destructor Documentation

◆ CAtlFileMappingBase() [1/2]

ATL::CAtlFileMappingBase::CAtlFileMappingBase ( )
throw (
)
inline

Definition at line 37 of file atlfile.h.

42 {
44 }
ULARGE_INTEGER m_nOffset
Definition: atlfile.h:33
#define NULL
Definition: types.h:112
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

◆ ~CAtlFileMappingBase()

ATL::CAtlFileMappingBase::~CAtlFileMappingBase ( )
throw (
)
inline

Definition at line 46 of file atlfile.h.

47 {
48 Unmap();
49 }

◆ CAtlFileMappingBase() [2/2]

ATL::CAtlFileMappingBase::CAtlFileMappingBase ( CAtlFileMappingBase orig)
inline

Definition at line 51 of file atlfile.h.

52 {
53 HRESULT hr;
54
55 m_pData = NULL;
60
61 hr = CopyFrom(orig);
62 if (FAILED(hr))
63 AtlThrow(hr);
64 }
#define AtlThrow(x)
Definition: atldef.h:20
HRESULT CopyFrom(CAtlFileMappingBase &orig)
Definition: atlfile.h:77
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183

Member Function Documentation

◆ CopyFrom()

HRESULT ATL::CAtlFileMappingBase::CopyFrom ( CAtlFileMappingBase orig)
throw (
)
inline

Definition at line 77 of file atlfile.h.

78 {
79 HRESULT hr = S_OK;
80
81 if (&orig == this)
82 return S_OK;
83
86 ATLASSERT(orig.m_pData != NULL);
87
91
93 {
95 if (!m_pData)
96 {
100 }
101 }
102 else
103 {
105 }
106
107 return hr;
108 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
#define MapViewOfFile
Definition: compat.h:745
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
#define S_OK
Definition: intsafe.h:52
HRESULT AtlHresultFromLastError()
Definition: atlcomcli.h:56
$ULONG LowPart
Definition: ntbasedef.h:569
$ULONG HighPart
Definition: ntbasedef.h:570
#define DUPLICATE_SAME_ACCESS

Referenced by CAtlFileMappingBase(), and operator=().

◆ GetData()

void * ATL::CAtlFileMappingBase::GetData ( ) const
throw (
)
inline

Definition at line 251 of file atlfile.h.

252 {
253 return m_pData;
254 }

Referenced by ATL::CAtlFileMapping< T >::operator T*().

◆ GetHandle()

HANDLE ATL::CAtlFileMappingBase::GetHandle ( )
throw (
)
inline

Definition at line 256 of file atlfile.h.

257 {
258 return m_hMapping;
259 }

◆ GetMappingSize()

SIZE_T ATL::CAtlFileMappingBase::GetMappingSize ( )
throw (
)
inline

Definition at line 261 of file atlfile.h.

262 {
263 return m_nMappingSize;
264 }

◆ MapFile()

HRESULT ATL::CAtlFileMappingBase::MapFile ( HANDLE  hFile,
SIZE_T  nMappingSize = 0,
ULONGLONG  nOffset = 0,
DWORD  dwMappingProtection = PAGE_READONLY,
DWORD  dwViewDesiredAccess = FILE_MAP_READ 
)
throw (
)
inline

Definition at line 110 of file atlfile.h.

116 {
117 HRESULT hr = S_OK;
119
123
125 FileSize.QuadPart = nMappingSize > FileSize.QuadPart ? nMappingSize : FileSize.QuadPart;
126
128 if (m_hMapping)
129 {
130 m_nMappingSize = nMappingSize == 0 ? (SIZE_T)(FileSize.QuadPart - nOffset) : nMappingSize;
131 m_nOffset.QuadPart = nOffset;
132 m_dwViewDesiredAccess = dwViewDesiredAccess;
133
135 if (!m_pData)
136 {
140 }
141 }
142 else
143 {
145 }
146
147 return hr;
148 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_In_ HANDLE hFile
Definition: mswsock.h:90
ULONG_PTR SIZE_T
Definition: typedefs.h:80
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
#define CreateFileMapping
Definition: winbase.h:3621

◆ MapSharedMem()

HRESULT ATL::CAtlFileMappingBase::MapSharedMem ( SIZE_T  nMappingSize,
LPCTSTR  szName,
BOOL pbAlreadyExisted = NULL,
LPSECURITY_ATTRIBUTES  lpsa = NULL,
DWORD  dwMappingProtection = PAGE_READWRITE,
DWORD  dwViewDesiredAccess = FILE_MAP_ALL_ACCESS 
)
throw (
)
inline

Definition at line 150 of file atlfile.h.

157 {
158 HRESULT hr = S_OK;
160
161 ATLASSERT(nMappingSize > 0);
165
166 m_nMappingSize = nMappingSize;
167 m_dwViewDesiredAccess = dwViewDesiredAccess;
169 Size.QuadPart = nMappingSize;
170
171 m_hMapping = ::CreateFileMapping(NULL, lpsa, dwMappingProtection, Size.HighPart, Size.LowPart, szName);
172 if (m_hMapping != NULL)
173 {
174 if (pbAlreadyExisted)
175 *pbAlreadyExisted = GetLastError() == ERROR_ALREADY_EXISTS;
176
178 if (!m_pData)
179 {
183 }
184 }
185 else
186 {
188 }
189
190 return hr;
191 }
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static const WCHAR szName[]
Definition: powrprof.c:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
DWORD WINAPI GetLastError(void)
Definition: except.c:1040

◆ OpenMapping()

HRESULT ATL::CAtlFileMappingBase::OpenMapping ( LPCTSTR  szName,
SIZE_T  nMappingSize,
ULONGLONG  nOffset = 0,
DWORD  dwViewDesiredAccess = FILE_MAP_ALL_ACCESS 
)
throw (
)
inline

Definition at line 193 of file atlfile.h.

198 {
199 HRESULT hr = S_OK;
200
204
205 m_nMappingSize = nMappingSize;
206 m_dwViewDesiredAccess = dwViewDesiredAccess;
207 m_nOffset.QuadPart = nOffset;
208
210 if (m_hMapping)
211 {
213 if (!m_pData)
214 {
218 }
219 }
220 else
221 {
223 }
224
225 return hr;
226 }
#define FALSE
Definition: types.h:117
#define OpenFileMapping
Definition: winbase.h:3758

◆ operator=()

CAtlFileMappingBase & ATL::CAtlFileMappingBase::operator= ( CAtlFileMappingBase orig)
inline

Definition at line 66 of file atlfile.h.

67 {
68 HRESULT hr;
69
70 hr = CopyFrom(orig);
71 if (FAILED(hr))
72 AtlThrow(hr);
73
74 return *this;
75 }

◆ Unmap()

HRESULT ATL::CAtlFileMappingBase::Unmap ( )
throw (
)
inline

Definition at line 228 of file atlfile.h.

229 {
230 HRESULT hr = S_OK;
231
232 if (m_pData)
233 {
236
237 m_pData = NULL;
238 }
239 if (m_hMapping)
240 {
241 // If we already had an error, do not overwrite it
244
246 }
247
248 return hr;
249 }
#define UnmapViewOfFile
Definition: compat.h:746
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by ~CAtlFileMappingBase().

Member Data Documentation

◆ m_dwViewDesiredAccess

DWORD ATL::CAtlFileMappingBase::m_dwViewDesiredAccess
private

Definition at line 34 of file atlfile.h.

Referenced by CAtlFileMappingBase(), CopyFrom(), MapFile(), MapSharedMem(), and OpenMapping().

◆ m_hMapping

HANDLE ATL::CAtlFileMappingBase::m_hMapping
private

◆ m_nMappingSize

SIZE_T ATL::CAtlFileMappingBase::m_nMappingSize
private

◆ m_nOffset

ULARGE_INTEGER ATL::CAtlFileMappingBase::m_nOffset
private

Definition at line 33 of file atlfile.h.

Referenced by CAtlFileMappingBase(), CopyFrom(), MapFile(), MapSharedMem(), and OpenMapping().

◆ m_pData

void* ATL::CAtlFileMappingBase::m_pData
private

Definition at line 30 of file atlfile.h.

Referenced by CAtlFileMappingBase(), CopyFrom(), GetData(), MapFile(), MapSharedMem(), OpenMapping(), and Unmap().


The documentation for this class was generated from the following file: