From a71ae3394d05c8e9bf8482ed5bf3197cd0f44b50 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Thu, 9 May 2019 22:09:17 +0200 Subject: [PATCH] Some fixes and improvements to wow64fsredir_disable() function. --- include/MUtils/OSSupport.h | 4 ++-- src/OSSupport_Win32.cpp | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index 467ce3c..b1d558a 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -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); diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index a5d783f..862bf02 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -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(nullptr); const Wow64DisableWow64FsRedirectionFun wow64redir_disable = MUtils::Win32Utils::resolve(QLatin1String("kernel32"), QLatin1String("Wow64DisableWow64FsRedirection")); if(wow64redir_disable) { - if (wow64redir_disable(oldValue)) + PVOID temp = NULL; + if (wow64redir_disable(&temp)) { + oldValue = reinterpret_cast(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(QLatin1String("kernel32"), QLatin1String("Wow64RevertWow64FsRedirection")); if (wow64redir_disable) { - if (wow64redir_disable(oldValue)) + if (wow64redir_disable(reinterpret_cast(oldValue))) { return true; }