WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Finding memory leaks, I am trying to learn how to use this to find memory leaks; the help file for it is kinda slim

Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 287
Member No.: 5004
Joined: 11-May 07


I am trying to learn how to use this to find memory leaks.

The help file for it is kinda slim.

If there is a better program, I would be interested.

Using RunTimeChecker on my code, after my program had gracefully exited,

I got "one memory block in use".
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2301
Member No.: 160
Joined: 22-June 04


in small programs i usually check the source if there is any way to leave memory block or any object not deleted after use. in (very) complex application it is better way to use object programming with proper destructor.
PMEmail PosterUsers Website
Top
Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 287
Member No.: 5004
Joined: 11-May 07


Hi,

I found the leak.

I had left out a GlobalFree.

What I would like is to store the text someplace other than the clipboard
so that I can use multiple keyboard combinations in order to insert text.

Ex.
Ctrl Alt A -> login name1
Ctrl Alt B -> login name2



CODE
; Txt_From_HK.asm Beta version  
;
; Creates CTRL ALT A keyboard combination shortcut.
; Ctrl Alt A to activate, then Shift Insert to insert text
;               2010 QHR Inc.

include \masm32\include\masm32rt.inc

WinMain PROTO   :DWORD,:DWORD,:DWORD,:DWORD

.data

hglb dd 0; ',\; need space before quote
str1 db 'Ich habe keine Ahnung.'

ClassName db "DLGCLASS",0
DlgName   db "MyDialog",0
AppName   db "Ctrl_Alt_A",0
Mess1     db "SetClipboardData failed",0
Mess2     db "GlobalAlloc failed",0
Mess3     db "OpenClipboard failed",0

.data?

hInstance HINSTANCE ?
CommandLine LPSTR ?

.code

start:
invoke GetModuleHandle, NULL
mov    hInstance,eax                    
invoke GetCommandLine
mov    CommandLine,eax
   invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
     invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hWnd:HWND
mov   wc.cbSize,SIZEOF WNDCLASSEX
mov   wc.style, CS_HREDRAW or CS_VREDRAW
mov   wc.lpfnWndProc, OFFSET WndProc
mov   wc.cbClsExtra,NULL
mov   wc.cbWndExtra,NULL
push  hInst
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_WINDOW+1
mov   wc.lpszMenuName,NULL
mov   wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov   wc.hIcon,eax
mov   wc.hIconSm,0
invoke LoadCursor,NULL,IDC_ARROW
mov   wc.hCursor,eax
invoke RegisterClassEx, addr wc


INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
          WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
          CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
          hInst,NULL
mov   hWnd,eax

invoke ShowWindow, hWnd,SW_MINIMIZE  ;Minimal window
invoke UpdateWindow, hWnd

.WHILE TRUE
               INVOKE GetMessage, ADDR msg,NULL,0,0
               .BREAK .IF (!eax)
               invoke IsDialogMessage, hWnd, ADDR msg
               .if eax==FALSE
                       INVOKE TranslateMessage, ADDR msg
                       INVOKE DispatchMessage, ADDR msg
               .endif
.ENDW
mov     eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
       
    .if uMsg==WM_CREATE
           invoke RegisterHotKey,hWnd,065h,MOD_CONTROL or MOD_ALT, 041h; CTRL ALT A

     .ELSEIF uMsg==WM_DESTROY
           invoke UnregisterHotKey,hWnd,065h
 
           invoke GlobalFree,hglb; help by Nathan in comp.lang.asm.x86

           invoke PostQuitMessage,NULL
     .ELSEIF uMsg == WM_HOTKEY

; OpenClipboard
; SetClipboardData
; CloseClipboard

; Put text on the clipboard.
 
   invoke OpenClipboard,NULL
   .IF (eax)

     invoke EmptyClipboard
     invoke GlobalAlloc,GMEM_MOVEABLE,SIZEOF str1

   .IF (eax)
       mov hglb, eax
       invoke GlobalLock,hglb
         
       invoke MemCopy,ADDR str1,eax,SIZEOF str1
       invoke GlobalUnlock,hglb
       invoke SetClipboardData,CF_TEXT,hglb
         
   .IF (eax == 0)

        invoke MessageBox,NULL, ADDR AppName,ADDR Mess1,  MB_ICONEXCLAMATION
   .ENDIF

   .ELSE

      invoke MessageBox,NULL, ADDR AppName,ADDR Mess2,  MB_ICONEXCLAMATION

   .ENDIF
      invoke CloseClipboard
               
   .ELSE

   invoke MessageBox,NULL, ADDR AppName,ADDR Mess3,  MB_ICONEXCLAMATION

  .ENDIF
   
  .ELSE
 invoke DefWindowProc,hWnd,uMsg,wParam,lParam
 ret
  .ENDIF

xor    eax,eax
ret

WndProc endp

end start


Regards,
PMEmail Poster
Top
Gunner
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 210
Member No.: 27608
Joined: 11-October 09


either keep the different text in a text file, and read each line into an array,
have the text in a resource and load on demand,
have the text in data section with a pointers to the strings, load the pointers

and where ever you keep the text, display with your hotkey..
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google