Some fixes and improvements to wow64fsredir_disable() function.

This commit is contained in:
LoRd_MuldeR 2019-05-09 22:09:17 +02:00
parent 3916593e63
commit a71ae3394d
2 changed files with 11 additions and 8 deletions

View File

@ -259,8 +259,8 @@ namespace MUtils
MUTILS_API QString get_file_path(const int &fd);
//WOW64 redirection
MUTILS_API bool wow64fsredir_disable(void *oldValue);
MUTILS_API bool wow64fsredir_revert (void *oldValue);
MUTILS_API bool wow64fsredir_disable(uintptr_t &oldValue);
MUTILS_API bool wow64fsredir_revert (const uintptr_t oldValue);
//Environment variables
MUTILS_API QString get_envvar(const QString &name);

View File

@ -1715,28 +1715,31 @@ void MUtils::OS::shell_change_notification(void)
// WOW64 REDIRECTION
///////////////////////////////////////////////////////////////////////////////
typedef BOOL (_stdcall *Wow64DisableWow64FsRedirectionFun)(void *OldValue);
typedef BOOL (_stdcall *Wow64RevertWow64FsRedirectionFun )(void *OldValue);
typedef BOOL (_stdcall *Wow64DisableWow64FsRedirectionFun)(PVOID *OldValue);
typedef BOOL (_stdcall *Wow64RevertWow64FsRedirectionFun) (PVOID OldValue);
bool MUtils::OS::wow64fsredir_disable(void *oldValue)
bool MUtils::OS::wow64fsredir_disable(uintptr_t &oldValue)
{
oldValue = reinterpret_cast<uintptr_t>(nullptr);
const Wow64DisableWow64FsRedirectionFun wow64redir_disable = MUtils::Win32Utils::resolve<Wow64DisableWow64FsRedirectionFun>(QLatin1String("kernel32"), QLatin1String("Wow64DisableWow64FsRedirection"));
if(wow64redir_disable)
{
if (wow64redir_disable(oldValue))
PVOID temp = NULL;
if (wow64redir_disable(&temp))
{
oldValue = reinterpret_cast<uintptr_t>(temp);
return true;
}
}
return false;
}
bool MUtils::OS::wow64fsredir_revert(void *oldValue)
bool MUtils::OS::wow64fsredir_revert(const uintptr_t oldValue)
{
const Wow64RevertWow64FsRedirectionFun wow64redir_disable = MUtils::Win32Utils::resolve<Wow64RevertWow64FsRedirectionFun>(QLatin1String("kernel32"), QLatin1String("Wow64RevertWow64FsRedirection"));
if (wow64redir_disable)
{
if (wow64redir_disable(oldValue))
if (wow64redir_disable(reinterpret_cast<PVOID>(oldValue)))
{
return true;
}