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); }
private void addEntry_Click(object sender, RoutedEventArgs e) { AVEntry newEntry = new AVEntry(tbTitle.Text); string[] offset = tbOffset.Text.Split(';'); if (offset.Count() != 2) { return; } newEntry.setSignatureInfo(Convert.ToInt16(offset[0]), Convert.ToInt16(offset[1]), tbSignature.Text, tbTypes.Text); entryList.insertNode(newEntry); update_ListBox(); }