"Use of GoBug" demonstrations
Api errors

This demonstrates how GoBug deals with API errors at run-time. Start Testbug as the debuggee and set a breakpoint at API_ERRORS using GoBug's "action, run to .. procedure" menu, then run the test using Testbug's menu.

When single-stepping or F7 (run/trap/full log) GoBug monitors the error code which is kept in the thread database for each thread. If this changes, then the API might be reporting an error (a change to zero, however, would mark success). The error code is what you get if you call GetLastError.

Here when the breakpoint is reached, single-step through the following code. See the error reported in the log (all 3 panes), with details and descriptions of the error (in so far as provided by Windows). See that the last offending instruction is outlined by a red box.

API_ERRORS:
PUSH 0,80h,3            ;3=open existing
PUSH 0,1h,0C0000000h    ;0C=read/write access
PUSH ADDR SPLOPFILE   ;filename
CALL CreateFileA        ;try to open file (no such file will be found)
PUSH 0,0,0,0            ;valid file handle expected
CALL SetFilePointer     ;but not found
PUSH 0,0,0
CALL ControlService     ;not sure what this does
PUSH ADDR SPLOPFILE,0,0,0
CALL CreateEventA       ;create a SPLOPFILE 
PUSH ADDR SPLOPFILE,0,0,0
CALL CreateEventA       ;and try to make another with same name
PUSH 0,85h              ;windows class 85h
CALL UnregisterClassA   ;not allowed to remove this class
PUSH 0,0,0
CALL VirtualFree        ;must be wrong parameters
RET