summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-02-26 22:13:42 +0000
committerMichael Smith <mikesmiffy128@gmail.com>2024-02-26 23:08:38 +0000
commit21428559de8acaffd6d673c9a43fcccd6c325351 (patch)
treeb0e4a233453ebffd69d4778f7344e3e745a092da
parentefd2491a3d19160d9cae2a094e7baa9f2d958196 (diff)
Remove useless/accidental/duped/leftover codev1.1
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.
-rw-r--r--src/version.h2
-rw-r--r--src/wrap.c14
2 files changed, 3 insertions, 13 deletions
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,