Separate patches. allow for plugin loading
This commit is contained in:
parent
722ca5c01e
commit
80f57678aa
31
patches/8.18/Makefile
Normal file
31
patches/8.18/Makefile
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
OUT = patches.818
|
||||||
|
CC := clang
|
||||||
|
TARGET := x86_64-pc-windows-gnu
|
||||||
|
SRC = dllmain.c
|
||||||
|
OBJ = ${addprefix ${TARGET}/,${SRC:.c=.o}}
|
||||||
|
EXTERN_SRC = tomlc99/toml.c minhook/src/buffer.c minhook/src/hook.c minhook/src/trampoline.c minhook/src/hde/hde32.c minhook/src/hde/hde64.c
|
||||||
|
EXTERN_OBJ = ${addprefix ../../${TARGET}/,${EXTERN_SRC:.c=.o}}
|
||||||
|
CFLAGS = -std=c99 -I../../src -I../../minhook/include -I../../tomlc99 -Wall -Ofast -target ${TARGET} -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=_WIN32_WINNT_WIN7
|
||||||
|
LDFLAGS := -shared -static -static-libgcc -s
|
||||||
|
LIBS := -lmingw32 -luuid -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lsetupapi -lversion
|
||||||
|
|
||||||
|
all: options ${OUT}
|
||||||
|
|
||||||
|
.PHONY: dirs
|
||||||
|
dirs:
|
||||||
|
@mkdir -p ${TARGET}
|
||||||
|
|
||||||
|
.PHONY: options
|
||||||
|
options:
|
||||||
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
|
@echo "CC = ${CC}"
|
||||||
|
|
||||||
|
${TARGET}/%.o: %.c
|
||||||
|
@echo BUILD $@
|
||||||
|
@${CC} -c ${CFLAGS} $< -o $@
|
||||||
|
|
||||||
|
.PHONY: ${OUT}
|
||||||
|
${OUT}: dirs ${DEPS} ${OBJ}
|
||||||
|
@echo LINK $@
|
||||||
|
@${CC} ${CFLAGS} -o ${TARGET}/$@.dll ${OBJ} ${EXTERN_OBJ} ${LDFLAGS} ${LIBS}
|
25
patches/8.18/dllmain.c
Normal file
25
patches/8.18/dllmain.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#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);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
@ -92,7 +92,6 @@ u16 __fastcall bnusio_GetCoin (i32 a1) {
|
|||||||
if (IsButtonTapped (TEST)) testEnabled = !testEnabled;
|
if (IsButtonTapped (TEST)) testEnabled = !testEnabled;
|
||||||
if (IsButtonTapped (EXIT)) ExitProcess (0);
|
if (IsButtonTapped (EXIT)) ExitProcess (0);
|
||||||
}
|
}
|
||||||
printf ("%d %d\n", a1, coin_count);
|
|
||||||
return coin_count;
|
return coin_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,27 +105,35 @@ u32 __stdcall bnusio_GetSwIn () {
|
|||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
|
||||||
if (cause == DLL_PROCESS_DETACH) DisposePoll ();
|
if (cause == DLL_PROCESS_DETACH) DisposePoll ();
|
||||||
if (cause != DLL_PROCESS_ATTACH) return true;
|
if (cause != DLL_PROCESS_ATTACH) return true;
|
||||||
|
|
||||||
INSTALL_HOOK (CrtMain);
|
|
||||||
init_boilerplate ();
|
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
|
||||||
|
// Create a message box if they fail to load
|
||||||
|
wchar_t path[MAX_PATH];
|
||||||
|
GetModuleFileNameW (NULL, path, MAX_PATH);
|
||||||
|
*wcsrchr (path, '\\') = '\0';
|
||||||
|
SetCurrentDirectoryW (path);
|
||||||
|
|
||||||
|
WIN32_FIND_DATAW fd;
|
||||||
|
HANDLE hFind = FindFirstFileW (L"plugins/*.dll", &fd);
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE) {
|
||||||
|
do {
|
||||||
|
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
|
||||||
|
wchar_t filePath[MAX_PATH];
|
||||||
|
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));
|
||||||
|
FindClose (hFind);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user