This commit is contained in:
DavidXanatos 2023-08-04 21:54:11 +02:00
parent 7f043d73a2
commit a86de9925f
3 changed files with 25 additions and 12 deletions

View File

@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- fixed issues with pinned shortcuts
- fixed Process Suspend/Resume context menu [#3156](https://github.com/sandboxie-plus/Sandboxie/issues/3156)
- fixed issues with Installers created with Qt [#2493](https://github.com/sandboxie-plus/Sandboxie/issues/2493) [#3153](https://github.com/sandboxie-plus/Sandboxie/issues/3153)

View File

@ -220,6 +220,25 @@ _FX BOOL Gui_ConnectConsole(ULONG ShowFlag)
if (! AttachConsole(rpl->process_id))
status = STATUS_NOT_SAME_DEVICE;
//
// wait for the count to inidcate the service has quit
//
typedef DWORD (*P_GetConsoleProcessList)(LPDWORD lpdwProcessList, DWORD dwProcessCount);
P_GetConsoleProcessList GetConsoleProcessList = (P_GetConsoleProcessList)
GetProcAddress(Dll_Kernel32, "GetConsoleProcessList");
DWORD pids[10]; // 2 should be enough but lets go with 10
while (1) {
Sleep(50);
ULONG num_pids = GetConsoleProcessList(pids, ARRAYSIZE(pids));
if (num_pids < 2)
break;
}
}
Dll_Free(rpl);
@ -264,6 +283,7 @@ _FX void Gui_InitConsole2(void)
HANDLE *Handles;
HMODULE User32;
// $Workaround$ - 3rd party fix
//
// hack: the Kaspersky process klwtblfs.exe is protected from
// termination through TerminateProcess, so make sure we terminate

View File

@ -4306,9 +4306,7 @@ void GuiServer::RunConsoleSlave(const WCHAR *evtname)
HANDLE hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, evtname);
const ULONG max_pids = 16000;
ULONG pids_len = max_pids * sizeof(ULONG);
ULONG *pids = (ULONG *)HeapAlloc(GetProcessHeap(), 0, pids_len);
DWORD pids[10]; // 2 should be enough but lets go with 10
if (hEvent && pids) {
@ -4329,18 +4327,13 @@ void GuiServer::RunConsoleSlave(const WCHAR *evtname)
while (1) {
Sleep(2000);
Sleep(50);
ULONG num_pids = GetConsoleProcessList(pids, max_pids);
if (num_pids > 1 && num_pids < max_pids) {
Sleep(2000);
ULONG num_pids = GetConsoleProcessList(pids, ARRAYSIZE(pids));
if (num_pids > 1)
break;
}
}
}
//HeapFree(GetProcessHeap(), 0, pids); // don't bother we ExitProcess aynways
}
ExitProcess(0);