Commit 19aa3a79 authored by Turchanov Sergey's avatar Turchanov Sergey Committed by Alexandre Julliard

Added VIRTUAL_MapFileW to map file to memory in one function call.

parent 656eb965
......@@ -33,6 +33,7 @@ extern WORD WINAPI GlobalHandleToSel( HGLOBAL16 handle );
extern BOOL32 VIRTUAL_Init( void );
extern DWORD VIRTUAL_GetPageSize(void);
extern DWORD VIRTUAL_GetGranularity(void);
extern LPVOID VIRTUAL_MapFileW( LPCWSTR name );
typedef BOOL32 (*HANDLERPROC)(LPVOID, LPVOID);
extern BOOL32 VIRTUAL_SetFaultHandler(LPVOID addr, HANDLERPROC proc, LPVOID arg);
......
......@@ -1447,3 +1447,30 @@ BOOL32 WINAPI UnmapViewOfFile(
VIRTUAL_DeleteView( view );
return TRUE;
}
/***********************************************************************
* VIRTUAL_MapFileW
*
* Helper function to map a file to memory:
* name - file name
* [RETURN] ptr - pointer to mapped file
*/
LPVOID VIRTUAL_MapFileW( LPCWSTR name )
{
HANDLE32 hFile, hMapping;
LPVOID ptr = NULL;
hFile = CreateFile32W( name, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0);
if (hFile != INVALID_HANDLE_VALUE32)
{
hMapping = CreateFileMapping32A( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
CloseHandle( hFile );
if (hMapping)
{
ptr = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
CloseHandle( hMapping );
}
}
return ptr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment