News:

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

Req: Completion Reminders

Started by Mark Jones, July 14, 2005, 10:12:15 PM

Previous topic - Next topic

Mark Jones

Hello. Does there exist, or could I request a plugin which warns the coder of unclosed file handles, open brushes, and unfreed memory handles?  :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Biterider

Hi Mark
ObjAsm32 has a Debug system that includes a module called ResGuard that does exactly this. It was designed to run also outside ObjAsm32 so it can be included to other MASM projects too. The final result is a displayed on the DebugCenter window. All resources that are not freed when the application was ended were listed together with the memory address (stack) where it was allocated. It handles almost all type of resources... Since the source code is availabe too, it can be expanded to cover your own needs.

For a better understanding, ResGuard works in a similar way as MemProof but it requires to be compiled into the application to debug it. Finally, when you are ready you simply remove it!

Regards,

Biterider

CObject

Hi
I just write this:


invoke ResGuardStart
invoke CreatePen,PS_SOLID,5,255
invoke ResGuardShow



.. and ResGuard doesn't detect any leakage ?!!

It simply reports:

ResGuard started
————————————————————————————————————————————————————————————

Mark Jones

That's pretty cool Byterider! It works with MASM/RadAsm just fine, thanks. :)

Get it working yet, CObject?
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Biterider

Hi CObject
Try this code

; ==================================================================================================
; Title:   ResLeak.asm
; Author:  G. Friedrich  @ July 2005
; Version: 1.0.0
; Purpose: Resource Leakage demonstration program.
; ==================================================================================================

option casemap:none                 ;Case sensitive
.686p                               ;Use 686 protected mode
.model flat, stdcall                ;Memory model = flat, use StdCall as default calling convention

include \Masm32\Include\Windows.inc
include \Masm32\Include\ResGuard.inc
include \Masm32\Include\Gdi32.inc
include \Masm32\Include\Kernel32.inc

includelib \Masm32\Lib\ResGuard.lib
includelib \Masm32\Lib\Gdi32.lib
includelib \Masm32\Lib\Kernel32.lib

.code
start:
    invoke ResGuardStart
    invoke CreatePen, PS_SOLID, 5, 255
    invoke ResGuardShow
    invoke ResGuardStop
    invoke ExitProcess, 0
end start


If all work OK, the output should be

QuoteResGuard started
GDI Pens:           cur. =   1, max. =     1, tot. =     1
· 00401013h « EOS
————————————————————————————————————————————————————————————
ResGuard stopped

Hope this helps...

Regards,

Biterider

CObject

Thanks for help :)
I was made stupid mistake: forgot to include gdi32.inc  :red

Now ResGuard work fine. It's a great tool :)