mirror of https://github.com/x64dbg/TitanEngine
Make sure stepping is called back on the same thread
- When issuing a step command, remember its thread ID so that other threads cannot hijack the callback and trigger their breakpoints.
This commit is contained in:
parent
49f59781da
commit
d77456f43e
|
|
@ -31,7 +31,7 @@ std::vector<ULONG_PTR> tlsCallBackList;
|
|||
std::vector<PROCESS_ITEM_DATA> hListProcess;
|
||||
DWORD engineStepCount = 0;
|
||||
LPVOID engineStepCallBack = NULL;
|
||||
bool engineStepActive = false;
|
||||
DWORD engineStepTID = 0;
|
||||
bool engineProcessIsNowDetached = false;
|
||||
DWORD DBGCode = DBG_CONTINUE;
|
||||
bool engineFileIsBeingDebugged = false;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ extern std::vector<ULONG_PTR> tlsCallBackList;
|
|||
extern std::vector<PROCESS_ITEM_DATA> hListProcess;
|
||||
extern DWORD engineStepCount;
|
||||
extern LPVOID engineStepCallBack;
|
||||
extern bool engineStepActive;
|
||||
extern DWORD engineStepTID;
|
||||
extern bool engineProcessIsNowDetached;
|
||||
extern DWORD DBGCode;
|
||||
extern bool engineFileIsBeingDebugged;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ __declspec(dllexport) void TITCALL ForceClose()
|
|||
__declspec(dllexport) void TITCALL StepInto(LPVOID StepCallBack)
|
||||
{
|
||||
EnterCriticalSection(&engineStepActiveCr);
|
||||
if (!engineStepActive)
|
||||
if (engineStepTID == 0)
|
||||
{
|
||||
ULONG_PTR ueCurrentPosition = GetContextData(UE_CIP);
|
||||
unsigned char instr[16];
|
||||
|
|
@ -60,7 +60,7 @@ __declspec(dllexport) void TITCALL StepInto(LPVOID StepCallBack)
|
|||
myDBGContext.EFlags |= UE_TRAP_FLAG;
|
||||
SetThreadContext(hActiveThread, &myDBGContext);
|
||||
EngineCloseHandle(hActiveThread);
|
||||
engineStepActive = true;
|
||||
engineStepTID = DBGEvent.dwThreadId;
|
||||
engineStepCallBack = StepCallBack;
|
||||
engineStepCount = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@
|
|||
static void engineStep()
|
||||
{
|
||||
EnterCriticalSection(&engineStepActiveCr);
|
||||
if (engineStepActive)
|
||||
if (engineStepTID == DBGEvent.dwThreadId)
|
||||
{
|
||||
DBGCode = DBG_CONTINUE;
|
||||
if (engineStepCount == 0)
|
||||
{
|
||||
typedef void(TITCALL* fCustomBreakPoint)(void);
|
||||
auto cbStep = fCustomBreakPoint(engineStepCallBack);
|
||||
engineStepActive = false;
|
||||
engineStepTID = 0;
|
||||
engineStepCallBack = NULL;
|
||||
LeaveCriticalSection(&engineStepActiveCr);
|
||||
cbStep();
|
||||
|
|
@ -1237,7 +1237,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
//general unhandled exception callback
|
||||
if(DBGCode == DBG_EXCEPTION_NOT_HANDLED)
|
||||
{
|
||||
engineStepActive = false;
|
||||
engineStepTID = 0;
|
||||
|
||||
if(DBGCustomHandler->chUnhandledException != NULL)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue