示例#1
0
 public static FarPtr ReadFarPtr(FarPtr ptr, int ofs)
 {
     byte[] data = ptr.memory.ReadMemory(ptr.value, ptr.memory.PointerSize);
     if (data.Length > 8)
     {
         throw new OverflowException("Target memory pointer size is not representable.");
     }
     Array.Resize(ref data, 8);
     return(new FarPtr(ptr.memory, BitConverter.ToInt64(data, 0)));
 }
示例#2
0
        public static void WriteFarPtr(FarPtr ptr, int ofs, FarPtr val)
        {
            ptr.CheckSameMemory(ref val);
            byte[] data    = BitConverter.GetBytes(val.value);
            int    ptrsize = ptr.memory.PointerSize;

            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(data);
                Array.Resize(ref data, ptrsize);
                Array.Reverse(data);
            }
            else
            {
                Array.Resize(ref data, ptrsize);
            }
            ptr.memory.WriteMemory(ptr.value + ofs, data);
        }
示例#3
0
 public static void WriteByte(FarPtr ptr, int ofs, byte val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, new[] { val });
 }
示例#4
0
 public static double ReadDouble(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToDouble(ptr.memory.ReadMemory(ptr.value + ofs, 8), 0));
 }
示例#5
0
 public static float ReadSingle(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToSingle(ptr.memory.ReadMemory(ptr.value + ofs, 4), 0));
 }
示例#6
0
 public static long ReadInt64(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt64(ptr.memory.ReadMemory(ptr.value + ofs, 8), 0));
 }
示例#7
0
 public static int ReadInt32(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt32(ptr.memory.ReadMemory(ptr.value + ofs, 4), 0));
 }
示例#8
0
 public static short ReadInt16(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt16(ptr.memory.ReadMemory(ptr.value + ofs, 2), 0));
 }
示例#9
0
 /// <summary>
 /// Gets the pointer size of the memory context where a far pointer is located.
 /// </summary>
 /// <param name="pointer">The far pointer specifying the memory context.</param>
 /// <returns>The pointer size in bytes.</returns>
 public static int GetTargetContextPointerSize(FarPtr pointer)
 {
     return(pointer.memory.PointerSize);
 }
示例#10
0
 public static void WriteDouble(FarPtr ptr, double val)
 {
     WriteDouble(ptr, 0, val);
 }
示例#11
0
 public static void WriteSingle(FarPtr ptr, float val)
 {
     WriteSingle(ptr, 0, val);
 }
示例#12
0
 public static void WriteInt64(FarPtr ptr, int ofs, long val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, BitConverter.GetBytes(val));
 }
示例#13
0
 public static void WriteInt64(FarPtr ptr, long val)
 {
     WriteInt64(ptr, 0, val);
 }
示例#14
0
 public static void WriteInt32(FarPtr ptr, int val)
 {
     WriteInt32(ptr, 0, val);
 }
示例#15
0
 public static void WriteInt16(FarPtr ptr, short val)
 {
     WriteInt16(ptr, 0, val);
 }
示例#16
0
 public static byte ReadByte(FarPtr ptr, int ofs)
 {
     return(ptr.memory.ReadMemory(ptr.value + ofs, 1)[0]);
 }
示例#17
0
 public static short ReadInt16(FarPtr ptr)
 {
     return(ReadInt16(ptr, 0));
 }
示例#18
0
 public static void WriteDouble(FarPtr ptr, int ofs, double val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, BitConverter.GetBytes(val));
 }
示例#19
0
 public static int ReadInt32(FarPtr ptr)
 {
     return(ReadInt32(ptr, 0));
 }
示例#20
0
 public static void WriteFarPtr(FarPtr ptr, FarPtr val)
 {
     WriteFarPtr(ptr, 0, val);
 }
示例#21
0
 public static long ReadInt64(FarPtr ptr)
 {
     return(ReadInt64(ptr, 0));
 }
示例#22
0
 public static void Write(FarPtr ptr, byte[] val)
 {
     Write(ptr, 0, val);
 }
示例#23
0
 public static float ReadSingle(FarPtr ptr)
 {
     return(ReadSingle(ptr, 0));
 }
示例#24
0
 public static void Write(FarPtr ptr, int ofs, byte[] val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, val);
 }
示例#25
0
 public static double ReadDouble(FarPtr ptr)
 {
     return(ReadDouble(ptr, 0));
 }
示例#26
0
 public static void Lock(FarPtr ptr, int size)
 {
     ptr.memory.Lock(ptr.value, size);
 }
示例#27
0
 public static FarPtr ReadFarPtr(FarPtr ptr)
 {
     return(ReadFarPtr(ptr, 0));
 }
示例#28
0
 public static byte ReadByte(FarPtr ptr)
 {
     return(ReadByte(ptr, 0));
 }
示例#29
0
 public static byte[] Read(FarPtr ptr, int size)
 {
     return(Read(ptr, 0, size));
 }
示例#30
0
 public static byte[] Read(FarPtr ptr, int ofs, int size)
 {
     return(ptr.memory.ReadMemory(ptr.value + ofs, size));
 }