Enumerating All Modules For a Process
2010-08-10 12:39
316 查看
#include <windows.h> #include <tchar.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++ ) { TCHAR szModName[MAX_PATH]; // Get the full path to the module's file. if ( GetModuleFileNameEx( hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { // Print the module name and handle value. _tprintf( TEXT("\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
- tomcat版本低招致启动报"Unable to process Jar entry" for all javassist classes
- make: Nothing to be done for `all_modules'.问题解决
- <modules runAllManagedModulesForAllRequests="true" />(转1)
- 塞翁失马,焉知非福:由 Styles.Render 所引发 runAllManagedModulesForAllRequests="true" 的思考
- runAllManagedModulesForAllRequests 和 invalid url
- SysLib (mandatory lib for all modules)
- "Unable to process Jar entry" for all javassist classes
- 编译framework出现Nothing to be done for `all_modules'
- 【续集】塞翁失马,焉知非福:由 Styles.Render 所引发 runAllManagedModulesForAllRequests="true" 的思考
- runAllManagedModulesForAllRequests="true" 的思考
- 不要随便使用 runAllManagedModulesForAllRequests="true" 来解决问题
- 编译framework出现Nothing to be done for `all_modules'
- runAllManagedModulesForAllRequests
- How to proceed for rework process in sap PP
- Client Side Expand/Collapse All Nodes For ASP.NET 2.0 Treeview
- 窥探 kernel,just for fun --- copy_process
- Android’s PreferenceActivity for all API versions