diff --git a/src/micetools/dll/network.c b/src/micetools/dll/network.c index a50f478..68bc662 100644 --- a/src/micetools/dll/network.c +++ b/src/micetools/dll/network.c @@ -26,7 +26,9 @@ const char* INTERCEPT_DNS[] = { "ib.naominet.jp", // Billing "aime.naominet.jp", // Aime (duh) "tenporouter.loc", // Routers - "bbrouter.loc", "mobirouter.loc", "dslrouter.loc", + "bbrouter.loc", // + "mobirouter.loc", // + "dslrouter.loc", // }; DNS_RECORDA dummy_record; diff --git a/src/micetools/dll/processes.c b/src/micetools/dll/processes.c index f624f81..fc92901 100644 --- a/src/micetools/dll/processes.c +++ b/src/micetools/dll/processes.c @@ -20,8 +20,8 @@ BOOL WINAPI FakeCreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, CHAR commandLine[MAX_PATH + 1]; WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, commandLine, sizeof commandLine, NULL, NULL); - HANDLE child = start_and_inject(applicationName, commandLine, MICELIB); + HANDLE child = start_and_inject(applicationName, commandLine, MICELIB, false); return child != NULL; } -void hook_processes() { hook("Kernel32.dll", "CreateProcessW", FakeCreateProcessW, (void**)&TrueCreateProcessW, 6); } \ No newline at end of file +void hook_processes() { hook("Kernel32.dll", "CreateProcessW", FakeCreateProcessW, (void**)&TrueCreateProcessW, 6); } diff --git a/src/micetools/launcher/main.c b/src/micetools/launcher/main.c index 3e47ff1..2f3a74c 100644 --- a/src/micetools/launcher/main.c +++ b/src/micetools/launcher/main.c @@ -6,20 +6,55 @@ const char* VERSION = "0.0-pre"; -int main(int argc, CHAR** argv) { +bool boot_delay = false; +bool gametest = false; +char exe_name[MAX_PATH + 1] = ""; + +void print_help(char* exe) { + log_info(BOOT_LOGGER, "Usage: %s [-h] [-t] [-b executable.exe] [-d]", exe); + log_info(BOOT_LOGGER, " -h: Print this help message and exit"); + log_info(BOOT_LOGGER, " -t: Start the game in test mode"); + log_info(BOOT_LOGGER, " -b: Specify the game binary to use"); + log_info(BOOT_LOGGER, " -d: Wait for a debugger to attach when starting"); + exit(0); +} + +void parse_cmdline(int argc, char* argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h") == 0) { + print_help(argv[0]); + } else if (strcmp(argv[i], "-b") == 0) { + if (i + 1 == argc) print_help(argv[0]); + strcpy(exe_name, argv[++i]); + } else if (strcmp(argv[i], "-d") == 0) { + boot_delay = true; + } else if (strcmp(argv[i], "-t") == 0) { + gametest = true; + } + } +} + +int main(int argc, char* argv[]) { setup_logging(); log_info(BOOT_LOGGER, "Micetools version: %s", VERSION); - char path[MAX_PATH + 1]; - if (!locate_game(path, MAX_PATH + 1)) { - log_error(BOOT_LOGGER, "Failed to locate a game"); - return 0; + parse_cmdline(argc, argv); + + if (exe_name[0] == '\0') { + if (!locate_game(exe_name, MAX_PATH + 1)) { + log_error(BOOT_LOGGER, "Failed to locate a game"); + return 0; + } + } else { + DWORD dwAttrib = GetFileAttributes(exe_name); + if (dwAttrib == INVALID_FILE_ATTRIBUTES || dwAttrib & FILE_ATTRIBUTE_DIRECTORY) { + log_error(BOOT_LOGGER, "%s: no such file found", exe_name); + } } - char* cmdline = ""; - - log_info(BOOT_LOGGER, "%s %s", path, cmdline); + char* cmdline = gametest ? "gametest" : ""; + log_info(BOOT_LOGGER, "%s %s", exe_name, cmdline); char micepath[MAX_PATH + 1]; if (!locate_library(micepath, MAX_PATH + 1)) { @@ -27,7 +62,7 @@ int main(int argc, CHAR** argv) { return 0; } - HANDLE game_proc = start_and_inject(path, cmdline, micepath); + HANDLE game_proc = start_and_inject(exe_name, cmdline, micepath, boot_delay); if (!game_proc) return -1; if (FAILED(WaitForSingleObject(game_proc, INFINITE))) { diff --git a/src/micetools/lib/mice/exe.c b/src/micetools/lib/mice/exe.c index ac7a118..c479d84 100644 --- a/src/micetools/lib/mice/exe.c +++ b/src/micetools/lib/mice/exe.c @@ -68,7 +68,7 @@ bool inject_dll(HANDLE process, LPCSTR inject) { return remote_call(process, addr_LoadLibraryA, inject); } -HANDLE start_and_inject(LPCSTR path, LPSTR cmdline, LPCSTR inject) { +HANDLE start_and_inject(LPCSTR path, LPSTR cmdline, LPCSTR inject, BOOL delay) { log_misc(BOOT_LOGGER, "Using %s for hooks", inject); STARTUPINFOA startupInfo; PROCESS_INFORMATION processInformation; @@ -94,7 +94,9 @@ HANDLE start_and_inject(LPCSTR path, LPSTR cmdline, LPCSTR inject) { goto abort; } - // if (!inject_debug_wait(processInformation.hProcess)) goto abort; + if (delay) { + if (!inject_debug_wait(processInformation.hProcess)) goto abort; + } if (!inject_dll(processInformation.hProcess, inject)) goto abort; // Injection completed, let the program continue execution diff --git a/src/micetools/lib/mice/exe.h b/src/micetools/lib/mice/exe.h index b843373..0f578b4 100644 --- a/src/micetools/lib/mice/exe.h +++ b/src/micetools/lib/mice/exe.h @@ -1,7 +1,7 @@ #include #include -HANDLE start_and_inject(LPCSTR path, LPSTR cmdline, LPCSTR inject); +HANDLE start_and_inject(LPCSTR path, LPSTR cmdline, LPCSTR inject, BOOL delay); #ifndef MICELIB #ifdef MICE_WIN32