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 Read(System.ProcessStream pc, int bytes) { int num; int num1; int i; byte[] numArray = new byte[bytes]; pc.Read(numArray, 0, bytes); switch (bytes) { case 1: { return((sbyte)numArray[0]); } case 2: { return((short)(numArray[0] | numArray[1] << 8)); } case 3: { num = 0; num1 = 0; for (i = 0; i < (int)numArray.Length; i++) { num = num | numArray[i] << (num1 & 31); num1 = num1 + 8; } return(num); } case 4: { return(numArray[0] | numArray[1] << 8 | numArray[2] << 16 | numArray[3] << 24); } default: { num = 0; num1 = 0; for (i = 0; i < (int)numArray.Length; i++) { num = num | numArray[i] << (num1 & 31); num1 = num1 + 8; } return(num); } } }
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); }
public static int Search(ProcessStream pc, byte[] buffer) { const int chunkSize = 4096; int readSize = chunkSize + buffer.Length; pc.BeginAccess(); byte[] read = new byte[readSize]; for (int i = 0; ; ++i) { pc.Seek(0x400000 + (i * chunkSize), SeekOrigin.Begin); int count = pc.Read(read, 0, readSize); if (count != readSize) break; for (int j = 0; j < chunkSize; ++j) { bool ok = true; for (int k = 0; ok && k < buffer.Length; ++k) ok = (buffer[k] == read[j + k]); if (ok) { pc.EndAccess(); return 0x400000 + (i * chunkSize) + j; } } } pc.EndAccess(); return 0; }
public static int Search(ProcessStream pc, byte[] mask, byte[] vals) { if (mask.Length != vals.Length) throw new Exception(); const int chunkSize = 4096; int readSize = chunkSize + mask.Length; pc.BeginAccess(); byte[] read = new byte[readSize]; for (int i = 0; ; ++i) { pc.Seek(0x400000 + (i * chunkSize), SeekOrigin.Begin); int count = pc.Read(read, 0, readSize); if (count != readSize) break; for (int j = 0; j < chunkSize; ++j) { bool ok = true; for (int k = 0; ok && k < mask.Length; ++k) ok = ((read[j + k] & mask[k]) == vals[k]); if (ok) { pc.EndAccess(); return 0x400000 + (i * chunkSize) + j; } } } pc.EndAccess(); return 0; }
public static int Read(ProcessStream pc, int bytes) { byte[] buffer = new byte[bytes]; pc.Read(buffer, 0, bytes); switch (bytes) { case 1: return (sbyte)buffer[0]; case 2: return (short)(buffer[0] | (buffer[1] << 8)); case 4: return (int)(buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24)); } int val = 0; int bits = 0; for (int i = 0; i < buffer.Length; ++i) { val |= buffer[i] << bits; bits += 8; } return val; }