![]() |
Delphi-Version: 7
Letzte section einer PE Datei auslesen.
Hallo,
hier ein kleiner Teil meines Codes, den ich vorher in c++ geschrieben habe und nun versuche nach delphi zu portieren:
Delphi-Quellcode:
Kurze Erläuterung:
asm
mov eax, dword ptr fs:[$30] mov eax, dword ptr [eax+8] mov dwImageBase, eax end; IDH := Pointer(dwImageBase); INH := Pointer(DWORD(IDH) + IDH^._lfanew); ISH := Pointer(DWORD(IDH) + IDH^._lfanew + 248 + (40 * (INH.FileHeader.NumberOfSections-1))); SetLength(sfile,ISH.Misc.VirtualSize); CopyMemory(@sfile[1], Pointer(dwImageBase + ISH.VirtualAddress), ISH.Misc.VirtualSize); Structs : IDH = IMAGE_DOS_HEADER INH = IMAGE_NT_HEADERS ISH = IMAGE_SECTION_HEADER IDH + _lfanew + 248 = Ende Optionalheader + 40(grße einer einzelnen section) * anzahl der sections-1 = Pointer zu dem Anfang der letzten Section. CopyMemory kopiert leider nicht korrekt, irgendetwas stimmt wohl nicht bei @sfile[1] oder so. :) |
AW: Letzte section einer PE Datei auslesen.
Man kann folgenden Code
Delphi-Quellcode:
so vereinfachen:
SetLength(sfile,ISH.Misc.VirtualSize);
CopyMemory(@sfile[1], Pointer(dwImageBase + ISH.VirtualAddress), ISH.Misc.VirtualSize);
Delphi-Quellcode:
SetString(sFile, PAnsiChar(dwImageBase + ISH.VirtualAddress), ISH.Misc.VirtualSize);
|
AW: Letzte section einer PE Datei auslesen.
Ja vielen Dank.
Das problem liegt doch nicht daran, sondern an dem Pointer ISH. Der zeigt nämlich irgendwo in die Mitte bei .idata. In c++ klappt es so eben super:
Delphi-Quellcode:
ISH := Pointer(DWORD(IDH) + IDH^._lfanew + 248 + (40 * (INH^.FileHeader.NumberOfSections-1)));
Irgendeiner eine Idee? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:51 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz