Nucleus handler tools › Docs › Context › PatchFileFindPattern
Context.PatchFileFindPattern
Open in the workbench (search, and try it in a handler)
Context.PatchFileFindPattern(
originalFile: string | number | boolean,
patchedFile: string | number | boolean,
origPattern: string | number | boolean,
patchPattern: string | number | boolean,
patchall: boolean
): boolean
Context.PatchFileFindPattern(
originalFile: string | number | boolean,
patchedFile: string | number | boolean,
origPattern: string | number | boolean,
insert: number,
offset: number,
patchall: boolean
): boolean
Reads originalFile, replaces every occurrence of the hex byte pattern origPattern (spaces allowed) and writes the result to patchedFile, even if nothing matched. Two forms: (originalFile, patchedFile, origPattern, patchPattern, patchall) puts the hex patchPattern in place of each match; (originalFile, patchedFile, origPattern, insert, offset, patchall) writes the low two bytes of the number insert (little-endian) into the pattern at one-based byte position offset. Throws if originalFile doesn't exist; returns true. In the first form, patchall false patches only the first byte of each match: pass true.
✎ AI-written, based on Nucleus GenericContext.cs (PatchFileFindPattern, both overloads). Not from the official docs. Is it wrong? Tell us
originalFile: Full path of the file to read.patchedFile: Full path the patched bytes are written to; may be the same as originalFile.origPattern: Bytes to find as a hex string, spaces allowed, e.g. "8B 45 FC 89"; no wildcards.patchPattern: Replacement bytes as a hex string, at least as long as origPattern, written over each match byte by byte.patchall: With patchPattern: true patches every match fully, false only the first byte of each match. With insert: false stops after the first match.insert: Number whose low two bytes (little-endian) are written into a copy of origPattern at offset, which then replaces the match.offset: Position in origPattern, counting bytes from 1, where the two insert bytes go.
✎ Parameters: AI-written from the Nucleus source.