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 bool FindLocation(ref int x, ref int y, ref int z, ref int facet) { Ultima.LocationPointer locationPointer = Client.LocationPointer; System.ProcessStream processStream = Client.ProcessStream; if (processStream == null || locationPointer == null) { return(false); } processStream.BeginAccess(); if (locationPointer.PointerX > 0) { processStream.Seek((long)locationPointer.PointerX, SeekOrigin.Begin); x = Client.Read(processStream, locationPointer.SizeX); } if (locationPointer.PointerY > 0) { processStream.Seek((long)locationPointer.PointerY, SeekOrigin.Begin); y = Client.Read(processStream, locationPointer.SizeY); } if (locationPointer.PointerZ > 0) { processStream.Seek((long)locationPointer.PointerZ, SeekOrigin.Begin); z = Client.Read(processStream, locationPointer.SizeZ); } if (locationPointer.PointerF > 0) { processStream.Seek((long)locationPointer.PointerF, SeekOrigin.Begin); facet = Client.Read(processStream, locationPointer.SizeF); } processStream.EndAccess(); return(true); }
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; }