View GDI handles/resources list and detect GDI leaks

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

View GDI handles/resources list and detect GDI leaks

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: View GDI handles/resources list and detect GDI leaks

Post by Antonio Linares »

Buscando he llegado hasta esto con código muy interesante :-)

http://drmemory.googlecode.com/svn/trun ... handle.cpp

y desde ahi a su página:
https://code.google.com/p/drmemory/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: View GDI handles/resources list and detect GDI leaks

Post by Antonio Linares »

I was curious to know how they get such info, so I started googling and it seems as first of all we need to identify the running processes. Here you can test it from FWH :-)

Code: Select all

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd

   DEFINE WINDOW oWnd TITLE "Right click me"

   ACTIVATE WINDOW oWnd ;
      ON RIGHT CLICK XBrowse( GetProcesses(), "Processes" )

return nil

//----------------------------------------------------------------------------//

#pragma BEGINDUMP

#include <windows.h>
#include <tlhelp32.h>
#include <hbapi.h>
#include <hbapiitm.h>

HB_FUNC( GETPROCESSES )
{
   HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPALL, 0 );
   HANDLE hProcess;
   PROCESSENTRY32 pe;
   PHB_ITEM pProcesses = hb_itemArrayNew( 0 );
   PHB_ITEM pProcess = hb_itemNew( NULL );
    
   pe.dwSize = sizeof( pe );
   Process32First( hSnapshot, &pe );
   
   do 
   {
      hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID );

      hb_arrayNew( pProcess, 2 );
      hb_arraySetNLL( pProcess, 1, pe.th32ProcessID );
      hb_arraySetC( pProcess, 2, pe.szExeFile );
      hb_arrayAddForward( pProcesses, pProcess );
      
   } while( Process32Next( hSnapshot, &pe ) );
    
   hb_itemRelease( pProcess ); 
   hb_itemReturnRelease( pProcesses );
    
   CloseHandle( hProcess );
   CloseHandle( hSnapshot );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: View GDI handles/resources list and detect GDI leaks

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: View GDI handles/resources list and detect GDI leaks

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply