DBG: fixed some more stuff (event filters are not not executed when the debugger is already closed)
This commit is contained in:
parent
2ba3de4b3a
commit
d3da3e867e
|
@ -26,6 +26,7 @@
|
|||
#include "function.h"
|
||||
#include "loop.h"
|
||||
#include "error.h"
|
||||
#include "x64_dbg.h"
|
||||
|
||||
static bool bOnlyCipAutoComments = false;
|
||||
|
||||
|
@ -635,6 +636,17 @@ extern "C" DLL_EXPORT bool _dbg_functionoverlaps(uint start, uint end)
|
|||
|
||||
extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* param2)
|
||||
{
|
||||
if(dbgisstopped())
|
||||
{
|
||||
switch(type) //ignore win events
|
||||
{
|
||||
case DBG_WIN_EVENT:
|
||||
case DBG_WIN_EVENT_GLOBAL:
|
||||
return 0;
|
||||
default:
|
||||
__debugbreak(); //we cannot process messages when the debugger is stopped, this must be a bug
|
||||
}
|
||||
}
|
||||
switch(type)
|
||||
{
|
||||
case DBG_SCRIPT_LOAD:
|
||||
|
|
|
@ -36,6 +36,8 @@ static int ecount = 0;
|
|||
static std::vector<ExceptionRange> ignoredExceptionRange;
|
||||
static SIZE_T cachePrivateUsage = 0;
|
||||
static HANDLE hEvent = 0;
|
||||
static HANDLE hMemMapThread = 0;
|
||||
static bool bStopMemMapThread = false;
|
||||
static String lastDebugText;
|
||||
char szFileName[MAX_PATH] = "";
|
||||
char szSymbolCachePath[MAX_PATH] = "";
|
||||
|
@ -47,10 +49,16 @@ bool bEnableSourceDebugging = true;
|
|||
|
||||
static DWORD WINAPI memMapThread(void* ptr)
|
||||
{
|
||||
while(true)
|
||||
while(!bStopMemMapThread)
|
||||
{
|
||||
while(!DbgIsDebugging())
|
||||
{
|
||||
if(bStopMemMapThread)
|
||||
break;
|
||||
Sleep(1);
|
||||
}
|
||||
if(bStopMemMapThread)
|
||||
break;
|
||||
const SIZE_T PrivateUsage = dbggetprivateusage(fdProcessInfo->hProcess);
|
||||
if(cachePrivateUsage != PrivateUsage && !dbgisrunning()) //update the memory map when the memory usage changed
|
||||
{
|
||||
|
@ -67,7 +75,13 @@ void dbginit()
|
|||
{
|
||||
ExceptionCodeInit();
|
||||
ErrorCodeInit();
|
||||
CloseHandle(CreateThread(0, 0, memMapThread, 0, 0, 0));
|
||||
hMemMapThread = CreateThread(0, 0, memMapThread, 0, 0, 0);
|
||||
}
|
||||
|
||||
void dbgstop()
|
||||
{
|
||||
bStopMemMapThread = true;
|
||||
WaitForThreadTermination(hMemMapThread);
|
||||
}
|
||||
|
||||
SIZE_T dbggetprivateusage(HANDLE hProcess, bool update)
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef struct _THREADNAME_INFO
|
|||
//functions
|
||||
SIZE_T dbggetprivateusage(HANDLE hProcess, bool update = false);
|
||||
void dbginit();
|
||||
void dbgstop();
|
||||
uint dbgdebuggedbase();
|
||||
bool dbgisrunning();
|
||||
bool dbgisdll();
|
||||
|
|
|
@ -117,7 +117,7 @@ BOOL CALLBACK StackReadProcessMemoryProc64(HANDLE hProcess, DWORD64 lpBaseAddres
|
|||
// Fix for 64-bit sizes
|
||||
SIZE_T bytesRead = 0;
|
||||
|
||||
if(MemRead(lpBaseAddress, lpBuffer, nSize, &bytesRead))
|
||||
if(MemRead((uint)lpBaseAddress, lpBuffer, nSize, &bytesRead))
|
||||
{
|
||||
if(lpNumberOfBytesRead)
|
||||
*lpNumberOfBytesRead = (DWORD)bytesRead;
|
||||
|
@ -133,7 +133,7 @@ DWORD64 CALLBACK StackGetModuleBaseProc64(HANDLE hProcess, DWORD64 Address)
|
|||
if(hProcess != fdProcessInfo->hProcess)
|
||||
__debugbreak();
|
||||
|
||||
return ModBaseFromAddr(Address);
|
||||
return (DWORD64)ModBaseFromAddr((uint)Address);
|
||||
}
|
||||
|
||||
DWORD64 CALLBACK StackTranslateAddressProc64(HANDLE hProcess, HANDLE hThread, LPADDRESS64 lpaddr)
|
||||
|
|
|
@ -25,6 +25,7 @@ static COMMAND* command_list = 0;
|
|||
static HANDLE hCommandLoopThread = 0;
|
||||
static bool bStopCommandLoopThread = false;
|
||||
static char alloctrace[MAX_PATH] = "";
|
||||
static bool bIsStopped = false;
|
||||
|
||||
static CMDRESULT cbStrLen(int argc, char* argv[])
|
||||
{
|
||||
|
@ -366,7 +367,10 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
|
|||
SectionLockerGlobal::Deinitialize();
|
||||
dputs("Cleaning up wait objects...");
|
||||
waitdeinitialize();
|
||||
dputs("Cleaning up debugger threads...");
|
||||
dbgstop();
|
||||
dputs("Exit signal processed successfully!");
|
||||
bIsStopped = true;
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
|
||||
|
@ -380,3 +384,8 @@ COMMAND* dbggetcommandlist()
|
|||
{
|
||||
return command_list;
|
||||
}
|
||||
|
||||
bool dbgisstopped()
|
||||
{
|
||||
return bIsStopped;
|
||||
}
|
|
@ -19,5 +19,6 @@ DLL_EXPORT void _dbg_dbgexitsignal();
|
|||
#endif
|
||||
|
||||
COMMAND* dbggetcommandlist();
|
||||
bool dbgisstopped();
|
||||
|
||||
#endif // _X64_DBG_H
|
||||
|
|
|
@ -97,6 +97,8 @@ int main(int argc, char* argv[])
|
|||
mConfiguration->save(); //save config on exit
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
QAbstractEventDispatcher::instance(application.thread())->removeNativeEventFilter(filter);
|
||||
#else
|
||||
QAbstractEventDispatcher::instance(application.thread())->setEventFilter(nullptr);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue