static void TestCreateSuspendedProcessAndInjectDll(string cmdLine, string dllName) { DeviareLiteInterop.HookLib.STARTUPINFO si; DeviareLiteInterop.HookLib.ProcessInfo pi; uint exitCode; pi.threadHandle = null; MessageBox.Show("Launching suspended NOTEPAD, injecting DLL and resume\r\r(close Notepad to next test)", "Dll Inject Test", MessageBoxButtons.OK); try { si = new DeviareLiteInterop.HookLib.STARTUPINFO(); pi = cHook.CreateProcess(cmdLine, "", null, null, false, DeviareLiteInterop.HookLib.ProcessCreationFlags.CREATE_SUSPENDED, null, null, si); cHook.InjectDll(pi.procId, dllName, ""); cHook.ResumeThread(pi.threadHandle); WaitForSingleObject(pi.procHandle.DangerousGetHandle(), 0xFFFFFFFF); } catch (Exception ex) { if (pi.threadHandle != null && pi.threadHandle.IsInvalid == false) { cHook.ResumeThread(pi.threadHandle); } MessageBox.Show("Couldn't complete operation\r\rError: " + ex.ToString(), "Dll Inject Test", MessageBoxButtons.OK, MessageBoxIcon.Error); } }