#include #include #include const char LAUNCHER_INJECT_DLL[] = "launcher_payload.dll"; const char GAME_INJECT_DLL[] = "game_payload.dll"; #define SHIFT(argc, argv) argc--, argv++ int main(int argc, char **argv) { // Read arguments char *gamePath = NULL; char *launcherPath = NULL; // Skip executable SHIFT(argc, argv); switch (argc) { case 0: printf("Usage: wine jadeite.exe [game path] \n"); return 0; case 1: gamePath = argv[0]; SHIFT(argc, argv); launcherPath = "--"; break; default: gamePath = argv[0]; SHIFT(argc, argv); launcherPath = argv[0]; SHIFT(argc, argv); break; } // Default launcher path if (strcmp(launcherPath, "--") == 0) { printf("No launcher process specified! Using explorer.exe\n"); launcherPath = "C:\\Windows\\explorer.exe"; } // cd into the injector directory char injectorPath[MAX_PATH]; GetModuleFileNameA(GetModuleHandleA(NULL), injectorPath, sizeof(injectorPath)); *(strrchr(injectorPath, '\\')) = '\0'; SetCurrentDirectoryA(injectorPath); // Compute absolute paths char gameExePath[MAX_PATH]; GetFullPathNameA(gamePath, sizeof(gameExePath), gameExePath, NULL); char gamePayloadPath[MAX_PATH]; GetFullPathNameA(GAME_INJECT_DLL, sizeof(gamePayloadPath), gamePayloadPath, NULL); char launcherPayloadPath[MAX_PATH]; GetFullPathNameA(LAUNCHER_INJECT_DLL, sizeof(launcherPayloadPath), launcherPayloadPath, NULL); // Construct commandline for the game process char cmdline[8192]; sprintf(cmdline, "\"%s\"", gameExePath); while (argc) { char arg[8192]; sprintf(arg, " \"%s\"", argv[0]); strcat(cmdline, arg); SHIFT(argc, argv); } // Set envvars SetEnvironmentVariableA(ENV_EXE_PATH, gameExePath); SetEnvironmentVariableA(ENV_DLL_PATH, gamePayloadPath); SetEnvironmentVariableA(ENV_PROC_CMD, cmdline); // Start the launcher printf("Starting '%s' via '%s'\n", gameExePath, launcherPath); STARTUPINFO si; ZeroMemory(&si, sizeof(si)); PROCESS_INFORMATION pi; si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); if (!CreateProcessA( launcherPath, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi )) { fprintf(stderr, "Could not start process! (%ld)\n", GetLastError()); exit(1); } printf("Started launcher process (%ld)\n", pi.dwProcessId); // Inject void *payloadStart = &_binary_ipayload_o_p_payload_bin_start; size_t payloadSize = (size_t)&_binary_ipayload_o_p_payload_bin_size; // yes this is valid inject(pi.hProcess, payloadStart, payloadSize, launcherPayloadPath); // Resume the process ResumeThread(pi.hThread); return 0; }