Since I don't have a working debugger, I'd like to include some debugging code in my program. The code
would be something like:
ldbe PROC
pushad
(load regs with selected values)
(display regs)
(wait for keypress)
popad
retn
ENDM
with calls to ldbg at one or more points in my program.
I want to bypass the windows message system if there is a not-too-complicated way to do this.
Any thoughts?
Thanks
PS: Thanks to PBrennick re ollydbg. I tried and abandoned it a long time ago because I couldn't
find a way to use source code. I think I'll try again, since even when it was working, windbg seemed
unnecessarily complex and incredibly user unfriendly. Thanks.
You do realize you could build it all into one buffer with CRLFs and use a MessageBox to display it? Other than that, if it is not a console app there is no easier way IMO. I routinely use a MessageBox and remove it when done. The only pratfall is it destroys some registers so you have to be careful.
OllyDebug - :U
Paul
If you're debugging a GUI app you can add a console by building it as a console app, and then you can display your debug output on the console. Instead of waiting for a key you can just let the output scroll, and under Windows 2000 and later you can at any point recall the last 300 lines of output. To display the registers and flags, without altering either, you can use something like this (patterned after the DumpRegs procedure in the Irvine32 library).
DumpRegs:
.data
_eax dd 0
_ebx dd 0
_ecx dd 0
_edx dd 0
_esi dd 0
_edi dd 0
_ebp dd 0
_esp dd 0
_eip dd 0
_efl dd 0
.code
pop _eip
mov _esp, esp
push _eip
pushfd
pushad
pushfd
pop _efl
mov _eax, eax
mov _ebx, ebx
mov _ecx, ecx
mov _edx, edx
mov _esi, esi
mov _edi, edi
mov _ebp, ebp
print "EAX="
print uhex$(_eax)," "
print "EBX="
print uhex$(_ebx)," "
print "ECX="
print uhex$(_ecx)," "
print "EDX="
print uhex$(_edx)," ",13,10
print "ESI="
print uhex$(_esi)," "
print "EDI="
print uhex$(_edi)," "
print "EBP="
print uhex$(_ebp)," "
print "ESP="
print uhex$(_esp)," ",13,10
print "EIP="
print uhex$(_eip)," "
print "EFL="
print uhex$(_efl)," "
.IF _efl & 1 SHL 11 ; Overflow (bit 11)
print "OF=1 "
.ELSE
print "OF=0 "
.ENDIF
.IF _efl & 1 SHL 7 ; Sign (bit 7)
print "SF=1 "
.ELSE
print "SF=0 "
.ENDIF
.IF _efl & 1 SHL 6 ; Zero (bit 6)
print "ZF=1 "
.ELSE
print "ZF=0 "
.ENDIF
.IF _efl & 1 SHL 0 ; Carry (bit 0)
print "CF=1",13,10
.ELSE
print "CF=0",13,10
.ENDIF
popad
popfd
ret
Could be a great alternative.
Not needed now, since I've got windbg working again by uninstalling/deleting everything and starting from scratch.
Thanks
Robert
``````
Re: Direct Access to Keyboard and Screen
« Reply #1 on: Today at 03:24:25 PM »
You do realize you could build it all into one buffer with CRLFs and use a MessageBox to display it? Other than that, if it is not a console app there is no easier way IMO. I routinely use a MessageBox and remove it when done. The only pratfall is it destroys some registers so you have to be careful.
OllyDebug - ThumbsUp
Paul
I use "OutputDebugString".