Replace linear time ThreadGetId(hActiveThread) with constant time GetDebugData()->dwThreadId
This commit is contained in:
parent
3b8c001d6e
commit
088b088a86
|
|
@ -233,7 +233,7 @@ static void HandleZydisOperand(const Zydis & zydis, int opindex, DISASM_ARGTYPE*
|
|||
const auto & mem = op.mem;
|
||||
if(mem.segment == ArchValue(ZYDIS_REGISTER_FS, ZYDIS_REGISTER_GS))
|
||||
{
|
||||
*value += ThreadGetLocalBase(ThreadGetId(hActiveThread));
|
||||
*value += ThreadGetLocalBase(GetDebugData()->dwThreadId);
|
||||
}
|
||||
*memorySize = op.size / 8;
|
||||
if(*memorySize <= memoryContentSize && DbgMemIsValidReadPtr(*value))
|
||||
|
|
@ -264,7 +264,7 @@ void TraceRecordManager::TraceExecuteRecord(const Zydis & newInstruction)
|
|||
duint oldMemory[memoryArrayCount];
|
||||
unsigned char newMemoryArrayCount = 0;
|
||||
DbgGetRegDumpEx((REGDUMP_AVX512*)&newContext.registers, sizeof(REGDUMP)); //TODO: Migrate
|
||||
newThreadId = ThreadGetId(hActiveThread);
|
||||
newThreadId = GetDebugData()->dwThreadId;
|
||||
// Don't try to resolve memory values for invalid/lea/nop instructions
|
||||
if(newInstruction.Success() && !newInstruction.IsNop() && newInstruction.GetId() != ZYDIS_MNEMONIC_LEA)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -728,7 +728,7 @@ extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP_AVX512* regdump)
|
|||
|
||||
TranslateTitanContextToRegContext(titcontext, titcontext_AVX512, regdump->regcontext);
|
||||
|
||||
auto threadId = ThreadGetId(hActiveThread);
|
||||
auto threadId = GetDebugData()->dwThreadId;
|
||||
regdump->lastError = ThreadGetLastError(threadId);
|
||||
regdump->lastStatus = ThreadGetLastStatus(threadId);
|
||||
|
||||
|
|
@ -1528,7 +1528,7 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
|
|||
|
||||
case DBG_GET_THREAD_ID:
|
||||
{
|
||||
return duint(ThreadGetId(hActiveThread));
|
||||
return duint(GetDebugData()->dwThreadId);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ bool cbDebugPause(int argc, char* argv[])
|
|||
//WORKAROUND: If a program is stuck in NtUserGetMessage (GetMessage was called), this
|
||||
//will send a WM_NULL to stop the waiting. This only works if the message is not filtered.
|
||||
//OllyDbg also does this in a similar way.
|
||||
PostThreadMessageA(ThreadGetId(hActiveThread), WM_NULL, 0, 0);
|
||||
PostThreadMessageA(GetDebugData()->dwThreadId, WM_NULL, 0, 0);
|
||||
if(ResumeThread(hActiveThread) == -1)
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error resuming thread"));
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ bool cbDebugSwitchthread(int argc, char* argv[])
|
|||
return false;
|
||||
}
|
||||
//switch thread
|
||||
if(ThreadGetId(hActiveThread) != threadid)
|
||||
if(GetDebugData()->dwThreadId != threadid)
|
||||
{
|
||||
hActiveThread = ThreadGetHandle((DWORD)threadid);
|
||||
HistoryClear();
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ void cbDebuggerPaused()
|
|||
static DWORD PrevThreadId = 0;
|
||||
if(PrevThreadId == 0)
|
||||
PrevThreadId = fdProcessInfo->dwThreadId; // Initialize to Main Thread
|
||||
DWORD currentThreadId = ThreadGetId(hActiveThread);
|
||||
DWORD currentThreadId = GetDebugData()->dwThreadId;
|
||||
if(currentThreadId != PrevThreadId && PrevThreadId != 0)
|
||||
{
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Thread switched from %X to %X !\n"), PrevThreadId, currentThreadId);
|
||||
|
|
@ -501,7 +501,7 @@ static void DebugUpdateTitle(duint disasm_addr, bool analyzeThreadSwitch)
|
|||
else
|
||||
_snprintf_s(modtext, _TRUNCATE, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Module: %s - ")), modname);
|
||||
char threadswitch[256] = "";
|
||||
DWORD currentThreadId = ThreadGetId(hActiveThread);
|
||||
DWORD currentThreadId = GetDebugData()->dwThreadId;
|
||||
if(analyzeThreadSwitch)
|
||||
{
|
||||
static DWORD PrevThreadId = 0;
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ static void HandleZydisOperand(Zydis & zydis, int opindex, DISASM_ARG* arg, bool
|
|||
if(mem.segment == ArchValue(ZYDIS_REGISTER_FS, ZYDIS_REGISTER_GS))
|
||||
{
|
||||
arg->segment = ArchValue(SEG_FS, SEG_GS);
|
||||
value += ThreadGetLocalBase(ThreadGetId(hActiveThread));
|
||||
value += ThreadGetLocalBase(GetDebugData()->dwThreadId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ namespace Exprfunc
|
|||
|
||||
duint tid()
|
||||
{
|
||||
return duint(ThreadGetId(hActiveThread));
|
||||
return duint(GetDebugData()->dwThreadId);
|
||||
}
|
||||
|
||||
duint kusd()
|
||||
|
|
|
|||
Loading…
Reference in New Issue