Gammadyne Corporation

GPATCH.EXE

GPATCH.EXE is a free Windows command line program that alters a block of bytes in a file.

Usage

First, specify the filepath of the file that is to be patched.  Then, specify the /i switch, followed immediately by the 0-based index of where the data should be stored in the file.  The actual data can be specified one of two ways:
  • The /s switch, immediately followed by the data, inside quotes.  The data is expressed literally.  8-bit characters are inserted.
  • The /w switch, immediately followed by the data, inside quotes.  The data is expressed literally.  16-bit characters are inserted.
  • The /h switch, immediately followed by a string of hexadecimal pairs, inside quotes.  Each hexadecimal pair corresponds to a single byte of data.  Each pair can be separated by spaces, commas, dashes, or nothing at all.

In addition, you may optionally specify the /n switch, immediately followed by the number of bytes that is to be deleted at the specified index before the data is inserted at the index.  If this switch is omitted, this defaults to the length of the data, which has the end result of overwriting a section of the file without modifying its size.  If the /n value is less than the length of data, the file will grow.  Likewise, if the /n value is more, the file will shrink.  If /n0 is specified, the data is effectively inserted into the file at the index.

Notes

  • To append the data to the file, specify the /a switch instead of /i.
  • You may specify multiple /s, /w, and /h switches.  The final data will be the concatenation of the data specified by each switch.
  • Multiple files can be patched at the same time.  Either list each file, separated by semi-colons.  Or, use the * or ? wildcard.
  • The /r switch will recursively enter sub-folders looking for filename matches.
  • The /nologo switch will omit the program banner.
  • The /nw switch will suppress warnings in the file specification (such as "File does not exist").

Example #1: Changing the 3rd, 4th, and 5th bytes to "abc".

c:\dos>gpatch f:\g\foo.txt /i2 /s"abc"
GPATCH 4.0 - File Patching Utility - www.Gammadyne.com
Copyright (C) 2002-2024 By Greg Wittmeyer - All Rights Reserved

Replaced 3 bytes at index 2 in file "f:\g\foo.txt" with "abc"

Example #2: Inserting "abc" at the beginning.

c:\dos>gpatch f:\g\foo.txt /i0 /n0 /h"6162 63"
GPATCH 4.0 - File Patching Utility - www.Gammadyne.com
Copyright (C) 2002-2024 By Greg Wittmeyer - All Rights Reserved

Replaced 0 bytes at index 0 in file "f:\g\foo.txt" with "abc"

Example #3: Appending "abc" to the end.

c:\dos>gpatch f:\g\foo.txt /a /s"abc"
GPATCH 4.0 - File Patching Utility - www.Gammadyne.com
Copyright (C) 2002-2024 By Greg Wittmeyer - All Rights Reserved

Replaced 0 bytes at index 4 in file "f:\g\foo.txt" with "abc"

Example #4: Deleting the first 100 bytes.

c:\dos>gpatch f:\g\foo.txt /i0 /n100 /s""
GPATCH 4.0 - File Patching Utility - www.Gammadyne.com
Copyright (C) 2002-2024 By Greg Wittmeyer - All Rights Reserved

Replaced 100 bytes at index 0 in file "f:\g\foo.txt" with ""

Example #5: Patching multiple files.

c:\dos>gpatch "f:\g\foo?.txt;bar.txt" /i0 /n100 /s"abc"
GPATCH 4.0 - File Patching Utility - www.Gammadyne.com
Copyright (C) 2002-2024 By Greg Wittmeyer - All Rights Reserved

Replaced 100 bytes at index 0 in file "f:\g\foo1.txt" with "abc"
Replaced 100 bytes at index 0 in file "f:\g\foo2.txt" with "abc"
Replaced 100 bytes at index 0 in file "f:\g\bar.txt" with "abc"

Download

Click the button below to download GPATCH.EXE version 4.0, released April 1st, 2024.