The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Larry Hammick on November 07, 2007, 06:48:33 PM

Title: Useful little debugging tool "peek.dll"
Post by: Larry Hammick on November 07, 2007, 06:48:33 PM
It's a small dll that can interrupt any program at any point and show the main cpu registers or a block of memory. Very easy to use, and saves time versus loading a bulky debugger and then trying to find where to put a breakpoint.


[attachment deleted by admin]
Title: Re: Useful little debugging tool "peek.dll"
Post by: Vortex on November 07, 2007, 08:53:59 PM
Larry,

Welcome to the forum.

Nice idea.

Why not to use an import library instead of calling the exported functions with LoadLibrary?
Title: Re: Useful little debugging tool "peek.dll"
Post by: Larry Hammick on November 07, 2007, 10:49:45 PM
Hi Vortex. Yes, an import library is okay, and masm produces one automatically along with the *.obj. But I like the low-overhead approach: just the dll and one clever macro. I used to use a macro alone, containing just enough code to dump EAX or a bit of memory to a message box. I found it so useful that I figured it was worthwhile to do it right, with fixed pitch fonts and all. Here's the EAX part:

@dumpeax macro
.code
dumpeax:
  pushfd
  pushad
  cld
  sub esp,0Ch  ;more than enough, but using an odd esp makes trouble
  mov ecx,4     ;number of bytes in eax
  mov edi,esp    ;where to assemble a text string
@@: rol eax,8
  push eax
  call _al2hexax
  stosw
  pop eax
  loop @B
  mov [edi],cl  ;0
  mov eax,esp
  push 1       ;MB_OKCANCEL
  call @F
  db "dumpeax",0
@@: push eax
  push 0
  call MessageBoxA
  add esp,0Ch
  sub eax,2      ;IDCANCEL
  je short @F
  popad
  popfd
  ret
@@: invoke ExitProcess,eax
_al2hexax: mov ah,al
    shr ah,4
    call @F
    xchg al,ah
@@: and al,0Fh
    cmp al,0Ah
    sbb al,69h
    das
    ret
endm


A lot better than nothing :)
Title: Re: Useful little debugging tool "peek.dll"
Post by: hutch-- on November 08, 2007, 02:30:44 AM
Hi Larry,

Glad to see you back.  :thumbu
Title: Re: Useful little debugging tool "peek.dll"
Post by: Vortex on November 08, 2007, 06:29:16 PM
Hi Larry,

OK, I understand your method.

You would like to check GoLink, it's a linker developed for GoAsm but it can link Masm object files. This tool does not require import libraries to resolve external functions.
Title: Re: Useful little debugging tool "peek.dll"
Post by: Larry Hammick on November 16, 2007, 09:05:11 AM
Here's a version for debugging console apps. Simpler source code, very similar usage and output.


[attachment deleted by admin]
Title: Re: Useful little debugging tool "peek.dll"
Post by: RuiLoureiro on November 16, 2007, 03:31:09 PM
Hi Larry.
I tried to use Peek and the result was syntax error and undefined Symbol: WidthMemBtn.
I put peek.asm, peek.inc and peek.dll in the folder where are the files to compile to a Lib.
Inside one file i put include peek.inc and @peek and inside a proc call regs. I compiled and the result was symbol (that) not find. Why ?
RuiLoureiro
Title: Re: Useful little debugging tool "peek.dll"
Post by: RuiLoureiro on November 16, 2007, 04:34:55 PM
Hi
Sorry Larry, the procedure works well ! There was a problem with the definition of WidthMemBtn in my file peek.asm.  It was  «WidthMemBtn     qu   WidthMemDlg/2 ».
My thanks Larry
RuiLoureiro