Switch to using wide strings in the injector
This commit is contained in:
@ -5,28 +5,28 @@
|
||||
|
||||
#include <launcher_p.h>
|
||||
|
||||
const char LAUNCHER_INJECT_DLL[] = "launcher_payload.dll";
|
||||
const char GAME_INJECT_DLL[] = "game_payload.dll";
|
||||
const wchar_t *LAUNCHER_INJECT_DLL = L"launcher_payload.dll";
|
||||
const wchar_t *GAME_INJECT_DLL = L"game_payload.dll";
|
||||
|
||||
#define SHIFT(argc, argv) argc--, argv++
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int wmain(int argc, wchar_t **argv) {
|
||||
// Read arguments
|
||||
char *gamePath = NULL;
|
||||
char *launcherPath = NULL;
|
||||
wchar_t *gamePath = NULL;
|
||||
wchar_t *launcherPath = NULL;
|
||||
|
||||
// Skip executable
|
||||
SHIFT(argc, argv);
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
printf("Usage: wine jadeite.exe [game path] <launcher path>\n");
|
||||
wprintf(L"Usage: wine jadeite.exe [game path] <launcher path>\n");
|
||||
return 0;
|
||||
case 1:
|
||||
gamePath = argv[0];
|
||||
SHIFT(argc, argv);
|
||||
|
||||
launcherPath = "--";
|
||||
launcherPath = L"--";
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -40,57 +40,57 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Default launcher path
|
||||
if (strcmp(launcherPath, "--") == 0) {
|
||||
printf("No launcher process specified! Using explorer.exe\n");
|
||||
launcherPath = "C:\\Windows\\explorer.exe";
|
||||
if (wcscmp(launcherPath, L"--") == 0) {
|
||||
wprintf(L"No launcher process specified! Using explorer.exe\n");
|
||||
launcherPath = L"C:\\Windows\\explorer.exe";
|
||||
}
|
||||
|
||||
// cd into the injector directory
|
||||
char injectorPath[MAX_PATH];
|
||||
GetModuleFileNameA(GetModuleHandleA(NULL), injectorPath, sizeof(injectorPath));
|
||||
wchar_t injectorPath[MAX_PATH];
|
||||
GetModuleFileNameW(GetModuleHandleW(NULL), injectorPath, MAX_PATH);
|
||||
|
||||
*(strrchr(injectorPath, '\\')) = '\0';
|
||||
*(wcsrchr(injectorPath, L'\\')) = L'\0';
|
||||
|
||||
SetCurrentDirectoryA(injectorPath);
|
||||
SetCurrentDirectoryW(injectorPath);
|
||||
|
||||
// Compute absolute paths
|
||||
char gameExePath[MAX_PATH];
|
||||
GetFullPathNameA(gamePath, sizeof(gameExePath), gameExePath, NULL);
|
||||
wchar_t gameExePath[MAX_PATH];
|
||||
GetFullPathNameW(gamePath, MAX_PATH, gameExePath, NULL);
|
||||
|
||||
char gamePayloadPath[MAX_PATH];
|
||||
GetFullPathNameA(GAME_INJECT_DLL, sizeof(gamePayloadPath), gamePayloadPath, NULL);
|
||||
wchar_t gamePayloadPath[MAX_PATH];
|
||||
GetFullPathNameW(GAME_INJECT_DLL, MAX_PATH, gamePayloadPath, NULL);
|
||||
|
||||
char launcherPayloadPath[MAX_PATH];
|
||||
GetFullPathNameA(LAUNCHER_INJECT_DLL, sizeof(launcherPayloadPath), launcherPayloadPath, NULL);
|
||||
wchar_t launcherPayloadPath[MAX_PATH];
|
||||
GetFullPathNameW(LAUNCHER_INJECT_DLL, MAX_PATH, launcherPayloadPath, NULL);
|
||||
|
||||
// Construct commandline for the game process
|
||||
char cmdline[8192];
|
||||
sprintf(cmdline, "\"%s\"", gameExePath);
|
||||
wchar_t cmdline[8192];
|
||||
wsprintfW(cmdline, L"\"%ls\"", gameExePath);
|
||||
|
||||
while (argc) {
|
||||
char arg[8192];
|
||||
sprintf(arg, " \"%s\"", argv[0]);
|
||||
strcat(cmdline, arg);
|
||||
wchar_t arg[8192];
|
||||
wsprintfW(arg, L" \"%ls\"", argv[0]);
|
||||
wcscat(cmdline, arg);
|
||||
|
||||
SHIFT(argc, argv);
|
||||
}
|
||||
|
||||
// Set envvars
|
||||
SetEnvironmentVariableA(ENV_EXE_PATH, gameExePath);
|
||||
SetEnvironmentVariableA(ENV_DLL_PATH, gamePayloadPath);
|
||||
SetEnvironmentVariableA(ENV_PROC_CMD, cmdline);
|
||||
SetEnvironmentVariableW(ENV_EXE_PATH, gameExePath);
|
||||
SetEnvironmentVariableW(ENV_DLL_PATH, gamePayloadPath);
|
||||
SetEnvironmentVariableW(ENV_PROC_CMD, cmdline);
|
||||
|
||||
// Start the launcher
|
||||
printf("Starting '%s' via '%s'\n", gameExePath, launcherPath);
|
||||
wprintf(L"Starting '%ls' via '%ls'\n", gameExePath, launcherPath);
|
||||
|
||||
STARTUPINFO si;
|
||||
STARTUPINFOW si;
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
if (!CreateProcessA(
|
||||
if (!CreateProcessW(
|
||||
launcherPath,
|
||||
NULL,
|
||||
NULL,
|
||||
@ -102,11 +102,11 @@ int main(int argc, char **argv) {
|
||||
&si,
|
||||
&pi
|
||||
)) {
|
||||
fprintf(stderr, "Could not start process! (%ld)\n", GetLastError());
|
||||
fwprintf(stderr, L"Could not start process! (%ld)\n", GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Started launcher process (%ld)\n", pi.dwProcessId);
|
||||
wprintf(L"Started launcher process (%ld)\n", pi.dwProcessId);
|
||||
|
||||
// Inject
|
||||
void *payloadStart = &_binary_launcher_p_o_p_launcher_p_bin_start;
|
||||
|
||||
Reference in New Issue
Block a user