procedure GetDLLMemToFile; var PID: Dword; Hand: THandle; lppe: TModuleEntry32; found: boolean; File111: TFileStream; dd, Add1, Add2, index: dword; begin Hand := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessID); lppe.dwSize := SizeOf(lppe); found := Module32First(Hand, lppe); while found do begin File111 := TFileStream.Create('debug\' + extractfilename(lppe.szExePath), $FFFF);
Add1 := dword(lppe.modBaseAddr); Add2 := Add1 + lppe.modBaseSize; index := dword(lppe.modBaseAddr); while true do begin dd := Pdword(index)^; File111.WriteBuffer(dd, 4); inc(index, 4); if index >= Add2 - 4 then break; end;
File111.Destroy;
found := Module32Next(Hand, lppe); end; CloseHandle(Hand); // 释放快照句柄 end;