Search notes:

WinAPI: Process Status (PSAPI)

Show modules

EnumProcessModules is used to get an array of HANDLES of loaded modules. Iterating over this array and printing module name using GetModuleBaseName:
#include <windows.h>
#include <psapi.h>

HANDLE stdOut;

void out(char const* text) {
   DWORD charsWritten;
   WriteConsole(stdOut, text, lstrlen(text), &charsWritten, NULL);
}

int main() {

  stdOut = GetStdHandle(STD_OUTPUT_HANDLE);

  HMODULE process = GetCurrentProcess();

#define nofModules 256
  HMODULE modules[nofModules];
  DWORD   bytesNeeded;


  if (! EnumProcessModules(
      process,
      modules, // HMODULE *lphModule,
      sizeof(modules),
     &bytesNeeded
  )) {
      out("EnumProcessModulesEx returned FALSE!\n");
      return 1;
  }

  for (int i=0; i<bytesNeeded/sizeof(HANDLE); i++) {

    char baseName[MAX_PATH];

    GetModuleBaseName(process, modules[i], baseName, MAX_PATH);
    out(baseName); out("\n");
  }

}
Github repository WinAPI, path: /Diagnostics/Process-Status/show-modules.c

See also

WinAPI

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1759612271, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/development/WinAPI/Diagnostics/Process-Status/index(83): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78