I am trying to code an Anti-Virus scanner & can get a single file scan to work, but my "Full System scan" doesn't work correctly. Here is the code (for one location to be scanned):
Dim hash_type As String
Dim file_name As String
Dim array() As Byte
Dim dir As New DirectoryInfo(Environment.SpecialFolder.ProgramFiles)
For Each foundFile As FileInfo In dir.GetFiles("*.exe", SearchOption.AllDirectories)
ScanLocation.Items.Add(dir)
Dim path As String = foundFile.ToString
txtFilePath.Text = path
Dim sample As String
sample = md5_hash(path)
Dim File As System.IO.StreamReader = System.IO.File.OpenText("C:\Program Files\MalwareBlocker\Signatures.txt")
Dim File1 As String = File.ReadToEnd()
File.Close()
If File1.Contains(sample) Then
InfectedFiles.Items.Add(sample)
Else
'IGNORE
End If
Next foundFile
I would like the scanner to covert each .exe file in directories such as "Program Files", "Roaming" & "Temp" & then check each .exe file MD5 to a text file of signatures.