diff --git a/Release/TitanEngine.dll b/Release/x32/TitanEngine.dll
similarity index 59%
rename from Release/TitanEngine.dll
rename to Release/x32/TitanEngine.dll
index 11a93d0..5b52e02 100644
Binary files a/Release/TitanEngine.dll and b/Release/x32/TitanEngine.dll differ
diff --git a/Release/TitanEngine.exp b/Release/x32/TitanEngine.exp
similarity index 93%
rename from Release/TitanEngine.exp
rename to Release/x32/TitanEngine.exp
index 17577fc..f4d96b0 100644
Binary files a/Release/TitanEngine.exp and b/Release/x32/TitanEngine.exp differ
diff --git a/Release/TitanEngine.lib b/Release/x32/TitanEngine.lib
similarity index 51%
rename from Release/TitanEngine.lib
rename to Release/x32/TitanEngine.lib
index 67c331c..337d65e 100644
Binary files a/Release/TitanEngine.lib and b/Release/x32/TitanEngine.lib differ
diff --git a/Release/TitanEngine_x86.a b/Release/x32/TitanEngine_x86.a
similarity index 92%
rename from Release/TitanEngine_x86.a
rename to Release/x32/TitanEngine_x86.a
index 0877b9f..adfe65b 100644
Binary files a/Release/TitanEngine_x86.a and b/Release/x32/TitanEngine_x86.a differ
diff --git a/Release/lib2a.bat b/Release/x32/lib2a.bat
similarity index 100%
rename from Release/lib2a.bat
rename to Release/x32/lib2a.bat
diff --git a/x64/Release/TitanEngine.dll b/Release/x64/TitanEngine.dll
similarity index 54%
rename from x64/Release/TitanEngine.dll
rename to Release/x64/TitanEngine.dll
index a408f13..bd6b5b4 100644
Binary files a/x64/Release/TitanEngine.dll and b/Release/x64/TitanEngine.dll differ
diff --git a/x64/Release/TitanEngine.exp b/Release/x64/TitanEngine.exp
similarity index 93%
rename from x64/Release/TitanEngine.exp
rename to Release/x64/TitanEngine.exp
index 2efc58a..491243e 100644
Binary files a/x64/Release/TitanEngine.exp and b/Release/x64/TitanEngine.exp differ
diff --git a/Release/x64/TitanEngine.lib b/Release/x64/TitanEngine.lib
new file mode 100644
index 0000000..c0399f0
Binary files /dev/null and b/Release/x64/TitanEngine.lib differ
diff --git a/x64/Release/TitanEngine_x64.a b/Release/x64/TitanEngine_x64.a
similarity index 89%
rename from x64/Release/TitanEngine_x64.a
rename to Release/x64/TitanEngine_x64.a
index ae2e4a4..666f069 100644
Binary files a/x64/Release/TitanEngine_x64.a and b/Release/x64/TitanEngine_x64.a differ
diff --git a/x64/Release/lib2a.bat b/Release/x64/lib2a.bat
similarity index 100%
rename from x64/Release/lib2a.bat
rename to Release/x64/lib2a.bat
diff --git a/TitanEngine/TitanEngine.cbp b/TitanEngine/TitanEngine.cbp
index d18e885..9c85310 100644
--- a/TitanEngine/TitanEngine.cbp
+++ b/TitanEngine/TitanEngine.cbp
@@ -7,7 +7,7 @@
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/TitanEngine/TitanEngine.cpp b/TitanEngine/TitanEngine.cpp
index 0426ef6..c294c88 100644
--- a/TitanEngine/TitanEngine.cpp
+++ b/TitanEngine/TitanEngine.cpp
@@ -188,8 +188,6 @@ unsigned long Crc32Table[256];
#define UE_MODULEx86 0x2000;
#define UE_MODULEx64 0x2000;
-
-
// Global.Handle.functions:
bool EngineCloseHandle(HANDLE myHandle)
{
@@ -16470,6 +16468,7 @@ __declspec(dllexport) void DebugLoop()
bool ResetBPX = false;
bool BreakDBG = false;
bool ResetHwBPX = false;
+ bool ResetMemBPX = false;
bool CompareResult = false;
bool SecondChance = false;
ULONG_PTR CmpValue1 = NULL;
@@ -16491,6 +16490,8 @@ __declspec(dllexport) void DebugLoop()
ULONG_PTR MemoryBpxCallBack = 0;
DWORD ResetBPXSize = 0;
ULONG_PTR ResetBPXAddressTo = 0;
+ ULONG_PTR ResetMemBPXAddress = 0;
+ SIZE_T ResetMemBPXSize = 0;
int MaximumBreakPoints = 0;
ULONG_PTR NumberOfBytesReadWritten = 0;
MEMORY_BASIC_INFORMATION MemInfo;
@@ -17037,7 +17038,6 @@ __declspec(dllexport) void DebugLoop()
#endif
SetThreadContext(hActiveThread, &myDBGContext);
EngineCloseHandle(hActiveThread);
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)BreakPointBuffer[MaximumBreakPoints].ExecuteCallBack);
if(BreakPointBuffer[MaximumBreakPoints].NumberOfExecutions != -1 && BreakPointBuffer[MaximumBreakPoints].NumberOfExecutions != 0)
@@ -17185,14 +17185,12 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
DBGCode = DBG_CONTINUE;
}
}
else
{
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
DBGCode = DBG_EXCEPTION_NOT_HANDLED;
}
@@ -17280,10 +17278,10 @@ __declspec(dllexport) void DebugLoop()
DBGCustomHandler->chSingleStep = NULL;
}
}*/
- if(ResetBPX == true || ResetHwBPX == true)
+ if(ResetBPX == true || ResetHwBPX == true || ResetMemBPX == true)
{
DBGCode = DBG_CONTINUE;
- if(!ResetHwBPX)
+ if(ResetBPX) //restore 'normal' breakpoint
{
if(ResetBPXAddressTo + ResetBPXSize != (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress)
{
@@ -17325,7 +17323,7 @@ __declspec(dllexport) void DebugLoop()
EngineCloseHandle(hActiveThread);
}
}
- else
+ else if(ResetHwBPX) //restore hardware breakpoint
{
ResetHwBPX = false;
SetHardwareBreakPoint(DebugRegisterX.DrxBreakAddress, DebugRegisterXId, DebugRegisterX.DrxBreakPointType, DebugRegisterX.DrxBreakPointSize, (LPVOID)DebugRegisterX.DrxCallBack);
@@ -17351,8 +17349,37 @@ __declspec(dllexport) void DebugLoop()
}
}
}
+ else if(ResetMemBPX) //restore memory breakpoint
+ {
+ ResetMemBPX = false;
+ VirtualQueryEx(dbgProcessInformation.hProcess, (LPCVOID)ResetMemBPXAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
+ OldProtect = MemInfo.AllocationProtect;
+ NewProtect = OldProtect | PAGE_GUARD;
+ VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)ResetMemBPXAddress, ResetMemBPXSize, NewProtect, &OldProtect);
+ if(engineStepActive)
+ {
+ if(engineStepCount == NULL)
+ {
+ myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
+ __try
+ {
+ engineStepActive = false;
+ engineStepCallBack = NULL;
+ myCustomBreakPoint();
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ }
+ }
+ else
+ {
+ SingleStep(engineStepCount, engineStepCallBack);
+ }
+ }
+ }
}
- else
+ else //no resetting needed (debugger reached hardware breakpoint or the user stepped)
{
if(engineStepActive)
{
@@ -17376,7 +17403,7 @@ __declspec(dllexport) void DebugLoop()
SingleStep(engineStepCount, engineStepCallBack);
}
}
- else
+ else //handle hardware breakpoints
{
hActiveThread = OpenThread(THREAD_GET_CONTEXT+THREAD_SET_CONTEXT+THREAD_QUERY_INFORMATION, false, DBGEvent.dwThreadId);
myDBGContext.ContextFlags = CONTEXT_ALL;
@@ -17394,14 +17421,7 @@ __declspec(dllexport) void DebugLoop()
myCustomHandler = (fCustomHandler)(DebugRegister0.DrxCallBack);
__try
{
- ULONG_PTR addr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
- if(myDBGContext.Dr6 & 0x1)
-#if defined(_WIN64)
- addr=(ULONG_PTR)myDBGContext.Rip;
-#else
- addr=(ULONG_PTR)myDBGContext.Eip;
-#endif
- myCustomHandler((void*)addr);
+ myCustomHandler((void*)myDBGContext.Dr0);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -17431,14 +17451,7 @@ __declspec(dllexport) void DebugLoop()
myCustomHandler = (fCustomHandler)(DebugRegister1.DrxCallBack);
__try
{
- ULONG_PTR addr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
- if(myDBGContext.Dr6 & 0x2)
-#if defined(_WIN64)
- addr=(ULONG_PTR)myDBGContext.Rip;
-#else
- addr=(ULONG_PTR)myDBGContext.Eip;
-#endif
- myCustomHandler((void*)addr);
+ myCustomHandler((void*)myDBGContext.Dr1);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -17468,14 +17481,7 @@ __declspec(dllexport) void DebugLoop()
myCustomHandler = (fCustomHandler)(DebugRegister2.DrxCallBack);
__try
{
- ULONG_PTR addr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
- if(myDBGContext.Dr6 & 0x4)
-#if defined(_WIN64)
- addr=(ULONG_PTR)myDBGContext.Rip;
-#else
- addr=(ULONG_PTR)myDBGContext.Eip;
-#endif
- myCustomHandler((void*)addr);
+ myCustomHandler((void*)myDBGContext.Dr2);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -17505,14 +17511,7 @@ __declspec(dllexport) void DebugLoop()
myCustomHandler = (fCustomHandler)(DebugRegister3.DrxCallBack);
__try
{
- ULONG_PTR addr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
- if(myDBGContext.Dr6 & 0x8)
-#if defined(_WIN64)
- addr=(ULONG_PTR)myDBGContext.Rip;
-#else
- addr=(ULONG_PTR)myDBGContext.Eip;
-#endif
- myCustomHandler((void*)addr);
+ myCustomHandler((void*)myDBGContext.Dr3);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -17554,40 +17553,32 @@ __declspec(dllexport) void DebugLoop()
}
else if(DBGEvent.u.Exception.ExceptionRecord.ExceptionCode == STATUS_GUARD_PAGE_VIOLATION)
{
- /*if(DBGCustomHandler->chPageGuard != NULL)
- {
- myCustomHandler = (fCustomHandler)((LPVOID)DBGCustomHandler->chPageGuard);
- __try
- {
- myCustomHandler(&DBGEvent.u.Exception.ExceptionRecord);
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- DBGCustomHandler->chPageGuard = NULL;
- }
- }*/
- char temp[20]="";
- sprintf(temp, "%X", (unsigned int)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress);
- MessageBoxA(0,temp,0,0);
MemoryBpxFound = false;
MaximumBreakPoints = 0;
+ ULONG_PTR bpaddr;
for(MaximumBreakPoints = 0; MaximumBreakPoints < BreakPointSetCount; MaximumBreakPoints++)
{
ULONG_PTR addr=BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
- ULONG_PTR bpaddr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
- if(((BreakPointBuffer[MaximumBreakPoints].BreakPointType >= UE_MEMORY) && (BreakPointBuffer[MaximumBreakPoints].BreakPointType <= UE_MEMORY_WRITE)) && bpaddr>=addr && bpaddr<=(addr+BreakPointBuffer[MaximumBreakPoints].BreakPointSize))
+ if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 1)
+ bpaddr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]; //page accessed
+ else
+ bpaddr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress;
+ if(((BreakPointBuffer[MaximumBreakPoints].BreakPointType >= UE_MEMORY) && (BreakPointBuffer[MaximumBreakPoints].BreakPointType <= UE_MEMORY_EXECUTE)) && bpaddr>=addr && bpaddr<=(addr+BreakPointBuffer[MaximumBreakPoints].BreakPointSize))
{
MemoryBpxFound = true;
break;
}
}
- if(MaximumBreakPoints < MAXIMUM_BREAKPOINTS || MemoryBpxFound == true)
+ if(MaximumBreakPoints < MAXIMUM_BREAKPOINTS || MemoryBpxFound == true) //found memory breakpoint
{
- if(BreakPointBuffer[MaximumBreakPoints].BreakPointActive == UE_BPXACTIVE)
+ if(BreakPointBuffer[MaximumBreakPoints].BreakPointActive == UE_BPXACTIVE) //memory breakpoint is active
{
+ hActiveThread = OpenThread(THREAD_GET_CONTEXT+THREAD_SET_CONTEXT+THREAD_QUERY_INFORMATION, false, DBGEvent.dwThreadId);
+ myDBGContext.ContextFlags = CONTEXT_ALL;
+ GetThreadContext(hActiveThread, &myDBGContext);
DBGCode = DBG_CONTINUE;
MemoryBpxCallBack = BreakPointBuffer[MaximumBreakPoints].ExecuteCallBack;
- if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY)
+ if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY) //READ|WRITE|EXECUTE
{
if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1)
{
@@ -17595,22 +17586,26 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- VirtualQueryEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
- OldProtect = MemInfo.AllocationProtect;
- NewProtect = OldProtect ^ PAGE_GUARD;
- VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, NewProtect, &OldProtect);
+ if(!(myDBGContext.EFlags & 0x100))
+ {
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
+ }
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
}
- myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)MemoryBpxCallBack);
+ myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
- myCustomBreakPoint();
+ myCustomHandler((void*)bpaddr);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
- else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_READ)
+ else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_READ) //READ
{
if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1)
{
@@ -17618,17 +17613,62 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- VirtualQueryEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
- OldProtect = MemInfo.AllocationProtect;
- NewProtect = OldProtect ^ PAGE_GUARD;
- VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, NewProtect, &OldProtect);
+ if(!(myDBGContext.EFlags & 0x100))
+ {
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
+ }
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
}
- if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0)
+ if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0) //read operation
{
- myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)MemoryBpxCallBack);
+ myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
- myCustomBreakPoint();
+ myCustomHandler((void*)bpaddr);
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+
+ }
+ }
+ else //no read operation, restore breakpoint
+ {
+ if(!(myDBGContext.EFlags & 0x100))
+ {
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
+ }
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
+ }
+ }
+ else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_WRITE) //WRITE
+ {
+ if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1) //remove breakpoint
+ {
+ RemoveMemoryBPX(BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize);
+ }
+ else //restore breakpoint after trap flag
+ {
+ if(!(myDBGContext.EFlags & 0x100))
+ {
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
+ }
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
+ }
+ if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 1) //write operation
+ {
+ myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
+ __try
+ {
+ myCustomHandler((void*)bpaddr);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
@@ -17637,16 +17677,17 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- if(BreakPointBuffer[MaximumBreakPoints].BreakPointAddress >= (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress && (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress <= BreakPointBuffer[MaximumBreakPoints].BreakPointAddress + BreakPointBuffer[MaximumBreakPoints].BreakPointSize)
+ if(!(myDBGContext.EFlags & 0x100))
{
- VirtualQueryEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
- OldProtect = MemInfo.AllocationProtect;
- NewProtect = OldProtect ^ PAGE_GUARD;
- VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, NewProtect, &OldProtect);
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
}
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
}
}
- else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_WRITE)
+ else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_EXECUTE) //EXECUTE
{
if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1)
{
@@ -17654,41 +17695,47 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- VirtualQueryEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
- OldProtect = MemInfo.AllocationProtect;
- NewProtect = OldProtect ^ PAGE_GUARD;
- VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, NewProtect, &OldProtect);
+ if(!(myDBGContext.EFlags & 0x100))
+ {
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
+ }
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
}
- if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 1)
+ if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0 && (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress >= BreakPointBuffer[MaximumBreakPoints].BreakPointAddress && (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress <= BreakPointBuffer[MaximumBreakPoints].BreakPointAddress + BreakPointBuffer[MaximumBreakPoints].BreakPointSize) //read operation
{
- myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)MemoryBpxCallBack);
+ myCustomHandler = (fCustomHandler)(MemoryBpxCallBack);
__try
{
- myCustomBreakPoint();
+ myCustomHandler((void*)bpaddr);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
- else
+ else //no execute operation, restore breakpoint
{
- if(BreakPointBuffer[MaximumBreakPoints].BreakPointAddress >= (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress && (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress <= BreakPointBuffer[MaximumBreakPoints].BreakPointAddress + BreakPointBuffer[MaximumBreakPoints].BreakPointSize)
+ if(!(myDBGContext.EFlags & 0x100))
{
- VirtualQueryEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, &MemInfo, sizeof MEMORY_BASIC_INFORMATION);
- OldProtect = MemInfo.AllocationProtect;
- NewProtect = OldProtect ^ PAGE_GUARD;
- VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, NewProtect, &OldProtect);
+ myDBGContext.EFlags = myDBGContext.EFlags ^ 0x100;
}
+ SetThreadContext(hActiveThread, &myDBGContext);
+ ResetMemBPXAddress = BreakPointBuffer[MaximumBreakPoints].BreakPointAddress;
+ ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize;
+ ResetMemBPX = true;
}
}
+ EngineCloseHandle(hActiveThread);
}
else
{
DBGCode = DBG_EXCEPTION_NOT_HANDLED;
}
}
- else
+ else //no memory breakpoint found
{
DBGCode = DBG_EXCEPTION_NOT_HANDLED;
}
@@ -17772,7 +17819,6 @@ __declspec(dllexport) void DebugLoop()
}
SetThreadContext(hActiveThread, &myDBGContext);
EngineCloseHandle(hActiveThread);
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)BreakPointBuffer[MaximumBreakPoints].ExecuteCallBack);
if(BreakPointBuffer[MaximumBreakPoints].NumberOfExecutions != -1 && BreakPointBuffer[MaximumBreakPoints].NumberOfExecutions != 0)
@@ -17920,14 +17966,12 @@ __declspec(dllexport) void DebugLoop()
}
else
{
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
DBGCode = DBG_CONTINUE;
}
}
else
{
- //TODO fixed
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize, OldProtect, &OldProtect);
DBGCode = DBG_EXCEPTION_NOT_HANDLED;
}
diff --git a/TitanEngine/TitanEngine.vcxproj b/TitanEngine/TitanEngine.vcxproj
index 532165c..e71b3cf 100644
--- a/TitanEngine/TitanEngine.vcxproj
+++ b/TitanEngine/TitanEngine.vcxproj
@@ -66,10 +66,10 @@
$(SolutionDir)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\
true
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- $(SolutionDir)$(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
+ $(SolutionDir)\$(IntDir)x32
+ $(Configuration)\x32
+ $(SolutionDir)\$(Configuration)\x64
+ $(Configuration)\x64
false
AllRules.ruleset
diff --git a/TitanEngine/stdafx.h b/TitanEngine/stdafx.h
index 124f171..4984a21 100644
--- a/TitanEngine/stdafx.h
+++ b/TitanEngine/stdafx.h
@@ -415,6 +415,7 @@ typedef struct
#define UE_MEMORY 3
#define UE_MEMORY_READ 4
#define UE_MEMORY_WRITE 5
+#define UE_MEMORY_EXECUTE 6
#define UE_BREAKPOINT_TYPE_INT3 0x10000000
#define UE_BREAKPOINT_TYPE_LONG_INT3 0x20000000
#define UE_BREAKPOINT_TYPE_UD2 0x30000000
diff --git a/x64/Release/TitanEngine.lib b/x64/Release/TitanEngine.lib
deleted file mode 100644
index 0a86fca..0000000
Binary files a/x64/Release/TitanEngine.lib and /dev/null differ