BOOL Enable64BitRedirection(BOOLEAN EnableRedirection)
{
typedef BOOLEAN (
WINAPI *LPF_Wow64EnableWow64FsRedirection)(BOOLEAN EnableRedirection);
typedef BOOL (
WINAPI *LPF_IsWow64Process) (__in
HANDLE hProcess, __out PBOOL Wow64Process);
BOOL Wow64Process;
HMODULE hLib = LoadLibrary("kernel32.dll");
LPF_IsWow64Process IsWow64Process = (LPF_IsWow64Process)GetProcAddress(hLib, "IsWow64Process");
LPF_Wow64EnableWow64FsRedirection Wow64EnableWow64FsRedirection = (LPF_Wow64EnableWow64FsRedirection)GetProcAddress(hLib, "Wow64EnableWow64FsRedirection");
if (IsWow64Process != NULL && Wow64EnableWow64FsRedirection != NULL)
{
if (IsWow64Process(GetCurrentProcess(), &Wow64Process) && Wow64Process)
{
// 64 bit process
return Wow64EnableWow64FsRedirection(EnableRedirection);
}
}
return FALSE;
}
DWORD getFileSize(LPCSTR FileName){
LARGE_INTEGER lpSize = {};
HANDLE hFile = CreateFileA(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE)
{
GetFileSizeEx(hFile, &lpSize);
CloseHandle(hFile);
}
return lpSize.u.LowPart;
}
int
WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
DWORD filesize1, filesize2;
char szOutput[200];
filesize1 = getFileSize("c:\\windows\\system32\\notepad.exe");
Enable64BitRedirection(FALSE);
filesize2 = getFileSize("c:\\windows\\system32\\notepad.exe");
wsprintfA(szOutput, "Size 1: %d bytes\nSize 2: %d bytes\n", filesize1, filesize2);
MessageBox(0, szOutput, "Filesize", 0);
return 0;
}