mirror of https://github.com/x64dbg/TitanEngine
- resolved issue #42 (fixed the pre/post filters)
- resolved issue #34 (critical sections lock tested & working) - dynamic DLLLoader name (avoids detection + you can debug two DLL files in the same directory)
This commit is contained in:
parent
51bf507216
commit
d777ee3590
|
|
@ -126,15 +126,10 @@ void BreakPointPostReadFilter(ULONG_PTR lpBaseAddress, unsigned char* lpBuffer,
|
|||
ULONG_PTR cur_addr=curBp->BreakPointAddress;
|
||||
for(SIZE_T j=0; j<curBp->BreakPointSize; j++)
|
||||
{
|
||||
if(cur_addr+j==start && cur_addr+j<end) //breakpoint is in range
|
||||
if(cur_addr+j>=start && cur_addr+j<end) //breakpoint is in range
|
||||
{
|
||||
ULONG_PTR index=cur_addr+j-start; //calculate where to write in the buffer
|
||||
int n=curBp->BreakPointSize-j;
|
||||
if((cur_addr+n)>end)
|
||||
n=end-cur_addr; //do not overflow the buffer
|
||||
memcpy(lpBuffer+index, &curBp->OriginalByte[j], n);
|
||||
if(n==curBp->BreakPointSize)
|
||||
break;
|
||||
memcpy(lpBuffer+index, &curBp->OriginalByte[j], sizeof(char));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +149,7 @@ void BreakPointPreWriteFilter(ULONG_PTR lpBaseAddress, SIZE_T nSize, CriticalSec
|
|||
ULONG_PTR cur_addr=curBp->BreakPointAddress;
|
||||
for(SIZE_T j=0; j<curBp->BreakPointSize; j++)
|
||||
{
|
||||
if(cur_addr+j==start && cur_addr+j<end) //breakpoint byte is in range
|
||||
if(cur_addr+j>=start && cur_addr+j<end) //breakpoint byte is in range
|
||||
{
|
||||
lock->unlock();
|
||||
DisableBPX(cur_addr);
|
||||
|
|
@ -180,7 +175,7 @@ void BreakPointPostWriteFilter(ULONG_PTR lpBaseAddress, SIZE_T nSize, CriticalSe
|
|||
ULONG_PTR cur_addr=curBp->BreakPointAddress;
|
||||
for(SIZE_T j=0; j<curBp->BreakPointSize; j++)
|
||||
{
|
||||
if(cur_addr+j==start && cur_addr+j<end) //breakpoint byte is in range
|
||||
if(cur_addr+j>=start && cur_addr+j<end) //breakpoint byte is in range
|
||||
{
|
||||
curBp->BreakPointActive = UE_BPXINACTIVE; //little hack
|
||||
lock->unlock();
|
||||
|
|
|
|||
|
|
@ -2,37 +2,45 @@
|
|||
#include "definitions.h"
|
||||
#include "Global.Engine.Threading.h"
|
||||
|
||||
static CRITICAL_SECTION locks[LockLast];
|
||||
static CRITICAL_SECTION locks[LockLast] = {};
|
||||
static bool bInitDone = false;
|
||||
|
||||
void CriticalSectionInitializeLocks()
|
||||
static void CriticalSectionInitializeLocks()
|
||||
{
|
||||
if(bInitDone)
|
||||
return;
|
||||
for(int i=0; i<LockLast; i++)
|
||||
InitializeCriticalSection(&locks[i]);
|
||||
bInitDone=true;
|
||||
}
|
||||
|
||||
void CriticalSectionDeleteLocks()
|
||||
{
|
||||
if(!bInitDone)
|
||||
return;
|
||||
for(int i=0; i<LockLast; i++)
|
||||
DeleteCriticalSection(&locks[i]);
|
||||
bInitDone=false;
|
||||
}
|
||||
|
||||
CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
|
||||
{
|
||||
gCriticalSection=&locks[lock];
|
||||
EnterCriticalSection(gCriticalSection);
|
||||
CriticalSectionInitializeLocks(); //initialize critical sections
|
||||
gLock=lock;
|
||||
EnterCriticalSection(&locks[gLock]);
|
||||
}
|
||||
|
||||
CriticalSectionLocker::~CriticalSectionLocker()
|
||||
{
|
||||
LeaveCriticalSection(gCriticalSection);
|
||||
LeaveCriticalSection(&locks[gLock]);
|
||||
}
|
||||
|
||||
void CriticalSectionLocker::unlock()
|
||||
{
|
||||
LeaveCriticalSection(gCriticalSection);
|
||||
LeaveCriticalSection(&locks[gLock]);
|
||||
}
|
||||
|
||||
void CriticalSectionLocker::relock()
|
||||
{
|
||||
EnterCriticalSection(gCriticalSection);
|
||||
EnterCriticalSection(&locks[gLock]);
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ enum CriticalSectionLock
|
|||
LockLast
|
||||
};
|
||||
|
||||
void CriticalSectionInitializeLocks();
|
||||
void CriticalSectionDeleteLocks();
|
||||
|
||||
class CriticalSectionLocker
|
||||
|
|
@ -19,7 +18,7 @@ public:
|
|||
void relock();
|
||||
|
||||
private:
|
||||
LPCRITICAL_SECTION gCriticalSection;
|
||||
CriticalSectionLock gLock;
|
||||
};
|
||||
|
||||
#endif //_GLOBAL_ENGINE_THREADING_H
|
||||
|
|
@ -170,22 +170,17 @@ __declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool Rese
|
|||
{
|
||||
i--;
|
||||
}
|
||||
wchar_t DLLLoaderName[64]=L"";
|
||||
#ifdef _WIN64
|
||||
wsprintfW(DLLLoaderName, L"DLLLoader64_%.4X.exe", GetTickCount()&0xFFFF);
|
||||
#else
|
||||
wsprintfW(DLLLoaderName, L"DLLLoader32_%.4X.exe", GetTickCount()&0xFFFF);
|
||||
#endif
|
||||
if(i)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
lstrcpyW(szDebuggerName+i+1, L"DLLLoader64.exe");
|
||||
#else
|
||||
lstrcpyW(szDebuggerName+i+1, L"DLLLoader32.exe");
|
||||
#endif
|
||||
}
|
||||
lstrcpyW(szDebuggerName+i+1, DLLLoaderName);
|
||||
else
|
||||
{
|
||||
#ifdef _WIN64
|
||||
lstrcpyW(szDebuggerName, L"DLLLoader64.exe");
|
||||
#else
|
||||
lstrcpyW(szDebuggerName, L"DLLLoader32.exe");
|
||||
#endif
|
||||
}
|
||||
lstrcpyW(szDebuggerName, DLLLoaderName);
|
||||
|
||||
#if defined(_WIN64)
|
||||
ReturnData = EngineExtractResource("LOADERX64", szDebuggerName);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
switch(fdwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
CriticalSectionInitializeLocks(); //initialize critical sections
|
||||
engineHandle=hinstDLL;
|
||||
EngineInit();
|
||||
EmptyGarbage();
|
||||
|
|
|
|||
Loading…
Reference in New Issue