Skip to content

Commit 34ec2c0

Browse files
committed
Adds extra hop on proxy method on debug builds, resolves #1
Resolves issue on x64 proxy dll builds on debug mode, and now returns NULL on setup() if loading the proxied DLL is not successful.
1 parent e2c4aad commit 34ec2c0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-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.1 LANGUAGES CXX)
2+
project("dllforward" VERSION 1.2.1.2 LANGUAGES CXX)
33

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

include/headerboilerplate/bottom.inl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ static HMODULE setup()
33
{
44
HMODULE hProxiedDLL{ LoadLibraryA(internal::proxiedDll) };
55
6+
if (!hProxiedDLL)
7+
return NULL;
8+
69
for (const internal::Export& exportEntry : internal::exports)
710
{
811
// uintptr_t pProxiedMethod{ reinterpret_cast<uintptr_t>(hProxiedDLL) + exportEntry.rva };
@@ -11,6 +14,14 @@ static HMODULE setup()
1114
1215
uintptr_t pProxyMethod{ reinterpret_cast<uintptr_t>(exportEntry.method) };
1316
17+
#ifdef _DEBUG
18+
if (*reinterpret_cast<uint8_t*>(pProxyMethod) == 0xE9)
19+
{
20+
int32_t offset{ *reinterpret_cast<int32_t*>(pProxyMethod + 1) };
21+
pProxyMethod += offset + 5;
22+
}
23+
#endif
24+
1425
#ifdef _WIN64
1526
uint8_t opcodes[14]{ 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 };
1627
*reinterpret_cast<uintptr_t*>(opcodes + 6) = pProxiedMethod;

0 commit comments

Comments
 (0)