/// <summary> /// Write Paritioned Bytes to the Wii U /// </summary> /// <param name="address">Address to write to</param> /// <param name="byteChunks">Partitioned Bytes to write</param> private void WritePartitionedBytes(uint address, IEnumerable <byte[]> byteChunks) { IEnumerable <byte[]> enumerable = byteChunks as IList <byte[]> ?? byteChunks.ToList(); var length = (uint)enumerable.Sum(chunk => chunk.Length); try { SendCommand(GeckoUCommands.Command.COMMAND_UPLOAD_MEMORY); uint bytesRead = 0; var start = BitConverter.GetBytes(ByteSwap.Swap(address)); var end = BitConverter.GetBytes(ByteSwap.Swap(address + length)); GUC.Write(start, 4, ref bytesRead); GUC.Write(end, 4, ref bytesRead); enumerable.Aggregate(address, UploadBytes); } catch (Exception Error) { Console.Write(Error.Message); } }
/// <summary> /// Call a function from an RPL/RPX /// </summary> /// <param name="address">The function address to call</param> /// <param name="args">The arguements to pass through</param> /// <returns>UInt64</returns> public UInt64 CallFunction64(uint address, params uint[] args) { byte[] buffer = new Byte[4 + 8 * 4]; address = ByteSwap.Swap(address); BitConverter.GetBytes(address).CopyTo(buffer, 0); for (int i = 0; i < 8; i++) { if (i < args.Length) { BitConverter.GetBytes(ByteSwap.Swap(args[i])).CopyTo(buffer, 4 + i * 4); } else { BitConverter.GetBytes(0xfecad0ba).CopyTo(buffer, 4 + i * 4); } } if (RawCommand(GeckoUCommands.cmd_rpc) != FTDICommand.CMD_OK) { throw new GeckoUException(GeckoUException.ETCPErrorCode.FTDICommandSendError); } if (GeckoUWrite(buffer, buffer.Length) != FTDICommand.CMD_OK) { throw new GeckoUException(GeckoUException.ETCPErrorCode.FTDICommandSendError); } if (GeckoURead(buffer, 8) != FTDICommand.CMD_OK) { throw new GeckoUException(GeckoUException.ETCPErrorCode.FTDICommandSendError); } return(ByteSwap.Swap(BitConverter.ToUInt64(buffer, 0))); }
public UInt32 ReadAddress32(UInt32 addressToRead) { //dumpStream.Seek(addressToRead - startAddress, SeekOrigin.Begin); //byte [] buffer = new byte[4]; //dumpStream.Read(buffer, 0, 4); if (addressToRead < startAddress) { return(0); } if (addressToRead > endAddress - 4) { return(0); } Byte[] buffer = new Byte[4]; Buffer.BlockCopy(mem, index(addressToRead), buffer, 0, 4); //GeckoApp.SubArray<byte> buffer = new GeckoApp.SubArray<byte>(mem, (int)(addressToRead - startAddress), 4); //Read buffer UInt32 result = BitConverter.ToUInt32(buffer, 0); //Swap to machine endianness and return return(ByteSwap.Swap(result)); }