Add this to your code in Button1_click (or w/e you want)
Then add this code anywhere.
Code:
int processId = 0;
private void AttachProcess()
{
bool newInstanceFound = false;
while (!newInstanceFound)
{
Process[] processes = Process.GetProcessesByName(Engine.exe); // or Engine (I don't know)
foreach (Process process in processes)
{
// Simply attach to the first one found.
// If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
if (process.MainWindowHandle == IntPtr.Zero)
{
continue;
}
// Keep track of hooked processes in case more than one need to be hooked
HookManager.AddHookedProcess(proces*****);
processId = proces*****;
// Inject DLL into target process
RemoteHooking.Inject(
proces*****,
InjectionOptions.Default,
"FlamesHack32.dll", // 32-bit version (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll
"FlamesHack64.dll", // 64-bit version (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll
// the optional parameter list...
ChannelName // The name of the IPC channel for the injected assembly to connect to
);
// Ensure the target process is in the foreground,
// this prevents issues where the target app appears to be in
// the foreground but does not receive any user inputs.
// Note: the first Alt+Tab out of the target application after injection
// may still be an issue - switching between windowed and
// fullscreen fixes the issue however (see ScreenshotInjection.cs for another option)
BringProcessWindowToFront(process);
newInstanceFound = true;
break;
}
Thread.Sleep(10);
}
}
Please Test for me and enjoy if it works