Exemple #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)));
 }
Exemple #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);
        }
Exemple #3
0
 public static void WriteByte(FarPtr ptr, int ofs, byte val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, new[] { val });
 }
Exemple #4
0
 public static double ReadDouble(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToDouble(ptr.memory.ReadMemory(ptr.value + ofs, 8), 0));
 }
Exemple #5
0
 public static float ReadSingle(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToSingle(ptr.memory.ReadMemory(ptr.value + ofs, 4), 0));
 }
Exemple #6
0
 public static long ReadInt64(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt64(ptr.memory.ReadMemory(ptr.value + ofs, 8), 0));
 }
Exemple #7
0
 public static int ReadInt32(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt32(ptr.memory.ReadMemory(ptr.value + ofs, 4), 0));
 }
Exemple #8
0
 public static short ReadInt16(FarPtr ptr, int ofs)
 {
     return(BitConverter.ToInt16(ptr.memory.ReadMemory(ptr.value + ofs, 2), 0));
 }
Exemple #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);
 }
Exemple #10
0
 public static void WriteDouble(FarPtr ptr, double val)
 {
     WriteDouble(ptr, 0, val);
 }
Exemple #11
0
 public static void WriteSingle(FarPtr ptr, float val)
 {
     WriteSingle(ptr, 0, val);
 }
Exemple #12
0
 public static void WriteInt64(FarPtr ptr, int ofs, long val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, BitConverter.GetBytes(val));
 }
Exemple #13
0
 public static void WriteInt64(FarPtr ptr, long val)
 {
     WriteInt64(ptr, 0, val);
 }
Exemple #14
0
 public static void WriteInt32(FarPtr ptr, int val)
 {
     WriteInt32(ptr, 0, val);
 }
Exemple #15
0
 public static void WriteInt16(FarPtr ptr, short val)
 {
     WriteInt16(ptr, 0, val);
 }
Exemple #16
0
 public static byte ReadByte(FarPtr ptr, int ofs)
 {
     return(ptr.memory.ReadMemory(ptr.value + ofs, 1)[0]);
 }
Exemple #17
0
 public static short ReadInt16(FarPtr ptr)
 {
     return(ReadInt16(ptr, 0));
 }
Exemple #18
0
 public static void WriteDouble(FarPtr ptr, int ofs, double val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, BitConverter.GetBytes(val));
 }
Exemple #19
0
 public static int ReadInt32(FarPtr ptr)
 {
     return(ReadInt32(ptr, 0));
 }
Exemple #20
0
 public static void WriteFarPtr(FarPtr ptr, FarPtr val)
 {
     WriteFarPtr(ptr, 0, val);
 }
Exemple #21
0
 public static long ReadInt64(FarPtr ptr)
 {
     return(ReadInt64(ptr, 0));
 }
Exemple #22
0
 public static void Write(FarPtr ptr, byte[] val)
 {
     Write(ptr, 0, val);
 }
Exemple #23
0
 public static float ReadSingle(FarPtr ptr)
 {
     return(ReadSingle(ptr, 0));
 }
Exemple #24
0
 public static void Write(FarPtr ptr, int ofs, byte[] val)
 {
     ptr.memory.WriteMemory(ptr.value + ofs, val);
 }
Exemple #25
0
 public static double ReadDouble(FarPtr ptr)
 {
     return(ReadDouble(ptr, 0));
 }
Exemple #26
0
 public static void Lock(FarPtr ptr, int size)
 {
     ptr.memory.Lock(ptr.value, size);
 }
Exemple #27
0
 public static FarPtr ReadFarPtr(FarPtr ptr)
 {
     return(ReadFarPtr(ptr, 0));
 }
Exemple #28
0
 public static byte ReadByte(FarPtr ptr)
 {
     return(ReadByte(ptr, 0));
 }
Exemple #29
0
 public static byte[] Read(FarPtr ptr, int size)
 {
     return(Read(ptr, 0, size));
 }
Exemple #30
0
 public static byte[] Read(FarPtr ptr, int ofs, int size)
 {
     return(ptr.memory.ReadMemory(ptr.value + ofs, size));
 }