var TModuleArray : array of TModuleEntry32;
function GetModulesListByProcessId(ProcessId: Cardinal): TModuleArray;
var
hSnapshot: THandle;
lpme: TModuleEntry32;
procedure AddModuleToList;
begin
SetLength(Result, High(Result) + 2);
Result[high(Result)] := lpme;
end;
begin
SetLength(Result, 0);
hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessId);
lpme.dwSize := SizeOf(lpme);
if Module32First(hSnapshot, lpme) then
begin
AddModuleToList;
while Module32Next(hSnapshot, lpme) do
AddModuleToList;
end;
end;