diff --git a/EntryPoint.cs b/EntryPoint.cs index 7941e40..7e712ef 100644 --- a/EntryPoint.cs +++ b/EntryPoint.cs @@ -18,10 +18,12 @@ public void Initialize() /// The Path to the Application to launch /// The CommandLine Flags to pass to the Application /// The Path to the DLL to inject into the process (Payload) + /// The Folder where all the mods/mods.json are located (profile folder) /// Additional args that are passed to the Payload side of Andraste /// The Process or null, if the application has crashed /// Various Exceptions may be thrown if the application could not be started or the injection failed - public virtual Process? StartApplication(string applicationPath, string commandLine, string modFrameworkPath, params object[] args) + public virtual Process? StartApplication(string applicationPath, string commandLine, string modFrameworkPath, + string profileFolder, params object[] args) { if (!File.Exists(applicationPath)) { @@ -34,7 +36,7 @@ public void Initialize() } Inject(applicationPath, commandLine, 0, modFrameworkPath, - modFrameworkPath, out int pid, args); + modFrameworkPath, profileFolder, out int pid, args); try { @@ -46,14 +48,15 @@ public void Initialize() } } - public virtual void AttachToApplication(Process process, string modFrameworkPath, params object[] args) + public virtual void AttachToApplication(Process process, string modFrameworkPath, string profileFolder, + params object[] args) { if (!File.Exists(modFrameworkPath)) { throw new ArgumentException("Mod Framework file does not exist", nameof(modFrameworkPath)); } - InjectRunning(process, modFrameworkPath,modFrameworkPath, args); + InjectRunning(process, modFrameworkPath,modFrameworkPath, profileFolder, args); } /// @@ -67,11 +70,17 @@ public virtual void AttachToApplication(Process process, string modFrameworkPath /// Additional flags being passed to CreateProcess /// The 32bit DLL to inject into the process /// The 64bit DLL to inject into the process + /// The Folder where all the mods/mods.json are located (profile folder) /// The PID of the freshly created process /// Additional args that are passed to the Payload side of Andraste protected virtual void Inject(string applicationPath, string commandLine, int additionalCreateProcessFlags, - string injectionLibrary32, string injectionLibrary64, out int targetPid, params object[] args) + string injectionLibrary32, string injectionLibrary64, string profileFolder, out int targetPid, + params object[] args) { + var argsArray = new object[args.Length + 1]; + argsArray[0] = profileFolder; + args.CopyTo(argsArray, 1); + // start and inject into a new process RemoteHooking.CreateAndInject( applicationPath, // executable to run @@ -81,15 +90,19 @@ protected virtual void Inject(string applicationPath, string commandLine, int ad injectionLibrary32, // 32-bit library to inject (if target is 32-bit) injectionLibrary64, // 64-bit library to inject (if target is 64-bit) out targetPid, // retrieve the newly created process ID - args // the parameters to pass into injected library + argsArray // the parameters to pass into injected library ); } protected virtual void InjectRunning(Process process, string injectionLibrary32, string injectionLibrary64, - params object[] args) + string profileFolder, params object[] args) { + var argsArray = new object[args.Length + 1]; + argsArray[0] = profileFolder; + args.CopyTo(argsArray, 1); + RemoteHooking.Inject(process.Id, InjectionOptions.DoNotRequireStrongName | InjectionOptions.NoWOW64Bypass, - injectionLibrary32, injectionLibrary64, args); + injectionLibrary32, injectionLibrary64, argsArray); } } #nullable restore