예제 #1
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));
            }
        }
예제 #2
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));
            }
        }
예제 #3
0
        public ulong FollowMainPointer(long[] jumps)
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.FollowMainPointer(jumps);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[17];
                var _      = ReadInternal(buffer);
                var bytes  = Decoder.ConvertHexByteStringToBytes(buffer);
                return(BitConverter.ToUInt64(bytes, 0));
            }
        }
예제 #4
0
파일: USBBot.cs 프로젝트: val7x/NHSE
        public byte[] ReadBytes(uint offset, int length)
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.PeekRaw(offset, length);
                SendInternal(cmd);

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

                var buffer = new byte[length];
                var _      = ReadInternal(buffer);
                //return Decoder.ConvertHexByteStringToBytes(buffer);
                return(buffer);
            }
        }
예제 #5
0
        public void WriteBytes(byte[] data, uint offset)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset);
            }
            else
            {
                lock (_sync)
                {
                    SendInternal(SwitchCommand.Poke(offset, data));

                    // give it time to push data back
                    Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
                }
            }
        }
예제 #6
0
        public void WriteBytes(byte[] data, uint offset)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset);
            }
            else
            {
                lock (_sync)
                {
                    AndroidUSBUtils.CurrentInstance.WriteToEndpoint(SwitchCommand.PokeRaw(offset, data));

                    // give it time to push data back
                    Thread.Sleep((data.Length / 256) + 100);
                }
            }
        }
예제 #7
0
        public byte[] ReadBytes(uint offset, int length)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length));
            }
            lock (_sync)
            {
                var cmd = SwitchCommand.Peek(offset, length);
                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));
            }
        }
예제 #8
0
        public byte[] ReadBytes(uint offset, int length)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length));
            }
            lock (_sync)
            {
                byte[] cmd = SwitchCommand.PeekRaw(offset, length);
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(cmd);

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

                byte[] buffer = AndroidUSBUtils.CurrentInstance.ReadEndpoint(length);
                return(buffer);
            }
        }