Exemple #1
0
 public static void SetPackerPluginCallbacks(ChangeVolCallback changeVol, ChangeVolCallbackW changeVolW, ProcessDataCallback processData, ProcessDataCallbackW processDataW, PkCryptCallback crypt, PkCryptCallbackW cryptW)
 {
     if (changeVolCallback == null)
     {
         changeVolCallback = changeVol;
     }
     if (changeVolCallbackW == null)
     {
         changeVolCallbackW = changeVolW;
     }
     if (processDataCallback == null)
     {
         processDataCallback = processData;
     }
     if (processDataCallbackW == null)
     {
         processDataCallbackW = processDataW;
     }
     if (pkCryptCallback == null)
     {
         pkCryptCallback = crypt;
     }
     if (pkCryptCallbackW == null)
     {
         pkCryptCallbackW = cryptW;
     }
 }
Exemple #2
0
        public static void SetProcessDataProc(IntPtr arcData, ProcessDataCallback processDataProc)
        {
            callSignature = String.Format("SetProcessDataProc ({0})", arcData.ToString());
            try {
                TcCallback.SetPackerPluginCallbacks(null, null, processDataProc, null, null, null);

                TraceCall(TraceLevel.Warning,
                          processDataProc.Method.MethodHandle.GetFunctionPointer().ToString());
            } catch (Exception ex) {
                ProcessException(ex);
            }
        }
Exemple #3
0
        private void ProcessData(string data)
        {
            if (this.InvokeRequired)
            {
                ProcessDataCallback d = new ProcessDataCallback(ProcessData);
                this.Invoke(d, new object[] { data });
            }
            else
            {
                PrintDebug(3, "ProcessData");
                if (checkBoxRawDebugEnable.Checked == true)
                {
                    PrintDebug(1, data);
                }

                //printDebug("", "Data length:" + data.Length);
                receivedDataString = receivedDataString + data;
                //printDebug("", "Received Data String Length:" + receivedDataString.Length);
                //if(data.EndsWith("\r\n")==false)
                //{
                //    printDebug("", "Bad packet.");
                //}
                bool packetsRemaining = true;

                while (packetsRemaining == true)
                {
                    int headerLocation = receivedDataString.IndexOf(headerMask);
                    int footerLocation = receivedDataString.IndexOf(footerMask, headerLocation + headerMask.Length);
                    if (headerLocation != footerLocation && headerLocation > 0 && footerLocation > 0)
                    {
                        //printDebug("", "Full packet found.");

                        //printDebug("", "Packet data:" + receivedDataString + "<END PACKET DATA>");
                        string packetString = receivedDataString.Substring(headerLocation + headerMask.Length, ((footerLocation) - (headerLocation + headerMask.Length)));

                        String[] packetDataValues = packetString.Split(',');
                        //PrintDebug(1, receivedDataString);
                        if (checkBoxRxTxLogEnable.Checked == true)
                        {
                            PrintDebug(1, "packetDataValues:" + packetDataValues[0] + "," + packetDataValues[1]);
                        }
                        dataSeries1.addData(packetDataValues, 2);
                        //printDebug("", "String length:" + value1.GetLength(0).ToString());
                        receivedDataString = receivedDataString.Remove(0, footerLocation - 1);
                        //receivedDataString = "";
                    }
                    else
                    {
                        //printDebug("", "No packet found. (" + headerLocation + "/" + footerLocation + ")");
                        packetsRemaining = false;
                    }

                    /*if (footerLocation > -1)
                     * {
                     *
                     *  printDebug("", "Packet footer found@" + footerLocation);
                     *
                     *
                     * }*/
                }
            }
        }