import struct


def scan_version_byte(exe, pattern, offset):
    """
        Scans a file for a specific byte-pattern and returns the value located at the given offset.

        exe is the path to the file to search, usually the game EXE
        pattern is the byte-string to search for, with 0xFF values indicating any value
        offset is the index within the pattern of the version byte
    """
    with open(exe, 'rb') as fh:
        value = b""
        while b := fh.read(1):
            if b[0] == pattern[len(value)] or pattern[len(value)] == 0xff:
                value += b

                if len(value) == len(pattern):
                    return struct.unpack_from("<I", value, offset)[0]
            else:
                value = b""