Skip to content

Commit e2c4aad

Browse files
committed
Don't attempt RevertWow64Fs on x64
Now only calls Wow64RevertWow64FsRedirection on x86
1 parent b5d7099 commit e2c4aad

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.21)
2-
project("dllforward" VERSION 1.2.1 LANGUAGES CXX)
2+
project("dllforward" VERSION 1.2.1.1 LANGUAGES CXX)
33

44
## Project's base, containing all that's to be inherited
55
set(PROJECT_BASE ${PROJECT_NAME}-base)

src/parser.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ Architecture parseArchitecture(const fs::path& path)
1818
IMAGE_DOS_HEADER dosHeader;
1919
IMAGE_NT_HEADERS32 ntHeader32;
2020

21+
#ifndef _WIN64
2122
PVOID oldRedirection{ NULL };
2223
if (!Wow64DisableWow64FsRedirection(&oldRedirection))
2324
throw std::system_error(std::error_code(GetLastError(), std::system_category()), "Failed to disable Wow64Fs redirection");
25+
#endif
2426

2527
std::ifstream file(path, std::ios::binary);
2628

29+
#ifndef _WIN64
2730
if (!Wow64RevertWow64FsRedirection(oldRedirection))
2831
throw std::system_error(std::error_code(GetLastError(), std::system_category()), "Failed to revert Wow64Fs redirection");
32+
#endif
2933

3034
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
3135

@@ -47,15 +51,19 @@ std::vector<Export> parseExports(const fs::path& path)
4751
{
4852
_LOADED_IMAGE LoadedImage;
4953

54+
#ifndef _WIN64
5055
PVOID oldRedirection{ NULL };
5156
if (!Wow64DisableWow64FsRedirection(&oldRedirection))
5257
throw std::system_error(std::error_code(GetLastError(), std::system_category()), "Failed to disable Wow64Fs redirection");
58+
#endif
5359

5460
if (!MapAndLoad(path.u8string().c_str(), nullptr, &LoadedImage, TRUE, TRUE))
5561
throw std::system_error(std::error_code(GetLastError(), std::system_category()), "MapAndLoad failed to load DLL");
5662

63+
#ifndef _WIN64
5764
if (!Wow64RevertWow64FsRedirection(oldRedirection))
5865
throw std::system_error(std::error_code(GetLastError(), std::system_category()), "Failed to revert Wow64Fs redirection");
66+
#endif
5967

6068
std::vector<Export> exportVector;
6169

0 commit comments

Comments
 (0)