Quality Software Solutions
  • Specializing in professional hex editor tools,
    including disk editing and process editing.





010 Editor - Hex Editor Homepage


The following is a list of functions for communicating with the 010 Editor program when writing a Template or Script.

void CopyToClipboard()
Copies the currently selected bytes to the clipboard. See SetSelection to change the selection.

void CutToClipboard()
Copies the currently selected bytes to the clipboard and deletes them from the file. See SetSelection to change the selection.

int DeleteFile( char filename[] )
Deletes the file given by filename from disk. Note that the file should not be open in the editor or the delete will fail. Returns a value less than zero on failure.

void DisableUndo()
Turns off undo support for a file. This function will speed up a script when writing a large number of changes to a file. Undo is automatically turned on after the script is finished. Note that undo is automatically disabled for files created with FileNew. See EnableUndo below.

void DisplayFormatBinary()
void DisplayFormatDecimal()
void DisplayFormatHex()
void DisplayFormatOctal()
Sets the display format of variables in the Inspector to binary, decimal, hexadecimal, or octal. Any variables declared after this function is called will be displayed in the selected format. Note that the format can also be set for one variable using the syntax <format=hex|decimal|octal|binary> after a declaration or typedef (see Declaring Template Variables for more information).

void EnableUndo()
Turns back on Undo support for a file after calling DisableUndo. Undo is automatically turned on after the script is finished.

int Exec( const char program[], const char arguments[] )
Executes an external application using the given program and arguments. Returns true if successful, or false if an error occurred.

void Exit( int errorcode )
Ends execution of the current script or template and displays the errorcode in the Output text area. Note that usually the keyword return can be used to accomplish the same task unless execution is inside of a custom function.

This function is special in that it can be used to return an ERRORLEVEL code to a batch file (see Command Line Parameters for more information). The last errorcode that was passed to an Exit function, either from a script or a template, will be returned as the global ERRORLEVEL when 010 Editor exits.

void FileClose()
Closes the current file. See FileSelect to set the current file.

int FileCount()
Returns the number of existing file handles. See FileSelect to set the current file.

int FileExists( const char filename[] )
Returns true if the given file name exists on disk, or false if it does not.

int FileNew()
Creates a new file in the editor and returns the index of the created file (see GetFileNum). If this function is run from a script, the created file becomes the current file. If this function is run from a template, the current file does not change (use the FPrintf function to write data to the returned file handle). Note that when new files are created, the undo buffer is turned off by default, but will be turned on as soon as the script finishes.

int FileOpen( const char filename[] )
Opens the file specified by the file name into the editor. Returns a value less than zero on error.

int FileSave( const char filename[] )
Saves the current file to the given file name. See GetFileName to retrieve the name of the current file. Returns a value less than zero on error.

void FileSelect( int index )
Only one file can be active at a time and all of the Read/Write operations occur on that file. Use FileSelect to select a different file to be the current file. The files are numbered from 0 up to FileCount()-1. See GetFileNum to get the index of the current file.

int GetBytesPerLine()
Returns the number of bytes displayed per line in the current Hex Editor Window. This value is by default 16, but may change depending upon the current settings in the View Menu.

quad GetCursorPos()
Returns the address of the cursor in the file.

char[] GetFileName()
Returns a string representing the file name of the current file including the path.

int GetFileNum()
Each open file is assigned a index from 0 up to FileCount()-1. This function returns the index of the current file. Use the FileSelect function to make another file the active file.

int GetReadOnly()
Returns true if the file is marked as read-only, or false if the file can be modified.

quad GetSelSize()
Returns the number of bytes that have been selected. Returns 0 if no selection is made.

quad GetSelStart()
Returns the start address of the selection. Use GetSelSize to determine if a selection has been made.

double InputFloat(
    const char title[],
    const char caption[],
    const char defaultValue[] )

Opens up a dialog with a single edit box. The title displays in the title bar of the dialog and the caption displays above the edit box. The defaultValue specifies the starting value in the edit box. This function returns the floating-point value of the number entered in the edit box. If an invalid number is entered or Cancel is pressed, the constant BAD_VALUE is returned.

int InputNumber(
    const char title[],
    const char caption[],
    const char defaultValue[] )

Similar to InputFloat except an integer is returned instead of a float value. If an invalid number is entered or Cancel is pressed, the constant BAD_VALUE is returned.

char[] InputOpenFileName(
    char title[],
    char filter[]="All files (*.*)|*.*",
    char filename[]="" )

Shows a standard file open dialog box with the caption title. The filter controls which file masks are available in the File Type drop-down list. Specify filters as an array of strings separated by the '|' character. The first string of a pair is the caption that is displayed in the file dialog box and the second string is the actual filter mask used (use the ';' character to separate masks). The filename gives the default file name of the file to open and may just contain a directory to start the dialog in that directory. Only a single file may be selected with the file dialog box. The returned value is the full chosen file name, or an empty string if cancel was pressed.

TOpenFileNames InputOpenFileNames(
    char title[],
    char filter[]="All files (*.*)|*.*",
    char filename[]="" )

Similar to InputOpenFileName except that multiple files may be selected. The results are returned in a structure TOpenFileNames that contains a count variable indicating the number of opened files (zero if cancel was pressed), and an array of file variables which each have a filename variable indicating the selected file. For example:

    int i;
    TOpenFileNames f = InputOpenFileNames( 
        "Open File Test", 
        "C Files|*.c;*.cpp|All Files|*.*" );
    for( i = 0; i < f.count; i++ )
        Printf( "%s\n", f.file[i].filename );

will print out all file names selected.

char[] InputSaveFileName(
    char title[],
    char filter[]="All files (*.*)|*.*",
    char filename[]="",
    char extension[]="" )

Uses a standard file save dialog box to select a file name suitable to use when saving a file. The user will be asked to overwrite a file if it already exists on disk. The title, filter and filename arguments are similar to the InputOpenFileName function. If no extension is given for the file name, a period and the extension argument will automatically be appended to the file name. The return value is the full chosen file name, or an empty string if cancel was pressed.

char[] InputString(
    const char title[],
    const char caption[],
    const char defaultValue[] )

Similar to InputFloat except that the string value of the edit box is returned instead of a float value. If Cancel is pressed, an empty string is returned.

int InsertFile( const char filename[], quad position )
Inserts all of the bytes in the file given by filename into the current file starting at position. A negative number is returned if the file cannot be inserted.

int IsEditorFocused()
Returns true if a Hex Editor Window is currently focused. This function is useful if you want to build a script that controls the cursor of the Hex Editor Window and only want the cursor to move when the window is focused.

int IsModified()
Returns true if any changes have been made to the file, or false otherwise.

int MessageBox( int mask, const char title[], const char format[] [, argument, ... ] )
Displays a message box to the user with a number of buttons to press. The buttons displayed depend upon an OR mask of four values. The Ok, Cancel, Yes, or No buttons can be displayed by using the constants idOk, idCancel, idYes, or idNo respectively (note that not all possible combinations are supported). The title is display in the title bar of the message box. The message to display is obtained using a syntax similar to printf (see Printf below). The return value is one of the constants idOk, idCancel, idYes, or idNo depending upon which button was pressed. For example, to display a message box with Yes and No buttons use:

 if( MessageBox( idYes | idNo, 
    "Script", 
    "Save changes to '%s'?", 
    GetFileName() ) 
      == idYes )
  . . .

void PasteFromClipboard()
Inserts any bytes in the clipboard into the file starting at the current cursor position. If a selection has been made, the selected bytes will be deleted before the bytes are inserted.

int Printf( const char format[] [, argument, ... ] )
Similar to the standard C printf function. Accepts a format specifier and a series of arguments. The results of the Printf are displayed in the Output text area in the
Code Editor. The following codes can be used to specify different data types:

  • %d, %i - signed integer
  • %u - unsigned integer
  • %x, %X - hex integer
  • %o - octal integer
  • %c - character
  • %s - string
  • %f, %e, %g - float
  • %lf - double
  • %Ld - signed quad
  • %Lu - unsigned quad
  • %Lx, %LX - hex quad

Width, precision, and justification characters are also supported (e.g. "%5.2lf", or "%-15s"). The newline character can be specified with '\n'. Consult documentation on the standard C printf function for more information.

int RenameFile( const char originalname[], const char newname[] )
Renames a file on disk from originalname to newname. Note that the file should not be open in the editor when it is renamed. A negative number if returned if the rename fails.

void SetBackColor( int color )
void SetColor( int forecolor, int backcolor )
void SetForeColor( int color )
These functions are used when writing a Template to apply color to different variables. All variables defined after calling one of these functions will be displayed in the given color. SetForeColor sets the foreground (text) color, and SetBackColor sets the background color. Use SetColor to set both the foreground and background color at the same time. A color is an integer made up of 3 hex bytes specifying the blue, green, and red components of the color. The following constants are defined and may be used when setting colors:

  • cBlack - 0x000000
  • cRed - 0x0000ff
  • cDkRed - 0x000080
  • cLtRed - 0x8080ff
  • cGreen - 0x00ff00
  • cDkGreen - 0x008000
  • cLtGreen - 0x80ff80
  • cBlue - 0xff0000
  • cDkBlue - 0x800000
  • cLtBlue - 0xff8080
  • cPurple - 0xff00ff
  • cDkPurple - 0x800080
  • cLtPurple - 0xffe0ff
  • cAqua - 0xffff00
  • cDkAqua - 0x808000
  • cLtAqua - 0xffffe0
  • cYellow - 0x00ffff
  • cDkYellow - 0x008080
  • cLtYellow - 0x80ffff
  • cDkGray - 0x404040
  • cGray - 0x808080,
  • cSilver - 0xc0c0c0,
  • cLtGray - 0xe0e0e0
  • cWhite - 0xffffff
  • cNone - 0xffffffff

The cNone constant indicates that no color should be applied.

void SetCursorPos( quad pos )
Sets the cursor position in the current file to pos. A flashing caret will visually indicate the cursor position in the file.

int SetReadOnly( int readonly )
Sets the read-only status of the current file to true or false. A negative number is returned if the read-only status could not be changed.

void SetSelection( quad start, quad size )
Selects size bytes from the file starting at the address start. The selected bytes will appear blue in the main window.

void Terminate( int force=true )
Exits out of the script and then shuts down 010 Editor. If force is true, all open files will be closed and any unsaved modifications will be lost. If force is false and files are modified, the user will be asked if they want to save the files and optionally given a chance to cancel the shut down procedure.

void Warning( const char format[] [, argument, ... ] )
Similar to the Printf function except the resulting string is displayed in the Status Bar of the application and is highlighted blue. This is useful to display an error that occurs in a Template.

















This is the manual for 010 Editor, a professional hex editor and binary file editor. Use 010 Editor to edit the individual bytes of any binary file, hard drive, or process on your machine. 010 Editor contains a whole host of powerful analysis and editing tools, plus Binary Templates technology that allows any binary format to be understood.






SweetScape Software
148 Pownal Rd. RR#1
Pownal, PEI
C0A 1Z0, Canada

E-mail: