コード例 #1
0
        static public T[] ReadArray <T>(
            this    IMemoryReader MemoryReader,
            Int64 Address,
            int NumberOfBytes)
            where T : struct
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var BytesRead = MemoryReader.ReadBytes(Address, NumberOfBytes);

            if (null == BytesRead)
            {
                return(null);
            }

            var ElementSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));

            var NumberOfElements = (BytesRead.Length - 1) / ElementSize + 1;

            var Array = new T[NumberOfElements];

            Buffer.BlockCopy(BytesRead, 0, Array, 0, BytesRead.Length);

            return(Array);
        }
コード例 #2
0
 internal static Guid ReadComGuid(this IMemoryReader reader, IntPtr p)
 {
     if (p == IntPtr.Zero)
     {
         return(IID_IUnknown);
     }
     return(new Guid(reader.ReadBytes(p, 16)));
 }
コード例 #3
0
 internal static Guid ReadGuid(IMemoryReader reader, IntPtr p)
 {
     if (p == IntPtr.Zero)
     {
         return(NdrInterfacePointerTypeReference.IID_IUnknown);
     }
     return(new Guid(reader.ReadBytes(p, 16)));
 }
コード例 #4
0
        public static byte[] ReadBytes(this IMemoryReader memoryReader, long address, int bytesCountMax)
        {
            byte[] array = new byte[bytesCountMax];
            int    num   = memoryReader.ReadBytes(address, bytesCountMax, array);

            if (num < 1)
            {
                return(null);
            }
            if (num == array.Length)
            {
                return(array);
            }
            byte[] array2 = new byte[num];
            Buffer.BlockCopy(array, 0, array2, 0, array2.Length);
            return(array2);
        }
コード例 #5
0
        public static T[] ReadArray <T>(this IMemoryReader memoryReader, long address, int numberOfBytes) where T : struct
        {
            if (memoryReader == null)
            {
                return(null);
            }
            byte[] array = memoryReader.ReadBytes(address, numberOfBytes);
            if (array == null)
            {
                return(null);
            }
            int num  = Marshal.SizeOf(typeof(T));
            int num2 = (array.Length - 1) / num + 1;

            T[] array2 = new T[num2];
            Buffer.BlockCopy(array, 0, array2, 0, array.Length);
            return(array2);
        }
コード例 #6
0
        static public string ReadUnicodeString(
            this IMemoryReader MemoryReader,
            Int64 Address,
            int length)
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var Bytes = MemoryReader.ReadBytes(Address, 2 * length);

            if (null == Bytes)
            {
                return(null);
            }

            return(Encoding.Unicode.GetString(Bytes));
        }
コード例 #7
0
        static public string ReadStringAsciiNullTerminated(
            this    IMemoryReader MemoryReader,
            Int64 Address,
            int LengthMax = 0x1000)
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var Bytes = MemoryReader.ReadBytes(Address, LengthMax);

            if (null == Bytes)
            {
                return(null);
            }

            var BytesNullTerminated = Bytes.TakeWhile((Byte) => 0 != Byte).ToArray();

            return(Encoding.ASCII.GetString(BytesNullTerminated));
        }
コード例 #8
0
        static public UInt32?ReadUInt32(
            this    IMemoryReader MemoryReader,
            Int64 Address)
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var Bytes = MemoryReader.ReadBytes(Address, 4);

            if (null == Bytes)
            {
                return(null);
            }

            if (Bytes.Length < 4)
            {
                return(null);
            }

            return(BitConverter.ToUInt32(Bytes, 0));
        }
コード例 #9
0
        static public bool?ReadBool(
            this IMemoryReader MemoryReader,
            Int64 Address)
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var Bytes = MemoryReader.ReadBytes(Address, 1);

            if (null == Bytes)
            {
                return(null);
            }

            if (Bytes.Length < 1)
            {
                return(null);
            }

            return(BitConverter.ToBoolean(Bytes, 0));
        }
コード例 #10
0
        static public double?ReadDouble(
            this IMemoryReader MemoryReader,
            Int64 Address)
        {
            if (null == MemoryReader)
            {
                return(null);
            }

            var Bytes = MemoryReader.ReadBytes(Address, 8);

            if (null == Bytes)
            {
                return(null);
            }

            if (Bytes.Length < 8)
            {
                return(null);
            }

            return(BitConverter.ToDouble(Bytes, 0));
        }
コード例 #11
0
 byte[] IMemoryReader.ReadBytes(long Address, int BytesCount)
 {
     return(MemoryReader.ReadBytes(Address, BytesCount));
 }
コード例 #12
0
 public static string ReadStringAsciiNullTerminated(this IMemoryReader memoryReader, long address, int lengthMax = 4096)
 {
     return(memoryReader?.ReadBytes(address, lengthMax)?.ReadStringAsciiNullTerminated(0, lengthMax));
 }
コード例 #13
0
        public static long ListeOktetLeeseVonAdrese(this IMemoryReader reader, long adrese, long listeOktetZuLeeseAnzaal, byte[] ziilArray)
        {
            int num = reader?.ReadBytes(adrese, (int)listeOktetZuLeeseAnzaal, ziilArray) ?? 0;

            return(num);
        }