mirror of
https://github.com/Artikash/Textractor.git
synced 2025-01-10 01:33:51 +08:00
Close process cleanly
This commit is contained in:
parent
9068228427
commit
aae330ebef
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -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*)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user