public bool Load() { try { if (!vdb.lame_open_vdb(null)) { return(false); } if (!lame.Load(vdb)) { return(false); } lame.SetEventHandle(EventHandle); //测试 //LameWithEvent lm = (LameWithEvent)lame.Clone(); //lame.Unload(); //lame = lm; return(true); } catch (System.Exception ex) { vdb.lame_close_vdb(); lame.Unload(); Console.WriteLine(ex.Message); } return(false); }
public bool Load(int sc) { if (!_vlib.lame_open_vdb(null)) { return(false); } _DirTravelWorker = new DirTravelWorker(_scan_obj_queue); for (var i = 0; i < sc; i++) { var s = new ScanWorker(_params, _scan_obj_queue); if (!s.Load(_vlib)) { continue; } _scanners.Add(s); } if (_scanners.Count == 0) { _vlib.lame_close_vdb(); _vlib = null; return(false); } return(true); }
public bool Load() { try { if (!vdb.lame_open_vdb(null)) { return(false); } if (!lame.Load(vdb)) { return(false); } lame.EnterFileEvent = EnterFileEventHandle; lame.LeaveFileEvent = LeaveFileEventHandle; lame.AlarmEvent = AlarmEventHandle; //测试 //LameWithEvent lm = (LameWithEvent)lame.Clone(); //lame.Unload(); //lame = lm; return(true); } catch (Exception ex) { vdb.lame_close_vdb(); lame.Unload(); Console.WriteLine(ex.Message); } return(false); }
public bool Load() { try { if (!_lib.lame_open_vdb(null)) { return(false); } if (!_lame.Load(_lib)) { _lib.lame_close_vdb(); _lib = null; _lame = null; return(false); } _lame.OnExtractEnterFileEvent = ExtractEnterFileEventHandle; _lame.OnExtractLeaveFileEvent = ExtractLeaveFileEventHandle; _dump_path = Path.Combine(Directory.GetCurrentDirectory(), "bin"); Directory.CreateDirectory(_dump_path); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(false); }
static void Main(string[] args) { if (args.Length == 0) { return; } VirusLib vdb = new VirusLib(); if (!vdb.lame_open_vdb(null)) { Console.WriteLine("Faild to load virus lib."); return; } LameTest(vdb, args[0]); LameWithEventTest(vdb, args[0]); vdb.lame_close_vdb(); }
public bool Load() { try { if (!vdb.lame_open_vdb(null)) { return(false); } if (!lame.Load(vdb)) { return(false); } return(true); } catch (System.Exception ex) { vdb.lame_close_vdb(); lame.Unload(); Console.WriteLine(ex.Message); } return(false); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Invalid Param."); Help(); return; } VirusLib vdb = null; IScan _Scanner = null; try { vdb = new VirusLib(); if (!vdb.lame_open_vdb(null)) { Console.WriteLine("Faild to load virus lib."); return; } List <string> path_list = new List <string>(); List <string> param_list = new List <string>(); int scan_thread_count = 2; int down_thread_count = 1; bool bShowVerion = false; bool bShowLicense = false; bool bShowFileList = false; bool bHold = false; bool bMd5List = false; foreach (string s in args) { string vl = s.ToLower(); if (s.StartsWith("-")) { if (vl == "-version") { bShowVerion = true; } else if (vl == "-license") { bShowLicense = true; } else if (vl == "-hold") { bHold = true; } else if (vl == "-show-file-list") { bShowFileList = true; } else if (vl == "-md5-list") { bMd5List = true; } else if (s.StartsWith("-workers=")) { string[] v1 = s.Split('='); if (v1.Length == 2) { string[] v2 = v1[1].Split(','); if (v2.Length > 0) { int value = 0; if (int.TryParse(v2[0], out value)) { scan_thread_count = value; } if (v2.Length > 1) { if (int.TryParse(v2[1], out value)) { down_thread_count = value; } } } } } else { param_list.Add(s.Substring(1)); } } else { path_list.Add(s); } } if (bShowFileList) { _Scanner = new ScannerEx(vdb); } else { _Scanner = new Scanner(vdb); } if (bShowVerion) { _Scanner.ShowVersion(); } if (bShowLicense) { _Scanner.ShowLicense(); } foreach (string s in param_list) { _Scanner.SetParam(s); } if (!_Scanner.Load()) { return; } if (bMd5List) { TaskScanner task = new TaskScanner(_Scanner, path_list); task.Run(scan_thread_count, down_thread_count); } else { foreach (string s in path_list) { _Scanner.Scan(s); } } if (bHold) { Console.Read(); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { if (_Scanner != null) { _Scanner.UnLoad(); } if (vdb != null) { vdb.lame_close_vdb(); } } }
private static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Invalid Param."); Help(); return; } VirusLib vdb = null; IScan _Scanner = null; try { vdb = new VirusLib(); if (!vdb.lame_open_vdb(null)) { Console.WriteLine("Faild to load virus lib."); return; } var path_list = new List <string>(); var param_list = new List <string>(); var bShowVerion = false; var bShowLicense = false; var bShowFileList = false; var bHold = false; var bMd5List = false; foreach (var s in args) { var vl = s.ToLower(); if (s.StartsWith("-")) { if (vl == "-version") { bShowVerion = true; } else if (vl == "-license") { bShowLicense = true; } else if (vl == "-hold") { bHold = true; } else if (vl == "-show-file-list") { bShowFileList = true; } else if (vl == "-md5-list") { bMd5List = true; } else { param_list.Add(s.Substring(1)); } } else { path_list.Add(s); } } if (bShowFileList) { _Scanner = new ScannerEx(vdb); } else { _Scanner = new Scanner(vdb); } if (bShowVerion) { _Scanner.ShowVersion(); } if (bShowLicense) { _Scanner.ShowLicense(); } foreach (var s in param_list) { _Scanner.SetParam(s); } if (!_Scanner.Load()) { return; } foreach (var s in path_list) { _Scanner.Scan(s); } if (bHold) { Console.Read(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (_Scanner != null) { _Scanner.UnLoad(); } if (vdb != null) { vdb.lame_close_vdb(); } } }