News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Useful little debugging tool "peek.dll"

Started by Larry Hammick, November 07, 2007, 06:48:33 PM

Previous topic - Next topic

Larry Hammick

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]

Vortex

Larry,

Welcome to the forum.

Nice idea.

Why not to use an import library instead of calling the exported functions with LoadLibrary?

Larry Hammick

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 :)

hutch--

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

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.

Larry Hammick

Here's a version for debugging console apps. Simpler source code, very similar usage and output.


[attachment deleted by admin]

RuiLoureiro

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

RuiLoureiro

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