This thread explains how to manage Wow64DisableWow64FsRedirection function to work both on a 32 bits and 64 bits systems: Wow64DisableWow64FsRedirection on 32-bit Windows XP
However, they do not seem to Revert after having disable the Wow64.
Normally, the code is:
PVOID pOldValue = NULL;
Wow64DisableWow64FsRedirection(&pOldValue);
std::string path = C:/Windows/system32/prog.exe;
ShellExecuteA(NULL, ("open"), LPCSTR(path.c_str()), NULL, NULL, SW_SHOWNORMAL);
Wow64RevertWow64FsRedirection(pOldValue);
However, with the code shown in the other thread, the is no "Revert":
typedef BOOL WINAPI fntype_Wow64DisableWow64FsRedirection(PVOID *OldValue);
auto pfnWow64DisableWow64FsRedirection = (fntype_Wow64DisableWow64FsRedirection*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "Wow64DisableWow64FsRedirection");
if (pfnWow64DisableWow64FsRedirection) {
// function found, call it via pointer
PVOID arg;
(*pfnWow64DisableWow64FsRedirection)(&arg);
std::string path = C:/Windows/system32/prog.exe;
ShellExecuteA(NULL, ("open"), LPCSTR(path.c_str()), NULL, NULL, SW_SHOWNORMAL);
}
I think I should do the following but I'm not sure with all the * and &
typedef BOOL WINAPI fntype_Wow64DisableWow64FsRedirection(PVOID *OldValue);
auto pfnWow64DisableWow64FsRedirection =(fntype_Wow64DisableWow64FsRedirection*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "Wow64DisableWow64FsRedirection");
typedef BOOL WINAPI fntype_Wow64RevertWow64FsRedirection(PVOID OldValue);
auto pfnWow64RevertWow64FsRedirection = (fntype_Wow64RevertWow64FsRedirection*)GetProcAddress(GetModuleHandleA("kernel32.dll"), "Wow64RevertWow64FsRedirection");
if (pfnWow64DisableWow64FsRedirection)
{
// function found, call it via pointer
PVOID arg;
(*pfnWow64DisableWow64FsRedirection)(&arg);
std::string path = C:/Windows/system32/prog.exe;
ShellExecuteA(NULL, ("open"), LPCSTR(path.c_str()), NULL, NULL, SW_SHOWNORMAL);
ShellExecuteA(NULL, ("open"), LPCSTR(path.c_str()), NULL, NULL, SW_SHOWNORMAL);
(*pfnWow64RevertWow64FsRedirection)(arg);
}
Thank you very much,
Alex