From 21428559de8acaffd6d673c9a43fcccd6c325351 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 26 Feb 2024 22:13:42 +0000 Subject: Remove useless/accidental/duped/leftover code Also bump version, for next release (already!). Would have been nice to just force-push this up and pretend it never happened but there's already a couple of people with v1.0 binaries, so let's just avoid any possible confusion. --- src/version.h | 2 +- src/wrap.c | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/version.h b/src/version.h index 89d1553..f66e9a4 100644 --- a/src/version.h +++ b/src/version.h @@ -1,3 +1,3 @@ #define VERSION "1.0" #define VERSION_MAJOR 1 -#define VERSION_MINOR 0 +#define VERSION_MINOR 1 diff --git a/src/wrap.c b/src/wrap.c index f856cb2..8cfe1c2 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -97,9 +97,7 @@ _Noreturn void __stdcall WinMainCRTStartup(void) { if (!k32) die(100, L"Couldn't get kernel32 module; everything is on fire!"); void *lladdr = (void *)GetProcAddress(k32, "LoadLibraryW"); int namebytes = (namelen + 1) * sizeof(*name); - int rsize = sizeof("ThreadFixEntryPoint"); - if (namebytes > rsize) rsize = namebytes; - void *rmem = VirtualAllocEx(info.hProcess, 0, rsize, + void *rmem = VirtualAllocEx(info.hProcess, 0, namebytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (!rmem) { TerminateProcess(info.hProcess, -1); @@ -114,7 +112,7 @@ _Noreturn void __stdcall WinMainCRTStartup(void) { } // injectentry will be at the same offset, just a different base void *rfunc = (char *)rdll + ((char *)&injectedentry - (char *)&__ImageBase); - VirtualFreeEx(info.hProcess, rmem, rsize, MEM_RELEASE); + VirtualFreeEx(info.hProcess, rmem, namebytes, MEM_RELEASE); // Fill out the "fake IAT" table and use WPM to copy it to the injected side // of things. See fakeiat.h for more exposition. #define PUTIAT(f) IAT.f = (_iat_##f##_func)GetProcAddress(k32, #f) @@ -122,14 +120,6 @@ _Noreturn void __stdcall WinMainCRTStartup(void) { PUTIAT(FlushInstructionCache); PUTIAT(VirtualProtect); #undef PUTIAT - IAT.GetSystemInfo = (_iat_GetSystemInfo_func)GetProcAddress( - k32, "GetSystemInfo"); - IAT.FlushInstructionCache = (_iat_FlushInstructionCache_func)GetProcAddress( - k32, "FlushInstructionCache"); - IAT.VirtualProtect = (_iat_VirtualProtect_func)GetProcAddress( - k32, "VirtualProtect"); - IAT.FlushInstructionCache = &FlushInstructionCache; - IAT.VirtualProtect = &VirtualProtect; void *riat = (char *)rdll + ((char *)&IAT - (char *)&__ImageBase); WriteProcessMemory(info.hProcess, riat, &IAT, sizeof(IAT), 0); if (!rpc(info.hProcess, rfunc, 0, -- cgit v1.2.3