diff --git a/TitanEngine/Global.Breakpoints.cpp b/TitanEngine/Global.Breakpoints.cpp index df10b05..787ced3 100644 --- a/TitanEngine/Global.Breakpoints.cpp +++ b/TitanEngine/Global.Breakpoints.cpp @@ -110,3 +110,26 @@ void uintdr7(ULONG_PTR dr7, DR7* ret) if(BITGET(dr7,31)) 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; iBreakPointActive || (curBp->BreakPointType != UE_BREAKPOINT && curBp->BreakPointType != UE_SINGLESHOOT)) + continue; + ULONG_PTR cur_addr=curBp->BreakPointAddress; + if(cur_addr>=start && cur_addrBreakPointSize; + if((cur_addr+n)>end) + n=end-cur_addr; //do not overflow the buffer + memcpy(lpBuffer+index, curBp->OriginalByte, n); + } + } +} \ No newline at end of file diff --git a/TitanEngine/Global.Breakpoints.h b/TitanEngine/Global.Breakpoints.h index 4bdd872..1e59776 100644 --- a/TitanEngine/Global.Breakpoints.h +++ b/TitanEngine/Global.Breakpoints.h @@ -7,5 +7,6 @@ extern std::vector BreakPointBuffer; void uintdr7(ULONG_PTR dr7, DR7* ret); ULONG_PTR dr7uint(DR7* dr7); +void FilterBreakPoints(ULONG_PTR lpBaseAddress, unsigned char* lpBuffer, SIZE_T nSize); #endif //_GLOBAL_BREAKPOINTS_H diff --git a/TitanEngine/TitanEngine.Debugger.Memory.cpp b/TitanEngine/TitanEngine.Debugger.Memory.cpp index 38bd8bd..ebed079 100644 --- a/TitanEngine/TitanEngine.Debugger.Memory.cpp +++ b/TitanEngine/TitanEngine.Debugger.Memory.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "definitions.h" #include "Global.Debugger.h" +#include "Global.Breakpoints.h" #include __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; bool retValue = false; + //read memory if ( (hProcess == 0) || (lpBaseAddress == 0) || (lpBuffer == 0) || (nSize == 0)) { return false; @@ -398,6 +400,10 @@ __declspec(dllexport) bool TITCALL MemoryReadSafe(HANDLE hProcess, LPVOID lpBase retValue = true; } + //filter breakpoints + if(retValue) + FilterBreakPoints((ULONG_PTR)lpBaseAddress, (unsigned char*)lpBuffer, nSize); + return retValue; }