This page summarises the tools I have developed to modify executables, data files and disk images
for the PC and Atari ST Computers. These programs can be used in general however to help patch any file.
The tools are:
These are all Win32 executables.
TrackCalc and ExecBoot have been written in .NET 2.0 and require the .NET 2.0 runtime.
A ZIP download is available in the download section containing all these tools.
Various tools had to be written to make some disks copyable by standard copy
programs such as FastCopy 3 on the Atari ST.
Example 1: Examining and modifying data
C:\UTILS\patchtools>hexdump test1.dat 0 10
C:\UTILS\patchtools>patchbytesoffset 8 ffff test1.dat test1out.dat
C:\UTILS\patchtools>hexsearch ffff test1out.dat
Found at offset
C:\UTILS\patchtools>hexdump test2.dat 0 10
Example 2: Patching all instances of a string
C:\UTILS\patchtools>patchbytes b200 4e714e714e71 test2.dat test2out.dat overwrite
Found at offset
note: the mode parameter is not used at the moment
C:\UTILS\patchtools>fc /B test2.dat test2out.dat
Comparing files test2.dat and TEST2OUT.DAT
00000002: B2 4E
00000003: 00 71
00000004: 20 4E
00000005: 20 71
00000006: 20 4E
00000007: 20 71
Example 3: Patching bytes at a known offset
This example patches the total track counter in the bootsector of an Atari ST disk image.
If the bootsector is executable the checksum alignment word (offset: 511) has to be recalculated.
Use ExecBoot to generate the patchbytesoffset command to do this.
C:\UTILS\patchtools>patchbytesoffset 19 4006 out.st temp.st
Example 4: Removing a call with nop instructions
debug shows us the call instruction op-code
ff15 call [di]
we know that the opcode for nop in x86 is 0x90 and we have to overwrite 2 bytes.
C:\UTILS\patchtools>patchbytesoffset 1067 9090 smallest.exe small.exe
Example 5: Boot Sector Track\Sector\Side Patch Calculator (Atari ST)
The track calculator is used to be able to patch boot sectors with the
correct number of tracks, sectors and sides. Some copy protections on
the Atari ST set these to incorrect values to prevent copiers like FastCopy 3
Simply type in the values of the number of tracks, sectors and sides
and press Calculate and the patch script will be output in the window below.
Example 6: Boot Sector Executable Checksum Calculator (Atari ST)
When an Atari ST boot sector is changed, if the boot sector is executable, then
a new checksum alignment value in bytes 510-511 will have to be written.
This value is the sum of the first 255 words - 0x1234.
Simply press the Make Executable button, select the .ST disk image or boot sector track image,
and the patch script will be written to the window below to patch in the correct
checksum alignment value.
1. For hexsearch the entire input file is read into memory for speed. For the other tools
the file is read simply using fgetc().
Extremely large files should not be read using these programs.
2. For ExecBoot the first 512 bytes are read into memory.
3. Deciding which parts of an executable program need to be patched
can be found using a disassembler or runtime debugger.
Useful nop opcodes
trap #14; 0x4e4e
Useful conditional and branch to subroutine opcodes
ff15 call [di]
cmp.b d0,d1 ; 0xb200
beq label ; xx nn nn (xx = conditional on branch instruction type, nn nn = 16 bit signed address offset)
0xcd call nnnn
The following tools are recommended for coding work in general.
Easy Rider 4
IDEs and runtime debuggers
OllyDbg, Visual Studio (Microsoft), Turbo Debugger (Borland), Watcom Disassembler, DJGPP
Atari ST: HiSoft Devpac 2 (especially MonST for debugging), Ultimate Ripper
Amiga: MonAm, Action Replay
Emulators: Steem, Steem Debug, WinUAE
Spectrum: Multiface (Genie), HiSoft Devpac
Emulators: Spectaculator, X128
Back to index.