HEDIT DOS File Editor Version 2.3 Copyright 1991-93 by Larry Michaels All rights reserved Table of Contents INTRODUCTION...................................1 NOTES ON USING HEDIT...........................3 FILES........................................3 CHANGING FILE READ/WRITE MODE................3 CHANGING FILE HIDDEN ATTRIBUTE...............4 EDITING ANOTHER FILE.........................4 IMPORTING FILES..............................4 DISPLAYING THE DIRECTORY.....................4 CONFIGURATION FILE...........................5 SCREEN LAYOUT................................5 EDITING......................................5 CURSOR MOVEMENT..............................6 SEARCH AND REPLACE...........................6 BLOCK OPERATIONS.............................7 PRINTING.....................................7 FILE TRUNCATION..............................7 REPEAT CHANGE................................7 BYTE TRANSLATION.............................7 SETTING BYTES IN A BLOCK.....................8 MACROS.......................................8 UNDO.........................................8 SCREEN ATTRIBUTES............................9 SCREEN MODE..................................9 HELP.........................................9 DOS SHELL....................................9 CALCULATOR...................................9 LIST OF HEDIT COMMANDS.........................10 1 INTRODUCTION HEDIT is a powerful, easy to use editor with which you can create, view, and edit DOS files in both hex and ASCII formats. I wrote HEDIT to fill a need which I often have to be able to create and edit binary files such as the input and output files for other applications which I am developing. I have included some special features such as the ability to set read/write and hidden attributes, jump to any file offset, search for/replace strings in both hex and ASCII formats, insert the contents of another file into the file being edited, truncate the file after the cursor, and set all bytes in a selected field to a certain value, to facilitate specific tasks which frequently need to be done. I hope that you will try out HEDIT, and find it usefull. I am anxious to receive comments and suggestions from users. Version 2.3 includes a few new features not in version 2.21, as well as a few bug fixes. This document describes HEDIT's features. While running HEDIT, help can be obtained by pressing F1. SHAREWARE NOTICE HEDIT is SHAREWARE software. This means that you are free to try it out for 30 days to decide whether or not you wish to use it. If you decide to use it, you are urged to please send a very modest $16 US registration fee, along with any comments or suggestions you may have. Registration includes a disk with a personalized version of the latest release. A registration form is included in this document, and can also be printed out by pressing 'P' from the startup screen. You are free (and encouraged) to distribute HEDIT to friends, co-workers, neighbors, etc. with the following conditions: - This file (HEDIT.DOC) is included, and the files are left as they are without any modifications, - If any fee is charged, it should be minimal, - The recipients know, or are informed about, the shareware concept. I have made a sincere effort to remove all bugs from this software. If any bugs are found however, I apologize and request that they be brought to my attention. No warranty, either explicit or implied is (or can be) made on this software. I assume no financial responsibilty for any loss of data, time, profits, or other damages resulting from the use (or misuse) of HEDIT. Thank you for trying HEDIT. I hope that you will find it useful. Larry Michaels 15712 Hilton Southfield, MI 48075 U.S.A. (313)569-5520 (after 5 Dec 93 area code will be 810) A registration form can be printed by pressing 'P' from the startup screen. A copy of the form is also included on the following page. REGISTRATION FORM FOR HEDIT VER 2.3 Remit to: From: Larry Michaels _______________________________ 15712 Hilton Southfield, MI 48075 _______________________________ U.S.A. _______________________________ _______________________________ _______________________________ _______________________________ Phone:_________________________ Where did you get your copy of HEDIT? __________________________ Registration $16 per use r Quantity:____ x $16 = ___________ Total: ___________ Disk: 5.25":____ 3.5":____ Comments: 3 NOTES ON USING HEDIT FILES HEDIT will accept any file which can be opened and read by DOS. The file name may be supplied on the command line. If no file name or an invalid file name is specified, the file "NONAME.###" will be created (or opened, if it already exists). If a non-existent file is specified, a new file will be created. For files which do not have write permission, HEDIT will display the file, but will not accept any commands to alter it. On the top line, the words "READ ONLY" will appear. The read/write mode of the file can be changed to allow editing using the Change File Mode command described later. For files which are not read-only, HEDIT automatically creates a backup file and a work file upon startup. The backup file is a duplicate of the file being edited, before any changes are made to it. All changes during editing are made to the work file. The original file is not altered until the user presses a save key (Alt S or Alt Z). If HEDIT detects upon startup that there is not enough disk space to create a backup file, it will open the file in read-only mode. The backup file is given the same name as the original file with the file extension ".BAK". If the original file has the extension ".BAK" the backup file is given the extension ".BAC". The work file is named "HEDIT.WKF". During an edit session, HEDIT may create a temporary storage file with the same name as the original file and the extension ".$@!". This file is automatically deleted upon exit. If HEDIT runs out of disk space during a disk write, the user will be informed, and the results may be unpredictable. The user should make sure that there is at least enough free disk space to accommodate a backup file of the same size as the original plus a temporary file of about 120 Kbytes. Large block operations will require more disk sapce. To save the file (ie. update the original file) without leaving HEDIT, Alt S is used. Alt Z will save the file and exit. Alt A will save the file under a new name provided by the user. HEDIT may be exited without affecting the original file (providing that Alt S has not been pressed already) by pressing Alt X. If any changes have been made during the editing session (or since the last save), the user will be prompted whether or not those changes should be abandoned. Pressing "Y", will cause HEDIT to close without saving, while "N" will cause the file to be updated. ESCAPE will cancel the request. CHANGING FILE READ/WRITE MODE As mentioned, HEDIT will open both files with read-write and read-only permission. The user may change the read/write permission mode of the file by pressing Alt M and selecting the desired file mode. A read-only file which is changed to read-write will be changed immediately to read-write, a backup file will be created, and 4 modifications will then be allowed. A file with read-write permission which is changed to read-only will not actually be changed until one of the save commands are issued by the user. Therefore, changes to the file will still be allowed until the file is saved. CHANGING FILE HIDDEN ATTRIBUTE HEDIT provides the facility to set the hidden attribute bit of the file being edited. Files with their hidden attribute bit set will not be listed by the DOS DIR command nor by many other applications. The user may set this attribute by pressing Alt H. When the file's hidden attribute is changed, HEDIT will indicate the change on the top line by placing parentheses around the file name (for hidden files), or by removing the parentheses. EDITING ANOTHER FILE At any time, the user can switch to a different file for editing by pressing Alt E. If changes have been made to the current file since the last save, the user will be prompted as to whether or not the changes should be abandoned. The user will then be prompted to enter a file name. If a valid file name is entered, the current file will be closed, the specified new file will be opened (or created), and editing will proceed with the new file. IMPORTING FILES HEDIT can insert the contents of any file into the file currently being edited. When Alt I is pressed, the user will be prompted for the name of the file to import. The contents of that file will be inserted in the current file, starting at the current offset. DISPLAYING THE DIRECTORY Whenever the user is in a file name prompt field (import file, save as, edit another file), the contents of the directory can be displayed by either pressing F7, or by entering a path name on the prompt line and pressing Enter. Disk drive specifiers can be included in the path. Up to about 4500 files per directory can be displayed. The names of hidden files and directories (ie. those which have their hidden attribute bit set) are displayed enclosed in parentheses. The upper left corner of the directory screen shows the current drive and directory. While viewing the directory, the arrow keys, PgUp, PgDn, Ctrl PgUp, and Ctrl PgDn are be used to move around the directory. The TAB key is used to toggle between the directory display and the prompt line. By entering a different path on the prompt line, a different directory can be displayed. Wilcard characters can be included in the file specification on the prompt line. The currently selected file can be deleted by pressing Delete. 5 CONFIGURATION FILE HEDIT reads and writes a startup file named HEDIT.CFG. This file stores the screen attributes, printer setup parameters, byte translation table, and macro definitions. Upon startup, HEDIT looks in the current directory for this file and if it is not found there, it searches the DOS path for it. If the file is still not found, default values are used. Upon exit, HEDIT updates this file if any configuration changes have been made, or creates a new file if none already exists. SCREEN LAYOUT The HEDIT screen is broken into three main sections. The top line displays the name of the file being edited on the left side, and the Insert/Overtype mode on the right. If the file's hidden attribute bit is set, the file name will appear enclosed in parentheses. The bottom line normally displays the file offset of the byte at which the cursor is positioned. This line is also used to prompt the user for information and to display messages. The main part of the screen is broken into three columns. On the left of each row is displayed the file offset of the first byte on that line. In the middle are the hex representations of up to 16 bytes, while on the right, the ASCII character repesentations of the same bytes are displayed. The cursor may be positioned on any byte in either the hex of ASCII fields. If the byte blinking mode is on, the current byte in the field opposite the cursor will have its blink attribute set. The mode is toggled by pressing Ctrl F6. The cursor can be toggled between hex and ASCII fields by pressing ALT T. EDITING The actions taken upon a keystroke depend on the current location of the cursor and the Insert/Overtype mode. When the Insert mode is set and the cursor is in the hex portion of the screen, only they keys 0-9, a-f (besides control keys) are accepted. If the cursor is on the upper nibble of a byte, a new byte will be inserted with the lower nibble the same as the original byte and the upper nibble depending on the key pressed. The cursor will then be positioned at the lower nibble of the new byte. The next keystroke will set the lower nibble of that byte. If the cursor is on the lower nibble of a byte when a key is pressed, a new byte will be inserted with the upper nibble the same as the original byte, and the lower nibble depending on the key pressed. In Overtype mode, the nibble at which the cursor is positioned will be overwritten. If the cursor is in the ASCII field when a key is pressed, a new byte will be inserted at the current position. Any byte value (0-255) will be accepted in this field. In Overtype mode, the current nibble or byte will be overwritten with the new one. The Insert/Overtype mode can be toggled by pressing the INSERT key, and is displayed on the top line of the screen. 6 In Insert mode, pressing the Delete key will cause the current byte to be deleted. The Backspace key will cause the previous byte to be deleted. To enter a backspace character in the ASCII field, Shift is used with Backspace. CURSOR MOVEMENT The arrow keys move the cursor one byte, nibble, or line at a time. Page Up and Page Down will position the cursor one page up or down. Ctrl Pg Up moves to the beginning of the file and Ctrl Pg Dn moves to the end of the file. The Home key causes the cursor to be positioned on the first byte on the current line, while the End key positions the cursor at the last byte on the line. Alt T toggles the cursor between the hex and ASCII fields. The right and left arrow keys, used with Ctrl, cause the cursor to jump up or down a number of bytes. The size of the jump is set by pressing Alt N, and entering the desired number (in decimal). Every time Ctrl Right Arrow or Ctrl Left Arrow are pressed, the cursor will jump up or down the number of bytes set. SEARCH AND REPLACE HEDIT allows the user to jump to any given file offset or search for a string of bytes. Strings may also be replaced one at a time or globally. To go to a particular byte offset, Alt G is used. The user will be prompted for an offset value which must be given in hex. Preceeding zeroes need not be entered. Pressing ESCAPE while in the will prompt field will cancel the operation while Enter will execute the operation. Strings for search and replace may be specified in either hex or ASCII. To specify a search string in hex, the F2 key is used, while Alt F2 is used for ASCII. The keys F3 (hex) and Alt F3 (ASCII) request search and replace. When entering a string in ASCII format, to enter an escape, backspace, or CR character, Shift is used with the ESCAPE, Backspace, and Enter keys. After a match of the search string has been found, the next or previous matches may be found by pressing F4 or Ctrl F4 respectively. HEDIT will also search the file to count the number of occurrences of a string. The keys F9 (hex) and Alt F9 (ASCII) are used. This function works much the same way as a global string replace, except that occurrences of the string are counted, but not replaced. For all string search and replace functions, searching begins at the current offset and proceeds in the forward direction. To search the file before the current offset Ctrl F4 (find previous) is used. Whenever the current offset lies within a selected block when a search is initiated, the user will be prompted whether the entire file should 7 be searched, or only the block. If the user selects the block only option, further F4 (find next) commands will only cause the blocked part of the file to be searched. BLOCK OPERATIONS Any section of the file may be blocked. Blocks may be created and resized using Alt B, or by using the cursor control keys while holding the Shift key. To copy a block into the block buffer Alt C is used. Shift Delete will cause the block to be deleted and copied into the block buffer. To remove the block highlight (unblock), Alt R is used. Once a block has been copied or deleted, Shift INSERT will cause the block to be inserted at the current offset. PRINTING HEDIT can print all or part of the file being edited. Alt P causes the entire file be printed, while ALT L prints only the blocked bytes. The file is printed in the same format as is displayed on the screen with the exception that bytes with values below 20h and above 7fh are replaced with space characters in the ASCII field to avoid confusing the printer. The printer port, lines per page, and end of page character can be set by pressing ALT O. These values are stored in the startup file HEDIT.CFG, and read upon startup. FILE TRUNCATION HEDIT provides a fast and simple way of truncating a file. By pressing F10, the file will be truncated following the cursor (ie. the current byte will become the last byte of the file). REPEAT CHANGE Single-byte changes can be repeated an indefinite number of times by pressing F8. In Insert mode, the last byte inserted or changed (ie. the new value) will be inserted at the current cursor position. In Overtype mode, the current byte will be changed to the value of the last changed or inserted byte. This feature is useful for entering multiple instances of special bytes which can not otherwise be produced with a single keystroke, such as those entered using the numeric keypad with Alt. BYTE TRANSLATION HEDIT provides a simple byte translation feature. Each byte value (0-ffh) can have a translation value specified. When the translation function is executed, every byte in the file or the selected block which has a translation value in the table is replaced by that translation value. 8 The translation table can be edited by pressing Alt F8. The values to the left of the arrows (->) are the values (in hex) to be translated, while fields to the right of the arrows are filled with the corresponding hex values to which the bytes are to be changed. For example, if the "36" is entered to the right of "25->" in the table, when the translate function is executed, all bytes in the file or block which have the value 25h will be automatically changed to 36h. The arrow and TAB keys are used to move around the table. Pressing R while in the table will reset all of the translation values, so that the translation function will have no effect. Enter or Esc are used to exit the table and return to the edit screen. All changes made to the table are automatically saved to the configuration file upon exiting the program. The translate function is executed by pressing Ctrl F8. If there is a block selected anywhere in the file, the user will be prompted whether only the bytes in the selected block, or all the bytes in the file (starting from the beginning) should be translated. If there is not a slected block, the user will be prompted whether or not the translation should proceed. Pressing Esc at either of these prompts will cancel the request. Translation cannot be undone. SETTING BYTES IN A BLOCK HEDIT provides a feature which sets all bytes within a selected block to a given value. If a block is selected, pressing F11 or Alt F11 will cause HEDIT to prompt for the value to which the bytes in the block are to be set. F11 is used to specify the value in hex, while Alt F11 is used to specify the value in ASCII. This action cannot be undone. MACROS Up to 10 macros can be recorded, each macro having up to 150 keystrokes. Macro recorded is begun by pressing Alt Q, and then entering a number between 0 and 9. The message "Recording Macro" will appear on the bottom line to indicate that keystrokes are being recorded. All keystrokes entered, up to 150, will be recorded, except the Help key (F1), and any keys pressed while in a help screen. Macro recording is terminated by pressing Alt Q again. If more than 150 keys are pressed, or the Edit Another File key (Alt E) is pressed, macro recording will terminate. The keys Alt 0 through Alt 9 are used to play back the macros. Recorded macros are saved to the configuration file upon exiting the program. UNDO Pressing Alt U will cause the last change to be undone. This works for single byte changes as well as replaces and block insertions and deletions. It does not work for the set bytes or translate actions. 9 SCREEN ATTRIBUTES The screen attributes may be changed by pressing F5 (foreground) and F6 (background). The foreground and background attributes of the top and bottom lines (and help screens) are changed with Alt F5 and Alt F6. SCREEN MODE The screen mode can be toggled between 25-line and 50-line modes by pressing Ctrl F5 at any time during editing. The file, cursor position, and other settings are not affected by the mode change. HELP Help screens can be displayed by pressing F1. DOS SHELL A DOS shell may be opened by pressing Alt D. Typing "ESCAPE" at the DOS prompt while in the shell will return control to HEDIT. Be careful not to alter the file being edited, the backup file, or the temporary file ("xxx.$@!") while in the DOS shell as the results will be unpredictable. CALCULATOR HEDIT 2.3 provides a simple integer calculator feature. Pressing Ctrl F9 enters the calculator, and Esc exits. Any expression including hex or decimal values, and the operators +, -, *, /, and = can be entered. The Enter key can be substituted for the '=' key. The results are displayed in both decimal and hex formats. Hex values can be entered by adding an 'h' to the end. For example, typing: "123+90h=" will result in: "267 (10Bh)" being displayed. To convert between decimal and hex representations of a value, simply enter the value and press '=' or Enter. Only integer values are allowed, and values must be less than ffffffffh. 10 The following is a list of HEDIT commands: Calculator Ctrl F9 Enters calculator mode. Change Num of Lines Ctrl F5 Toggles between 25 and 50 line modes. Change Scrn FG color F5 Changes the foreground color of the screen. Change Scrn BG color F6 Changes the background color of the screen. Change Scrn FG color Alt F5 Changes the foreground color of lines 1&25. Change Scrn BG color Alt F6 Changes the background color of lines 1&25. Configure Printer Alt O Allows printer parameters to be set. Copy Block Alt C Copies the selected block to the block buffer. Count Occurrs (ASCII) Alt F9 Counts the # of occurrences of an ASCII str. Count Occurrs (hex) F9 Counts the # of occurrences of a hex string. Delete Block Shift DEL Moves the selected block to the block buffer. DOS Shell Alt D Goes to DOS. Edit Another File Alt E Opens a different file for editing. Edit Translation Tabl Alt F8 Displays the translation table for editing. Find Next F4 Finds next occurrence of search string. Find Previous Shift F4 Finds previous occurrence of search string. Goto File Offset Alt G Jumps to to given file offset Help F1 Displays help screens. Import File Alt I Inserts the contents of the specified file. Insert Block Shift INS Inserts the contents of the block buffer. Move n Bytes Ctrl R/L Moves the cursor up or down a number of bytes. Arrow Play Macro Alt 0-9 Plays macros 0 through 9. Print All Alt P Prints entire file. Print Block Alt L Prints selected block. Quit Alt X Quits without saving. Record/End Macro Alt Q Starts and stops macro recording. Remove Block Markers Alt R Unselects block. Repeat Last Byte F8 Repeats last byte insert/change Replace ASCII String Alt F3 Searches for and replaces an ASCII string. Replace Hex String F3 Searches for and replaces a hex string. Save and Quit Alt Z Saves file and quits. Save As Alt A Saves file under specified name. Save File Alt S Saves file and continues. Search for ASCII Str Alt F2 Searches for a string entered in ASCII format. Search for Hex Str F2 Searches for a string entered in hex format. Set Block Marker Alt B Sets and moves block start and end. Set Bytes (ASCII) Alt F11 Sets all bytes in the selected block to the specified ASCII character. Set Bytes (Hex) F11 Sets all bytes in the selected block to the specified hex value. Set File Mode Alt M Sets the current file's read/write mode. Set File Hidden Attr Alt H Sets the current file's hidden attribute. Set Num Bytes to Move Alt N Sets the number of bytes to move when Ctrl R/L Arrow is pressed. Show Directory F7 When in file name fields displays directory. Toggle Byte Blinking Ctrl F6 Toggles blinking attribute of current byte. Toggle Field Alt T,F12 Toggles between hex and ASCII fields Togl Ins/Ovrtype mode Insert Toggles between Insert and Overtype modes. Translate File Ctrl F8 Translates all bytes in the block or file according to the translation table. Truncate File F10 Truncates the file after the current offset. Undo Alt U Undoes last change/insert/delete.