Prefix logs with exe name
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "hooks/_hooks.h"
|
#include "hooks/_hooks.h"
|
||||||
|
|
||||||
WCHAR exeName[MAX_PATH + 1];
|
WCHAR exeName[MAX_PATH + 1];
|
||||||
|
char exeNameC[MAX_PATH + 1];
|
||||||
DWORD imageOffset;
|
DWORD imageOffset;
|
||||||
|
|
||||||
#define WIN32_EXE_BASE 0x00400000
|
#define WIN32_EXE_BASE 0x00400000
|
||||||
@@ -61,9 +62,6 @@ void apply_patches(HMODULE hModule) {
|
|||||||
}
|
}
|
||||||
imageOffset = (DWORD)hModule - imageBase;
|
imageOffset = (DWORD)hModule - imageBase;
|
||||||
|
|
||||||
char exeNameC[MAX_PATH + 1];
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, exeName, -1, exeNameC, sizeof exeNameC, NULL, NULL);
|
|
||||||
|
|
||||||
if (!load_patches(MiceConfig.mice.patches_file, exeNameC)) {
|
if (!load_patches(MiceConfig.mice.patches_file, exeNameC)) {
|
||||||
log_error(plfBoot, "Failed to load patches file %s", MiceConfig.mice.patches_file);
|
log_error(plfBoot, "Failed to load patches file %s", MiceConfig.mice.patches_file);
|
||||||
return;
|
return;
|
||||||
@@ -98,15 +96,17 @@ void prebind_hooks() {
|
|||||||
hook_all();
|
hook_all();
|
||||||
install_devices();
|
install_devices();
|
||||||
// TODO: Figure out why we're needing to call this manually (medium priority)
|
// TODO: Figure out why we're needing to call this manually (medium priority)
|
||||||
if (wcscmp(exeName, L"ALLNetProc.exe") == 0) {
|
// if (wcscmp(exeName, L"ALLNetProc.exe") == 0) {
|
||||||
log_warning(plfBoot, "Making explicit call to OPENSSL_add_all_algorithms_noconf");
|
// log_warning(plfBoot, "Making explicit call to OPENSSL_add_all_algorithms_noconf");
|
||||||
|
|
||||||
// OPENSSL_add_all_algorithms_noconf
|
// // OPENSSL_add_all_algorithms_noconf
|
||||||
((void (*)(void))(0x00459770))();
|
// ((void (*)(void))(0x00459770))();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_injection(HMODULE hModule) {
|
void init_injection(HMODULE hModule) {
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, exeName, -1, exeNameC, sizeof exeNameC, NULL, NULL);
|
||||||
|
|
||||||
// Make sure our CRC32 tables are ready for anything that might want to use them
|
// Make sure our CRC32 tables are ready for anything that might want to use them
|
||||||
amiCrc32RInit();
|
amiCrc32RInit();
|
||||||
|
|
||||||
@@ -114,6 +114,7 @@ void init_injection(HMODULE hModule) {
|
|||||||
|
|
||||||
// We're in a new context now, so need to reconfigure
|
// We're in a new context now, so need to reconfigure
|
||||||
setup_logging();
|
setup_logging();
|
||||||
|
MiceSetLogBasename(exeNameC);
|
||||||
log_info(plfBoot, "Handover complete. Now executing within %ls", exeName);
|
log_info(plfBoot, "Handover complete. Now executing within %ls", exeName);
|
||||||
|
|
||||||
init_com_devices();
|
init_com_devices();
|
||||||
|
|||||||
@@ -164,13 +164,22 @@ void init_nv_storage() {
|
|||||||
|
|
||||||
void dump_nv_storage() {
|
void dump_nv_storage() {
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
fopen_s(&fp, "dev/kc/nvram.bin", "wb");
|
if (fopen_s(&fp, "dev/kc/nvram.bin", "wb")) {
|
||||||
|
log_error(plfMxParallel, "Failed to open nvram.bin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
fwrite(nvram, 1, sizeof nvram, fp);
|
fwrite(nvram, 1, sizeof nvram, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fopen_s(&fp, "dev/kc/eeprom.bin", "wb");
|
if (fopen_s(&fp, "dev/kc/eeprom.bin", "wb")) {
|
||||||
|
log_error(plfMxParallel, "Failed to open eeprom.bin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
fwrite(eeprom, 1, sizeof eeprom, fp);
|
fwrite(eeprom, 1, sizeof eeprom, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fopen_s(&fp, "dev/kc/flash.bin", "wb");
|
if (fopen_s(&fp, "dev/kc/flash.bin", "wb")) {
|
||||||
|
log_error(plfMxParallel, "Failed to open flash.bin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
fwrite(flash, 1, sizeof flash, fp);
|
fwrite(flash, 1, sizeof flash, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ void* Win32HotpatchHook(PVOID src, PVOID dst) {
|
|||||||
// We don't need a gateway; we can just jump right in
|
// We don't need a gateway; we can just jump right in
|
||||||
return bSrc + 2;
|
return bSrc + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CMP2(x, a, b) (x[0] == 0x##a && x[1] == 0x##b)
|
||||||
|
#define CMP3(x, a, b, c) (CMP2(x, a, b) && x[2] == 0x##c)
|
||||||
|
#define CMP4(x, a, b, c, d) (CMP3(x, a, b, c) && x[3] == 0x##d)
|
||||||
|
#define CMP5(x, a, b, c, d, e) (CMP4(x, a, b, c, d) && x[4] == 0x##e)
|
||||||
void* CreateHook32(PVOID src, PVOID dst) {
|
void* CreateHook32(PVOID src, PVOID dst) {
|
||||||
LPBYTE bSrc = (LPBYTE)src;
|
LPBYTE bSrc = (LPBYTE)src;
|
||||||
|
|
||||||
@@ -89,7 +94,7 @@ void* CreateHook32(PVOID src, PVOID dst) {
|
|||||||
|
|
||||||
// This is a very crude way to identify common instruction patterns
|
// This is a very crude way to identify common instruction patterns
|
||||||
// to select or patch length.
|
// to select or patch length.
|
||||||
if (bSrc[0] == 0xff && bSrc[1] == 0x25) {
|
if (CMP2(bSrc, ff, 25)) {
|
||||||
// jmp DWORD PTR ds:0x........
|
// jmp DWORD PTR ds:0x........
|
||||||
len = 6;
|
len = 6;
|
||||||
} else if (bSrc[0] == 0x6a && bSrc[2] == 0x68) {
|
} else if (bSrc[0] == 0x6a && bSrc[2] == 0x68) {
|
||||||
@@ -103,24 +108,24 @@ void* CreateHook32(PVOID src, PVOID dst) {
|
|||||||
} else if (bSrc[0] == 0x68) {
|
} else if (bSrc[0] == 0x68) {
|
||||||
// push 0x... (dword)
|
// push 0x... (dword)
|
||||||
len = 5;
|
len = 5;
|
||||||
} else if (bSrc[0] == 0x55 && bSrc[1] == 0x8B && bSrc[2] == 0xEC && bSrc[3] == 0x83 &&
|
} else if (CMP5(bSrc, 55, 8B, EC, 83, E4)) {
|
||||||
bSrc[4] == 0xE4) {
|
|
||||||
// pusb ebp
|
// pusb ebp
|
||||||
// mov ebp,esp
|
// mov ebp,esp
|
||||||
// and esp,ffffff**
|
// and esp,ffffff**
|
||||||
len = 6;
|
len = 6;
|
||||||
} else if (bSrc[0] == 0x55 && bSrc[1] == 0x8B && bSrc[2] == 0xEC && bSrc[3] == 0x8b &&
|
} else if (CMP5(bSrc, 55, 8B, EC, 8B, 45)) {
|
||||||
bSrc[4] == 0x45) {
|
|
||||||
// pusb ebp
|
// pusb ebp
|
||||||
// mov ebp,esp
|
// mov ebp,esp
|
||||||
// mov eax,DWORD PTR [...]
|
// mov eax,DWORD PTR [...]
|
||||||
len = 6;
|
len = 6;
|
||||||
} else if (bSrc[0] == 0x55 && bSrc[1] == 0x8B && bSrc[2] == 0xEC && bSrc[3] == 0x80 &&
|
} else if (CMP5(bSrc, 55, 8B, EC, 80, 3D)) {
|
||||||
bSrc[4] == 0x3D) {
|
|
||||||
// pusb ebp
|
// pusb ebp
|
||||||
// mov ebp,esp
|
// mov ebp,esp
|
||||||
// cmd BYTE PTR ds:0x...,0x...
|
// cmd BYTE PTR ds:0x...,0x...
|
||||||
len = 10;
|
len = 10;
|
||||||
|
} else if (CMP5(bSrc, B8, 00, 10, 00, 00)) {
|
||||||
|
// mov eax,0x1000
|
||||||
|
len = 5;
|
||||||
} else {
|
} else {
|
||||||
log_error(plfHooks, "Unable to identify gateway length! Function peek:");
|
log_error(plfHooks, "Unable to identify gateway length! Function peek:");
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
|
|||||||
@@ -20,12 +20,14 @@
|
|||||||
|
|
||||||
static BOOL logIsMaster = FALSE;
|
static BOOL logIsMaster = FALSE;
|
||||||
|
|
||||||
extern WCHAR exeName[MAX_PATH + 1];
|
CHAR logBasename[MAX_PATH + 1] = { 0 };
|
||||||
extern DWORD imageOffset;
|
extern DWORD imageOffset;
|
||||||
|
|
||||||
extern BOOL(WINAPI* TrueWriteFile)(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
extern BOOL(WINAPI* TrueWriteFile)(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
||||||
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
|
LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
|
||||||
|
|
||||||
|
void MiceSetLogBasename(char* baseName) { strcpy_s(logBasename, sizeof logBasename, baseName); }
|
||||||
|
|
||||||
char _log_prelude[64];
|
char _log_prelude[64];
|
||||||
char* log_prelude() {
|
char* log_prelude() {
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
@@ -34,7 +36,9 @@ char* log_prelude() {
|
|||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
localtime_s(&timeinfo, &rawtime);
|
localtime_s(&timeinfo, &rawtime);
|
||||||
|
|
||||||
strftime(_log_prelude, sizeof _log_prelude, "[%Y/%m/%d %H:%M:%S] ", &timeinfo);
|
size_t offset = strftime(_log_prelude, sizeof _log_prelude, "[%Y/%m/%d %H:%M:%S] ", &timeinfo);
|
||||||
|
if (logBasename[0])
|
||||||
|
sprintf_s(_log_prelude + offset, sizeof _log_prelude - offset, "%s:", logBasename);
|
||||||
return _log_prelude;
|
return _log_prelude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ extern PLOG_FACILITY plfNetwork;
|
|||||||
|
|
||||||
extern CRITICAL_SECTION logger_lock;
|
extern CRITICAL_SECTION logger_lock;
|
||||||
|
|
||||||
|
void MiceSetLogBasename(char* baseName);
|
||||||
|
|
||||||
int _log_trace(PLOG_FACILITY facility, const char* format, ...);
|
int _log_trace(PLOG_FACILITY facility, const char* format, ...);
|
||||||
int _log_misc(PLOG_FACILITY facility, const char* format, ...);
|
int _log_misc(PLOG_FACILITY facility, const char* format, ...);
|
||||||
int _log_info(PLOG_FACILITY facility, const char* format, ...);
|
int _log_info(PLOG_FACILITY facility, const char* format, ...);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ void mdkPcpStatus(pcpa_t* stream, void* data) { pcpaSetSendPacket(stream, KC_STA
|
|||||||
|
|
||||||
void mdkPcpAbGameId(pcpa_t* stream, void* data) {
|
void mdkPcpAbGameId(pcpa_t* stream, void* data) {
|
||||||
// TODO: Can we do better?
|
// TODO: Can we do better?
|
||||||
pcpaSetSendPacket(stream, AB_GAMEID, "----");
|
// pcpaSetSendPacket(stream, AB_GAMEID, "----");
|
||||||
|
pcpaSetSendPacket(stream, AB_GAMEID, "SDEY");
|
||||||
}
|
}
|
||||||
void mdkPcpAbSystemFlag(pcpa_t* stream, void* data) {
|
void mdkPcpAbSystemFlag(pcpa_t* stream, void* data) {
|
||||||
// systemflag 24 = billing + allnet, which should suffice for everything
|
// systemflag 24 = billing + allnet, which should suffice for everything
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ mxmaster.exe: mxmaster.patch
|
|||||||
mxgfetcher.exe: mxgfetcher.patch
|
mxgfetcher.exe: mxgfetcher.patch
|
||||||
ORIG_mxsegaboot.exe: mxsegaboot.patch
|
ORIG_mxsegaboot.exe: mxsegaboot.patch
|
||||||
mxsegaboot.exe: mxsegaboot.patch
|
mxsegaboot.exe: mxsegaboot.patch
|
||||||
ALLNetProc_win.exe: ALLNetProc.patch
|
|
||||||
ALLNetProc.exe: ALLNetProc.patch
|
|
||||||
Game.exe: Game.patch
|
Game.exe: Game.patch
|
||||||
mxnetwork.exe: mxnetwork.patch
|
mxnetwork.exe: mxnetwork.patch
|
||||||
maimai_dump_.exe: maimai_dump_.patch
|
maimai_dump_.exe: maimai_dump_.patch
|
||||||
RingGame.exe: UnderNightInBirthExLate[st].patch
|
RingGame.exe: UnderNightInBirthExLate[st].patch
|
||||||
nxAuth.exe: nxAuth.patch
|
nxAuth.exe: nxAuth.patch
|
||||||
ALLNetProc_Win.exe: ALLNetProc_Win.patch
|
ALLNetProc_Win.exe: ALLNetProc_Win.patch
|
||||||
|
ALLNetProc.exe: ALLNetProc_Win.patch
|
||||||
|
|||||||
Reference in New Issue
Block a user