Enumerating All Modules For a Process
2014-12-16 09:13
513 查看
To determine which processes have loaded a particular DLL, you must enumerate the modules for each process. The following sample code uses the EnumProcessModules function to enumerate the modules of current processes in the system.
#include <windows.h> #include <stdio.h> #include "psapi.h" void PrintModules( DWORD processID ) { HMODULE hMods[1024]; HANDLE hProcess; DWORD cbNeeded; unsigned int i; // Print the process identifier. printf( "\nProcess ID: %u\n", processID ); // Get a list of all the modules in this process. hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); if (NULL == hProcess) return; if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) { for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ ) { char szModName[MAX_PATH]; // Get the full path to the module's file. if ( GetModuleFileNameEx( hProcess, hMods[i], szModName, sizeof(szModName))) { // Print the module name and handle value. printf("\t%s (0x%08X)\n", szModName, hMods[i] ); } } } CloseHandle( hProcess ); } void main( ) { // Get the list of process identifiers. DWORD aProcesses[1024], cbNeeded, cProcesses; unsigned int i; if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return; // Calculate how many process identifiers were returned. cProcesses = cbNeeded / sizeof(DWORD); // Print the name of the modules for each process. for ( i = 0; i < cProcesses; i++ ) PrintModules( aProcesses[i] ); }
相关文章推荐
- Enumerating All Modules For a Process
- Enumerating All Modules For a Process
- Enumerating All Modules For a Process
- runAllManagedModulesForAllRequests
- tomcat版本低招致启动报"Unable to process Jar entry" for all javassist classes
- <modules runAllManagedModulesForAllRequests="true" />(转1)
- make: Nothing to be done for `all_modules'.问题解决
- 编译framework出现Nothing to be done for `all_modules'
- 塞翁失马,焉知非福:由 Styles.Render 所引发 runAllManagedModulesForAllRequests="true" 的思考
- 【续集】塞翁失马,焉知非福:由 Styles.Render 所引发 runAllManagedModulesForAllRequests="true" 的思考
- SysLib (mandatory lib for all modules)
- runAllManagedModulesForAllRequests 和 invalid url
- runAllManagedModulesForAllRequests="true" 的思考
- "Unable to process Jar entry" for all javassist classes
- 不要随便使用 runAllManagedModulesForAllRequests="true" 来解决问题
- 编译framework出现Nothing to be done for `all_modules'
- 迈克尔·杰克逊新歌新版《For All Time 2008版》已播出!, 迈克尔·杰克逊最新歌曲!
- Allwin WinExec add new local administrator + ExitProcess Shellcode
- Linux - Sysstat [ All-in-One System Performance and Usage Activity Monitoring Tool For Linux]
- 阅读<All Digital VCXO Replacement for Gigabit Transceiver Applications>笔记(2)---XAPP589