コード例 #1
0
        public bool GetInstructions(uint aAddress, TArmInstructionSet aInstructionSet, int aCount, out IArmInstruction[] aInstructions)
        {
            bool valid = false;

            aInstructions = new IArmInstruction[0];

            // We need the code and the instruction converter
            if (IsCodeAvailable && IfaceInstructionConverter != null)
            {
                // Check range is valid
                AddressRange range = new AddressRange(iBaseAddress, 0);
                range.UpdateMax(range.Min + iCode.Length);
                uint extent = aAddress + ((uint)aCount * (uint)aInstructionSet);
                //
                valid = range.Contains(aAddress) && range.Contains(extent);
                if (valid)
                {
                    List <uint> rawInstructions = new List <uint>();
                    //
                    using (SymbianStreamReaderLE reader = SymbianStreamReaderLE.New(new MemoryStream(iCode)))
                    {
                        uint address = aAddress - iBaseAddress;
                        reader.Seek(address);
                        //
                        for (int i = 0; i < aCount; i++)
                        {
                            uint value = 0;
                            //
                            switch (aInstructionSet)
                            {
                            case TArmInstructionSet.ETHUMB:
                                value = reader.ReadUInt16();
                                break;

                            case TArmInstructionSet.EARM:
                                value = reader.ReadUInt32();
                                break;

                            default:
                            case TArmInstructionSet.EJAZELLE:
                                throw new NotSupportedException("Jazelle is not supported");
                            }
                            //
                            rawInstructions.Add(value);
                            address += (uint)aInstructionSet;
                        }
                    }
                    //
                    aInstructions = iInstructionConverter.ConvertRawValuesToInstructions(aInstructionSet, rawInstructions.ToArray(), aAddress);
                }
            }

            // Return empty array if not valid
            return(valid);
        }
コード例 #2
0
        public bool IsInstructionAddressValid(uint aAddress)
        {
            bool valid = false;

            //
            if (IsCodeAvailable)
            {
                AddressRange range = new AddressRange(this.BaseAddress, 0);
                range.UpdateMax(range.Min + iCode.Length);
                //
                valid = range.Contains(aAddress);
            }
            //
            return(valid);
        }