# Include <windows. h> # include <tchar. h> # include <stdio. h> # include <psapi. h> void printmodules (DWORD processid) {hmodule hmod [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, hmod, sizeof (hmod), & 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, hmod [I], szmodname, sizeof (szmodname)/sizeof (tchar) {// print the module name and handle value. _ tprintf (text ("\ t % s (0x % 08x) \ n"), szmodna Me, hmod [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]);}