+ Reply to Thread
Results 1 to 2 of 2

Thread: How to know that a DLL is loaded in process or not?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    48

    How to know that a DLL is loaded in process or not?

    How can I know that a specific DLL is loaded in process or not.? I want to do this in MFC application using Microsoft VC++. Is there any way to do this?

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    20
    Example:

    Code:
    BOOL GetProcessNameFromProcessID(DWORD dwProcessID, CString strDLLName)
    {
    	BOOL	bIsDLLLoaded	= FALSE ;
    	HANDLE	hProcess		= OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
    								   FALSE, dwProcessID) ;
    
    	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) ) ;
    
    				if (strDLLName.CompareNoCase(szProcessName)  == 0)
    				{
    					bIsDLLLoaded = TRUE ;
    				}
    			}
    		}
    
    		CloseHandle(hProcess) ;
    	}
    
    	return bIsDLLLoaded ;
    }
    Enjoy!

+ 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