From UFOpaedia
Jump to navigation Jump to search


MS-Edit is an old simple text editor that was introduced as an offshoot of the QBasic IDE (integrated development environment) that was bundled with the tools in MS-Dos 6.0. In fact, MS-Edit was Qbasic but run with a separate switch so that only its plain text editor was available. As of version 2.0.026, MS-Edit was no longer tied to Qbasic and became its own separate program and came with various improvements.

One of the improvements that it gained was the ability to read and write binary files of up to 2 megabytes in size.

The binary files are opened at varying line widths. For files that simply contain series of similar data, setting MS-Edit to open them at the correct line width will allow you open these files to view them as a table.

For files with mixed data, the files can be opened at line width such as 100 and use decimal file offsets (offset by 1) to get to the part of the file you wish to work on.

Though unorthodox, particularly with entering the offsets, it's easy to master and is prepackaged with a lot of the legacy programs that come with many versions from Windows 95 to XP.

Note: Later iterations of Windows after XP such as Windows 8 and Windows 10 no longer come packaged with MS-EDIT.

To use it

  • /Start /Run then type EDIT. Alternatively, navigate to Start --> Programs --> Accessories --> Command Prompt, then type EDIT. If you frequently use this tool for editing, you can make a shortcut to it and place it on your desktop or start menu for easy access.
    • If you want MS-Edit to display the maximum number of horizontal lines as your hardware is capable of, run it by typing EDIT /H.
  • Point to the game file of interest. This DOS tool uses common established directory conventions such as the two periods (..) at the top of the Directory list. This moves you up one directory level. Use Help (F1) for more info.
  • Once you've highlighted the file of interest, checkmark "Open Binary"
  • If you know the record length for your file of interest, enter it in "Line Width". For example, SOLDIER.DAT has record lengths of 68. This causes file entries to "line up" and makes patterns obvious like a spreadsheet.
  • If you're new to hacking, set the "Open Read-Only" field so that you cannot accidentally save over the file by mistake.


Finding your way around

Ms edit Screen.png

The "Col" and "Value" info along the bottom bar show you the current byte column you're in, and next to it the numerical value is shown.

When browsing through the file structures on the file pages, many folks will reference byte positions using offsets (starts at 0, and is indicated by [square brackets]) whereas EDIT does not (starts with column 1). If the values don't seem to be jiving, try looking one column to the the immediate left, right or the row above or below.


When discussing file editing, offsets are almost always used to identify particular portions of a data file that you go to find the date you want to look up or edit.

Offsets can be presented in decimal (base-10) offsets, or more common to the computer programmer and hackers in general, the hexadecimal (base-16) offset (hence, hex-editing).

Decimal offsets are simple and straightforward as it uses the everyday base-10 numbering system that of us are familiar with, with every digit in a value being represented by a number from 0 to 9. If it's at offset 32, 165 for example, you go to offset 32, 165.

Hexadecimal offsets are more complex as each digit is represented by 16 different values. The values range from 0 to 9, then continuing with letters A to F.

In a decimal system, we'd count from 0 to 9 then 10, in hexadecimal, it will go 0 to F, then 10, and then it will continue to 11, 12 ... 19, 1A, 1B, 1C, 1D, 1E, 1F and then 20.

Hex numbers are often represented with 0x in front of the value. Like 0x10ef.

For editing purposes in MS-Edit, we need to convert hexadecimal offsets to a base-10 offset. Any scientific calculator with Base-n functions will allow you to enter a value in one base, and then to simply convert it to another. MS Calculator that is standard with almost all versions of Windows has this capability once you switch on its scientific mode. Otherwise any cheap store bought scientific calculator for school will do.

Understanding how to work with hexadecimal and decimal is also vital for working with any data values greater than 255. That is a different subject entirely however.


WARNING: When you first start to edit, hit the Insert key once to get the big block cursor. This puts you in Overwrite mode instead of Insert mode (the small underline cursor). Be VERY CAREFUL about hitting the Insert key again. Insert mode is a Very Bad Thing™ for binary files. Inserting a byte moves every subsequent byte over by one, thus nuking position-based files (i.e., most XCOM files).

DOS Characters in MS-Edit

Likewise, be VERY CAREFUL about hitting keys like Delete, Backspace, or Enter. All these (and more!) mess with byte positions in the file. If you attempt to run the game with all the expected offsets being changed, you will cause it to crash or even dosome unpredictable damage.

If you ever see that records aren't lining up, Close without saving!

Make a copy of the file if you're unsure of what you're doing. EDIT prompts you about making a .BAK backup file when you save edits, which is a nice convenience. A manual backup is still preferable.

Entering Data

  • To enter numeric values into a byte:
    • Hold down an Alt key (either one)
    • Using the NUMERIC KEYPAD (the numbers on right side of keyboard, not the ones along the top of keyboard), type in the number you want to enter. It doesn't matter if Numlock is on or off.
    • Let go of the Alt key. In the case where your computer doesn't have a numeric keypad such as a laptop, you must press the function (Fn) key along with ALT in order to enter these values.
    • The number will now be entered.
      • One small fault in MS-Edit is that it cannot enter values less than 28 this way. To enter them, you have to go through special MS-Edit only key sequences. First, hit Control-P (^P). Then:
        • For 0, hit ^2 (don't ask why)
        • For 1-26, hit ^A to ^Z. For example, ^A is 1, ^M is 13, ^Z is 26.
        • For 27, hit ^[
  • A handy lookup table for numbers versus characters can be found as a .GIF (see right) or the same thing in a .PDF here
  • If you see that your number makes a "regular" character (e.g. 65=A), you can also simply type in that character. However, the space character (number 32) looks just like a null character (number 0); don't use a space to mean zero!

Misc Notes

Some save files store 'rubbish' in a field that's not being used. For example, not all soldier and alien names are 25 characters long (26 including the null byte, value 00, that shows where it ends). You'll usually find rubbish stored in the columns past the name end. It can be the remains of old (longer) names, or more worryingly anything that was in that particular position of RAM when the file was last in memory. Garbage characters may show up in fields that's not being used. Don't worry about them. If there's no reason for the game to use them, they're meaningless.

If you have a file open in EDIT, it is not locked by the system. You can keep the file open indefinitely even when the game is running and nothing strange will happen. Just make sure to save your changes so that they show up. In the case if the executable, it is always best to save and restart.

Fixing the X-COM UFO (1994) Difficulty Bug with MS-Edit

In addition to general editing of game files for fun and in-game profit, MS-Edit can be used for the important task of fixing the difficulty bug that plague the dos version of X-Com Enemy Unknown/UFO Defense (1994).

Normally this is fixed with XComUtil, fixing the difficulty bug yourself will allow you to keep the game as unaltered as possible.

Follow these easy steps to use MS-Edit to fix the bug:

Step 0

As with any editing operation, as a safety precaution, make a backup copy of the ufoexe\geoscape.exe file in your game folder before you start.

Step 1

Open Geoscape.exe in binary mode with a column setting of 100.

To do this, you can do it from the Dos console. Change into your UFO Defense/Enemy Unknown folder and type the following:

edit /100 ufoexe\geoscape.exe

Alternately, open MS-Edit, go to File then Open... and look for geoscape.exe in the game's ufoexe\ directory. Select it, then check Open Binary and set the Line Width to 100. Finally hit OK.

Step 2

The next step is to locate the affected byte and alter it. Refer to the bottom right corner of the screen for the Row, Column and Value information.

Use the Page Up, Page Down and cursor keys to change the cursor so that the row and column values match the following. Pick the one appropriate to your version of the game.

Game Version Row Column
DOS Version 1.0 973 29
DOS Version 1.2 1011 69
DOS Version 1.3 1011 69
DOS Version 1.4 957 77

Note that many CD-ROM versions of the the game are v1.4 by default. The dos portion of the Steam release is 1.4.

Once you are at the specified row and column, your cursor will be resting on a < symbol and the value field should read 60. If not, you might have a different version - try referring to the other row/col values until you find this symbol.

If it's showing an @ symbol and a value of 64 - then your bug is fixed and you don't need to do anything further.

Step 3

Press Insert to switch your cursor to the block cursor.

Now the moment of truth: you need to replace the value of 60 with 64. To do this, type an @ symbol to replace the <.

Alternately, hold down alt and type 064 on the numeric keypad.

Important: If you weren't using the block cursor, make absolutely sure you use delete or backspace to remove the < symbol after entering the @. Not doing this will increase the size of the executable by 1 byte and really mess it up.

Step 4

File > Save and finish up with File > Exit

And you're done. Launch the game and enjoy it on the proper difficulty levels. Note that only new games will be affected. Any saves made prior to the fix will retain their original difficulty.

See Also