2023-06-05 21:23:08 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <injshared.h>
|
|
|
|
|
|
|
|
#include <ipayload.h>
|
|
|
|
|
|
|
|
const char LAUNCHER_INJECT_DLL[] = "launcher_payload.dll";
|
|
|
|
const char GAME_INJECT_DLL[] = "game_payload.dll";
|
|
|
|
|
2023-06-11 15:04:24 +00:00
|
|
|
#define SHIFT(argc, argv) argc--, argv++
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
// Read arguments
|
|
|
|
char *gamePath = NULL;
|
|
|
|
char *launcherPath = NULL;
|
|
|
|
|
2023-06-11 15:04:24 +00:00
|
|
|
// Skip executable
|
|
|
|
SHIFT(argc, argv);
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
switch (argc) {
|
2023-06-11 15:04:24 +00:00
|
|
|
case 0:
|
2023-06-05 21:23:08 +00:00
|
|
|
printf("Usage: wine jadeite.exe [game path] <launcher path>\n");
|
|
|
|
return 0;
|
2023-06-11 15:04:24 +00:00
|
|
|
case 1:
|
|
|
|
gamePath = argv[0];
|
|
|
|
SHIFT(argc, argv);
|
|
|
|
|
|
|
|
launcherPath = "--";
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
2023-06-11 15:04:24 +00:00
|
|
|
gamePath = argv[0];
|
|
|
|
SHIFT(argc, argv);
|
|
|
|
|
|
|
|
launcherPath = argv[0];
|
|
|
|
SHIFT(argc, argv);
|
|
|
|
|
|
|
|
break;
|
2023-06-05 21:23:08 +00:00
|
|
|
}
|
|
|
|
|
2023-06-11 15:04:24 +00:00
|
|
|
// Default launcher path
|
|
|
|
if (strcmp(launcherPath, "--") == 0) {
|
|
|
|
printf("No launcher process specified! Using explorer.exe\n");
|
|
|
|
launcherPath = "C:\\Windows\\explorer.exe";
|
|
|
|
}
|
|
|
|
|
2023-06-07 17:09:02 +00:00
|
|
|
// cd into the injector directory
|
|
|
|
char injectorPath[MAX_PATH];
|
|
|
|
GetModuleFileNameA(GetModuleHandleA(NULL), injectorPath, sizeof(injectorPath));
|
|
|
|
|
2023-06-10 15:28:19 +00:00
|
|
|
*(strrchr(injectorPath, '\\')) = '\0';
|
2023-06-07 17:09:02 +00:00
|
|
|
|
|
|
|
SetCurrentDirectoryA(injectorPath);
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
// 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);
|
|
|
|
|
2023-06-11 15:04:24 +00:00
|
|
|
// 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);
|
|
|
|
}
|
2023-06-05 21:23:08 +00:00
|
|
|
|
|
|
|
// Set envvars
|
2023-06-06 17:23:15 +00:00
|
|
|
SetEnvironmentVariableA(ENV_EXE_PATH, gameExePath);
|
|
|
|
SetEnvironmentVariableA(ENV_DLL_PATH, gamePayloadPath);
|
2023-06-11 15:04:24 +00:00
|
|
|
SetEnvironmentVariableA(ENV_PROC_CMD, cmdline);
|
2023-06-05 21:23:08 +00:00
|
|
|
|
|
|
|
// Start the launcher
|
2023-06-11 15:04:24 +00:00
|
|
|
printf("Starting '%s' via '%s'\n", gameExePath, launcherPath);
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
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;
|
|
|
|
}
|