resolved issue #44 (by removing the push ss, pop ss 'fix') + fixed SingleStep

This commit is contained in:
Mr. eXoDia 2014-12-08 23:37:59 +01:00
parent d572dd2bfc
commit c541b9d764
4 changed files with 16 additions and 30 deletions

View File

@ -30,7 +30,7 @@ DWORD ProcessExitCode = 0;
HANDLE DBGFileHandle;
std::vector<ULONG_PTR> tlsCallBackList;
std::vector<PROCESS_ITEM_DATA> hListProcess;
int engineStepCount = INFINITE;
DWORD engineStepCount = 0;
LPVOID engineStepCallBack = NULL;
bool engineStepActive = false;
bool engineProcessIsNowDetached = false;

View File

@ -29,7 +29,7 @@ extern DWORD ProcessExitCode;
extern HANDLE DBGFileHandle;
extern std::vector<ULONG_PTR> tlsCallBackList;
extern std::vector<PROCESS_ITEM_DATA> hListProcess;
extern int engineStepCount;
extern DWORD engineStepCount;
extern LPVOID engineStepCallBack;
extern bool engineStepActive;
extern bool engineProcessIsNowDetached;

View File

@ -50,27 +50,20 @@ __declspec(dllexport) void TITCALL ForceClose()
__declspec(dllexport) void TITCALL StepInto(LPVOID StepCallBack)
{
ULONG_PTR ueCurrentPosition = GetContextData(UE_CIP);
unsigned char instr[32]; //two instructions
unsigned char instr[16];
MemoryReadSafe(dbgProcessInformation.hProcess, (void*)ueCurrentPosition, instr, sizeof(instr), 0);
char* DisassembledString = (char*)StaticDisassembleEx(ueCurrentPosition, (LPVOID)instr);
if(strstr(DisassembledString, "PUSHF"))
StepOver(StepCallBack);
else
{
int len = StaticLengthDisassemble((LPVOID)instr);
DisassembledString = (char*)StaticDisassembleEx(ueCurrentPosition + len, (LPVOID)(instr + len));
if(strstr(DisassembledString, "PUSHF")) //we wanna land on PUSHF safely (to prevent 'PUSH SS, POP SS' problems
SetBPX(ueCurrentPosition + len, UE_BREAKPOINT_TYPE_INT3 + UE_SINGLESHOOT, StepCallBack);
else
{
ULONG_PTR ueContext = NULL;
ueContext = (ULONG_PTR)GetContextData(UE_EFLAGS);
ueContext |= UE_TRAP_FLAG;
SetContextData(UE_EFLAGS, ueContext);
engineStepActive = true;
engineStepCallBack = StepCallBack;
engineStepCount = NULL;
}
ULONG_PTR ueContext = NULL;
ueContext = (ULONG_PTR)GetContextData(UE_EFLAGS);
ueContext |= UE_TRAP_FLAG;
SetContextData(UE_EFLAGS, ueContext);
engineStepActive = true;
engineStepCallBack = StepCallBack;
engineStepCount = 0;
}
}
@ -98,15 +91,8 @@ __declspec(dllexport) void TITCALL StepOut(LPVOID StepOut, bool StepFinal)
__declspec(dllexport) void TITCALL SingleStep(DWORD StepCount, LPVOID StepCallBack)
{
ULONG_PTR ueContext = NULL;
ueContext = (ULONG_PTR)GetContextData(UE_EFLAGS);
ueContext |= UE_TRAP_FLAG;
SetContextData(UE_EFLAGS, ueContext);
engineStepActive = true;
engineStepCount = (int)StepCount;
engineStepCallBack = StepCallBack;
engineStepCount--;
StepInto(StepCallBack);
engineStepCount = StepCount - 1; //We already stepped once
}
__declspec(dllexport) void TITCALL SetNextDbgContinueStatus(DWORD SetDbgCode)

View File

@ -681,7 +681,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
ResetBPX = false;
if(engineStepActive)
{
if(engineStepCount == NULL)
if(engineStepCount == 0)
{
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
@ -717,7 +717,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
SetHardwareBreakPoint(DebugRegisterX.DrxBreakAddress, DebugRegisterXId, DebugRegisterX.DrxBreakPointType, DebugRegisterX.DrxBreakPointSize, (LPVOID)DebugRegisterX.DrxCallBack);
if(engineStepActive)
{
if(engineStepCount == NULL)
if(engineStepCount == 0)
{
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
@ -746,7 +746,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)ResetMemBPXAddress, ResetMemBPXSize, NewProtect, &OldProtect);
if(engineStepActive)
{
if(engineStepCount == NULL)
if(engineStepCount == 0)
{
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try
@ -898,7 +898,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(engineStepActive)
{
DBGCode = DBG_CONTINUE;
if(engineStepCount == NULL)
if(engineStepCount == 0)
{
myCustomBreakPoint = (fCustomBreakPoint)(engineStepCallBack);
__try