You should use a TMemoryStream. Then, you should iterate directly through the stream's memory like:
Delphi-Quellcode:
Size := MyStream.Size;
Memory := MyStream.Memory;
StreamPos := 0;
while StreamPos < Size do
begin
FirstStreamPos := StreamPos;
Buffer := Byte(Pointer(Longint(Memory)+StreamPos)^);
inc(StreamPos);
if the Buffer variable corresponds to the first byte of the sequence searched, then iterate through the sequence as long as buffer and sequence's bytes are the same. When a difference is found, exit. If you reach the end of the sequence without finding a difference, you found the sequence and have the starting position in a value previously saved (e.g. FirstStreamPos). You could also incorprate
asm code and split the sequnce in 4, 2, 1 byte parts to increase comparison and copy operations speed.