The Gaudi Framework  v37r0 (b608885e)
MEMORY_MAPPED_FILE Class Reference

#include </builds/gaudi/Gaudi/GaudiKernel/src/Util/LibSymbolInfo.h>

Public Member Functions

 MEMORY_MAPPED_FILE (PSTR pszFileName)
 
 ~MEMORY_MAPPED_FILE (void)
 
PVOID GetBase (void)
 
DWORD GetFileSize (void)
 
BOOL IsValid (void)
 
errMMF GetErrorType ()
 

Private Attributes

HANDLE m_hFile
 
HANDLE m_hFileMapping
 
PVOID m_pMemoryMappedFileBase
 
DWORD m_cbFile
 
errMMF m_errCode
 

Detailed Description

Definition at line 44 of file LibSymbolInfo.h.

Constructor & Destructor Documentation

◆ MEMORY_MAPPED_FILE()

MEMORY_MAPPED_FILE::MEMORY_MAPPED_FILE ( PSTR  pszFileName)

Definition at line 181 of file LibSymbolInfo.cpp.

181  {
182 
183  //
184  // Given a filename, the constructor opens a file handle, creates a file
185  // mapping, and maps the entire file into memory.
186  //
187  m_hFile = INVALID_HANDLE_VALUE;
188  m_hFileMapping = 0;
190  m_cbFile = 0;
191  m_errCode = errMMF_FileOpen; // Initial error code: not found
192  // First get a file handle
193  m_hFile =
194  CreateFile( pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0 );
195 
196  if ( m_hFile == INVALID_HANDLE_VALUE ) {
198  return;
199  }
201  // Now, create a file mapping
202  m_hFileMapping = CreateFileMapping( m_hFile, NULL, PAGE_READONLY, 0, 0, NULL );
203  if ( m_hFileMapping == 0 ) {
204  // Oops. Something went wrong. Clean up.
205  CloseHandle( m_hFile );
206  m_hFile = INVALID_HANDLE_VALUE;
208  return;
209  }
210  m_pMemoryMappedFileBase = (PCHAR)MapViewOfFile( m_hFileMapping, FILE_MAP_READ, 0, 0, 0 );
211  if ( m_pMemoryMappedFileBase == 0 ) {
212  // Oops. Something went wrong. Clean up.
213  CloseHandle( m_hFileMapping );
214  m_hFileMapping = 0;
215  CloseHandle( m_hFile );
216  m_hFile = INVALID_HANDLE_VALUE;
218  return;
219  }
221 }

◆ ~MEMORY_MAPPED_FILE()

MEMORY_MAPPED_FILE::~MEMORY_MAPPED_FILE ( void  )

Definition at line 223 of file LibSymbolInfo.cpp.

223  {
224  // Clean up everything that was created by the constructor
225  if ( m_pMemoryMappedFileBase ) UnmapViewOfFile( m_pMemoryMappedFileBase );
226 
227  if ( m_hFileMapping ) CloseHandle( m_hFileMapping );
228 
229  if ( m_hFile != INVALID_HANDLE_VALUE ) CloseHandle( m_hFile );
230 
232 }

Member Function Documentation

◆ GetBase()

PVOID MEMORY_MAPPED_FILE::GetBase ( void  )
inline

Definition at line 49 of file LibSymbolInfo.h.

49 { return m_pMemoryMappedFileBase; }

◆ GetErrorType()

errMMF MEMORY_MAPPED_FILE::GetErrorType ( )
inline

Definition at line 52 of file LibSymbolInfo.h.

52 { return m_errCode; }

◆ GetFileSize()

DWORD MEMORY_MAPPED_FILE::GetFileSize ( void  )
inline

Definition at line 50 of file LibSymbolInfo.h.

50 { return m_cbFile; }

◆ IsValid()

BOOL MEMORY_MAPPED_FILE::IsValid ( void  )
inline

Definition at line 51 of file LibSymbolInfo.h.

51 { return errMMF_NoError == m_errCode; }

Member Data Documentation

◆ m_cbFile

DWORD MEMORY_MAPPED_FILE::m_cbFile
private

Definition at line 58 of file LibSymbolInfo.h.

◆ m_errCode

errMMF MEMORY_MAPPED_FILE::m_errCode
private

Definition at line 59 of file LibSymbolInfo.h.

◆ m_hFile

HANDLE MEMORY_MAPPED_FILE::m_hFile
private

Definition at line 55 of file LibSymbolInfo.h.

◆ m_hFileMapping

HANDLE MEMORY_MAPPED_FILE::m_hFileMapping
private

Definition at line 56 of file LibSymbolInfo.h.

◆ m_pMemoryMappedFileBase

PVOID MEMORY_MAPPED_FILE::m_pMemoryMappedFileBase
private

Definition at line 57 of file LibSymbolInfo.h.


The documentation for this class was generated from the following files:
MEMORY_MAPPED_FILE::GetFileSize
DWORD GetFileSize(void)
Definition: LibSymbolInfo.h:50
MEMORY_MAPPED_FILE::m_cbFile
DWORD m_cbFile
Definition: LibSymbolInfo.h:58
MEMORY_MAPPED_FILE::m_errCode
errMMF m_errCode
Definition: LibSymbolInfo.h:59
errMMF_NoError
@ errMMF_NoError
Definition: LibSymbolInfo.h:42
errMMF_FileMapping
@ errMMF_FileMapping
Definition: LibSymbolInfo.h:42
MEMORY_MAPPED_FILE::m_hFileMapping
HANDLE m_hFileMapping
Definition: LibSymbolInfo.h:56
errMMF_FileOpen
@ errMMF_FileOpen
Definition: LibSymbolInfo.h:42
MEMORY_MAPPED_FILE::m_hFile
HANDLE m_hFile
Definition: LibSymbolInfo.h:55
errMMF_MapView
@ errMMF_MapView
Definition: LibSymbolInfo.h:42
MEMORY_MAPPED_FILE::m_pMemoryMappedFileBase
PVOID m_pMemoryMappedFileBase
Definition: LibSymbolInfo.h:57