private unsafe bool CallBack(byte *buffer, int CurrentStart, int CurrentEnd, int size) { _lpTempBuffer = buffer; if (_createFiles) { string FileName = Path.Combine(Session.output, GlobalDataAndMethods.OutputFormat(CurrentStart, CurrentEnd, true)); try { ApplyFixedRanges(buffer, size); WriteToFile(buffer, size, FileName); } catch { } } _counter++; worker.ReportProgress((int)(_counter * 100.0 / _numberOfLoops)); return(_continue); }
protected override void worker_DoWork(object sender, DoWorkEventArgs e) { _signatures.Clear(); /// use unkSize Config cfg = GlobalDataAndMethods.Config; while (_continue) { // process(); SendState("process"); base.worker_DoWork(sender, e); //scan(); //wait(); SendState("scan"); GlobalDataAndMethods.Scan(true); //if (!noFile) if (NextInterval()) { SendState("next"); // TakeResult[index]; //already done by NextInterval(); } else { if (cfg.AutoGenerateFixedRange) { if ((base.Session.end - base.Session.start) > cfg.SignatureMaxSize) { SendState("split"); // SplitToVarAndFixed(); } else { SaveSignature(); if (Session.AutoAddedFixedRanges.Count > 0) { SendState("update"); Session.AutoAddedFixedRanges.Clear(); Session.AutoAddedFixedRanges.AddRange(_signatures); //updateVariableRangeToOldOneMinusSignatures(); } else { break; } } } SaveSignature(); break; } } SendState("done"); #region Draft //while (true) //{ // // process // base.worker_DoWork(sender, e); // // scan // GlobalDataAndMethods.Scan(WaitForExit: true); // av config should be checked in frmAuto // if (!NextInterval()) // no file // { // if (GlobalDataAndMethods.Config.AutoGenerateFixedRange) // { // if (base.Session.size <= GlobalDataAndMethods.Config.SignatureMaxSize) // { // /// // //// this is the case where viral sig is found and conform to criteras // /// // //add viral interval to this.Signatures // SaveSignature(); // // if (there is auto defined fixed interval) // if (Session.AutoAddedFixedRanges.Count > 0) // { // //////////////// // // INCOMPLETE // // //////////////// // // clear Session.AutoAddedFixedRanges // Session.AutoAddedFixedRanges.Clear(); // // add all viral intervals to Session.SetAutoAddedFixedRangesWithoutCollisionWithVariableRange // Session.AutoAddedFixedRanges.AddRange(Signatures); // // variable range without signatures // //Session.ExcludeAutoAddedRangeFromVariableRange(); // throw new NotImplementedException(); // } // else // { // //break; // } // } // else // { // //SplitRange(); // } // } // else // { // SaveSignature(); // } // } //} #endregion }