示例#1
0
        //=========================================
        // allocMem
        //=========================================
        public void allocMem(uint pHeap, uint pBlock, uint blockSize, HaloWarsMem.BALContext context)
        {
            SymbolInfo.LookupInfo li = new SymbolInfo.LookupInfo();

            for (int i = 0; i < context.mBackTraceSize; i++)
            {
                HaloWarsMem.getSymbolInfo().lookup(context.mBackTrace[i], ref li);
                if (HaloWarsMem.getSymbolInfo().isIgnoreSymbol(Path.GetFileName(li.mFilename)))
                {
                    continue;
                }

                if (mBlockToFile.Contains(pBlock))
                {
                    GlobalErrors.addError("HeapAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x"));
                    return;
                }

                FileAlloc fa = (FileAlloc)mAllocations[li.mFilename];
                if (fa == null)
                {
                    fa = new FileAlloc(li.mFilename);
                    mAllocations.Add(li.mFilename, fa);
                }

                mBlockToFile.Add(pBlock, li.mFilename);
                fa.allocMem(pHeap, pBlock, blockSize, (uint)li.mLine, context);


                break;
            }

            mNumNews++;
        }
示例#2
0
        //==============================================================================
        // deleteMem
        //==============================================================================
        public void deleteMem(uint pBlock)
        {
            if (!mAllocations.Contains(pBlock))
            {
                GlobalErrors.addError(" LineAlloc : Stray Delete of block 0x" + pBlock.ToString("x"));
                return;
            }

            mTotalBytes -= ((BlockAlloc)mAllocations[pBlock]).mBlockSize;

            mAllocations.Remove(pBlock);
        }
示例#3
0
        //============================================================================
        // registerHeap
        //============================================================================
        static public void registerHeap(HaloWarsMem.BALPacketRegisterHeap pkt)
        {
            HeapAlloc pHeap = getHeapFromBasePtr(pkt.mPtr);

            if (pHeap != null)
            {
                //ALREADY HAVE THIS HEAP!!
                GlobalErrors.addError("Multiple allocations of heap 0x" + pkt.mPtr.ToString("x"));
                return;
            }

            HeapAlloc hm = new HeapAlloc(pkt.mPtr, pkt.mFlags, pkt.mName);

            mRegisteredHeaps.Add(hm);
        }
示例#4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string str = GlobalErrors.popError();

            while (str != "")
            {
                errorListBox.Items.Add(str);
                str = GlobalErrors.popError();
                if (errorListBox.Items.Count > 100)
                {
                    errorListBox.Items.Add("Erros exceeds 100. Stopping logging");
                    timer1.Enabled = false;
                    return;
                }
            }
        }
示例#5
0
        //==============================================================================
        // deleteMem
        //==============================================================================
        public void deleteMem(uint pBlock)
        {
            LineAlloc la = getLineContaining(pBlock);

            mBlockToLineNum.Remove(pBlock);

            if (la != null)
            {
                mTotalBytes -= la.getBlockSize(pBlock);
                la.deleteMem(pBlock);

                if (la.getTotalAllocatedBytes() == 0)
                {
                    mAllocations.Remove(la);
                }
                return;
            }

            GlobalErrors.addError("FileAlloc : Stray Delete of block 0x" + pBlock.ToString("x"));
        }
示例#6
0
        //=========================================
        // allocMem
        //=========================================
        public void allocMem(uint pHeap, uint pBlock, uint blockSize, HaloWarsMem.BALContext context)
        {
            if (mAllocations.Contains(pBlock))
            {
                GlobalErrors.addError(" LineAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x"));
                return;
            }


            BlockAlloc ba = new BlockAlloc();

            ba.mpHeap     = pHeap;
            ba.mpBlock    = pBlock;
            ba.mBlockSize = blockSize;
            context.copyTo(ref ba.mContext);

            mAllocations.Add(pBlock, ba);

            mTotalBytes += blockSize;
        }
示例#7
0
        //==============================================================================
        // deleteMem
        //==============================================================================
        public void deleteMem(uint pBlock, HaloWarsMem.BALContext context)
        {
            mNumDeletes++;

            FileAlloc fa = getFileContaining(pBlock);

            mBlockToFile.Remove(pBlock);


            if (fa != null)
            {
                fa.deleteMem(pBlock);
                if (fa.getTotalAllocatedBytes(false) == 0)
                {
                    mAllocations.Remove(fa.getFilename());
                }
                return;
            }

            GlobalErrors.addError("HeapAlloc : Stray delete of block 0x" + pBlock.ToString("x") + ". No file!");
        }
示例#8
0
        //============================================================================
        // ListenForClients
        //============================================================================
        private void ListenForClients()
        {
            try
            {
                this.tcpListener.Start();
                this.tcpListener.Server.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true);
                //blocks until a client has connected to the server

                mTCPClient = this.tcpListener.AcceptTcpClient();
            }
            catch (Exception e)
            {
                GlobalErrors.addError("SHIT!");
            }



            //create a thread to handle communication with connected client
            Thread clientThread = new Thread(new  ParameterizedThreadStart(HandleClientComm));

            clientThread.Start(mTCPClient);
        }
示例#9
0
        //=========================================
        // allocMem
        //=========================================
        public void allocMem(uint pHeap, uint pBlock, uint blockSize, uint lineNum, HaloWarsMem.BALContext context)
        {
            if (mBlockToLineNum.Contains(pBlock))
            {
                GlobalErrors.addError("FileAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x"));
                return;
            }

            LineAlloc la = (LineAlloc)mAllocations[lineNum];

            if (la == null)
            {
                la = new LineAlloc(lineNum);
                mAllocations.Add(lineNum, la);
            }

            la.allocMem(pHeap, pBlock, blockSize, context);

            mBlockToLineNum.Add(pBlock, lineNum);

            mTotalBytes += blockSize;
        }
示例#10
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();
        }
示例#11
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();
        }