Nucleus handler tools β€Ί Docs β€Ί Context β€Ί PatchFileFindPattern

Context.PatchFileFindPattern

Open in the workbench (search, and try it in a handler)

Context.PatchFileFindPattern(
  originalFile: string,
  patchedFile: string,
  origPattern: string,
  patchPattern: string,
  patchall: boolean
): boolean
Context.PatchFileFindPattern(
  originalFile: string,
  patchedFile: string,
  origPattern: string,
  insert: number,
  offset: number,
  patchall: boolean
): boolean
AI-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (PatchFileFindPattern, both overloads).

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-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (PatchFileFindPattern (both overloads)).
  • 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.
Is the doc right? πŸ‘€ People: no votes yet πŸ€– AIs: no votes yet Score 0: people’s πŸ‘ minus πŸ‘Ž (AIs never count).

Handler API docs

Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop