コード例 #1
0
        public Disassembly(USBGecko UGecko, String UVdappPath, ListBox UMainBox,
                           VScrollBar UScroll, TextBox UAInput, TextBox UASAddress, TextBox UASText, ExceptionHandler UEXCHandler)
        {
            gecko             = UGecko;
            exceptionHandling = UEXCHandler;
            vdappPath         = UVdappPath;
            if (!GlobalFunctions.tryToHex(GeckoApp.Properties.Settings.Default.MemViewAddr, out cAddress))
            {
                // If the restored value is corrupt, use this instead
                cAddress = 0x80003100;
            }
            scrollbar   = UScroll;
            mainBox     = UMainBox;
            adressInput = UAInput;
            asAddress   = UASAddress;
            asText      = UASText;

            mainBox.SelectedIndexChanged += MainBoxClick;
            mainBox.DoubleClick          += MainBoxDoubleClick;
            mainBox.KeyDown  += MainBoxKeyDown;
            scrollbar.Scroll += Scrolling;

#if MONO
            GAs = "powerpc-eabi-as";
            GLd = "powerpc-eabi-ld";
            GOc = "powerpc-eabi-objcopy";
#else
            GAs = "powerpc-gekko-as.exe";
            GLd = "powerpc-gekko-ld.exe";
            GOc = "powerpc-gekko-objcopy.exe";
#endif
        }
コード例 #2
0
        private bool ValidUserMask(out uint mask)
        {
            if (radioButton32Bit.Checked)
            {
                mask = 0;
                return(true);
            }

            if (!GlobalFunctions.tryToHex(textBoxMask.Text, out mask))
            {
                MessageBox.Show("Invalid mask");
                textBoxMask.Focus();
                textBoxMask.SelectAll();
                return(false);
            }

            if (mask > 0xFFFF)
            {
                MessageBox.Show("mask must be <= FFFF");
                textBoxMask.Focus();
                textBoxMask.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #3
0
        private bool ValidUserFill(out uint fill)
        {
            if (radioButton32Bit.Checked)
            {
                fill = 0;
                return(true);
            }

            if (comboBoxCodeSubType.SelectedIndex == 0)
            {
                fill = 0;
                return(true);
            }

            if (!GlobalFunctions.tryToHex(textBoxFill.Text, out fill))
            {
                MessageBox.Show("Invalid fill");
                textBoxFill.Focus();
                textBoxFill.SelectAll();
                return(false);
            }

            if (fill > 0xFFFF)
            {
                MessageBox.Show("fill must be <= FFFF");
                textBoxFill.Focus();
                textBoxFill.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #4
0
        private bool ValidUserAddress(out uint address)
        {
            if (!GlobalFunctions.tryToHex(textBoxAddress.Text, out address) ||
                !ValidMemory.validAddress(address))
            {
                MessageBox.Show("Invalid address");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            if (radioButton16Bit.Checked && ((address & 1) != 0))
            {
                MessageBox.Show("address must be multiple of 2");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }
            else if (radioButton32Bit.Checked && ((address & 3) != 0))
            {
                MessageBox.Show("address must be multiple of 4");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #5
0
        private bool ValidUserValue(out uint value)
        {
            if (!GlobalFunctions.tryToHex(textBoxValue.Text, out value))
            {
                MessageBox.Show("Invalid value");
                textBoxValue.Focus();
                textBoxValue.SelectAll();
                return(false);
            }

            if (radioButton16Bit.Checked && value > 0xFFFF)
            {
                MessageBox.Show("value must be <= FFFF");
                textBoxValue.Focus();
                textBoxValue.SelectAll();
                return(false);
            }
            else if (radioButton8Bit.Checked && value > 0xFF)
            {
                MessageBox.Show("value must be <= FF");
                textBoxValue.Focus();
                textBoxValue.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #6
0
        private bool ValidUserFill(out UInt32 fill)
        {
            if (radioButton32Bit.Checked)
            {
                // fill is unused by 32-bit if
                fill = 0;
                return(true);
            }

            if (comboBoxCodeSubType.SelectedIndex == 0)
            {
                // "Write" sub-type is a fill of 0!
                fill = 0;
                return(true);
            }

            if (!GlobalFunctions.tryToHex(textBoxFill.Text, out fill))
            {
                MessageBox.Show("Invalid fill");
                textBoxFill.Focus();
                textBoxFill.SelectAll();
                return(false);
            }

            if (fill > 0xFFFF)
            {
                MessageBox.Show("fill must be <= FFFF");
                textBoxFill.Focus();
                textBoxFill.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #7
0
        private bool ValidUserAddress(out UInt32 address)
        {
            // Is it a valid 32-bit hexadecimal address?
            if (!GlobalFunctions.tryToHex(textBoxAddress.Text, out address) ||
                !ValidMemory.validAddress(address))
            {
                MessageBox.Show("Invalid address");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            // Check alignment
            if (radioButton16Bit.Checked && ((address & 1) != 0))
            {
                MessageBox.Show("address must be multiple of 2");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }
            else if (radioButton32Bit.Checked && ((address & 3) != 0))
            {
                MessageBox.Show("address must be multiple of 4");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            return(true);
        }
コード例 #8
0
        private void MainBoxDoubleClick(object sender, EventArgs e)
        {
            int index = mainBox.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            string assembly = mainBox.Items[index].ToString();

            assembly = assembly.Substring(20, assembly.Length - 20);
            string[] sep = assembly.Split(new char[1] {
                '\t'
            }, StringSplitOptions.RemoveEmptyEntries);

            sep[0] = sep[0].ToLower();
            if (sep[0].StartsWith("b") && sep.Length > 1)
            {
                sep[1] = sep[1].Substring(sep[1].IndexOf("0x"));

                uint bAddress;
                if (GlobalFunctions.tryToHex(sep[1], out bAddress) && ValidMemory.validAddress(bAddress))
                {
                    DissToBox(bAddress);
                }
            }
        }
コード例 #9
0
ファイル: breakpoints.cs プロジェクト: hinxx/imgecko
        public UInt32 GetRegisterValue(int regIndex)
        {
            if (regIndex >= BPList.longRegNames.Length)
            {
                return(0);
            }
            uint foo = 0;

            GlobalFunctions.tryToHex(bpOutput.longRegTextBox[regIndex].Text, out foo);
            return(foo);
        }
コード例 #10
0
        private bool extractTargetAddress(UInt32 address, ref String command)
        {
            if (command.ToLower().Contains("lr") || command.Contains("ctr"))
            {
                return(true);
            }
            String[] parts = command.ToLower().Split(new char[1] {
                ' '
            });
            String[] orgparts = command.Split(new char[1] {
                ' '
            });
            String numeric = parts[parts.Length - 1];
            String number;
            bool   hex;

            if (numeric.Substring(0, 2) == "0x")
            {
                number = numeric.Substring(2, numeric.Length - 2);
                hex    = true;
            }
            else
            {
                number = numeric;
                hex    = false;
            }

            UInt32 tAddress;
            bool   result;

            if (hex)
            {
                result = GlobalFunctions.tryToHex(number, out tAddress);
            }
            else
            {
                result = UInt32.TryParse(number, out tAddress);
            }

            if (result)
            {
                Int32 offset = (Int32)((long)tAddress - (long)address);
                orgparts[orgparts.Length - 1] = "0x" + GlobalFunctions.toHex(offset);
                command = "";
                for (int i = 0; i < orgparts.Length; i++)
                {
                    command += orgparts[i] + " ";
                }
                command = command.Trim();
            }

            return(result);
        }
コード例 #11
0
        private void CheckInput_Click(object sender, EventArgs e)
        {
            UInt32 tryHex;

            if (GlobalFunctions.tryToHex(PValue.Text, out tryHex))
            {
                inputValue   = tryHex;
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Invalid value!");
            }
        }
コード例 #12
0
ファイル: breakpoints.cs プロジェクト: hinxx/imgecko
        public static BreakpointCondition FromString(String cond)
        {
            if (cond == String.Empty)
            {
                return(null);
            }
            String[] sep      = cond.Split(new char[] { ' ', ':' });
            int      register = Convert.ToInt32(BPList.regTextToID(sep[2]));

            if (sep[2] == "VoA")
            {
                register = BPList.longRegNames.Length;
            }

            uint value;

            if (!(GlobalFunctions.tryToHex(sep[4], out value)))
            {
                return(null);
            }
            uint group = Convert.ToUInt32(sep[0]);
            BreakpointComparison comp;

            switch (sep[3])
            {
            case "==":
                comp = BreakpointComparison.Equal; break;

            case "!=":
                comp = BreakpointComparison.NotEqual; break;

            case ">":
                comp = BreakpointComparison.Greater; break;

            case ">=":
                comp = BreakpointComparison.GreaterEqual; break;

            case "<":
                comp = BreakpointComparison.Lower; break;

            case "<=":
                comp = BreakpointComparison.LowerEqual; break;

            default:
                comp = BreakpointComparison.Equal; break;
            }
            return(new BreakpointCondition(register, value, comp, group));
        }
コード例 #13
0
        private void MainBoxDoubleClick(object sender, EventArgs e)
        {
            int index = mainBox.SelectedIndex;

            // If index is negative, bail out
            if (index == -1)
            {
                return;
            }

            // Grab the instruction that they selected
            String assembly = mainBox.Items[index].ToString();

            assembly = assembly.Substring(20, assembly.Length - 20);
            String[] sep = assembly.Split(new char[1] {
                '\t'
            }, StringSplitOptions.RemoveEmptyEntries);

            // Is it some sort of branch?  Does it have an address parameter?
            sep[0] = sep[0].ToLower();
            if (sep[0].StartsWith("b") && sep.Length > 1)
            {
                // Most of the time, this won't matter
                // However, some branches specify the cr (e.g. bge- cr6,0x802e583c)
                // So parse out anything before the 0x
                sep[1] = sep[1].Substring(sep[1].IndexOf("0x"));

                // Does it have a valid address after it?
                UInt32 bAddress;
                if (GlobalFunctions.tryToHex(sep[1], out bAddress) && ValidMemory.validAddress(bAddress))
                {
                    // tell the disassembly window to jump there
                    DissToBox(bAddress);
                }
            }
        }