mirror of https://github.com/x64dbg/TitanEngine
- MemoryReadSafe now actually filters breakpoints out of the buffer
This commit is contained in:
parent
93a8582044
commit
92eb890c7f
|
|
@ -110,3 +110,26 @@ void uintdr7(ULONG_PTR dr7, DR7* ret)
|
||||||
if(BITGET(dr7,31))
|
if(BITGET(dr7,31))
|
||||||
BITSET(ret->HWBP_SIZE[3],1);
|
BITSET(ret->HWBP_SIZE[3],1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilterBreakPoints(ULONG_PTR lpBaseAddress, unsigned char* lpBuffer, SIZE_T nSize)
|
||||||
|
{
|
||||||
|
ULONG_PTR start=lpBaseAddress;
|
||||||
|
ULONG_PTR end=start+nSize;
|
||||||
|
int bpcount=BreakPointBuffer.size();
|
||||||
|
for(int i=0; i<bpcount; i++)
|
||||||
|
{
|
||||||
|
BreakPointDetail* curBp=&BreakPointBuffer.at(i);
|
||||||
|
//check if the breakpoint is one we should be concerned about
|
||||||
|
if(!curBp->BreakPointActive || (curBp->BreakPointType != UE_BREAKPOINT && curBp->BreakPointType != UE_SINGLESHOOT))
|
||||||
|
continue;
|
||||||
|
ULONG_PTR cur_addr=curBp->BreakPointAddress;
|
||||||
|
if(cur_addr>=start && cur_addr<end) //breakpoint is in range
|
||||||
|
{
|
||||||
|
ULONG_PTR index=cur_addr-start; //calculate where to write in the buffer
|
||||||
|
int n=curBp->BreakPointSize;
|
||||||
|
if((cur_addr+n)>end)
|
||||||
|
n=end-cur_addr; //do not overflow the buffer
|
||||||
|
memcpy(lpBuffer+index, curBp->OriginalByte, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,5 +7,6 @@ extern std::vector<BreakPointDetail> BreakPointBuffer;
|
||||||
|
|
||||||
void uintdr7(ULONG_PTR dr7, DR7* ret);
|
void uintdr7(ULONG_PTR dr7, DR7* ret);
|
||||||
ULONG_PTR dr7uint(DR7* dr7);
|
ULONG_PTR dr7uint(DR7* dr7);
|
||||||
|
void FilterBreakPoints(ULONG_PTR lpBaseAddress, unsigned char* lpBuffer, SIZE_T nSize);
|
||||||
|
|
||||||
#endif //_GLOBAL_BREAKPOINTS_H
|
#endif //_GLOBAL_BREAKPOINTS_H
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
#include "Global.Debugger.h"
|
#include "Global.Debugger.h"
|
||||||
|
#include "Global.Breakpoints.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL MatchPatternEx(HANDLE hProcess, void* MemoryToCheck, int SizeOfMemoryToCheck, void* PatternToMatch, int SizeOfPatternToMatch, PBYTE WildCard)
|
__declspec(dllexport) bool TITCALL MatchPatternEx(HANDLE hProcess, void* MemoryToCheck, int SizeOfMemoryToCheck, void* PatternToMatch, int SizeOfPatternToMatch, PBYTE WildCard)
|
||||||
|
|
@ -368,6 +369,7 @@ __declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBase
|
||||||
DWORD dwProtect = 0;
|
DWORD dwProtect = 0;
|
||||||
bool retValue = false;
|
bool retValue = false;
|
||||||
|
|
||||||
|
//read memory
|
||||||
if ( (hProcess == 0) || (lpBaseAddress == 0) || (lpBuffer == 0) || (nSize == 0))
|
if ( (hProcess == 0) || (lpBaseAddress == 0) || (lpBuffer == 0) || (nSize == 0))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -398,6 +400,10 @@ __declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBase
|
||||||
retValue = true;
|
retValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//filter breakpoints
|
||||||
|
if(retValue)
|
||||||
|
FilterBreakPoints((ULONG_PTR)lpBaseAddress, (unsigned char*)lpBuffer, nSize);
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue