forked from Public-Mirror/Textractor
Close process cleanly
This commit is contained in:
parent
9068228427
commit
aae330ebef
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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*)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user