public static int Search(System.ProcessStream pc, byte[] buffer) { int length = 4096 + (int)buffer.Length; pc.BeginAccess(); byte[] numArray = new byte[length]; int num = 0; while (true) { pc.Seek((long)(4194304 + num * 4096), SeekOrigin.Begin); if (pc.Read(numArray, 0, length) != length) { break; } for (int i = 0; i < 4096; i++) { bool flag = true; for (int j = 0; flag && j < (int)buffer.Length; j++) { flag = buffer[j] == numArray[i + j]; } if (flag) { pc.EndAccess(); return 4194304 + num * 4096 + i; } } num++; } pc.EndAccess(); return 0; }
public static int Search(System.ProcessStream pc, byte[] mask, byte[] vals) { if ((int)mask.Length != (int)vals.Length) { throw new Exception(); } int length = 4096 + (int)mask.Length; pc.BeginAccess(); byte[] numArray = new byte[length]; int num = 0; while (true) { pc.Seek((long)(4194304 + num * 4096), SeekOrigin.Begin); if (pc.Read(numArray, 0, length) != length) { break; } for (int i = 0; i < 4096; i++) { bool flag = true; for (int j = 0; flag && j < (int)mask.Length; j++) { flag = (numArray[i + j] & mask[j]) == vals[j]; } if (flag) { pc.EndAccess(); return 4194304 + num * 4096 + i; } } num++; } pc.EndAccess(); return 0; }