我想做一个redlof病毒的专杀工具。
现在有两个关键技术问题请教大家。
1.如何检测内存中的病毒代码,以及如何清除内存中的病毒代码。
2.如何遍历某个驱动器下的所有文件(深度优先,广度优先,各举一例最好)病毒分析:
http://expert.csdn.net/Expert/topic/1773/1773517.xml?temp=.1025049
现在有两个关键技术问题请教大家。
1.如何检测内存中的病毒代码,以及如何清除内存中的病毒代码。
2.如何遍历某个驱动器下的所有文件(深度优先,广度优先,各举一例最好)病毒分析:
http://expert.csdn.net/Expert/topic/1773/1773517.xml?temp=.1025049
var
sr: TSearchRec;
strdeltime,dirpath:string;
deltime:array[1..50] of char;
begin
{****************
读ini,取得要删除的文件夹名称
// 备份的时候写ini文件
删除的时候取得最老的文件夹
读取ini文件,判断是否删除。
******************}
//取得文件夹路径
dirpath:= backupath+'\old\';//取得最早的文件夹
dirname:='';
if FindFirst(dirpath+'*.*', faDirectory, sr) = 0 then
begin
repeat
if (sr.Attr and faDirectory) = sr.Attr then
begin
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
if dirname = '' then
dirname:=sr.Name
else
begin
if strtodate(dirname)> strtodate(sr.Name) then
dirname:= sr.Name;
end;
end;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
// edit1.Text:=dirname;取得要删除的文件夹名称
//读取该文件夹内ini文件,返回数值
GetPrivateProfileString(
//从.INI文件中获取路径信息
'backupInfo',//[]中节的名称
'deltime', //=保存路径
'2003-1-1', //如果没有找到字符串时,返回c:\
@deltime,//存放取得字符串
25,//取得字符的允许最大长度
pchar(dirpath+'\'+dirname+'\detail.ini') //.INI文件名
);
strdeltime:=deltime;
strdeltime:=string(strdeltime);
strdeltime:=strpas(pchar(strdeltime));
if strdeltime <= datetostr(date) then
result:=true
else
result:=false;
dirname:=dirpath+dirname;
end;
至于遍历操作,先取得所有硬盘
procedure GetAvailableDriver(var ADriverList: TStringList);
var
drives: set of 0..25;
DrivePath, _Drive: string;
I: integer;
begin
ADriverList.Clear;
DWORD(drives) := windows.GetLogicalDrives;
for I := 0 to 25 do
if I in drives then //如果驱动器存在
begin
DrivePath := Char(Ord('A') + i) + ':\';
_Drive := Char(Ord('A') + i);
case GetDriveType(pchar(DrivePath)) of
DRIVE_FIXED, DRIVE_REMOTE: ADriverList.Add(trim(_Drive)); //如果是硬盘
end;
end;
end;遍历查找文件
代码如下:1. 从搜索记录中判断是否是子目录。 function IsValidDir(SearchRec:TSearchRec):Boolean;begin
if (SearchRec.Attr=16) and(SearchRec.Name<>'.') and(SearchRec.Name<>'..') thenResult:=TrueelseResult:=False;end;2. 这是查询主体函数。参数介绍:Mainpath: 指定的查询目录。Filename: 欲查询的文件。Foundresult: 返回的含完整路径的匹配文件(可能有多个)。如果有匹配文件,函数返回True,否则,返回False; function SearchFile(mainpath:string;filename:string;var foundresult:TStrings):Boolean;vari:integer;Found:Boolean;subdir1:TStrings;searchRec:TsearchRec;beginfound:=false;if Trim(filename)<>'' thenbeginsubdir1:=TStringList.Create;//字符串列表必须动态生成//找出所有下级子目录。if (FindFirst(mainpath+'*.*', faDirectory, SearchRec)=0) thenbeginif IsValidDir(SearchRec) thensubdir1.Add(SearchRec.Name);while (FindNext(SearchRec) = 0) dobeginif IsValidDir(SearchRec) thensubdir1.Add(SearchRec.Name);end;end;FindClose(SearchRec);//查找当前目录。if FileExists(mainpath+filename) thenbeginfound:=true;foundresult.Add(mainpath+filename);end;//这是递归部分,查找各子目录。for i:=0 to subdir1.Count-1 dofound:=Searchfile(mainpath+subdir1.Strings[i]+'\',Filename,foundresult)or found;//资源释放并返回结果。subdir1.Free;end;result:=found;end;
不是可以访问其他程序的内存空间么