1
0
mirror of synced 2024-11-23 22:51:02 +01:00

Clean up code

This commit is contained in:
BroGamer 2022-12-11 11:30:32 +13:00
parent 344b45b77b
commit c9ecc20987
4 changed files with 29 additions and 53 deletions

View File

@ -1,14 +1,13 @@
OUT = patches.8.18
CC := clang
TARGET := x86_64-pc-windows-gnu
SRC = dllmain.c song_limits.s
OBJ_NO_PREFIX = dllmain.o song_limits.o
OBJ = ${addprefix ../../${TARGET}/plugins/8.18/,${OBJ_NO_PREFIX}}
CC = clang
TARGET = x86_64-pc-windows-gnu
SRC = dllmain.c
OBJ = ${addprefix ../../${TARGET}/plugins/8.18/,${SRC:.c=.o}}
EXTERN_SRC = src/helpers.c 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
LDFLAGS = -shared -static -static-libgcc -s
LIBS = -lmingw32 -luuid -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lsetupapi -lversion
all: options ${OUT}
@ -26,10 +25,6 @@ options:
@echo BUILD $@
@${CC} -c ${CFLAGS} $< -o $@
../../${TARGET}/plugins/8.18/%.o: %.s
@echo BUILD $@
@${CC} -m64 -masm=intel -Wall -Ofast -target ${TARGET} -c $< -o $@
.PHONY: ${OUT}
${OUT}: dirs ${OBJ}
@echo LINK $@

View File

@ -4,20 +4,11 @@
const u64 song_data_size = 1024 * 1024 * 64;
void *song_data;
extern void set_song_data_rdx ();
extern void set_song_data_r8 ();
#define GENERATE_CALL(to) \
0x48, 0xB8, (u8)(u64)(to), (u8)((u64)(to) >> 8), (u8)((u64)(to) >> 16), (u8)((u64)(to) >> 24), (u8)((u64)(to) >> 32), (u8)((u64)(to) >> 40), \
(u8)((u64)(to) >> 48), (u8)((u64)(to) >> 56), 0xFF, 0xD0
#define NOPS_NEEDED(start, return_location) WRITE_NOP ((u64)(start) + 12, (u64)(return_location)-1 - (u64)(start)-11)
#define HOOK_SONG_DATA(function, start_loc, ret_loc, handle) \
{ \
WRITE_MEMORY (ASLR (start_loc, handle), u8, GENERATE_CALL (function)); \
NOPS_NEEDED (ASLR (start_loc, handle), ASLR (ret_loc, handle)); \
}
#define RDX_MOV 0x48, 0xBA
#define R8_MOV 0x49, 0xB8
#define GENERATE_MOV(instruction, location) \
instruction, (u8)(u64)(location), (u8)((u64)(location) >> 8), (u8)((u64)(location) >> 16), (u8)((u64)(location) >> 24), \
(u8)((u64)(location) >> 32), (u8)((u64)(location) >> 40), (u8)((u64)(location) >> 48), (u8)((u64)(location) >> 56)
HOOK_DYNAMIC (u8, __fastcall, qrVtable1, u64 a1) { return 1; }
HOOK_DYNAMIC (u8, __fastcall, qrReadFromCOM1, u64 a1) {
@ -78,26 +69,26 @@ PreInit () {
memset (song_data, 0, song_data_size);
// Song data
HOOK_SONG_DATA (set_song_data_r8, 0x140313678, 0x140313685, handle);
WRITE_MEMORY (ASLR (0x14031367B, handle), u8, GENERATE_MOV (R8_MOV, song_data));
// Crown data
HOOK_SONG_DATA (set_song_data_rdx, 0x1402F3AC2, 0x1402F3AD0, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x1402F39F8, 0x1402F3A06, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x1402F3BF6, 0x1402F3C04, handle);
HOOK_SONG_DATA (set_song_data_r8, 0x1403140D4, 0x1403140E1, handle)
WRITE_MEMORY (ASLR (0x1402F3AC6, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1402F39FC, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1402F3BFA, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1403140D7, handle), u8, GENERATE_MOV (R8_MOV, song_data));
// Score ranks
HOOK_SONG_DATA (set_song_data_rdx, 0x1403065E6, 0x1403065F4, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x14030651A, 0x140306528, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x14030644E, 0x14030645C, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x1403068A6, 0x1403068B4, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x1403067DA, 0x1403067E8, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x14030670E, 0x14030671C, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x14030699E, 0x1403069B1, handle);
WRITE_MEMORY (ASLR (0x1403065EA, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x14030651E, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140306452, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1403068AA, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1403067DE, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140306712, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x1403069A2, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
// Unknown
HOOK_SONG_DATA (set_song_data_rdx, 0x140313752, 0x14031375F, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x140313A08, 0x140313A15, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x140313B49, 0x140313B56, handle);
HOOK_SONG_DATA (set_song_data_rdx, 0x140313D35, 0x140313D42, handle);
HOOK_SONG_DATA (set_song_data_r8, 0x140313C3F, 0x140313C4C, handle);
WRITE_MEMORY (ASLR (0x140313755, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140313A0B, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140313B4C, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140313D38, handle), u8, GENERATE_MOV (RDX_MOV, song_data));
WRITE_MEMORY (ASLR (0x140313C42, handle), u8, GENERATE_MOV (R8_MOV, song_data));
// Save settings cross session without F:/ and G:/ drive
WRITE_MEMORY (ASLR (0x140B5C528, handle), char, "./Setting1.bin");

View File

@ -1,10 +0,0 @@
.global set_song_data_rdx
.global set_song_data_r8
set_song_data_rdx:
mov rdx, qword ptr song_data [rip]
ret
set_song_data_r8:
mov r8, qword ptr song_data [rip]
ret

View File

@ -11,7 +11,7 @@ char accessCode1[21] = "00000000000000000001";
char accessCode2[21] = "00000000000000000002";
char chipId1[33] = "00000000000000000000000000000001";
char chipId2[33] = "00000000000000000000000000000002";
char *server = "https://divamodarchive.com";
char *server = "127.0.0.1";
typedef i32 (*callbackAttach) (i32, i32, i32 *);
typedef void (*callbackTouch) (i32, i32, u8[168], u64);