Exemple #1
0
        public void LoadPayload(bool suspendStream = true)
        {
            var  originalMemory = new List <Tuple <uint, byte[]> >();
            bool success        = true;

            if (suspendStream)
            {
                Config.Stream.Suspend();
            }

            foreach (var(address, data) in _payload)
            {
                // Hacks are entered as big endian; we need to swap the address endianess before writing
                var fixedAddress = EndiannessUtilities.SwapAddressEndianness(address, data.Length);

                // Read original memory before replacing
                originalMemory.Add(new Tuple <uint, byte[]>(fixedAddress, Config.Stream.ReadRam((UIntPtr)fixedAddress, data.Length, EndiannessType.Big)));
                success &= Config.Stream.WriteRam(data, fixedAddress, EndiannessType.Big);
            }

            if (suspendStream)
            {
                Config.Stream.Resume();
            }

            // Update original memory upon success
            if (success)
            {
                _originalMemory.Clear();
                _originalMemory.AddRange(originalMemory);
            }

            Enabled = success;
        }
Exemple #2
0
        public static uint GetRelativeAddressFromAbsoluteAddress(uint addr, int byteCount)
        {
            UIntPtr addressPtr = new UIntPtr(addr);
            uint    address    = EndiannessUtilities.SwapAddressEndianness(
                Config.Stream.GetRelativeAddress(addressPtr, byteCount), byteCount);

            return(address | 0x80000000);
        }
Exemple #3
0
        public uint GetRamAddress(bool addressArea = true, List <uint> addresses = null)
        {
            List <uint> addressList = addresses ?? AddressList;

            if (addressList.Count == 0)
            {
                return(0);
            }

            UIntPtr addressPtr = new UIntPtr(addressList[0]);
            uint    address;

            if (UseAbsoluteAddressing)
            {
                address = EndiannessUtilities.SwapAddressEndianness(
                    Config.Stream.GetRelativeAddress(addressPtr, ByteCount.Value), ByteCount.Value);
            }
            else
            {
                address = addressPtr.ToUInt32();
            }

            return(addressArea ? address | 0x80000000 : address& 0x0FFFFFFF);
        }