📄 unit1.pas
字号:
TabChar=#9;
aa='==============================================================================================';
bb=TabChar+'→';
cc=TabChar+'%s'+TabChar+'%s';
dd='----------------------------------------------------------------------------------------------';
CharSpe=TabChar+'-------------------------------------------------------------';
var
i,j:Integer;
tFile:TextFile;
tName:ShortString;
TmpComponent:TComponent;
procedure SaveTreeToText;
const
EndOfLine=#13#10;
var
i:Integer;
ANode:TTreeNode;
NodeStr:String;
begin
ANode:=TreeView1.TopItem;
while ANode<>nil do
begin
NodeStr:='';
for i:=0 to ANode.Level-1 do
NodeStr:=NodeStr+TabChar;
NodeStr:=NodeStr+ANode.Text;//+EndOfLine;
writeln(tFile,NodeStr);
Flush(tFile);
ANode:=ANode.GetNext;
end;
end;
begin
if not Dumped then exit;
if SaveDialog1.Execute then
begin
tName:=SaveDialog1.FileName;
AssignFile(tFile,tName);
Rewrite(tFile);
writeln(tFile,'=================================PEDUMP文件分析器分析结果报告=================================');
writeln(tFile);
writeln(tFile,'==============================作者[万重] 主页[HTTP://www.2ccc.com]============================');
writeln(tFile);
writeln(tFile,Format(TabChar+'分析文件名[%s] 文件大小[%s] 分析日期[%s]',
[Edit_FileName.Text,
StatusBar1.Panels[1].Text,
DateToStr(Date)]));
writeln(tFile,dd);
writeln(tFile);
Flush(tFile);
{文件头}
writeln(tFile,aa);
writeln(tFile,TabChar+'文件头信息(FileHeader)');
writeln(tFile,aa);
for i:=1 to 9 do
begin
TmpComponent:=FindComponent('StaticText_'+IntToStr(i));
writeln(tFile,Format('%s(%s)',[(TmpComponent as TStaticText).Caption,(TmpComponent as TStaticText).Hint]));
TmpComponent:=FindComponent('Edit_'+IntToStr(i));
writeln(tFile,(TmpComponent as TEdit).Text);
writeln(tFile,bb+(TmpComponent as TEdit).Hint);
Flush(tFile);
end;
writeln(tFile,CharSpe);
for i:=1 to 15 do
begin
TmpComponent:=FindComponent('cb_file_'+IntToStr(i));
if (TmpComponent as TCheckBox).Checked then
writeln(tFile,Format(cc,[(TmpComponent as TCheckBox).Caption,(TmpComponent as TCheckBox).Hint]));
Flush(tFile);
end;
writeln(tFile,CharSpe);
writeln(tFile);
{ 可选文件头 }
writeln(tFile,aa);
writeln(tFile,TabChar+'可选文件头信息(OptionalHeader)');
writeln(tFile,aa);
for i:=10 to 35 do
begin
TmpComponent:=FindComponent('StaticText_'+IntToStr(i));
writeln(tFile,Format('%s(%s)',[(TmpComponent as TStaticText).Caption,(TmpComponent as TStaticText).Hint]));
TmpComponent:=FindComponent('Edit_'+IntToStr(i));
writeln(tFile,(TmpComponent as TEdit).Text);
writeln(tFile,bb+(TmpComponent as TEdit).Hint);
Flush(tFile);
end;
writeln(tFile,dd);
writeln(tFile);
{数据目录}
writeln(tFile,aa);
writeln(tFile,TabChar+'数据目录信息(DataDirectory)');
writeln(tFile,aa);
writeln(tFile,lv_Directory.Columns[0].Caption+TabChar+TabChar+TabChar+TabChar+
lv_Directory.Columns[1].Caption+TabChar+
lv_Directory.Columns[3].Caption);
writeln(tFile,'-------------------------------------- --------------------------');
for i:=0 to lv_Directory.Items.Count-1 do
begin
writeln(tFile,Format('%s'+TabChar+'%s'+TabChar+'%s',
[lv_Directory.Items.Item[i].Caption,
lv_Directory.Items.Item[i].SubItems.Strings[0],
lv_Directory.Items.Item[i].SubItems.Strings[2]]));
Flush(tFile);
end;
writeln(tFile,'------------------------------------------------------------------');
writeln(tFile);
{节表信息}
writeln(tFile,aa);
writeln(tFile,TabChar+'节表信息(PESectionHead)');
writeln(tFile,aa);
for i:=0 to pc_Section.PageCount-1 do
begin
writeln(tFile,Format('Section%u'+TabChar+'Name[%s]',[i,pc_Section.Pages[i].Caption]));
writeln(tFile,dd);
for j:=0 to 9 do
begin
TmpComponent:=FindComponent(Format('StaticText_%u_%u',[i,j]));
writeln(tFile,Format('%s(%s)',[(TmpComponent as TStaticText).Caption,(TmpComponent as TStaticText).Hint]));
TmpComponent:=FindComponent(Format('Edit_%u_%u',[i,j]));
writeln(tFile,(TmpComponent as TEdit).Text);
Flush(tFile);
end;
writeln(tFile,CharSpe);
for j:=0 to 13 do
begin
TmpComponent:=FindComponent(Format('CheckBox_%u_%u',[i,j]));
if (TmpComponent as TCheckBox).Checked then
writeln(tFile,Format(cc,[(TmpComponent as TCheckBox).Caption,(TmpComponent as TCheckBox).Hint]));
Flush(tFile);
end;
writeln(tFile,CharSpe);
writeln(tFile,dd);
Flush(tFile);
end;
writeln(tFile);
{资源目录}
writeln(tFile,aa);
writeln(tFile,TabChar+'资源目录(ImageResourceDirectory)');
writeln(tFile,aa);
for i:=36 to 41 do
begin
TmpComponent:=FindComponent('StaticText_'+IntToStr(i));
writeln(tFile,Format('%s'+TabChar+'(%s)',[(TmpComponent as TStaticText).Caption,(TmpComponent as TStaticText).Hint]));
TmpComponent:=FindComponent('Edit_'+IntToStr(i));
writeln(tFile,(TmpComponent as TEdit).Text);
writeln(tFile,bb+(TmpComponent as TEdit).Hint);
Flush(tFile);
end;
writeln(tFile,dd);
SaveTreeToText;
writeln(tFile,dd);
{结尾}
writeln(tFile);
writeln(tFile,'============================欢迎使用PEDUMP进行文件分析:)====================================');
Flush(tFile);
CloseFile(tFile);
end;
end;
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
ProgressBar1.Parent:=StatusBar1;
ProgressBar1.Top:=Rect.Top-1;
end;
procedure TForm1.TreePop1Click(Sender: TObject);
var
hThread:Thandle;
ThreadID:DWord;
function DoTreeExp(P:pointer):Longint;stdcall;
begin
Form1.TreeView1.FullExpand;
Result:=-1;
end;
function DoTreeColl(P:pointer):Longint;stdcall;
begin
Form1.TreeView1.FullCollapse;
Result:=-1;
end;
begin
if Sender=E1 then
begin
hThread:=CreateThread(nil,0,@DoTreeExp,nil,0,ThreadID);
if hThread=0 then
begin
TreeView1.FullExpand;
end;
end;
if Sender=C1 then
begin
hThread:=CreateThread(nil,0,@DoTreeColl,nil,0,ThreadID);
if hThread=0 then
begin
TreeView1.FullCollapse;
end;
end;
end;
procedure TForm1.ServiceClick(Sender: TObject);
begin
if Sender=Email then
ShellExecute(Self.Handle,'Open',PChar('mailto:mantousoft@sina.com?Subject=关于文件分析器[PEDUMP]'),nil,nil,1);
if Sender=homepage then
ShellExecute(Self.Handle,'Open',PChar('http://www.delphibox.com'),nil,nil,1);
end;
procedure TForm1.GetBuildInfo;
var
V1,V2,V3,V4: Word;
VerInfoSize: DWORD;
VerInfo: Pointer;
VerValueSize: DWORD;
VerValue: PVSFixedFileInfo;
Dummy: DWORD;
begin
VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
GetMem(VerInfo, VerInfoSize);
GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
with VerValue^ do
begin
V1 := dwFileVersionMS shr 16;
V2 := dwFileVersionMS and $FFFF;
V3 := dwFileVersionLS shr 16;
V4 := dwFileVersionLS and $FFFF;
end;
FreeMem(VerInfo, VerInfoSize);
Version.Caption:=Version.Caption+Format('%s (Build %d%d%d%d)',[ver,v1,v2,v3,v4]);
end;
procedure TForm1.GetMemoryInfo ;
var
MS: TMemoryStatus;
begin
MS.dwLength:=SizeOf(TMemoryStatus);
GlobalMemoryStatus(MS);
lblMemory.Caption:=lblMemory.Caption +FormatFloat('#,###" KB"',MS.dwTotalPhys div 1024);
end;
procedure TForm1.GetOSInfo;
var
Platform: string;
BuildNumber: Integer;
begin
case Win32Platform of
VER_PLATFORM_WIN32_WINDOWS:
begin
Platform := 'Windows 95';
BuildNumber := Win32BuildNumber and $0000FFFF;
end;
VER_PLATFORM_WIN32_NT:
begin
Platform := 'Windows NT';
BuildNumber := Win32BuildNumber;
end;
else
begin
Platform := 'Windows';
BuildNumber := 0;
end;
end;
if(Win32Platform = VER_PLATFORM_WIN32_WINDOWS)
or(Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
if Win32CSDVersion = ''
then lblOS.Caption := lblOS.Caption+Format('%s %d.%d (Build %d)',[Platform,Win32MajorVersion,Win32MinorVersion,BuildNumber])
else lblOS.Caption := lblOS.Caption+Format('%s %d.%d (Build %d: %s)',[Platform,Win32MajorVersion,Win32MinorVersion, BuildNumber,Win32CSDVersion]);
end else lblOS.Caption := lblOS.Caption+Format('%s %d.%d', [Platform,Win32MajorVersion,Win32MinorVersion])
end;
procedure TForm1.FormShow(Sender: TObject);
begin
{begin about infomation}
try
ProgramIcon.Picture.icon:=Application.Icon; //icon
ProductName.Caption:=ProductName.Caption+Application.Title;//name
GetBuildInfo; //version
Copyright.Caption:=Copyright.Caption+'中国-西安-孜孜软件';
GetMemoryInfo;
GetOsinfo;
except
MessageBox(Handle,'某些信息不能取得','提示',MB_OK);
end;
{end about infomation}
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePageIndex=5 then
begin
Timer1.Enabled:=True;
end else Timer1.Enabled:=False;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label2.Caption:=Format('[%s] [%s]',[DateToStr(Date),TimeToStr(Time)]);
Timer1.Tag:=Timer1.Tag+1;
case Timer1.Tag of
1: Label1.Caption:='←☆←★←☆←★←☆←★←☆←★←☆←';
2: Label1.Caption:='☆←★←☆←★←☆←★←☆←★←☆←★';
3: Label1.Caption:='←★←☆←★←☆←★←☆←★←☆←★←';
4: Label1.Caption:='★←☆←★←☆←★←☆←★←☆←★←☆';
end;
if Timer1.Tag=4 then Timer1.Tag:=0;
end;
procedure TForm1.TreeView1DblClick(Sender: TObject);
var
TmpStr:String;
TmpTreeNode:TTreeNode;
StrAddr,StrSize,StrID,StrType:String;
TmpPos,TmpPosE,i:Integer;
begin
if Assigned(TreeView1.Selected)and(TreeView1.Selected.Level=3) then
begin
TmpTreeNode:=TreeView1.Selected;
TmpStr:=TmpTreeNode.Text;
// TmpPos:=Pos('Size',TmpStr);
StrSize:=Copy(TmpStr,30,9);
// TmpPos:=Pos('AddressInFile',TmpStr);
StrAddr:=Copy(TmpStr,55,9);
{ 标题 }
TmpTreeNode:=TmpTreeNode.Parent;
TmpStr:=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -