Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi ImageDirectoryEntryToData() (https://www.delphipraxis.net/89005-imagedirectoryentrytodata.html)

Czerskowski 24. Mär 2007 15:36


ImageDirectoryEntryToData()
 
Ich möchte gerne die Module einer PE-Datei auslesen. Dies
möchte ich mit ImageDirectoryEntryToData() bewerkstelligen.

Leider bekomme ich immer einen Fehler, dass eine
EAccessViolation auftritt.

Hier mal mein Code:

Delphi-Quellcode:
type PIMAGE_IMPORT_DESCRIPTOR = record
    OriginalFirstThunk: DWORD;
    TimeDateStamp: DWORD;
    ForwarderChain: DWORD;
    Name: DWORD;
    FirstThunk: DWORD;
end;

procedure StartUp();
var
hCaller: HMODULE;
ImportDesc: ^PIMAGE_IMPORT_DESCRIPTOR;
szModName: PCHAR;
nSize: ULONG;
begin
hCaller := GetModuleHandle('Project1.exe');
ImportDesc := ImageDirectoryEntryToData(@hCaller,true,IMAGE_DIRECTORY_ENTRY_IMPORT, nSize);
while ImportDesc.Name <> 0 do
   begin
      //Mach was.
   end;
end;
Immer wenn ich zugriff auf die Structur haben will kommt diese Exception.
Zum besseren verständnis: Das Programm ist eine DLL die injiziert werden soll.

Danke für Hilfe!

ErazerZ 24. Mär 2007 16:27

Re: ImageDirectoryEntryToData()
 
Delphi-Quellcode:
procedure StartUp();
var
  hCaller: HMODULE;
  ImportDesc: ^PIMAGE_IMPORT_DESCRIPTOR;
  szModName: PCHAR;
  nSize: ULONG;
begin
  hCaller := GetModuleHandle('Project1.exe');
  ImportDesc := ImageDirectoryEntryToData(Pointer(hCaller),true,IMAGE_DIRECTORY_ENTRY_IMPORT, nSize);
  while ImportDesc.Name <> 0 do
  begin
    showmessage(inttohex(importdesc.FirstThunk, 8));
    Inc(ImportDesc);
  end;
end;

Czerskowski 24. Mär 2007 16:59

Re: ImageDirectoryEntryToData()
 
Ich danke dir, das war der Fehler.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz