コード例 #1
0
        public override int Read(byte[] Data, int Offset, int Count)
        {
            if (!IsOpen || IsDisposed)
            {
                throw new Exception("XboxMemoryStream.Read: The XMS stream is not open.");
            }
            if (Position < 0 || Position > uint.MaxValue)
            {
                throw new Exception("XboxMemoryStream.Read: Invalid position specified. It must be greater than or equal to 0 and less than uint.MaxValue.");
            }
            if (Data == null)
            {
                throw new Exception("XboxMemoryStream.Read: No recipient data array specified.");
            }
            if (Offset < 0)
            {
                throw new Exception("XboxMemoryStream.Read: Invalid offset specified. It must be greater than or equal to 0.");
            }
            if (Count < 0)
            {
                throw new Exception("XboxMemoryStream.Read: Invalid count specified. It must be greater than or equal to 0.");
            }
            if (Count == 0)
            {
                return(0);
            }
            if (Offset + Count > Data.Length)
            {
                throw new Exception("XboxMemoryStream.Read: Invalid offset/count specified. They must fit within the size of the data.");
            }
            uint read;

            target.InvalidateMemoryCache(true, (uint)Position, (uint)Count);
            if (Offset == 0)
            {
                target.GetMemory((uint)Position, (uint)Count, Data, out read);
            }
            else
            {
                var temp = new byte[Count];
                target.GetMemory((uint)Position, (uint)Count, temp, out read);
                temp.CopyTo(Data, Offset);
            }
            Position += read;
            return((int)read);
        }
コード例 #2
0
 public static double ReadDouble(this IXboxDebugTarget xdt, uint offset)
 {
     xdt.GetMemory(offset, 8, myBuffer, out outInt);
     Array.Reverse(myBuffer, 0, 8);
     return(BitConverter.ToDouble(myBuffer, 0));
 }
コード例 #3
0
 public static float ReadFloat(this IXboxDebugTarget xdt, uint offset)
 {
     xdt.GetMemory(offset, 4, myBuffer, out outInt);
     Array.Reverse(myBuffer, 0, 4);
     return(BitConverter.ToSingle(myBuffer, 0));
 }
コード例 #4
0
 public static ushort ReadUInt16(this IXboxDebugTarget xdt, uint offset)
 {
     xdt.GetMemory(offset, 2, myBuffer, out outInt);
     Array.Reverse(myBuffer, 0, 2);
     return(BitConverter.ToUInt16(myBuffer, 0));
 }
コード例 #5
0
 public static byte ReadByte(this IXboxDebugTarget xdt, uint offset)
 {
     xdt.GetMemory(offset, 1, myBuffer, out outInt);
     return(myBuffer[0]);
 }
コード例 #6
0
 public static bool ReadBool(this IXboxDebugTarget xdt, uint offset)
 {
     xdt.GetMemory(offset, 1, myBuffer, out outInt);
     return(myBuffer[0] != 0);
 }
コード例 #7
0
 public static string ReadString(this IXboxDebugTarget xdt, uint offset, byte[] readBuffer)      //My buffer is only 0x20 bytes, so you can use ur own
 {
     xdt.GetMemory(offset, (uint)readBuffer.Length, readBuffer, out outInt);
     return(new String(System.Text.Encoding.ASCII.GetChars(readBuffer)).Split('\0')[0]);
 }