Hey everyone. I'm having some problems with my homemade debugger, written in VB6, and I was hoping someone here could help me.
See, I'm writing this kind of debugger hack for Conquer Online. I'm using it to read the decrypted packets both incoming and outgoing. I'm using breakpoints at the "SendPacket()" and "ReceivePacket()" function inside the .exe and then I use the GetThreadContext API to read the register values and get the decrypted packets.
It works almost perfectly, although there's a tiny problem, and I was hoping someone here might know how to solve it. Whenever I hit a breakpoint, my tool is supposed to set the Resume Flag inside the CPU to 1 which should prevent exceptions from going into an infinite loop, but it does not work - the Resume Flag just won't change.
However, it works just fine on Windows Vista, which I cannot seem to understand why, I've google'd a million times, and still no luck. Here's the part of my code that's supposed to toggle the Resume Flag:
And this:
Also, another quick question:
I'm using CreateRemoteThread to execute code inside the .exe (e.g. using a skill), but whenever I'm debugging the application (using DebugActiveProcess) it just freezes. Is there a way to prevent a debugged application from freezing when using CreateRemoteThread? At the moment I have to use this whenever I need to call a function:
Thank you for your time :).
See, I'm writing this kind of debugger hack for Conquer Online. I'm using it to read the decrypted packets both incoming and outgoing. I'm using breakpoints at the "SendPacket()" and "ReceivePacket()" function inside the .exe and then I use the GetThreadContext API to read the register values and get the decrypted packets.
It works almost perfectly, although there's a tiny problem, and I was hoping someone here might know how to solve it. Whenever I hit a breakpoint, my tool is supposed to set the Resume Flag inside the CPU to 1 which should prevent exceptions from going into an infinite loop, but it does not work - the Resume Flag just won't change.
However, it works just fine on Windows Vista, which I cannot seem to understand why, I've google'd a million times, and still no luck. Here's the part of my code that's supposed to toggle the Resume Flag:
Code:
Do While bContinue
ContinueStatus = DBG_CONTINUE
If WaitForDebugEvent(DebugEvent, 0) Then
ExceptionAddress = DebugEvent.dwUnionData.ExceptionRecord.ExceptionAddress
ExceptionCode = DebugEvent.dwUnionData.ExceptionRecord.ExceptionCode
Select Case DebugEvent.dwDebugEventCode
Case EXCEPTION_DEBUG_EVENT
ContinueStatus = DBG_CONTINUE
If Not bSeenInitialBreakpoint And ExceptionCode = EXCEPTION_BREAKPOINT Then
ContinueStatus = DBG_CONTINUE
SetHardwareBreakpoint DebugEvent.dwProcessId
bSeenInitialBreakpoint = True
End If
If ExceptionCode = EXCEPTION_SINGLE_STEP Then
ContinueStatus = DBG_CONTINUE
ThreadHandle = OpenThread(THREAD_ALL_ACCESS, False, DebugEvent.dwThreadId)
' Debug.Print "Single step exception occured"
SuspendThread (ThreadHandle)
If DebugEvent.dwUnionData.ExceptionRecord.ExceptionAddress = SendPacketFunction Or DebugEvent.dwUnionData.ExceptionRecord.ExceptionAddress = RecvPacketFunction Then
ExceptionHandler ThreadHandle, ExceptionAddress
End If
ResumeThread (ThreadHandle)
CloseHandle (ThreadHandle)
End If
If ExceptionCode = EXCEPTION_BREAKPOINT Then
ContinueStatus = DBG_CONTINUE
End If
Case CREATE_THREAD_DEBUG_EVENT
'SetHardwareBreakpointInThread DebugEvent.dwThreadId
End Select
ContinueDebugEvent DebugEvent.dwProcessId, DebugEvent.dwThreadId, ContinueStatus
End If
DoEvents
Loop
End If
Code:
Public Sub ExceptionHandler(hThread As Long, ExceptionAddress As Long) Dim cThread As CONTEXT cThread.ContextFlags = CONTEXT_ALL GetThreadContext hThread, cThread cThread.EFlags = cThread.EFlags Or EFLAG_RF ' // EFLAG_RG = Resume Flag = &H10000 SetThreadContext hThread, cThread
I'm using CreateRemoteThread to execute code inside the .exe (e.g. using a skill), but whenever I'm debugging the application (using DebugActiveProcess) it just freezes. Is there a way to prevent a debugged application from freezing when using CreateRemoteThread? At the moment I have to use this whenever I need to call a function:
Code:
DebugActiveProcessStop(ProcessID) UseSkill SkillID, TargetID ' (Just an example) DebugActiveProcess(ProcessID)