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();
}
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)
{
if (processId == GetCurrentProcessId()) return false;

View File

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

View File

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

View File

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

View File

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