Procedure SysFileRecoverFromDistrib (Path, Name : string);
begin
if MessageDLG('Для замены повреждённого системного файла ' + Name + ', который находится в папке ' + Path + ', вставьте дистрибутив Windows в CD\DVD-привод и нажмите "Да". Если же у вас нет дистрибутива или Вы хотите выполнить замену самостоятельно, нажмите "Нет"', mtConfirmation, mbYes+mbNo, 0) = 6 then
begin
ExecuteFile('sfc /scannow', '', 1, 0, true);
AddToLog('Пользователь выполнил "sfc /scannow"');
end
else
AddToLog('Пользователь выбрал самостоятельный способ замены.');
end;
Procedure CompleteFix(Path, Name : string);
begin
RenameFile('%windir%\system32\' + Name, '%windir%\system32\' + Name + '.bak');
CopyFile(Path + Name, '%windir%\system32\' + Name);
DeleteFile('%windir%\system32\' + Name + '.bak');
end;
Procedure SysFileRecoverFromBackup(Path, Name : string);
begin
AddToLog('Файл ' + '%windir%\system32\' + Name + ' -> MD5 = ' + CalkFileMD5('%windir%\system32\' + Name));
if (FileExists('%windir%\system32\dllcache\' + Name) and FileExists('%windir%\ServicePackFiles\i386\dllcache\' + Name)) and ((CalkFileMD5('%windir%\system32\dllcache\' + Name) <> CalkFileMD5('%windir%\ServicePackFiles\i386\dllcache\' + Name))) then
begin
AddToLog('Замена из ServicePackFiles\i386\dllcache и dllcache не произведена - MD5 у файлов различные. Запрошен дистрибутив.');
AddToLog('Файл ' + '%windir%\system32\dllcache\' + Name + ' -> MD5 = ' + CalkFileMD5('%windir%\system32\dllcache\' + Name));
AddToLog('Файл ' + '%windir%\ServicePackFiles\i386\dllcache\' + Name + ' -> MD5 = ' + CalkFileMD5('%windir%\ServicePackFiles\i386\dllcache\' + Name));
SysFileRecoverFromDistrib(Path, Name);
end
else if FileExists('%windir%\system32\dllcache\' + Name) then
begin
AddToLog('Файл ' + '%windir%\system32\dllcache\' + Name + ' -> MD5 = ' + CalkFileMD5('%windir%\system32\dllcache\' + Name));
if (CalkFileMD5('%windir%\system32\dllcache\' + Name) <> CalkFileMD5(Path + Name)) then
begin
CompleteFix('%windir%\system32\dllcache\', Name);
AddToLog('Замена ' + Name + ' успешно произведена из \system32\dllcache\');
end
else if FileExists('%windir%\ServicePackFiles\i386\dllcache\' + Name) then
begin
AddToLog('Файл ' + '%windir%\ServicePackFiles\i386\dllcache\' + Name + ' -> MD5 = ' + CalkFileMD5('%windir%\ServicePackFiles\i386\dllcache\' + Name));
if (CalkFileMD5('%windir%\ServicePackFiles\i386\dllcache\' + Name) <> CalkFileMD5(Path + Name)) then
begin
CompleteFix('%windir%\ServicePackFiles\i386\dllcache\', Name);
AddToLog('Замена ' + Name + ' успешно произведена из \ServicePackFiles\i386\');
end
end
end;
if (not FileExists('%windir%\system32\dllcache\' + Name)) and (not FileExists('%windir%\ServicePackFiles\i386\dllcache\' + Name)) then
begin
AddToLog('Замена из ServicePackFiles\i386\dllcache и dllcache не произведена - нет файлов. Запрошен дистрибутив.');
SysFileRecoverFromDistrib(Path, Name);
end;
SaveLog('SafeZone.log');
end;
var SourcePath : String;
begin
SearchRootkit(true, true);
SetAVZGuardStatus(True);
ClearLog;
QuarantineFile('%windir%\system32\drivers\sfc.sys','');
DeleteFile('%windir%\system32\drivers\sfc.sys');
SysFileRecoverFromBackup('%windir%\system32\', 'sfcfiles.dll'); // Указываем имя файла.
BC_ImportAll;
ExecuteSysClean;
BC_DeleteSvc('sfc');
BC_Activate;
RebootWindows(true);
end.