コード例 #1
0
 public bool ReadOffset(ulong offset, RWMethod method = RWMethod.Heap)
 {
     byte[] data;
     if (Bot.com is not ICommunicatorNX nx)
     {
         data = Bot.ReadOffset(offset);
     }
コード例 #2
0
        private void WriteBytesLarge(byte[] data, ulong offset, RWMethod method)
        {
            int byteCount = data.Length;

            for (int i = 0; i < byteCount; i += MaximumTransferSize)
            {
                WriteBytes(SubArray(data, i, MaximumTransferSize), offset + (uint)i, method);
            }
        }
コード例 #3
0
        private byte[] ReadBytesLarge(ulong offset, int length, RWMethod method)
        {
            List <byte> read = new List <byte>();

            for (int i = 0; i < length; i += MaximumTransferSize)
            {
                read.AddRange(ReadBytes(offset + (uint)i, Math.Min(MaximumTransferSize, length - i), method));
            }
            return(read.ToArray());
        }
コード例 #4
0
 private byte[] ReadData(ulong offset, RWMethod method)
 {
     if (Bot.com is not ICommunicatorNX nx)
     {
         return(Bot.ReadOffset(offset));
     }
     return(method switch
     {
         RWMethod.Heap => Bot.ReadOffset(offset),
         RWMethod.Main => nx.ReadBytesMain(offset, Bot.SlotSize),
         RWMethod.Absolute => nx.ReadBytesAbsolute(offset, Bot.SlotSize),
         _ => Bot.ReadOffset(offset),
     });
コード例 #5
0
ファイル: USBBot.cs プロジェクト: x4317350/ACNHMobileSpawner
        public void WriteBytes(byte[] data, ulong offset, RWMethod method = RWMethod.Heap)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset, method);
            }
            lock (_sync)
            {
                SendInternal(SwitchCommandMethodHelper.GetPokeCommand(offset, data, method, true));

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
            }
        }
コード例 #6
0
        public bool ReadOffset(ulong offset, RWMethod method = RWMethod.Heap)
        {
            var data = ReadData(offset, method);
            var pkm  = SAV.SAV.GetDecryptedPKM(data);

            // Since data might not actually exist at the user-specified offset, double check that the pkm data is valid.
            if (!pkm.ChecksumValid)
            {
                return(false);
            }

            Editor.PopulateFields(pkm);
            return(true);
        }
コード例 #7
0
        public static byte[] GetPokeCommand(ulong offset, byte[] data, RWMethod method, bool usb)
        {
            switch (method)
            {
            case RWMethod.Heap when !usb: return(SwitchCommand.Poke((uint)offset, data));

            case RWMethod.Heap when usb: return(SwitchCommand.PokeRaw((uint)offset, data));

            case RWMethod.Main: return(SwitchCommand.PokeMain(offset, data));

            case RWMethod.Absolute: return(SwitchCommand.PokeAbsolute(offset, data));

            default: return(SwitchCommand.Poke((uint)offset, data));
            }
        }
コード例 #8
0
        public static byte[] GetPeekCommand(ulong offset, int count, RWMethod method, bool usb)
        {
            switch (method)
            {
            case RWMethod.Heap when !usb: return(SwitchCommand.Peek((uint)offset, count));

            case RWMethod.Heap when usb: return(SwitchCommand.PeekRaw((uint)offset, count));

            case RWMethod.Main: return(SwitchCommand.PeekMain(offset, count));

            case RWMethod.Absolute: return(SwitchCommand.PeekAbsolute(offset, count));

            default: return(SwitchCommand.Peek((uint)offset, count));
            }
        }
コード例 #9
0
        public void WriteBytes(byte[] data, ulong offset, RWMethod method = RWMethod.Heap)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset, method);
            }
            else
            {
                lock (_sync)
                {
                    AndroidUSBUtils.CurrentInstance.WriteToEndpoint(SwitchCommandMethodHelper.GetPokeCommand(offset, data, method, true));

                    // give it time to push data back
                    Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
                }
            }
        }
コード例 #10
0
        public byte[] ReadBytes(ulong offset, int length, RWMethod method = RWMethod.Heap)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length, method));
            }
            lock (_sync)
            {
                byte[] cmd = SwitchCommandMethodHelper.GetPeekCommand(offset, length, method, true);
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());

                byte[] buffer = AndroidUSBUtils.CurrentInstance.ReadEndpoint(length);
                return(buffer);
            }
        }
コード例 #11
0
ファイル: SysBot.cs プロジェクト: cpurse89/ACNHMobileSpawner
        public byte[] ReadBytes(ulong offset, int length, RWMethod method = RWMethod.Heap)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length, method));
            }
            lock (_sync)
            {
                var cmd = SwitchCommandMethodHelper.GetPeekCommand(offset, length, method, false);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[(length * 2) + 1];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }
コード例 #12
0
        public void WriteBytes(byte[] data, ulong offset, RWMethod method)
        {
            lock (_sync)
            {
                var cmd = method switch
                {
                    RWMethod.Heap => SwitchCommand.Poke((uint)offset, data),
                    RWMethod.Main => SwitchCommand.PokeMain(offset, data),
                    RWMethod.Absolute => SwitchCommand.PokeAbsolute(offset, data),
                    _ => SwitchCommand.Poke((uint)offset, data)
                };

                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + 100);
            }
        }
コード例 #13
0
 public SimpleHexEditor(byte[] originalBytes, PokeSysBotMini?bot = null, ulong addr = 0, RWMethod rwm = RWMethod.Heap)
 {
     InitializeComponent();
     this.TranslateInterface(WinFormsTranslator.CurrentLanguage);
     PG_BlockView.Size = RTB_RAM.Size;
     refresh.Interval  = (double)RT_Timer.Value;
     refresh.Elapsed  += new ElapsedEventHandler(AutoRefresh);
     refresh.AutoReset = false;
     if (addr == 0 || bot == null)
     {
         CB_AutoRefresh.Enabled = RT_Timer.Enabled = RT_Label.Enabled = false;
     }
     Bytes   = originalBytes;
     address = addr;
     method  = rwm;
     psb     = bot;
     CB_CopyMethod.DataSource   = Enum.GetValues(typeof(CopyMethod)).Cast <CopyMethod>();
     CB_CopyMethod.SelectedItem = CopyMethod.Bytes;
     RTB_RAM.Text = string.Join(" ", originalBytes.Select(z => $"{z:X2}"));
     Bytes        = originalBytes;
 }
コード例 #14
0
        public byte[] ReadBytes(ulong offset, int length, RWMethod method)
        {
            lock (_sync)
            {
                var cmd = method switch
                {
                    RWMethod.Heap => SwitchCommand.Peek((uint)offset, length),
                    RWMethod.Main => SwitchCommand.PeekMain(offset, length),
                    RWMethod.Absolute => SwitchCommand.PeekAbsolute(offset, length),
                    _ => SwitchCommand.Peek((uint)offset, length)
                };

                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + 100);
                var buffer = new byte[(length * 2) + 1];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }