for connected embedded systems
![]() |
![]() |
![]() |
spatch
Fullscreen patch utility (QNX)
Syntax:
spatch [-bp] file [offset] spatch -m pid selector offset
Options:
- -b
- Browse only: don't allow the Save command. The file or disk will be accessed in read-only mode.
- -m pid selector offset
- Examine RAM for the specified process, where pid is a process ID and selector can be either an LDT or a GDT selector.
- -p
- Pause before starting, for example to allow a floppy disk to be inserted in a disk drive.
- file
- The file or disk to be examined.
- offset
- The address -- in RAM, in the file, or on the disk -- where the spatch is to begin (specified in hex).
Description:
The spatch utility provides fullscreen editing of files or disk blocks. The screen displays a 16-by-16 (256) byte image of the data being examined, similar to that shown here:
Edit Next Prev Lastblk Home Goto Find Continue Save Addr Quit 000000000: 2E 28 6E 65 77 29 20 53 50 41 54 43 48 20 22 46 .(new) SPATCH "F 000000010: 75 6C 6C 20 73 63 72 65 65 6E 20 70 61 74 63 68 ull screen patch 000000020: 20 75 74 69 6C 69 74 79 22 1E 2E 28 73 79 6E 74 utility"..(synt 000000030: 61 78 29 1E 09 11 73 70 61 74 63 68 10 20 20 11 ax)...spatch. . 000000040: 66 69 6C 65 10 20 20 AE 66 69 6C 65 6E 61 6D 65 file. .filename 000000050: AF 1E 09 11 73 70 61 74 63 68 10 20 20 11 64 69 ....spatch. .di 000000060: 73 6B 10 20 20 AE 64 72 69 76 65 AF 20 20 AE 62 sk. .drive. .b 000000070: 6C 6F 63 6B AF 1E 09 11 73 70 61 74 63 68 10 20 lock....spatch. 000000080: 20 11 6D 65 6D 10 20 20 AE 73 65 67 6D 65 6E 74 .mem. .segment 000000090: AF 20 20 AE 6F 66 66 73 65 74 AF 1E 2E 28 65 78 . .offset...(ex 0000000a0: 61 6D 70 6C 65 73 29 1E 09 11 73 70 61 74 63 68 amples)...spatch 0000000b0: 20 20 66 69 6C 65 20 20 2F 63 6D 64 73 2F 6C 73 file /bin/ls 0000000c0: 1E 09 73 70 61 74 63 68 20 20 64 69 73 6B 20 20 ..spatch disk 0000000d0: 31 20 20 31 1E 09 73 70 61 74 63 68 20 20 6D 65 1 1..spatch me 0000000e0: 6D 20 20 62 30 30 30 20 20 30 10 1E 2E 28 73 74 m b000 0...(st 0000000f0: 61 72 74 29 1E 53 50 41 54 43 48 20 69 73 20 61 art).SPATCH is a
At the top of the screen, you'll see a list of commands. To select a command, either type its first letter, or move the cursor to the command (with the arrow keys) and type Enter.
The commands are as follows:
- Edit
- Enter the data area. Pressing Tab switches between hex and ASCII data entry. Pressing Esc returns you to the menu. The changed data isn't updated to the disk or memory.
- Next
- Move forward 256 bytes. You can also use PgDn.
- Prev
- Move backward 256 bytes. You can also use PgUp.
- Home
- Go to the start of the file, disk, or memory. You can also use Home.
- Lastblk
- Go to the last block of the file or disk. You can also use End.
- Goto
- Prompt the user for an address. The type of address will depend on the source of the data (file or disk) and the address type.
- Find
- Prompt the user for a pattern to search for. The pattern may consist of
single characters or hex digit pairs separated by a space. For example:
To stop the search, press any key.This pattern: Matches: 61 62 63 d e the 5 characters "abcde" a b c d e the 5 characters "abcde" - Continue
- Find the next occurrence of the last pattern found. Usually used after a Find when searching.
- Save
- Save the current screen back to the source. Without issuing this command all changes made using Edit will be lost as soon as you leave the current screen of data. The Save option is disabled by the -b (browse) option.
- Addr
- Toggle through two address types:
- Absolute (default for FILE)
- Disk Block:Offset (default for DISK)
- Quit
- Leave the spatch utility.
If you specify a directory in the file argument, the disk will be edited, but spatch will move only through the blocks that make up the directory. This is similar to "spatching" a file, but if you wish to make changes, the disk must be opened for exclusive use as would any block special file.
To run spatch on a directory or a block special file, you must either be root or have write permission for the disk's block special file.
The offset argument lets you specify the address where spatch is to begin. If file is a regular file, the offset is a byte offset. If file is a block special file, the offset is a block:byte offset. If file is a block special file with a QNX filesystem on it, the offset may be the name of a file or directory (the beginning address will be the first block of the named file). If the named file has extents, spatch won't thread through those extents, but will go to the next sequential block.
You can use spatch to recover lost files or directories. For more information, see the QNX Installation & Configuration manual.
Examples:
Patch the contents of the file /bin/ls:
spatch /bin/ls
Patch the contents of the block-special raw disk volume /dev/hd0:
spatch /dev/hd0
Environment variables:
- TERM
- Interpreted as the name of the terminal type.
Exit status:
- 0
- Successful.
- >0
- An error occurred.
Caveats:
You may not use the spatch utility on a disk when there are open files on the disk, unless the -b (browse) option is used.
See also:
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Next]](../next.gif)