コード例 #1
0
            public BALPacketDelete(int packetSize, byte[] packetData)
            {
                mpHeap  = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
                mpBlock = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 4));

                mContext.frompacket(packetSize, packetData, 8);
            }
コード例 #2
0
 public BALPacketVersion(int packetSize, byte[] packetData)
 {
     mVersion        = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
     mXEXChecksum    = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 4));
     mXEXBaseAddress = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 8));
     mTimerFreq      = Xbox_EndianSwap.endSwapI64(BitConverter.ToInt64(packetData, 12));
 }
コード例 #3
0
            public BALPacketResize(int packetSize, byte[] packetData)
            {
                mpHeap      = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
                mpOrigBlock = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 4));
                mNewSize    = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 8));
                mpNewBlock  = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 12));

                mContext.frompacket(packetSize, packetData, 16);
            }
コード例 #4
0
            public void frompacket(int packetSize, byte[] packetData, int startByte)
            {
                mThreadIndex = packetData[startByte];
                startByte++;
                mBackTraceSize = packetData[startByte];
                startByte++;

                mTime      = Xbox_EndianSwap.endSwapI64((Int64)BitConverter.ToUInt64(packetData, startByte));
                startByte += 8;

                for (int i = 0; i < (int)eFlags.cMaxBackTrace; i++)
                {
                    mBackTrace[i] = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, startByte));
                    startByte    += 4;
                }
            }
コード例 #5
0
            public BALPacketRegisterHeap(int packetSize, byte[] packetData)
            {
                mPtr   = (uint)Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
                mFlags = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 4));

                int plus = 8;

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < 32; i++)
                {
                    char ch = (char)packetData[i + plus];
                    if (ch == '\0')
                    {
                        break;
                    }
                    sb.Append(ch);
                }

                mName = sb.ToString();
            }
コード例 #6
0
 public BALPacketFrame(int packetSize, byte[] packetData)
 {
     mIndex = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
     mTime  = Xbox_EndianSwap.endSwapI64(BitConverter.ToInt64(packetData, 4));
 }
コード例 #7
0
 public BALPacketSnapshot(int packetSize, byte[] packetData)
 {
     mIndex = Xbox_EndianSwap.endSwapI32(BitConverter.ToInt32(packetData, 0));
 }
コード例 #8
0
        //============================================================================
        // processStream
        //============================================================================
        static public void processBinaryStream(BinaryReader pStream, string pdbFilename, uint throttleAmout)
        {
            forceOnConnectEvent("127.0.0.1", pdbFilename);


            byte[] header = new byte[4];

            Interlocked.Exchange(ref mIsRunning, 1);

            mNumBytesWritten = (ulong)pStream.BaseStream.Length;
            mNumBytesRead    = 0;

            int numPacketsRecieved = 0;

            while (mIsRunning > 0 && mNumBytesRead < mNumBytesWritten)
            {
                if (mIsPaused == 1)
                {
                    continue;
                }

                try
                {
                    pStream.Read(header, 0, 4); //read the header..

                    byte packetStart = header[0];
                    byte packetType  = header[1];
                    int  packetSize  = (int)Xbox_EndianSwap.endSwapI16(BitConverter.ToUInt16(header, 2));


                    if (packetStart != HaloWarsMem.cALPacketPrefix)
                    {
                        continue; //ERROR HERE??
                    }
                    //modify our packet size since we've already read in 4 bytes..
                    packetSize -= 4; // -= sizeof the data we've already read in..
                    if (packetSize < 0)
                    {
                        packetSize = 0;
                    }

                    //read in the rest of the packet data
                    byte[] packetData = null;
                    if (packetSize > 0)
                    {
                        //read the packet
                        packetData = new byte[packetSize];
                        int readSize = pStream.Read(packetData, 0, packetSize);

                        if (readSize != packetSize)
                        {
                            break; //ERROR HERE??
                        }
                    }

                    recieveProcessPacket(header, packetType, packetSize, ref packetData);

                    numPacketsRecieved++;

                    mNumBytesRead += (ulong)(4 + packetSize);

                    //this is for reading from Disk. We throttle a bit to let the UI catch up..
                    if (throttleAmout != 0)
                    {
                        for (int i = 0; i < throttleAmout; i++)
                        {
                            ;
                        }
                        //Thread.Sleep((int)throttleAmout);
                    }
                }
                catch (Exception e)
                {
                    GlobalErrors.addError(e.InnerException.ToString());
                    break;
                }
            }

            forceOnDisconnectEvent();
        }
コード例 #9
0
        //============================================================================
        // processNetworkStream
        //============================================================================
        static public void processNetworkStream(string IPAddy, NetworkStream pStream, string pdbFilename, TcpClient pClient)
        {
            forceOnConnectEvent(IPAddy, pdbFilename);
            Interlocked.Exchange(ref mIsRunning, 1);


            string cTempNetworkFile = "C:\\_tmpNetworkLog.bin";

            if (File.Exists(cTempNetworkFile))
            {
                File.Delete(cTempNetworkFile);
            }

            initNetworkReaderThread(cTempNetworkFile, pStream, pClient);

            FileStream mLoggedFileStreamReader = null;

            try
            {
                mLoggedFileStreamReader = new FileStream(cTempNetworkFile, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
            }catch (Exception ex)
            {
                GlobalErrors.addError("Error opening temp network stream file : \n" + ex.InnerException.ToString());
                Interlocked.Exchange(ref mIsRunning, 0);
            }

            BinaryReader br = new BinaryReader(mLoggedFileStreamReader);


            byte[] header = new byte[4];

            mNumBytesRead = 0;
            while (mIsRunning > 0)
            {
                try
                {
                    if (mIsPaused == 1 || mNumBytesRead >= mNumBytesWritten)
                    {
                        continue;
                    }

                    if (!fillBufferFromStream(br, header, 4, pClient))
                    {
                        GlobalErrors.addError("Error reading buffer from streams");
                        break;
                    }

                    byte packetStart = header[0];
                    byte packetType  = header[1];
                    int  packetSize  = (int)Xbox_EndianSwap.endSwapI16(BitConverter.ToUInt16(header, 2));


                    if (packetStart != HaloWarsMem.cALPacketPrefix)
                    {
                        GlobalErrors.addError("Invalid Packet recieved in network stream. Disconnecting..");
                        break;
                    }

                    //modify our packet size since we've already read in 4 bytes..
                    packetSize -= 4; // -= sizeof the data we've already read in..
                    if (packetSize < 0)
                    {
                        packetSize = 0;
                    }



                    //read in the rest of the packet data
                    byte[] packetData = null;
                    if (packetSize > 0)
                    {
                        //read the packet
                        packetData = new byte[packetSize];
                        if (!fillBufferFromStream(br, packetData, packetSize, pClient))
                        {
                            GlobalErrors.addError("Error reading buffer from streams");
                            break;
                        }
                    }


                    recieveProcessPacket(header, packetType, packetSize, ref packetData);

                    int incAmt = 4 + packetSize;


                    mNumBytesRead += (ulong)incAmt;
                }
                catch (Exception e)
                {
                    GlobalErrors.addError(e.InnerException.ToString());
                    break;
                }
            }
            stopProcessing();

            mLoggedFileStreamReader.Close();
            br.Close();

            forceOnDisconnectEvent();
        }