From 315f79982b50ce765b8eda5757e9063b1e82dbf8 Mon Sep 17 00:00:00 2001 From: "mr.exodia" Date: Sun, 26 Jan 2014 15:10:24 +0100 Subject: [PATCH] - changed build directories - fixed memory breakpoints (execute+read tested&working) - removed dllmain.cpp as it was not used --- TitanEngine/TitanEngine.cpp | 27 +++++++++++++------------ TitanEngine/TitanEngine.vcxproj | 22 ++++---------------- TitanEngine/TitanEngine.vcxproj.filters | 3 --- TitanEngine/dllmain.cpp | 19 ----------------- 4 files changed, 18 insertions(+), 53 deletions(-) delete mode 100644 TitanEngine/dllmain.cpp diff --git a/TitanEngine/TitanEngine.cpp b/TitanEngine/TitanEngine.cpp index 72859ba..4e91d9b 100644 --- a/TitanEngine/TitanEngine.cpp +++ b/TitanEngine/TitanEngine.cpp @@ -17310,11 +17310,10 @@ __declspec(dllexport) void TITCALL DebugLoop() for(MaximumBreakPoints = 0; MaximumBreakPoints < BreakPointSetCount; MaximumBreakPoints++) { ULONG_PTR addr=BreakPointBuffer[MaximumBreakPoints].BreakPointAddress; - 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)) + + bpaddr=(ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]; //page accessed + + if(((BreakPointBuffer[MaximumBreakPoints].BreakPointType >= UE_MEMORY) && (BreakPointBuffer[MaximumBreakPoints].BreakPointType <= UE_MEMORY_EXECUTE)) && bpaddr>=addr && bpaddr<(addr+BreakPointBuffer[MaximumBreakPoints].BreakPointSize)) { MemoryBpxFound = true; break; @@ -17324,10 +17323,10 @@ __declspec(dllexport) void TITCALL DebugLoop() { if(BreakPointBuffer[MaximumBreakPoints].BreakPointActive == UE_BPXACTIVE) //memory breakpoint is active { - hActiveThread = OpenThread(THREAD_GET_CONTEXT+THREAD_SET_CONTEXT+THREAD_QUERY_INFORMATION, false, DBGEvent.dwThreadId); + hActiveThread = OpenThread(THREAD_GET_CONTEXT|THREAD_SET_CONTEXT|THREAD_QUERY_INFORMATION, false, DBGEvent.dwThreadId); myDBGContext.ContextFlags = CONTEXT_ALL; GetThreadContext(hActiveThread, &myDBGContext); - DBGCode = DBG_CONTINUE; + DBGCode = DBG_CONTINUE; //debugger handled the exception MemoryBpxCallBack = BreakPointBuffer[MaximumBreakPoints].ExecuteCallBack; if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY) //READ|WRITE|EXECUTE { @@ -17358,12 +17357,12 @@ __declspec(dllexport) void TITCALL DebugLoop() } else if(BreakPointBuffer[MaximumBreakPoints].BreakPointType == UE_MEMORY_READ) //READ { - if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1) + if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 1) //do not restore the memory breakpoint { if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0) //read operation RemoveMemoryBPX(BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize); } - else + else //restore the memory breakpoint { if(!(myDBGContext.EFlags & 0x100)) { @@ -17428,7 +17427,7 @@ __declspec(dllexport) void TITCALL DebugLoop() } } - else + else //no write operation, restore breakpoint { if(!(myDBGContext.EFlags & 0x100)) { @@ -17444,7 +17443,8 @@ __declspec(dllexport) void TITCALL DebugLoop() { if(BreakPointBuffer[MaximumBreakPoints].MemoryBpxRestoreOnHit != 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 + if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0 && //read flag + (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress == DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]) //exception address == read address RemoveMemoryBPX(BreakPointBuffer[MaximumBreakPoints].BreakPointAddress, BreakPointBuffer[MaximumBreakPoints].BreakPointSize); } else @@ -17458,7 +17458,8 @@ __declspec(dllexport) void TITCALL DebugLoop() ResetMemBPXSize = BreakPointBuffer[MaximumBreakPoints].BreakPointSize; ResetMemBPX = true; } - 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 + if(DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[0] == 0 && //read flag + (ULONG_PTR)DBGEvent.u.Exception.ExceptionRecord.ExceptionAddress == DBGEvent.u.Exception.ExceptionRecord.ExceptionInformation[1]) //exception address == read address { myCustomHandler = (fCustomHandler)(MemoryBpxCallBack); __try @@ -17486,7 +17487,7 @@ __declspec(dllexport) void TITCALL DebugLoop() } else { - DBGCode = DBG_EXCEPTION_NOT_HANDLED; + DBGCode = DBG_EXCEPTION_NOT_HANDLED; //debugger did not handle the exception } } else //no memory breakpoint found diff --git a/TitanEngine/TitanEngine.vcxproj b/TitanEngine/TitanEngine.vcxproj index afbfc57..83026b7 100644 --- a/TitanEngine/TitanEngine.vcxproj +++ b/TitanEngine/TitanEngine.vcxproj @@ -60,11 +60,11 @@ <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(Configuration)\ + $(SolutionDir)\$(IntDir)x32 + $(Configuration)\x32 true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)\$(Configuration)\x64 + $(Configuration)\x64 true $(SolutionDir)\$(IntDir)x32 $(Configuration)\x32 @@ -215,20 +215,6 @@ - - - - false - - - false - - - false - - - false - Create Create diff --git a/TitanEngine/TitanEngine.vcxproj.filters b/TitanEngine/TitanEngine.vcxproj.filters index accd57d..de8ad07 100644 --- a/TitanEngine/TitanEngine.vcxproj.filters +++ b/TitanEngine/TitanEngine.vcxproj.filters @@ -24,9 +24,6 @@ - - Source Files - Source Files diff --git a/TitanEngine/dllmain.cpp b/TitanEngine/dllmain.cpp deleted file mode 100644 index 7f04770..0000000 --- a/TitanEngine/dllmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -/*BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - engineHandle = hModule; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -}*/ \ No newline at end of file