积累系统性知识
积聚技术精华
  首页    个人中心    撰写积文    建立课题    订立目标    整理积文    管理课题    管理目标    技能Get    代码积累 
列举系统中所有被加载的DLL
error997 (error997)    2014-11-20 21:09:50      目标    课题
切换到: 纯代码  
   
void ShowProcessModules(HWND hwnd, DWORD PId)
{
   SYSTEM_INFO si;
 memset(&si, 0, sizeof(si));
 GetSystemInfo( &si );
 if( PId == 0)
  PId = GetCurrentProcessId();
 DWORD LowAddr, HighAddr;
 LowAddr = (DWORD)si.lpMinimumApplicationAddress;
 HighAddr = (DWORD)si.lpMaximumApplicationAddress;
 HANDLE hdl = OpenProcess( PROCESS_QUERY_INFORMATION |PROCESS_VM_READ, 
         FALSE, PId );
 if (hdl == NULL)
  return;
 char mapfilename[MAX_PATH] = "unknown";
 char tempname[MAX_PATH];
 DWORD nSize = sizeof(mapfilename);
 DWORD MapAddr, MapAddrto = 0;
 
 for (MapAddr = LowAddr; MapAddr < HighAddr; MapAddr += si.dwAllocationGranularity)
 {
 GetMappedFileName( hdl, (LPVOID)MapAddr,mapfilename, nSize );
 if(MapAddr < MapAddrto)
  continue;
 if(strlen(mapfilename) == 0)
  continue;
  
 for(MapAddrto = MapAddr; ; MapAddrto += si.dwPageSize)
  {GetMappedFileName( hdl, (LPVOID)MapAddrto,tempname, nSize );
   if(strcmp(tempname, mapfilename) == 0)
   continue;
   else
    break;
  }
 wsprintf(tempname, "0x%p-0x%p: %s",MapAddr, MapAddrto, mapfilename);
 SendMessage(GetDlgItem(hwnd,IDC_LIST1),LB_ADDSTRING,0,(LPARAM)tempname);
   }
CloseHandle( hdl );
return;
}


转自 http://blog.csdn.net/y___y/article/details/1181479
(+0)技能Get

建议楼主:搜索关键字 |参考其他资源 |回复 |追问
  error997(error997):   个人中心    课题    目标    代码积累