2023-06-06 17:36:00 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
#include <injshared.h>
|
|
|
|
|
|
|
|
#include <lpayload.h>
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
|
|
|
// Only listen for attach
|
|
|
|
if (reason != DLL_PROCESS_ATTACH) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get target EXE path
|
2023-06-10 15:28:19 +00:00
|
|
|
char *targetExe = getenv(ENV_EXE_PATH);
|
2023-06-05 21:23:08 +00:00
|
|
|
|
|
|
|
// Get the path of the DLL to inject
|
2023-06-10 15:28:19 +00:00
|
|
|
char *injectDll = getenv(ENV_DLL_PATH);
|
2023-06-05 21:23:08 +00:00
|
|
|
|
2023-06-11 15:04:24 +00:00
|
|
|
// Get game commandline
|
|
|
|
char *cmdline = getenv(ENV_PROC_CMD);
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
// Compute the working directory path
|
|
|
|
char workdir[MAX_PATH];
|
|
|
|
strcpy(workdir, targetExe);
|
|
|
|
*(strrchr(workdir, '\\')) = '\0';
|
|
|
|
|
|
|
|
// Start the game
|
|
|
|
STARTUPINFO si;
|
|
|
|
ZeroMemory(&si, sizeof(si));
|
|
|
|
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
ZeroMemory(&pi, sizeof(pi));
|
|
|
|
|
|
|
|
if (!CreateProcessA(
|
|
|
|
NULL,
|
2023-06-11 15:04:24 +00:00
|
|
|
cmdline,
|
2023-06-05 21:23:08 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
CREATE_SUSPENDED,
|
|
|
|
NULL,
|
|
|
|
workdir,
|
|
|
|
&si,
|
|
|
|
&pi
|
|
|
|
)) {
|
2023-06-06 17:36:00 +00:00
|
|
|
char message[64];
|
|
|
|
sprintf(message, "Failed to start game process: %ld", GetLastError());
|
|
|
|
MessageBoxA(NULL, message, "Jadeite Launcher Payload", MB_OK | MB_ICONERROR);
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inject
|
|
|
|
void *payloadStart = &_binary_lpayload_o_p_payload_bin_start;
|
|
|
|
size_t payloadSize = (size_t)&_binary_lpayload_o_p_payload_bin_size;
|
|
|
|
inject(pi.hProcess, payloadStart, payloadSize, injectDll);
|
|
|
|
|
2023-06-10 15:23:43 +00:00
|
|
|
// Optional: wait for user input before resuming (useful for debugging)
|
|
|
|
char *waitEnabled = getenv("WAIT_BEFORE_RESUME");
|
|
|
|
if (waitEnabled && strcmp(waitEnabled, "") != 0) {
|
|
|
|
char message[64];
|
|
|
|
sprintf(message, "PID: %ld. Press OK to continue", pi.dwProcessId);
|
|
|
|
MessageBoxA(NULL, message, "Jadeite Launcher Payload", MB_OK | MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
|
2023-06-05 21:23:08 +00:00
|
|
|
// Resume the process
|
|
|
|
ResumeThread(pi.hThread);
|
|
|
|
|
|
|
|
// The launcher process should now hang untill the game terminates
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|