Jump to content
Tuts 4 You

[DELPHI]Return offset by AOB


Recommended Posts

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.

TStaticArray = ARray [0..6] Of Byte;
function RetOffset(const bSrc: TStaticArray): Integer;
Bof = 0; // Beginning of file
buffer: TStaticArray;
if (not FilePos(hFile) = Bof) then
seek(hFile, Bof); repeat
BlockRead(hFile, buffer, sizeof(buffer));
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 offset
Edited by rotem156
Link to comment

if the reading is offset 0A 0B 0C I try and read ??0A0B it does not work

But I'm just nearby

It'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 ****.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...