Beispiel #1
0
        public static long FindSequenceFirst(this IDeviceRW device, byte[] seq, ulong offset, ulong length, uint scanSize = 0x10000, long pid = -1)
        {
            var end = offset + length;
            var hop = scanSize - (uint)seq.Length + 1; // for each check, include enough from last sequence for overlap

            for (var i = offset; i < end; i += hop)
            {
                var data  = device.Read(i, scanSize, pid);
                var index = IndexOfBytes(data, seq);
                if (index >= 0)
                {
                    return((long)i + index);
                }
            }
            return(-1);
        }
Beispiel #2
0
        // Scan
        public static IEnumerable <ulong> FindSequences(this IDeviceRW device, byte[] seq, ulong offset, ulong length, uint maxScan = 0x10000, long pid = -1)
        {
            var end = offset + length;
            var hop = maxScan - (uint)seq.Length + 1;  // for each check, include enough from last sequence for overlap

            for (var i = offset; i < end; i += hop)
            {
                var data  = device.Read(i, maxScan, pid);
                var index = IndexOfBytes(data, seq);
                if (index < 0)
                {
                    continue;
                }

                yield return(i + (ulong)index);
            }
        }
Beispiel #3
0
 public static byte ReadByte(this IDeviceRW device, ulong offset) => device.Read(offset, 1)[0];
Beispiel #4
0
        public static short ReadInt16(this IDeviceRW device, ulong offset)
        {
            var data = device.Read(offset, 2);

            return(BitConverter.ToInt16(data, 0));
        }
Beispiel #5
0
        public static int ReadInt32(this IDeviceRW device, ulong offset)
        {
            var data = device.Read(offset, 4);

            return(BitConverter.ToInt32(data, 0));
        }
Beispiel #6
0
        public static long ReadInt64(this IDeviceRW device, ulong offset)
        {
            var data = device.Read(offset, 8);

            return(BitConverter.ToInt64(data, 0));
        }