Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conditional breakpoints being triggered unconditionally during stepping and hijacking the step #21

Open
wants to merge 1 commit into
base: x64dbg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TitanEngine/Global.Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TitanEngine/Global.Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions TitanEngine/TitanEngine.Debugger.Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions TitanEngine/TitanEngine.Debugger.DebugLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1237,7 +1237,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
//general unhandled exception callback
if(DBGCode == DBG_EXCEPTION_NOT_HANDLED)
{
engineStepActive = false;
engineStepTID = 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should only clear the field if the unhandled exception comes from the same thread that's awaiting the step to complete?


if(DBGCustomHandler->chUnhandledException != NULL)
{
Expand Down
Loading