Example #1
0
 public void StartAnalysisThread()
 {
     MatchedPayloadBuf = Unpooled.Buffer();
     new Thread(() =>
     {
         while (Frm.Device.Started)
         {
             try
             {
                 while (MatchedPayloadBuf.IsReadable())
                 {
                     if (IsAndroidQQProtocol(MatchedPayloadBuf))
                     {
                         string orientation = (MatchedPayloadBuf.GetInt(MatchedPayloadBuf.ReaderIndex + 9) == 0) ? "Recv" : "Send";
                         int pkg_len        = MatchedPayloadBuf.GetInt(MatchedPayloadBuf.ReaderIndex);
                         byte[] pkg_payload = new byte[pkg_len];
                         if (MatchedPayloadBuf.ReadableBytes >= pkg_payload.Length)
                         {
                             MatchedPayloadBuf.ReadBytes(pkg_payload, 0, pkg_payload.Length);
                             AppendPacketLogItems(orientation, pkg_payload);
                             MatchedPayloadBuf.DiscardReadBytes();
                         }
                     }
                     else if (MatchedPayloadBuf.ReadableBytes >= 9)
                     {
                         MatchedPayloadBuf.ReadBytes(9);
                     }
                     else
                     {
                         Thread.Sleep(1000);
                     }
                 }
             }
             catch (Exception ex)
             {
                 Logger.Error(ex, ex.Message);
             }
             Thread.Sleep(1000);
         }
         Logger.Info("The analysis thread has stopped.");
         MatchedSrcIp   = null;
         MatchedDstIp   = null;
         MatchedSrcPort = null;
         MatchedDstPort = null;
         MatchedPayloadBuf.SafeRelease();
     }).Start();
 }