コード例 #1
0
ファイル: CaptureManager.cs プロジェクト: jacob119/Overmind
 /// <summary>
 /// Callback on 7z task completed. Dispatches final compressed data bytes / Parses the extracted received data files
 /// </summary>
 /// <param name="owner">Sender's Id</param>
 /// <param name="e">Event options</param>
 /// <param name="errorOccured">Whether error occurred in opertaion</param>
 private void cmp_OnComplete(int owner, CompressionEventArgs e, bool errorOccured)
 {
     //this.DebugEvent("7z: " + e.Operation.ToString() + ", " + errorOccured);
     this._neuroLog.WriteFormat("Decoded Operation Complete", "Operation: {0}\nTarget File: {1}\nError Occured: {2}", e.Operation, e.TargetFile, errorOccured);
     if (e.Operation == NX.Collections.Compression7z.Action.Compress)
     {
         if (!errorOccured && File.Exists(e.TargetFile))
         {
             this.DispatchData(owner, ActionCenter.ActionType.CaptureStream, File.ReadAllBytes(e.TargetFile + ".7z"));
         }
     }
     else
     {
         if (!errorOccured)
         {
             File.Delete(e.TargetFile);
             //this.DebugEvent("Checking files in: " + Directory.GetParent(e.TargetFile).FullName);
             foreach (string f in Directory.GetFiles(Directory.GetParent(e.TargetFile).FullName))
             {
                 CapturePacket cp = new CapturePacket();
                 cp.ReadDecoded(f);
                 if (this.ReceivedCapture != null)
                 {
                     this.ReceivedCapture(owner, (cp.ScreenShot.Length != 0) ? Image.FromStream(cp.ScreenShot) : null, HookEventHelper.StreamToHookEvents(cp.Log));
                 }
             }
         }
         //this._decodeDisposeDir.Dispose();
     }
 }
コード例 #2
0
ファイル: CaptureManager.cs プロジェクト: jacob119/Overmind
 /// <summary>
 /// Decodes the capture data received over the network stream
 /// </summary>
 /// <param name="owner">Sender's Id</param>
 /// <param name="bytes">Data bytes</param>
 /// <param name="isSingleCapture">Live stream or buffered stream</param>
 public void DecodeCapture(int owner, byte[] bytes, bool isSingleCapture)
 {
     //this._neuroLog.WriteFormat("Decoding Capture", "Owner: {0}\nSingle Capture: {1}", owner, isSingleCapture);
     if (isSingleCapture)
     {
         CapturePacket cp = new CapturePacket();
         cp.Decode(new MemoryStream(bytes));
         //this._neuroLog.WriteFormat("Decoded Capture Packet", "Capture Packet: {0}", cp);
         if (this.ReceivedCapture != null)
         {
             this.ReceivedCapture(owner, (cp.ScreenShot.Length != 0) ? Image.FromStream(cp.ScreenShot) : null, HookEventHelper.StreamToHookEvents(cp.Log));
         }
     }
     else
     {
         this._decodeDisposeDir = new DisposableDirectory();
         //this.DebugEvent("New decodeDDir: " + this._decodeDisposeDir);
         string fileName = Path.Combine(this._decodeDisposeDir.DirectoryPath, Path.GetRandomFileName()) + ".7z";
         File.WriteAllBytes(fileName, bytes);                                                                // Write file bytes to disk
         this._bufferedOperator.AddTask(owner, false, this._decodeDisposeDir, new string[] { fileName });    // Queue extraction task
         this._neuroLog.WriteFormat("Decoded Capture Queued", "File: {0}", fileName);
         //this.DebugEvent("Extract: " + fileName);
     }
 }