diff --git a/patches/8.18/dllmain.c b/patches/8.18/dllmain.c index 932a360..20295cd 100644 --- a/patches/8.18/dllmain.c +++ b/patches/8.18/dllmain.c @@ -1,25 +1,19 @@ +#define BASE_ADDRESS 0x140000000 #include "helpers.h" -HOOK (i32, __stdcall, CrtMain, 0x140666d2c, HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, i32 nShowCmd) { - // Blatantly stolen patches from mon.im - WRITE_MEMORY (0x1400239C0, u8, 0xC3); // Stop error - WRITE_MEMORY (0x140314E8D, u8, 0xB0, 0x01); // Unlock songs - WRITE_MEMORY (0x140692E17, u8, 0xEB); // Shared audio - WRITE_MEMORY (0x140313726, u8, 0x00, 0x7F); // Remove song limit - WRITE_MEMORY (0x140517339, u8, 0xBA, 0x00, 0x00, 0x00, 0x00, - 0x90); // Disable VSync - // Save settings cross session - WRITE_MEMORY (0x140B5C528, u8, "./Setting1.bin"); - WRITE_MEMORY (0x140B5C538, u8, "./Setting2.bin"); - - return originalCrtMain (hInstance, hPrevInstance, lpCmdLine, nShowCmd); -} - i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) { - if (cause != DLL_PROCESS_ATTACH) - return 1; - - INSTALL_HOOK(CrtMain); + if (cause != DLL_PROCESS_ATTACH) + return 1; + + WRITE_MEMORY (ASLR(0x1400239C0), u8, 0xC3); // Stop error + WRITE_MEMORY (ASLR(0x140314E8D), u8, 0xB0, 0x01); // Unlock songs + WRITE_MEMORY (ASLR(0x140692E17), u8, 0xEB); // Shared audio + WRITE_MEMORY (ASLR(0x140313726), u8, 0x00, 0x7F); // Remove song limit + WRITE_MEMORY (ASLR(0x140517339), u8, 0xBA, 0x00, 0x00, 0x00, 0x00, + 0x90); // Disable VSync + // Save settings cross session + WRITE_MEMORY (ASLR(0x140B5C528), u8, "./Setting1.bin"); + WRITE_MEMORY (ASLR(0x140B5C538), u8, "./Setting2.bin"); - return 1; + return 1; } diff --git a/src/dllmain.c b/src/dllmain.c index 80748ec..32547a3 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -110,7 +110,7 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) { if (cause != DLL_PROCESS_ATTACH) return true; init_boilerplate (); - + // Set current directory to the directory of the executable // Find all files in the plugins directory that end with .dll // Call loadlibraryA on those files @@ -126,9 +126,9 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) { do { if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; wchar_t filePath[MAX_PATH]; - wcscpy(filePath, path); - wcscat(filePath, L"/plugins/"); - wcscat(filePath, fd.cFileName); + wcscpy (filePath, path); + wcscat (filePath, L"/plugins/"); + wcscat (filePath, fd.cFileName); HMODULE hModule = LoadLibraryW (filePath); if (!hModule) { MessageBoxW (NULL, L"Failed to load plugin", fd.cFileName, MB_ICONERROR); } } while (FindNextFileW (hFind, &fd)); diff --git a/src/helpers.h b/src/helpers.h index 128cf1d..5318e9a 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -15,6 +15,10 @@ typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +#ifdef BASE_ADDRESS +#define ASLR(address) ((u64)GetModuleHandle (0) + (u64)address - (u64)BASE_ADDRESS) +#endif + #define FUNCTION_PTR(returnType, callingConvention, function, location, ...) \ returnType (callingConvention *function) (__VA_ARGS__) = (returnType (callingConvention *) (__VA_ARGS__)) (location)