Example #1
0
        public void SearchString(byte[] searchBytes, bool caseSensitive, bool unicode, bool hex)
        //public void SearchString(String sString, bool caseSensitive, bool unicode)
        {
            byte[] stringBytes = searchBytes;

            UInt32 startAddr = selAddress + 4;

            UInt32 endAddress = 0;

            int dumpLength = (unicode ? 2:1);

            bool found = false;

            for (int i = 0; i < ValidMemory.ValidAreas.Length; i++)
            {
                if (startAddr >= ValidMemory.ValidAreas[i].low &&
                    startAddr < ValidMemory.ValidAreas[i].high)
                {
                    found      = true;
                    endAddress = ValidMemory.ValidAreas[i].high;
                    break;
                }
            }

            if (!found)
            {
                throw new Exception("Memory area could not be acquired!");
            }

            bool valueFound = false;
            int  inpos      = 0;

            UInt32 beginAddress = startAddr;

            MemoryStream ms        = new MemoryStream();
            long         streamPos = 0;
            UInt32       cVal;
            char         cChar;

            UInt32 SearchBufferSize = 0x400 * 256;   // 400 is the packet size in TCPGecko.cs

            UInt32 dumpHigh = Math.Min(startAddr + SearchBufferSize, endAddress);

            try
            {
                int index;

                do
                {
                    ms.Seek(0, SeekOrigin.End);
                    int startIndex = (int)ms.Position;
                    gecko.Dump(startAddr, dumpHigh, ms);

                    byte[] streamArray = ms.GetBuffer();

                    index = GlobalFunctions.IndexOfByteArray(streamArray, stringBytes, startIndex, caseSensitive);

                    if (index != -1)
                    {
                        valueFound = true;
                        break;
                    }

                    startAddr = dumpHigh;
                    dumpHigh  = Math.Min(startAddr + SearchBufferSize, endAddress);
                    Application.DoEvents();     // check for cancel search
                } while (dumpHigh != endAddress && !valueFound && searching);

                if (valueFound)
                {
                    UInt32 address = (UInt32)(beginAddress + index);
                    cAddress = address;
                }
                else
                {
                    // hack to fix the jumping disassembly window
                    cAddress = beginAddress - 4;
                    if (dumpHigh == endAddress)
                    {
                        MessageBox.Show("Could not find search query");
                    }
                }
            }
            catch (ETCPGeckoException exc)
            {
                exceptionHandling.HandleException(exc);
            }
        }
Example #2
0
        public void SearchString(byte[] searchBytes, bool caseSensitive, bool unicode, bool hex)
        {
            byte[] stringBytes = searchBytes;

            uint startAddr = selectedAddress + 4;

            uint endAddress = 0;

            int dumpLength = (unicode ? 2 : 1);

            bool found = false;

            for (int i = 0; i < ValidMemory.ValidAreas.Length; i++)
            {
                if (startAddr >= ValidMemory.ValidAreas[i].low &&
                    startAddr < ValidMemory.ValidAreas[i].high)
                {
                    found      = true;
                    endAddress = ValidMemory.ValidAreas[i].high;
                    break;
                }
            }

            if (!found)
            {
                throw new Exception("Memory area could not be acquired!");
            }

            bool valueFound = false;

            uint beginAddress = startAddr;

            MemoryStream ms = new MemoryStream();

            uint SearchBufferSize = 0x400 * 256;

            uint dumpHigh = Math.Min(startAddr + SearchBufferSize, endAddress);

            try
            {
                int index;

                do
                {
                    ms.Seek(0, SeekOrigin.End);
                    int startIndex = (int)ms.Position;
                    gecko.Dump(startAddr, dumpHigh, ms);

                    byte[] streamArray = ms.GetBuffer();

                    index = GlobalFunctions.IndexOfByteArray(streamArray, stringBytes, startIndex, caseSensitive);

                    if (index != -1)
                    {
                        valueFound = true;
                        break;
                    }

                    startAddr = dumpHigh;
                    dumpHigh  = Math.Min(startAddr + SearchBufferSize, endAddress);
                    Application.DoEvents();
                } while (dumpHigh != endAddress && !valueFound && Searching);

                if (valueFound)
                {
                    uint address = (uint)(beginAddress + index);
                    cAddress = address;
                }
                else
                {
                    cAddress = beginAddress - 4;
                    if (dumpHigh == endAddress)
                    {
                        MessageBox.Show("Could not find search query");
                    }
                }
            }
            catch (ETCPGeckoException exc)
            {
                exceptionHandling.HandleException(exc);
            }
        }