From 3015bac381594c0f68aee2bcf19c5d63ab13fdea Mon Sep 17 00:00:00 2001 From: CrazyRedMachine Date: Sun, 12 Feb 2023 02:25:52 +0100 Subject: [PATCH] offset adjust, pfree exit, hd on sd rework --- dist/popnhax/popnhax.xml | 6 +- popnhax/config.h | 1 + popnhax/dllmain.cc | 746 ++++++++++++++++++++++++++++++--------- 3 files changed, 581 insertions(+), 172 deletions(-) diff --git a/dist/popnhax/popnhax.xml b/dist/popnhax/popnhax.xml index 855d51a..25c5873 100644 --- a/dist/popnhax/popnhax.xml +++ b/dist/popnhax/popnhax.xml @@ -1,8 +1,10 @@ - + + 0 + 0 - + 0 1 diff --git a/popnhax/config.h b/popnhax/config.h index 74bbb9f..4dfb6d0 100644 --- a/popnhax/config.h +++ b/popnhax/config.h @@ -4,6 +4,7 @@ #include struct popnhax_config { + bool hidden_is_offset; bool pfree; uint8_t hd_on_sd; bool force_unlocks; diff --git a/popnhax/dllmain.cc b/popnhax/dllmain.cc index 73266f7..7e6eed2 100644 --- a/popnhax/dllmain.cc +++ b/popnhax/dllmain.cc @@ -24,11 +24,60 @@ #include "SearchFile.h" +#define DEBUG 0 + +#if DEBUG == 1 +double g_multiplier = 1.; +DWORD (*real_timeGetTime)(); +DWORD patch_timeGetTime() +{ + static DWORD last_real = 0; + static DWORD cumul_offset = 0; + + if (last_real == 0) + { + last_real = real_timeGetTime()*g_multiplier; + return last_real; + } + + DWORD real = real_timeGetTime()*g_multiplier; + DWORD elapsed = real-last_real; + if (elapsed > 16) cumul_offset+= elapsed; + + last_real = real; + return real - cumul_offset; + +} + +bool patch_get_time() +{ + HMODULE hinstLib = GetModuleHandleA("winmm.dll"); + MH_CreateHook((LPVOID)GetProcAddress(hinstLib, "timeGetTime"), (LPVOID)patch_timeGetTime, + (void **)&real_timeGetTime); + return true; +} + +static void memdump(uint8_t* addr, uint8_t len) +{ + printf("MEMDUMP :\n"); + for (int i=0; i