예제 #1
0
        public bool Compare(Stream regStream, BreakpointType bpType, UInt32 bpAddress, USBGecko gecko)
        {
            if (regStream.Length != 0x120)
            {
                return(false);
            }

            int spos = PRegister * 4;

            UInt32 val = 0;

            if (spos == 0x120) //Value of address is supposed to be checked
            {
                switch (bpType)
                {
                case BreakpointType.Read:
                    val = gecko.peek(bpAddress);
                    break;

                case BreakpointType.ReadWrite:
                case BreakpointType.Write:
                    gecko.Step();
                    val = gecko.peek(bpAddress);
                    break;

                default:
                    return(true);
                }
            }
            else
            {
                regStream.Seek(spos, SeekOrigin.Begin);
                val = GlobalFunctions.ReadStream(regStream);
            }

            switch (PCondition)
            {
            case BreakpointComparison.Equal:
                return(val == PValue);

            case BreakpointComparison.NotEqual:
                return(val != PValue);

            case BreakpointComparison.Greater:
                return(val > PValue);

            case BreakpointComparison.GreaterEqual:
                return(val >= PValue);

            case BreakpointComparison.Lower:
                return(val < PValue);

            case BreakpointComparison.LowerEqual:
                return(val <= PValue);
            }

            return(true);
        }
예제 #2
0
        public bool Compare(Stream regStream, BreakpointType bpType, uint bpAddress, TCPGecko gecko)
        {
            if (regStream.Length != 0x120)
            {
                return(false);
            }

            int spos = PRegister * 4;

            uint val = 0;

            if (spos == 0x120)
            {
                switch (bpType)
                {
                case BreakpointType.Read:
                    val = gecko.peek(bpAddress);
                    break;

                case BreakpointType.ReadWrite:
                case BreakpointType.Write:
                    gecko.Step();
                    val = gecko.peek(bpAddress);
                    break;

                default:
                    return(true);
                }
            }
            else
            {
                regStream.Seek(spos, SeekOrigin.Begin);
                val = GlobalFunctions.ReadStream(regStream);
            }

            switch (PCondition)
            {
            case BreakpointComparison.Equal:
                return(val == value);

            case BreakpointComparison.NotEqual:
                return(val != value);

            case BreakpointComparison.Greater:
                return(val > value);

            case BreakpointComparison.GreaterEqual:
                return(val >= value);

            case BreakpointComparison.Lower:
                return(val < value);

            case BreakpointComparison.LowerEqual:
                return(val <= value);
            }

            return(true);
        }
예제 #3
0
        public void Assemble(UInt32 address, String command)
        {
            if (!File.Exists(GAs))
            {
                MessageBox.Show(GAs + " not found! Cannot assemble!");
                return;
            }

            if (!File.Exists(GLd))
            {
                MessageBox.Show(GLd + " not found! Cannot assemble!");
                return;
            }

            if (!File.Exists(GOc))
            {
                MessageBox.Show(GOc + " not found! Cannot assemble!");
                return;
            }

            command = command.Trim();

            if (isBranch(command))
            {
                if (!extractTargetAddress(address, ref command))
                {
                    MessageBox.Show("Command parsing error!");
                    return;
                }
            }

            StreamWriter sw = new StreamWriter("ass.txt");

            sw.WriteLine(command);
            sw.Close();

            Process proc = new Process();

            proc.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            proc.StartInfo.UseShellExecute       = false;
            proc.StartInfo.FileName              = GAs;
            proc.StartInfo.Arguments             = "-mgekko -mregnames -o ass.o ass.txt";
            proc.StartInfo.CreateNoWindow        = true;
            proc.StartInfo.RedirectStandardError = true;
            proc.Start();
            String output = String.Empty;

            while (!proc.StandardError.EndOfStream)
            {
                output += proc.StandardError.ReadLine() + "\n";
            }
            proc.WaitForExit(/*2000*/);
            int exitCode = proc.ExitCode;

            proc.Close();
            File.Delete("ass.txt");
            if (exitCode != 0 || !File.Exists("ass.o"))
            {
                if (File.Exists("ass.o"))
                {
                    File.Delete("ass.o");
                }
                MessageBox.Show(output);
                return;
            }

            proc = new Process();
            proc.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            proc.StartInfo.UseShellExecute       = false;
            proc.StartInfo.FileName              = GLd;
            proc.StartInfo.Arguments             = " -Ttext 0x80000000 -o ass2.o ass.o";
            proc.StartInfo.CreateNoWindow        = true;
            proc.StartInfo.RedirectStandardError = true;
            proc.Start();
            output = String.Empty;
            while (!proc.StandardError.EndOfStream)
            {
                output += proc.StandardError.ReadLine() + "\n";
            }
            proc.WaitForExit();

            exitCode = proc.ExitCode;
            proc.Close();
            File.Delete("ass.o");
            if (exitCode != 0 || !File.Exists("ass2.o"))
            {
                if (File.Exists("ass2.o"))
                {
                    File.Delete("ass2.o");
                }
                MessageBox.Show(output);
                return;
            }

            proc = new Process();
            proc.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            proc.StartInfo.UseShellExecute       = false;
            proc.StartInfo.FileName              = GOc;
            proc.StartInfo.Arguments             = " -O binary ass2.o ass.bin";
            proc.StartInfo.CreateNoWindow        = true;
            proc.StartInfo.RedirectStandardError = true;
            proc.Start();
            output = String.Empty;
            while (!proc.StandardError.EndOfStream)
            {
                output += proc.StandardError.ReadLine() + "\n";
            }
            proc.WaitForExit();

            exitCode = proc.ExitCode;
            proc.Close();
            File.Delete("ass2.o");
            if (exitCode != 0)
            {
                if (File.Exists("ass.bin"))
                {
                    File.Delete("ass.bin");
                }
                MessageBox.Show(output);
                return;
            }

            UInt32     machineCode;
            FileStream sr = new FileStream("ass.bin", FileMode.Open);

            machineCode = GlobalFunctions.ReadStream(sr);
            sr.Close();
            File.Delete("ass.bin");

            try
            {
                gecko.poke(address, machineCode);

                System.Threading.Thread.Sleep(100);
                DissToBox(address);
            }
            catch (EUSBGeckoException e)
            {
                exceptionHandling.HandleException(e);
            }
        }
예제 #4
0
        private void GetRegisters(Stream regStream)
        {
            regStream.Seek(0, SeekOrigin.Begin);
            String regValue;
            UInt32 rStream;

            UInt32[] allReg = new UInt32[72];
            for (int i = 0; i < 72; i++)
            {
                rStream = GlobalFunctions.ReadStream(regStream);

                if (i < 40)
                {
                    changableRegs[i] = rStream;
                }
                allReg[i] = rStream;

                if (i < 40 || ShowFloatsInHex)
                {
                    regValue = GlobalFunctions.toHex(rStream);
                }
                else
                {
                    regValue = GlobalFunctions.UIntToSingle(rStream).ToString("G8");
                }
                bpOutput.longRegTextBox[i].Text = regValue; // TODO: invoke required?
            }
            listSet = true;
            regStream.Close();

            String output = "";

            for (int i = 0; i < 72; i++)
            {
                output += BPList.longRegNames[bpOutput.longRegIDs[i]] + ":" +
                          GlobalFunctions.toHex(allReg[bpOutput.longRegIDs[i]]);
                if (i % 4 == 3 && i != 71)
                {
                    output += "\r\n";
                }
                else if (i % 4 != 3)
                {
                    output += " ";
                }

                if (i == 39)
                {
                    output += "\r\n";
                }
            }

            InvokeClassicTextBoxUpdate(output);

            // Make sure that (SRR0?) contains a valid address
            // Otherwise we might not be pointing at any valid memory to pass to disassemble
            if (ValidMemory.validAddress(changableRegs[5]))
            {
                UInt32 assAdd = changableRegs[5];
                PHitAddress = assAdd;   // cache this for later

                // Fill an array of strings with instructions
                // TODO: subtract back some so we can see what comes BEFORE the assembly address...
                String[] assembly = disassembler.DissToBox(assAdd);

                // Grab the first (i.e. current) instruction
                if (assembly.Length > 0)
                {
                    String fCommand = assembly[0];
                    currentInstructionAndAddress = fCommand;
                    fCommand = fCommand.Substring(20, fCommand.Length - 20);

                    // Split it along tabs so we can extract the operation
                    String[] sep = fCommand.Split(new char[1] {
                        '\t'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    currentInstruction = sep;
                    fCommand           = sep[0].ToLower();

                    // If we're doing a branch-and-link, make a note that we can step over it
                    stepOverPossible = (fCommand == "bl" || fCommand == "bctrl");

                    GetMemoryAddress(sep);

                    UpdateBranchState(sep);
                }

                InvokeDissBoxUpdate(assembly);
            }
        }
예제 #5
0
        private void GetRegisters(Stream regStream)
        {
            regStream.Seek(0, SeekOrigin.Begin);
            string regValue;
            uint   rStream;

            uint[] allReg = new uint[72];
            for (int i = 0; i < 72; i++)
            {
                rStream = GlobalFunctions.ReadStream(regStream);

                if (i < 40)
                {
                    changableRegs[i] = rStream;
                }
                allReg[i] = rStream;

                if (i < 40 || ShowFloatsInHex)
                {
                    regValue = GlobalFunctions.toHex(rStream);
                }
                else
                {
                    regValue = GlobalFunctions.UIntToSingle(rStream).ToString("G8");
                }
                if (i > 40)
                {
                    GlobalFunctions.ReadStream(regStream);
                }
                bpOutput.longRegTextBox[i].Text = regValue;
            }
            listSet = true;
            regStream.Close();

            string output = string.Empty;

            for (int i = 0; i < 72; i++)
            {
                output += BPList.longRegNames[bpOutput.longRegIDs[i]] + ":" +
                          GlobalFunctions.toHex(allReg[bpOutput.longRegIDs[i]]);
                if (i % 4 == 3 && i != 71)
                {
                    output += "\r\n";
                }
                else if (i % 4 != 3)
                {
                    output += " ";
                }

                if (i == 39)
                {
                    output += "\r\n";
                }
            }

            InvokeClassicTextBoxUpdate(output);

            if (ValidMemory.validAddress(changableRegs[5]))
            {
                uint assAdd = changableRegs[5];
                hitAddress = assAdd;

                string[] assembly = disassembler.DissToBox(assAdd);

                if (assembly.Length > 0)
                {
                    string fCommand = assembly[0];
                    currentInstructionAndAddress = fCommand;
                    fCommand = fCommand.Substring(20, fCommand.Length - 20);

                    string[] sep = fCommand.Split(new char[1] {
                        '\t'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    currentInstruction = sep;
                    fCommand           = sep[0].ToLower();

                    stepOver = (fCommand == "bl" || fCommand == "bctrl");

                    GetMemoryAddress(sep);

                    UpdateBranchState(sep);
                }

                InvokeDissBoxUpdate(assembly);
            }
        }