Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created June 10, 2013 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/5746724 to your computer and use it in GitHub Desktop.
Save blaquee/5746724 to your computer and use it in GitHub Desktop.
Map view of File, return base
LPVOID createMapAndGetBase(LPCTSTR filePath)
{
LPVOID fBase = 0;
__try{
hFile = CreateFile( filePath,
GENERIC_READ|GENERIC_EXECUTE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
MessageBox(0, "failed to open game.exe! crc bypass will not function.", "error", 0);
__leave;
}
hMap = CreateFileMapping(hFile,
NULL,
PAGE_READONLY,
0,0,
NULL);
if(hMap == NULL)__leave;
hView = MapViewOfFile(hMap,FILE_MAP_READ,0,0,0);
return hView;
}__finally{
if(hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
if(hMap != NULL)
CloseHandle(hMap);
}
return hView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment