1
0
mirror of synced 2024-11-12 00:40:47 +01:00

mice86 cmdline

This commit is contained in:
Bottersnike 2022-06-14 13:49:45 +09:00
parent 463d94f1ee
commit a74ec83267
5 changed files with 54 additions and 15 deletions

View File

@ -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;

View File

@ -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); }
void hook_processes() { hook("Kernel32.dll", "CreateProcessW", FakeCreateProcessW, (void**)&TrueCreateProcessW, 6); }

View File

@ -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))) {

View File

@ -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

View File

@ -1,7 +1,7 @@
#include <Windows.h>
#include <stdbool.h>
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