0xFF Posted October 22, 2010 Posted October 22, 2010 (edited) This is a little silly code that will return the offset by searching it via a static array of size 7 byte(s).Made it for the patcher of QUAD RegistryCleaner 1.5.144, more to come, this code is first RLS, and could be optimized and tweaked using threads and better searching patterns, future updates to come.Usage: ShowMessageFmt( '%x', [RetOffset(lol)]);lol: array [0..6] of byte = ($FF, $FF, $FF, $FF, $FF, $FF, $FF); <-- change FF's to your needs.you can modify it and make it search bigger buffers, but be ware of getting "Eof", calculate file size and div by the amount of searches you're going to perfom.type TStaticArray = ARray [0..6] Of Byte;function RetOffset(const bSrc: TStaticArray): Integer;const Bof = 0; // Beginning of filevar buffer: TStaticArray;begin if (not FilePos(hFile) = Bof) then seek(hFile, Bof); repeat BlockRead(hFile, buffer, sizeof(buffer)); Application.ProcessMessages; until ((buffer[0] = bSrc[0]) and (buffer[1] = bSrc[1]) and (buffer[2] = bSrc[2]) and (buffer[3] = bSrc[3]) and (buffer[4] = bSrc[4]) and (buffer[5] = bSrc[5]) and (buffer[6] = bSrc[6]) ); Result := FilePos(hFile)-7; // will return the beginning of the offsetend; Edited October 22, 2010 by rotem156
arcosteami Posted October 22, 2010 Posted October 22, 2010 (edited) if the reading is offset 0A 0B 0C I try and read ??0A0B it does not workBut I'm just nearby Edited October 22, 2010 by arcosteami
0xFF Posted October 22, 2010 Author Posted October 22, 2010 if the reading is offset 0A 0B 0C I try and read ??0A0B it does not workBut I'm just nearbyIt's just a basic one, it doesn't have that. and i'm not going to improve it anyhow, i'll be using a pre-existing one.i don't have the power to make this ****.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now