Add this to your code in Button1_click (or w/e you want)
Then add this code anywhere.
Please Test for me and enjoy if it works
int processId = 0;
private void AttachProcess()
bool newInstanceFound = false;
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)
// Keep track of hooked processes in case more than one need to be hooked
processId = process.Id;
// Inject DLL into target process
"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)
newInstanceFound = true;