Minor injector and launcher payload refactoring
This commit is contained in:
parent
3994188b08
commit
54a127b848
@ -4,11 +4,6 @@
|
|||||||
|
|
||||||
#include <lpayload.h>
|
#include <lpayload.h>
|
||||||
|
|
||||||
static inline void read_env(const char *env, char *dest, size_t size) {
|
|
||||||
GetEnvironmentVariableA(env, dest, size);
|
|
||||||
SetEnvironmentVariableA(env, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
||||||
// Only listen for attach
|
// Only listen for attach
|
||||||
if (reason != DLL_PROCESS_ATTACH) {
|
if (reason != DLL_PROCESS_ATTACH) {
|
||||||
@ -16,12 +11,10 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get target EXE path
|
// Get target EXE path
|
||||||
char targetExe[MAX_PATH];
|
char *targetExe = getenv(ENV_EXE_PATH);
|
||||||
read_env(ENV_EXE_PATH, targetExe, sizeof(targetExe));
|
|
||||||
|
|
||||||
// Get the path of the DLL to inject
|
// Get the path of the DLL to inject
|
||||||
char injectDll[MAX_PATH];
|
char *injectDll = getenv(ENV_DLL_PATH);
|
||||||
read_env(ENV_DLL_PATH, injectDll, sizeof(injectDll));
|
|
||||||
|
|
||||||
// Compute the working directory path
|
// Compute the working directory path
|
||||||
char workdir[MAX_PATH];
|
char workdir[MAX_PATH];
|
||||||
|
@ -34,8 +34,7 @@ int main(int argc, char **argv) {
|
|||||||
char injectorPath[MAX_PATH];
|
char injectorPath[MAX_PATH];
|
||||||
GetModuleFileNameA(GetModuleHandleA(NULL), injectorPath, sizeof(injectorPath));
|
GetModuleFileNameA(GetModuleHandleA(NULL), injectorPath, sizeof(injectorPath));
|
||||||
|
|
||||||
char *lastSep = strrchr(injectorPath, '\\');
|
*(strrchr(injectorPath, '\\')) = '\0';
|
||||||
*lastSep = '\0';
|
|
||||||
|
|
||||||
SetCurrentDirectoryA(injectorPath);
|
SetCurrentDirectoryA(injectorPath);
|
||||||
|
|
||||||
@ -49,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
char launcherPayloadPath[MAX_PATH];
|
char launcherPayloadPath[MAX_PATH];
|
||||||
GetFullPathNameA(LAUNCHER_INJECT_DLL, sizeof(launcherPayloadPath), launcherPayloadPath, NULL);
|
GetFullPathNameA(LAUNCHER_INJECT_DLL, sizeof(launcherPayloadPath), launcherPayloadPath, NULL);
|
||||||
|
|
||||||
printf("Starting \"%s\" via \"%s\"\n", gameExePath, launcherPath);
|
printf("Starting '%s' via '%s'\n", gameExePath, launcherPath);
|
||||||
|
|
||||||
// Set envvars
|
// Set envvars
|
||||||
SetEnvironmentVariableA(ENV_EXE_PATH, gameExePath);
|
SetEnvironmentVariableA(ENV_EXE_PATH, gameExePath);
|
||||||
|
Loading…
Reference in New Issue
Block a user