static public AVEntryTree loadEntries() { AVEntryTree resList = new AVEntryTree(); FileStream db = File.Open(dbName, FileMode.Open); byte[] bytes = new byte[7]; db.Read(bytes, 0, 7); if (Encoding.ASCII.GetString(bytes) == Encoding.ASCII.GetString(name)) { int nEntries = db.ReadByte(); byte[] virusName = new byte[20]; byte[] signature = new byte[8]; byte[] hash = new byte[16]; byte[] type = new byte[5]; for (int i = 0; i < nEntries; i++) { db.Read(virusName, 0, 20); AVEntry entry = new AVEntry(Encoding.ASCII.GetString(virusName)); int lOffset = db.ReadByte(); int rOffset = db.ReadByte(); int length = db.ReadByte(); db.Read(signature, 0, 8); db.Read(hash, 0, 16); db.Read(type, 0, 5); entry.setSignatureInfo(lOffset, rOffset, length, signature, hash, Encoding.ASCII.GetString(type)); resList.insertNode(entry); } db.Close(); return(resList); } db.Close(); return(null); }
static public void saveEntries(AVEntryTree entries) { FileStream db = File.Open(dbName, FileMode.Open); db.Seek(7, SeekOrigin.Begin); db.WriteByte((byte)entries.size); writeEntry(entries.root, db); db.Close(); }
public MainWindow() { InitializeComponent(); AVLoader.initDB(); entryList = AVLoader.loadEntries(); if (entryList.root != null) { foreach (string entry in entryList.getAllNames(entryList.root)) { lbNames.Items.Add(entry); } } }
public void addBase(AVEntryTree avBase) { avBases.Add(avBase); }