Close process cleanly

This commit is contained in:
Akash Mozumdar 2018-12-03 18:31:00 -05:00
parent 9068228427
commit aae330ebef
5 changed files with 3 additions and 14 deletions

View File

@ -143,16 +143,6 @@ namespace Host
CreatePipe(); CreatePipe();
} }
void Shutdown()
{
auto NOP = [](auto... args) { return NULL; };
ProcessRecord::OnConnect = NOP;
ProcessRecord::OnDisconnect = NOP;
TextThread::OnCreate = NOP;
TextThread::OnDestroy = NOP;
TextThread::Output = NOP;
}
bool InjectProcess(DWORD processId, DWORD timeout) bool InjectProcess(DWORD processId, DWORD timeout)
{ {
if (processId == GetCurrentProcessId()) return false; if (processId == GetCurrentProcessId()) return false;

View File

@ -7,7 +7,6 @@ namespace Host
{ {
using ProcessEventCallback = std::function<void(DWORD)>; using ProcessEventCallback = std::function<void(DWORD)>;
void Start(ProcessEventCallback OnConnect, ProcessEventCallback OnDisconnect, TextThread::EventCallback OnCreate, TextThread::EventCallback OnDestroy, TextThread::OutputCallback Output); void Start(ProcessEventCallback OnConnect, ProcessEventCallback OnDisconnect, TextThread::EventCallback OnCreate, TextThread::EventCallback OnDestroy, TextThread::OutputCallback Output);
void Shutdown();
bool InjectProcess(DWORD processId, DWORD timeout = 5000); bool InjectProcess(DWORD processId, DWORD timeout = 5000);
void DetachProcess(DWORD processId); void DetachProcess(DWORD processId);

View File

@ -35,10 +35,10 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
Host::Shutdown();
settings.setValue(WINDOW, geometry()); settings.setValue(WINDOW, geometry());
settings.sync(); settings.sync();
delete ui; delete ui;
ExitProcess(0);
} }
void MainWindow::closeEvent(QCloseEvent*) void MainWindow::closeEvent(QCloseEvent*)

View File

@ -15,7 +15,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
{ {
delete w; if (lpReserved == NULL && w != nullptr) delete w; // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683
} }
break; break;
} }

View File

@ -15,7 +15,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
{ {
delete w; if (lpReserved == NULL && w != nullptr) delete w; // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683
} }
break; break;
} }