Hi VKim,

I have been implementing the Spy/StopSpy function in GoAsm and ofcourse the macro command language is very limited so it can be difficult. But I have run into a problem that happens on both the MASM version and the GoAsm versions for RadASM, say I have this:

@@:

inc dwLoopCount
cmp dwLoopCount,100
jne @B
PrintDec dwLoopCount


When exiting the loop dwLoopCount will be equal to 100, however if I try to Spy dwLoopCount:

Spy dwLoopCount

@@:
inc dwLoopCount
cmp dwLoopCount,100
jne @B
StopSpy
PrintDec dwLoopCount


When exiting the loop dwLoopCount will be equal to 1, in other words the jne is not executed. Is there a problem with the flags ? Similarly this will dump into an infinite loop if Spy'ed, it will exit at 64 if not.

Spy dwLoopCount

@@:
inc dwLoopCount
test dwLoopCount,64
jz @B
StopSpy
PrintDec dwLoopCount


The following is my Spy macro, as I said it is a little complicated in order to make up for forced loading of libs and no relative jumps in macros, the call is not executed it is only to force load the library so I can use the external vars.
Spy(ARG) = #IF DBGWIN_DEBUG_ON \

db 0EBh,05h \ ; jump past the next line
call \RadASM\GoAsm\lib\Debug.lib:debug_except_handler \
cmp D[__fTrap],0 \
db 75h, 34h \ ; if __fTrap then jmp to NOP (exit)
push eax \
mov D[__pVar],OFFSET ARG \
push OFFSET debug_except_handler \
FS push [0] \
FS mov [0],esp \
mov D[__fTrap],1 \
db 66h,9Ch \ ; pushfw (unsupported opcode)
popw ax \
or ax,100h \
pushw ax \
db 66h,9Dh \ ; popfw (unsupported opcode)
nop \ ; this is to have a place to jump to
#ELSE \
nop \ ; debug is turned off
#ENDIF

StopSpy = #IF DBGWIN_DEBUG_ON \
db 0EBh,05h \
call \RadASM\GoAsm\lib\Debug.lib:debug_except_handler \
mov D[__fTrap] ,0 \
mov eax,[esp] \
FS mov [0],esp \
add esp,8 \
pop eax \
#ELSE \
nop \
#ENDIF
Posted on 2003-12-29 20:11:38 by donkey
Hi VKim,

One other question, could you try the TrapException function, I tried with your example :
TestTrap:

TrapException(OFFSET EH)
xor edx, edx
mov eax, 1
xor ecx, ecx
div ecx
EH:
ret

It works fine however if you comment out the div ecx, the handler throws :
=========================================
Exception code: EXCEPTION_ILLEGAL_INSTRUCTION
Location: , 0

eax=00000386 ebx=7FFDF000 ecx=00000000 edx=00000000 esi=00000005
edi=C0000000 ebp=0012FFF0 esp=0012FFBC eip=0012FFE0
CS=001B DS=0023 SS=0023 ES=0023 FS=0038 GS=0000 o d I s Z a P c
----------------------------------------------------------------

This is from a MASM program and also in GoAsm, I was wondering if you could take a look at your macro for this function and tell me if it has to be modified (RadASM version).

DbgHelp Version 5.00.2195.6613, 2KSP4, debug.lib from RadASM distro.
Posted on 2003-12-30 17:10:28 by donkey