The MASM Forum Archive 2004 to 2012

Project Support Forums => IDE Development and Support => RadAsm Support Forum => Topic started by: Mark Jones on July 14, 2005, 10:12:15 PM

Title: Req: Completion Reminders
Post by: Mark Jones on July 14, 2005, 10:12:15 PM
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
Title: Re: Req: Completion Reminders
Post by: Biterider on July 15, 2005, 05:12:34 AM
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
Title: Re: Req: Completion Reminders
Post by: CObject on July 15, 2005, 12:34:20 PM
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
————————————————————————————————————————————————————————————
Title: Re: Req: Completion Reminders
Post by: Mark Jones on July 15, 2005, 03:07:30 PM
That's pretty cool Byterider! It works with MASM/RadAsm just fine, thanks. :)

Get it working yet, CObject?
Title: Re: Req: Completion Reminders
Post by: Biterider on July 15, 2005, 04:26:08 PM
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
Title: Re: Req: Completion Reminders
Post by: CObject on July 15, 2005, 04:43:52 PM
Thanks for help :)
I was made stupid mistake: forgot to include gdi32.inc  :red

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