+ Reply to Thread
Results 1 to 3 of 3

Thread: How to get all the dlls that my application loads?

  1. #1

    How to get all the dlls that my application loads?

    I am required to get all the name of dlls that have been loaded by my application.

    I have to log them at particular time.

    How can I get names of all the dlls that my application has loaded?

  2. #2
    You can use Process API defined in PSAPI.h and PSAPI.lib.

    Example:

    Code:
    void ListDlls(DWORD dwProcessID)
    {
    	CString strProcessName ;
    	HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
    								   FALSE, dwProcessID) ;
    
    	// Get the process name.
    	if (NULL != hProcess )
    	{
    		HMODULE hMod[1024] ;
    		DWORD cbNeeded ;
    
    		if ( EnumProcessModules( hProcess, &hMod[0], sizeof(hMod), &cbNeeded) )
    		{
    			for (int nModuleIndex = 0; nModuleIndex < (cbNeeded / sizeof(HMODULE)); nModuleIndex++ )
    			{
    				char szProcessName[MAX_PATH] = { 0 } ;
    				GetModuleBaseName(hProcess, hMod[nModuleIndex], szProcessName, 
    												sizeof(szProcessName) ) ;
    
    				strProcessName = szProcessName;
    				OutputDebugString(szProcessName) ;
    				OutputDebugString("\r\n") ;
    			}
    		}
    
    		CloseHandle( hProcess ) ;
    	}
    }
    Last edited by Maxi; 03-17-2012 at 03:36 AM.

  3. #3
    Thanks for reply. It helped a lot.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts