📄 peheaderform.pas
字号:
unit PEHeaderForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ResourceObjectForm, unitPEFile;
type
TfmPEHeader = class(TfmResourceObject)
ListView1: TListView;
private
function GetPEModule: TPEModule;
protected
fOffset : Integer;
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;
property PEModule : TPEModule read GetPEModule;
end;
var
fmPEHeader: TfmPEHeader;
implementation
{$R *.DFM}
{ TfmPEHeader }
procedure TfmPEHeader.AddEntry(const field: string; const value: DWORD; const comment : string);
begin
InternalAddEntry (field, 'dword', sizeof (DWORD), '$' + IntToHex (value, 8), comment);
end;
procedure TfmPEHeader.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 TfmPEHeader.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 TfmPEHeader.AddEntry(const field: string; const value: word; const comment : string);
begin
InternalAddEntry (field, 'word', sizeof (WORD), '$' + IntToHex (value, 4), comment);
end;
procedure TfmPEHeader.SetObject(const Value: TObject);
begin
inherited;
fOffset := 0;
end;
procedure TfmPEHeader.AddEntry(const field: string; const value: Integer;
const comment: string);
begin
InternalAddEntry (field, 'LongInt', sizeof (LongInt), '$' + IntToHex (value, 8), comment);
end;
procedure TfmPEHeader.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;
function TfmPEHeader.GetPEModule: TPEModule;
begin
result := (ResourceModule as TPEResourceModule);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -