예제 #1
0
            public GdbAsmLine(string aInput)
            {
                //"0x0056d2b9 <_end_data+0>:\tmov    DWORD PTR ds:0x550020,ebx\n"
                var s       = GDB.Unescape(aInput);
                var xSplit1 = s.Split(Global.TabSeparator, StringSplitOptions.RemoveEmptyEntries);

                var xSplit2 = xSplit1[0].Split(Global.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries);

                int xIndex = 0;

                //newer gdb above 6.6 or higher versions
                if (xSplit2[0] == "=>")
                {
                    mEIPHere = true;
                    xIndex   = 1;
                }
                mAddr = Global.FromHexWithLeadingZeroX(xSplit2[xIndex]);
                string xLabel;

                if (xSplit2.Length > xIndex + 1)
                {
                    xLabel = xSplit2[xIndex + 1];
                }

                xSplit2 = xSplit1[1].Split(Global.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries);
                mOp     = xSplit2[0];
                if (xSplit2.Length > 1)
                {
                    for (int j = 1; j < xSplit2.Length; j++)
                    {
                        mData += xSplit2[j] + " ";
                    }
                    mData = mData.TrimEnd();
                }
            }
예제 #2
0
        protected void OnDisassemble(GDB.Response xResponse)
        {
            var xResult = xResponse.Text;

            // In some cases GDB might return no results. This is common when no symbols are loaded.
            if (xResult.Count == 0)
            {
                return;
            }
            // Get function name
            var xSplit = GDB.Unescape(xResult[0]).Split(Global.SpaceSeparator, StringSplitOptions.RemoveEmptyEntries);

            mFuncName = xSplit[xSplit.Length - 1];
            textCurrentFunction.Text = mFuncName;

            // remove ':'
            mFuncName = mFuncName.Substring(0, mFuncName.Length - 1);

            int labelLine = Global.AsmSource.GetLineOfLabel(mFuncName);

            labelLine++;

            // 1 and -2 to eliminate header and footer line
            for (int i = 1; i <= xResult.Count - 2; i++, labelLine++)
            {
                var asmLine = Global.AsmSource.Lines[labelLine];

                while (asmLine.IsLabel ||
                       (asmLine.FirstToken != null && (asmLine.FirstToken == "global" || asmLine.FirstToken.StartsWith(";"))))
                {
                    labelLine++;
                    asmLine = Global.AsmSource.Lines[labelLine];
                }

                var gdbLine = new GdbAsmLine(xResult[i]);
                asmLine.Address = gdbLine.mAddr;

                // check if line different, if so, we set a line for tooltip
                string strGdbLine                 = gdbLine.ToString();
                string gdbLineWithoutAddress      = strGdbLine.Substring(strGdbLine.IndexOf(":") + 3);
                string gdbLineWithoutAddressLower = gdbLineWithoutAddress.Replace(" ", string.Empty).ToLower().Replace("dwordptr", string.Empty);

                string asmlineFromFile             = asmLine.OrignalLine.TrimStart('\t', ' ').ToLower().Replace("dword", string.Empty);
                string asmlineFromFileWithoutspace = asmlineFromFile.Replace(" ", string.Empty);
                if (gdbLineWithoutAddressLower != asmlineFromFileWithoutspace)
                {
                    asmLine.GDBLine = gdbLineWithoutAddress;
                }
            }
        }