📄 pesectionform.pas
字号:
unit PESectionForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, cmpHexDump, ExtCtrls, unitPEFile, ResourceObjectForm;
type
TfmPESection = class(TfmResourceObject)
Splitter1: TSplitter;
HexDump1: THexDump;
ListView1: TListView;
private
fOffset : Integer;
protected
procedure SetObject(const Value: TObject); override;
procedure InternalAddEntry (const field, tp : string; size : Integer; const value, comment : string);
public
procedure AddEntry (const field : string; const value : DWORD; const comment : string = ''); overload;
procedure AddEntry (const field : string; const value : LongInt; const comment : string = ''); overload;
procedure AddEntry (const field : string; const value : word; const comment : string = ''); overload;
procedure AddEntry (const field : string; const value : array of char; const comment : string = ''); overload;
procedure AddEntry (const field : string; const value : array of word; const comment : string = ''); overload;
end;
var
fmPESection: TfmPESection;
implementation
{$R *.DFM}
{ TfmPESection }
procedure TfmPESection.AddEntry(const field: string; const value: word;
const comment: string);
begin
InternalAddEntry (field, 'word', sizeof (WORD), '$' + IntToHex (value, 4), comment);
end;
procedure TfmPESection.AddEntry(const field: string; const value: Integer;
const comment: string);
begin
InternalAddEntry (field, 'LongInt', sizeof (LongInt), '$' + IntToHex (value, 8), comment);
end;
procedure TfmPESection.AddEntry(const field: string; const value: DWORD;
const comment: string);
begin
InternalAddEntry (field, 'dword', sizeof (DWORD), '$' + IntToHex (value, 8), comment);
end;
procedure TfmPESection.AddEntry(const field: string;
const value: array of word; const comment: string);
var
val : string;
i : Integer;
begin
val := '[';
for i := Low (value) to High (value) do
begin
val := val + IntToHex (value [i], 4);
if i < High (value) then
val := val + ','
else
val := val + ']'
end;
InternalAddEntry (field, Format ('word [%d..%d]', [Low (value), High (value)]), (High (value) - Low (value) + 1) * sizeof (word), val, comment);
end;
procedure TfmPESection.AddEntry(const field: string;
const value: array of char; const comment: string);
var
s : string;
begin
s := Format ('char [%d..%d]', [Low (value), High (value)]);
InternalAddEntry (field, s, High (value) - Low (value) + 1, value, comment);
end;
procedure TfmPESection.InternalAddEntry(const field, tp: string;
size: Integer; const value, comment: string);
begin
with ListView1.Items.Add do
begin
Caption := '$' + IntToHex (fOffset, 4);
Inc (fOffset, size);
SubItems.Add (field);
SubItems.Add (tp);
SubItems.Add (IntToStr (size));
SubItems.Add (value);
SubItems.Add (comment)
end
end;
procedure TfmPESection.SetObject(const Value: TObject);
var
section : TImageSection;
begin
inherited;
section := obj as TImageSection;
fOffset := 0;
ListView1.Items.BeginUpdate;
try
ListView1.Items.Clear;
InternalAddEntry ('Name', 'char [0..7]', 8, section.SectionName, '');
with section.SectionHeader do
begin
AddEntry ('VirtualSize', misc.VirtualSize);
AddEntry ('VirtualAddress', VirtualAddress);
AddEntry ('SizeOfRawData', SizeOfRawData);
AddEntry ('PointerToRawData', PointerToRawData);
AddEntry ('PointerToRelocations', PointerToRelocations);
AddEntry ('PointerToLineNumbers', PointerToLineNumbers);
AddEntry ('NumberOfRelocations', NumberOfRelocations);
AddEntry ('NumberOfLineNumbers', NumberOfLineNumbers);
AddEntry ('Characteristics', Characteristics);
end;
finally
ListView1.Items.EndUpdate
end;
HexDump1.CurrentLine := 0;
HexDump1.CurrentLinePos := 0;
Application.ProcessMessages;
HexDump1.Address := section.RawData.Memory;
HexDump1.DataSize := section.RawData.Size;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -