示例#1
0
文件: MainForm.cs 项目: killvxk/OSPE
 private void lvCaptures_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (lvCaptures.SelectedItems.Count == 1)
     {
         ActionStopCapture(); // Paramos la captura antes
                              // var recordId = int.Parse(lvCaptures.SelectedItems[0].SubItems[1].Text);
         var recordId = lvCaptures.Items.IndexOf(lvCaptures.SelectedItems[0]);
         var cr       = _captures[recordId];
         foreach (Packet p in cr.GetPacketList())
         {
             AddPacket(p);
         }
         PacketManager.LoadCapture(cr);
     }
 }
示例#2
0
        public static void StartPacketReaderMMF()
        {
            int nodeBufferSize = sizeof(byte) * _pktMmfBufferSize;

            SharedMemory.CircularBuffer packetMMF;
            if (!CheckMMFileExists(_pktMmfName))
            {
                packetMMF = new SharedMemory.CircularBuffer(_pktMmfName, _pktMmfNodeCount, nodeBufferSize);
            }
            else
            {
                packetMMF = new SharedMemory.CircularBuffer(_pktMmfName);
            }

            byte[] writtenData = new byte[_pktMmfBufferSize];

            //int threadCount = 0;
            Action reader = () =>
            {
                //int myThreadIndex = Interlocked.Increment(ref threadCount);
                //Output.outMsgBox("Started thread {0}: ", threadCount);

                for (; ;)
                {
                    //var t1 = Environment.TickCount; Debug.WriteLine("packetMMF.Read(writtenData) {0}", ID);
                    //var t2 = Environment.TickCount; if (t2-t1 > 0) Debug.WriteLine("ANTES de packetMMF.Read {0} - diff: {1}", ID, t2-t1);

                    //The number of milliseconds to wait, or Timeout.Infinite (-1) to wait indefinitely.
                    int amount = packetMMF.Read(writtenData, 0, -1);

                    //var t3 = Environment.TickCount; if (t3 - t2 > 0) Debug.WriteLine("DESPUES de server.Read {0} - diff: {1}", ID, t3 - t2);

                    if (amount == 0)
                    {
                        throw new Exception("Read 0 bytes from queue!");
                    }

                    Output.outString("Read data: {0}", BitConverter.ToString(writtenData));

                    // PacketInfo HEADER
                    var packetInfo = new PacketInfo();

                    var piSize = Marshal.SizeOf(packetInfo);
                    var piData = new byte[piSize];

                    // Reads the piSize bytes corresponding to the packetInfo
                    Buffer.BlockCopy(writtenData, 0, piData, 0, piSize);

                    // Converts the bytes to a packetInfo
                    IntPtr ptr = Marshal.AllocHGlobal(piSize);
                    Marshal.Copy(piData, 0, ptr, piSize);
                    packetInfo = (PacketInfo)Marshal.PtrToStructure(ptr, packetInfo.GetType());

                    var cSize = packetInfo.Size;
                    var cData = new byte[cSize];

                    // Packet size can not be bigger than buffer size
                    Debug.Assert(cSize < _pktMmfBufferSize);

                    Buffer.BlockCopy(writtenData, piSize, cData, 0, cSize);

                    PacketManager.PacketReceived(packetInfo, ref cData);

                    //var t4 = Environment.TickCount; if (t4- t3 > 0) Debug.WriteLine("DESPUES de PacketManager.PacketReceived {0} - diff: {1}", ID, t4 - t3);
                }
            };

            // Start reader thread
            ThreadPool.QueueUserWorkItem(o => { reader(); });
        }
示例#3
0
文件: MainForm.cs 项目: killvxk/OSPE
 private void StartFiltering()
 {
     DllCommunication.WriteCommandToCmdMMF(ServerCodes.SCODE_STARTFILTERING);
     PacketManager.StartFiltering();
     _isFiltering = true;
 }
示例#4
0
文件: MainForm.cs 项目: killvxk/OSPE
 private void StopFiltering()
 {
     DllCommunication.WriteCommandToCmdMMF(ServerCodes.SCODE_STOPFILTERING);
     PacketManager.StopFiltering();
     _isFiltering = false;
 }
示例#5
0
文件: MainForm.cs 项目: killvxk/OSPE
 private void StopCapture()
 {
     DllCommunication.WriteCommandToCmdMMF(ServerCodes.SCODE_STOPCAPTURE);
     PacketManager.StopCapture();
     _isCapturing = false;
 }