Hex Editor - Binary File Editing Software for Windows
Download Hex Editor Neo Hide this button

IFileDocument Interface

This interface is implemented by File Document Object. See the Creating File Document Object section to see how you create the object in your code.

Declaration

interface IFileDocument extends ${IDispatch} {
    // Properties
    ${AutoCreateBranch}: boolean;
    readonly ${FileName}: string;
    ${FileSize}: number;
    readonly ${Modified}: boolean;
    readonly ${Stream}: boolean;
    readonly ${ReadOnly}: boolean;
    ${RegExpSyntaxError}: string;
    readonly ${CanRedo}: boolean;
    readonly ${CanUndo}: boolean;
    readonly ${CanPaste}: boolean;

    // Methods
    ${Close}(): void;
    ${New}(): void;
    ${Open}(Name: string, ReadOnly: boolean): void;
    ${OpenPhysicalDisk}(PhysicalDiskName: string, FriendlyName: string, ReadOnly: boolean): void;
    ${OpenProcess}(ProcessId: number, Start: number, Size: number, ReadOnly: boolean): void;
    ${OpenVolume}(VolumeName: string, FriendlyName: string, ReadOnly: boolean): void;
    ${Save}(ForceBackup: boolean): void;
    ${SaveAs}(FileName: string): void;
    ${GetModifiedSel}(Selection: ${IMultiSelection}): void;
    ${Decrypt}(Provider: string,
        ProviderType: number,
        AlgoID: number,
        Password: string,
        Selection: ${IMultiSelection},
        KeyLength?: number): void;
    ${Delete}(Offset: number, Size: number): void;
    ${DeleteMulti}(Selection: ${IMultiSelection}): void;
    ${Encrypt}(Provider: string,
        ProviderType: number,
        AlgoID: number,
        Password: string,
        Selection: ${IMultiSelection},
        KeyLength?: number): void;
    ${FillByte}(FillValue: number, Offset: number, Size: number): void;
    ${FillByteMulti}(FillValue: number, Selection: ${IMultiSelection}): void;
    ${InsertByte}(ByteFill: number, Offset: number, Size: number): void;
    ${PutFile}(FileName: string, Offset: , InsertMode: boolean): void;
    ${CreatePatch}(PatchName: string, Options: ${PatchOptions}, PathToStubFile?: string): void;
    ${Purge}(Level: ${HistoryPurgeLevel}): void;
    ${Redo}(Steps?: number): void;
    ${Undo}(Steps?: number): void;
    ${Copy}(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
    ${Cut}(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
    ${Paste}(Offset: number, InsertMode: boolean): void;
    ${Paste2}(Offset: number, Type: ${TextType}, InsertMode: boolean): void;
    ${Paste3}(Offset: number, Type: ${TextType}, Flags: ${Paste3Flags}): void;
    ${PasteText}(Offset: number, Unicode: boolean, InsertMode: boolean): void;
    ${PasteText2}(Offset: number, CodePage: number, InsertMode: boolean): void;
    ${FindAllRegExp}(RegExp: string,
        SubExpression: number,
        Flags: ${RegExpFlags},
        StartFrom: number,
        Size: number,
        Found: ${IMultiSelection}): void;
    ${FindAllRegExp2}(RegExp: string,
        CodePage: number,
        SubExpression: number,
        Flags: ${RegExpFlags},
        StartFrom: number,
        Size: number,
        Found: ${IMultiSelection}): void;
    ${ReplaceAllRegExpWithRegExp}(RegExp: string,
        ReplacePattern: string,
        CodePage: number,
        Flags: ${RegExpFlags},
        StartFrom: number,
        Size: number): void;
    ${Gap}(pSelection: ${IMultiSelection}): void;
    ${ArithmeticOp}(Selection: ${IMultiSelection},
        Type: ${ArithmeticOpType},
        OpSize: ${OperandSizeType},
        Operand?: any): void;
    ${CaseOp}(Selection: ${IMultiSelection},
        Type: ${CaseOpType},
        Unicode: boolean,
        CodePage?: number): void;
    ${ShiftOp}(Selection: ${IMultiSelection}, Type: ${ShiftOpType}, OpSize: , Bits: number): void;
    ${ReverseOp}(Selection: ${IMultiSelection}, Type: ${ReverseOpType}, OpSize: ${OperandSizeType}): void;
    ${CreateEmptySelection}(): ${IMultiSelection};
    ${CreateSequence}(): ${ISequence};
    ${BitwiseOpS}(Selection: ${IMultiSelection}, Type: ${BitwiseOpType}, Sequence: ${ISequence}): void;
    ${FillMultiS}(Sequence: ${ISequence}, Selection: ${IMultiSelection}, Continue: boolean): void;
    ${FillS}(Sequence: ${ISequence}, Offset: number, Size: number): void;
    ${FindAllS}(Sequence: ${ISequence},
        Selection: ${IMultiSelection},
        IgnoreCase: boolean,
        Found: ${IMultiSelection}): void;
    ${FindS}(Sequence: ${ISequence},
        Selection: ${IMultiSelection},
        StartFrom: number,
        SearchUp: boolean,
        IgnoreCase: boolean): void;
    ${InsertPatternS}(Sequence: ${ISequence}, Offset: number, Size: number): void;
    ${InsertS}(Sequence: ${ISequence}, Offset: number): void;
    ${ReadS}(Sequence: ${ISequence}, Offset: number): void;
    ${ReplaceAllRegExpS}(RegExp: string,
        SubExpression: number,
        Flags: ${RegExpFlags},
        Sequence: ${ISequence},
        StartFrom: number,
        Size: number): void;
    ${ReplaceAllRegExp2S}(RegExp: string,
        CodePage: number,
        SubExpression: number,
        Flags: ${RegExpFlags},
        Sequence: ${ISequence},
        StartFrom: number,
        Size: number): void;
    ${ReplaceAllS}(SequenceFrom: ${ISequence},
        SequenceTo: ${ISequence},
        IgnoreCase: boolean,
        Selection: ${IMultiSelection}): void;
    ${ReplaceS}(Offset: number, Size: number, Sequence: ${ISequence}): void;
    ${ToNumber}(Value: any): number;
    ${WriteS}(Sequence: ${ISequence}, Offset: number): void;
}
public interface IFileDocument : ${IDispatch}
{
    // Properties
    bool ${AutoCreateBranch} { get; set; }
    string ${FileName} { get; }
    ulong ${FileSize} { get; set; }
    bool ${Modified} { get; }
    bool ${Stream} { get; }
    bool ${ReadOnly} { get; }
    string ${RegExpSyntaxError} { get; set; }
    bool ${CanRedo} { get; }
    bool ${CanUndo} { get; }
    bool ${CanPaste} { get; }

    // Methods
    void ${Close}();
    void ${New}();
    void ${Open}(string Name, bool ReadOnly);
    void ${OpenPhysicalDisk}(string PhysicalDiskName, string FriendlyName, bool ReadOnly);
    void ${OpenProcess}(uint ProcessId, long Start, ulong Size, bool ReadOnly);
    void ${OpenVolume}(string VolumeName, string FriendlyName, bool ReadOnly);
    void ${Save}(bool ForceBackup);
    void ${SaveAs}(string FileName);
    void ${GetModifiedSel}(${IMultiSelection} Selection);
    void ${Decrypt}(string Provider,
        uint ProviderType,
        uint AlgoID,
        string Password,
        ${IMultiSelection} Selection,
        uint KeyLength);
    void ${Delete}(ulong Offset, ulong Size);
    void ${DeleteMulti}(${IMultiSelection} Selection);
    void ${Encrypt}(string Provider,
        uint ProviderType,
        uint AlgoID,
        string Password,
        ${IMultiSelection} Selection,
        uint KeyLength);
    void ${Fill}(ref byte Pattern,
        uint PatternSize,
        ulong Offset,
        ulong Size);
    void ${FillByte}(byte FillValue, ulong Offset, ulong Size);
    void ${FillByteMulti}(byte FillValue, ${IMultiSelection} Selection);
    void ${FillMulti}(ref byte Pattern, uint PatternSize, ${IMultiSelection} Selection,  Continue);
    void ${Insert}(ref byte Data, ulong Offset, uint InsertSize);
    void ${InsertByte}(byte ByteFill, ulong Offset, ulong Size);
    void ${InsertPattern}(ref byte Pattern,
        uint PatternSize,
        ulong Offset,
        ulong Size);
    void ${PutFile}(string FileName, ulong Offset, bool InsertMode);
    void ${Read}(ref byte Data, ulong Offset, uint ReadSize);
    void ${Write}(ref byte Data, ulong Offset, uint WriteSize);
    void ${CreatePatch}(string PatchName, ${PatchOptions} Options, string PathToStubFile);
    void ${LoadHistory}(IStream Stream);
    void ${Purge}(${HistoryPurgeLevel} Level);
    void ${Redo}(uint Steps);
    void ${SaveHistory}(IStream Stream);
    void ${Undo}(uint Steps);
    void ${Copy}(${IMultiSelection} Selection, bool MergeBlocks);
    void ${Cut}(${IMultiSelection} Selection, bool MergeBlocks);
    void ${Paste}(ulong Offset, bool InsertMode);
    void ${Paste2}(ulong Offset, ${TextType} Type, bool InsertMode);
    void ${Paste3}(ulong Offset, ${TextType} Type, ${Paste3Flags} Flags);
    void ${PasteText}(ulong Offset, bool Unicode, bool InsertMode);
    void ${PasteText2}(ulong Offset, uint CodePage, bool InsertMode);
    ulong ${Find}(ref byte DataToFind,
        uint DataSize,
        ${IMultiSelection} Selection,
        ulong StartFrom,
        bool SearchUp,
        bool ignore_case);
    void ${FindRegExp}(string RegExp,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ulong StartFrom,
        ulong Size,
        ref ulong FoundOffset,
        ref ulong MatchSize);
    void ${FindRegExp2}(string RegExp,
        uint CodePage,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ulong StartFrom,
        ulong Size,
        ref ulong FoundOffset,
        ref ulong MatchSize);
    void ${FindAll}(ref byte DataToFind,
        uint DataSize,
        ${IMultiSelection} Selection,
        bool IgnoreCase,
        ${IMultiSelection} Found);
    void ${FindAllRegExp}(string RegExp,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ulong StartFrom,
        ulong Size,
        ${IMultiSelection} Found);
    void ${FindAllRegExp2}(string RegExp,
        uint CodePage,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ulong StartFrom,
        ulong Size,
        ${IMultiSelection} Found);
    void ${Replace}(ulong Offset,
        uint SizeFrom,
        ref byte To,
        uint SizeTo);
    void ${ReplaceAll}(ref byte From,
        uint SizeFrom,
        ref byte To,
        uint SizeTo,
        bool IgnoreCase,
        ${IMultiSelection} Selection);
    void ${ReplaceAllRegExp}(string RegExp,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ref byte To,
        uint SizeTo,
        ulong StartFrom,
        ulong Size);
    void ${ReplaceAllRegExp2}(string RegExp,
        uint CodePage,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ref byte To,
        uint SizeTo,
        ulong StartFrom,
        ulong Size);
    void ${ReplaceAllRegExpWithRegExp}(string RegExp,
        string ReplacePattern,
        uint CodePage,
        ${RegExpFlags} Flags,
        ulong StartFrom,
        ulong Size);
    void ${Gap}(${IMultiSelection} pSelection);
    void ${ArithmeticOp}(${IMultiSelection} Selection,
        ${ArithmeticOpType} Type,
        ${OperandSizeType} OpSize,
        object Operand);
    void ${BitwiseOp}(${IMultiSelection} Selection, ${BitwiseOpType} Type, ref byte Data, uint DataSize);
    void ${CaseOp}(${IMultiSelection} Selection,
        ${CaseOpType} Type,
        bool Unicode,
        object CodePage);
    void ${ShiftOp}(${IMultiSelection} Selection, ${ShiftOpType} Type,  OpSize, uint Bits);
    void ${ReverseOp}(${IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
    ulong[] ${GatherStatistics}(${IMultiSelection} Selection);
    void ${PatternStatistics}(ref byte Pattern,
        uint DataSize,
        bool IgnoreCase,
        ref ulong DataBuffer,
        uint Blocks,
        ${IMultiSelection} Selection);
    void ${PatternStatisticsRegExp}(string RegExp,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ref ulong DataBuffer,
        uint Blocks,
        ulong StartFrom,
        ulong Size);
    void ${PatternStatisticsRegExp2}(string RegExp,
        uint CodePage,
        uint SubExpression,
        ${RegExpFlags} Flags,
        ref ulong DataBuffer,
        uint Blocks,
        ulong StartFrom,
        ulong Size);
    ${IMultiSelection} ${CreateEmptySelection}();
    ${ISequence} ${CreateSequence}();
}
struct IFileDocument : IDispatch
{
    // Properties
    VARIANT_BOOL ${AutoCreateBranch};  // get set 
    _bstr_t ${FileName};  // get 
    unsigned long long ${FileSize};  // get set 
    VARIANT_BOOL ${Modified};  // get 
    VARIANT_BOOL ${Stream};  // get 
    VARIANT_BOOL ${ReadOnly};  // get 
    _bstr_t ${RegExpSyntaxError};  // get set 
    VARIANT_BOOL ${CanRedo};  // get 
    VARIANT_BOOL ${CanUndo};  // get 
    VARIANT_BOOL ${CanPaste};  // get 

    // Methods
    HRESULT ${Close}();
    HRESULT ${New}();
    HRESULT ${Open}(_bstr_t Name, VARIANT_BOOL ReadOnly);
    HRESULT ${OpenPhysicalDisk}(_bstr_t PhysicalDiskName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
    HRESULT ${OpenProcess}(unsigned long ProcessId, long long Start, unsigned long long Size, VARIANT_BOOL ReadOnly);
    HRESULT ${OpenVolume}(_bstr_t VolumeName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
    HRESULT ${Save}(VARIANT_BOOL ForceBackup);
    HRESULT ${SaveAs}(_bstr_t FileName);
    HRESULT ${GetModifiedSel}(${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${Decrypt}(_bstr_t Provider,
        unsigned long ProviderType,
        unsigned long AlgoID,
        _bstr_t Password,
        ${IMultiSelectionPtr#IMultiSelection} Selection,
        _variant_t KeyLength);
    HRESULT ${Delete}(unsigned long long Offset, unsigned long long Size);
    HRESULT ${DeleteMulti}(${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${Encrypt}(_bstr_t Provider,
        unsigned long ProviderType,
        unsigned long AlgoID,
        _bstr_t Password,
        ${IMultiSelectionPtr#IMultiSelection} Selection,
        _variant_t KeyLength);
    HRESULT ${Fill}(unsigned char * Pattern,
        unsigned long PatternSize,
        unsigned long long Offset,
        unsigned long long Size);
    HRESULT ${FillByte}(unsigned char FillValue, unsigned long long Offset, unsigned long long Size);
    HRESULT ${FillByteMulti}(unsigned char FillValue, ${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${FillMulti}(unsigned char * Pattern, unsigned long PatternSize, ${IMultiSelectionPtr#IMultiSelection} Selection,  Continue);
    HRESULT ${Insert}(unsigned char * Data, unsigned long long Offset, unsigned long InsertSize);
    HRESULT ${InsertByte}(unsigned char ByteFill, unsigned long long Offset, unsigned long long Size);
    HRESULT ${InsertPattern}(unsigned char * Pattern,
        unsigned long PatternSize,
        unsigned long long Offset,
        unsigned long long Size);
    HRESULT ${PutFile}(_bstr_t FileName, unsigned long long Offset, VARIANT_BOOL InsertMode);
    HRESULT ${Read}(unsigned char * Data, unsigned long long Offset, unsigned long ReadSize);
    HRESULT ${Write}(unsigned char * Data, unsigned long long Offset, unsigned long WriteSize);
    HRESULT ${CreatePatch}(_bstr_t PatchName, ${PatchOptions} Options, _variant_t PathToStubFile);
    HRESULT ${LoadHistory}(IStream * Stream);
    HRESULT ${Purge}(${HistoryPurgeLevel} Level);
    HRESULT ${Redo}(_variant_t Steps);
    HRESULT ${SaveHistory}(IStream * Stream);
    HRESULT ${Undo}(_variant_t Steps);
    HRESULT ${Copy}(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
    HRESULT ${Cut}(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
    HRESULT ${Paste}(unsigned long long Offset, VARIANT_BOOL InsertMode);
    HRESULT ${Paste2}(unsigned long long Offset, ${TextType} Type, VARIANT_BOOL InsertMode);
    HRESULT ${Paste3}(unsigned long long Offset, ${TextType} Type, ${Paste3Flags} Flags);
    HRESULT ${PasteText}(unsigned long long Offset, VARIANT_BOOL Unicode, VARIANT_BOOL InsertMode);
    HRESULT ${PasteText2}(unsigned long long Offset, unsigned long CodePage, VARIANT_BOOL InsertMode);
    unsigned long long ${Find}(unsigned char * DataToFind,
        unsigned long DataSize,
        ${IMultiSelectionPtr#IMultiSelection} Selection,
        unsigned long long StartFrom,
        VARIANT_BOOL SearchUp,
        VARIANT_BOOL ignore_case);
    HRESULT ${FindRegExp}(_bstr_t RegExp,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long StartFrom,
        unsigned long long Size,
        unsigned long long * FoundOffset,
        unsigned long long * MatchSize);
    HRESULT ${FindRegExp2}(_bstr_t RegExp,
        unsigned long CodePage,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long StartFrom,
        unsigned long long Size,
        unsigned long long * FoundOffset,
        unsigned long long * MatchSize);
    HRESULT ${FindAll}(unsigned char * DataToFind,
        unsigned long DataSize,
        ${IMultiSelectionPtr#IMultiSelection} Selection,
        VARIANT_BOOL IgnoreCase,
        ${IMultiSelectionPtr#IMultiSelection} Found);
    HRESULT ${FindAllRegExp}(_bstr_t RegExp,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long StartFrom,
        unsigned long long Size,
        ${IMultiSelectionPtr#IMultiSelection} Found);
    HRESULT ${FindAllRegExp2}(_bstr_t RegExp,
        unsigned long CodePage,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long StartFrom,
        unsigned long long Size,
        ${IMultiSelectionPtr#IMultiSelection} Found);
    HRESULT ${Replace}(unsigned long long Offset,
        unsigned long SizeFrom,
        unsigned char * To,
        unsigned long SizeTo);
    HRESULT ${ReplaceAll}(unsigned char * From,
        unsigned long SizeFrom,
        unsigned char * To,
        unsigned long SizeTo,
        VARIANT_BOOL IgnoreCase,
        ${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${ReplaceAllRegExp}(_bstr_t RegExp,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned char To,
        unsigned long SizeTo,
        unsigned long long StartFrom,
        unsigned long long Size);
    HRESULT ${ReplaceAllRegExp2}(_bstr_t RegExp,
        unsigned long CodePage,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned char * To,
        unsigned long SizeTo,
        unsigned long long StartFrom,
        unsigned long long Size);
    HRESULT ${ReplaceAllRegExpWithRegExp}(_bstr_t RegExp,
        _bstr_t ReplacePattern,
        unsigned long CodePage,
        ${RegExpFlags} Flags,
        unsigned long long StartFrom,
        unsigned long long Size);
    void ${Gap}(${IMultiSelection} pSelection);
    HRESULT ${ArithmeticOp}(${IMultiSelectionPtr#IMultiSelection} Selection,
        ${ArithmeticOpType} Type,
        ${OperandSizeType} OpSize,
        _variant_t Operand);
    HRESULT ${BitwiseOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${BitwiseOpType} Type, unsigned char * Data, unsigned long DataSize);
    HRESULT ${CaseOp}(${IMultiSelectionPtr#IMultiSelection} Selection,
        ${CaseOpType} Type,
        VARIANT_BOOL Unicode,
        _variant_t CodePage);
    HRESULT ${ShiftOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${ShiftOpType} Type,  OpSize, unsigned long Bits);
    HRESULT ${ReverseOp}(${IMultiSelectionPtr#IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
    unsigned long long[256] ${GatherStatistics}(${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${PatternStatistics}(unsigned char * Pattern,
        unsigned long DataSize,
        VARIANT_BOOL IgnoreCase,
        unsigned long long * DataBuffer,
        unsigned long Blocks,
        ${IMultiSelectionPtr#IMultiSelection} Selection);
    HRESULT ${PatternStatisticsRegExp}(_bstr_t RegExp,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long * DataBuffer,
        unsigned long Blocks,
        unsigned long long StartFrom,
        unsigned long long Size);
    HRESULT ${PatternStatisticsRegExp2}(_bstr_t RegExp,
        unsigned long CodePage,
        unsigned long SubExpression,
        ${RegExpFlags} Flags,
        unsigned long long * DataBuffer,
        unsigned long Blocks,
        unsigned long long StartFrom,
        unsigned long long Size);
    ${IMultiSelectionPtr#IMultiSelection} ${CreateEmptySelection}();
    ${ISequencePtr#ISequence} ${CreateSequence}();
};

IFileDocument Properties

AutoCreateBranch

AutoCreateBranch: boolean;
bool AutoCreateBranch { get; set; }
VARIANT_BOOL AutoCreateBranch;  // get set 

true if Auto Create Branches option enabled, false otherwise.

Query or set the AutoCreateBranch property value. See the History » Auto Create Branches switch description for more information about this property.

FileName

readonly FileName: string;
string FileName { get; }
_bstr_t FileName;  // get 

The full file's path name.

Using the FileName property

var fdoc=new ActiveXObject("FileDocument.FileDocument");
fdoc.Open("c:\\temp\\file.bin");
alert("Full file name is " + fdoc.FileName);

FileSize

FileSize: number;
ulong FileSize { get; set; }
unsigned long long FileSize;  // get set 

Retrieve or change the current file's size. When used to change the file's size, new operation is created in document's operation history.

Complexity: constant-time.

Setting file's size

var fdoc = new ActiveXObject("FileDocument.FileDocument");
fdoc.New();  // initialize a new, empty document
fdoc.FileSize = 1024*1024; // set the size of the file to 1 MB
fdoc.SaveAs("c:\\temp\\file.bin");

Modified

readonly Modified: boolean;
bool Modified { get; }
VARIANT_BOOL Modified;  // get 

Returns the modified document state.

Stream

readonly Stream: boolean;
bool Stream { get; }
VARIANT_BOOL Stream;  // get 

This property is true if document represents an NTFS stream and false otherwise.

ReadOnly

readonly ReadOnly: boolean;
bool ReadOnly { get; }
VARIANT_BOOL ReadOnly;  // get 

Retrieves the document's ReadOnly state.

RegExpSyntaxError

RegExpSyntaxError: string;
string RegExpSyntaxError { get; set; }
_bstr_t RegExpSyntaxError;  // get set 

Returns a textual representation (in English) of a regular expression syntax error, if any.

CanRedo

readonly CanRedo: boolean;
bool CanRedo { get; }
VARIANT_BOOL CanRedo;  // get 

Determine if you can call the IFileDocument.Redo method.

Sample implementation of the Redo method

void Redo(IFileDocument *pFileDocument)
{
  VARIANT_BOOL bCanRedo;
  
  pFileDocument->get_CanRedo(&bCanRedo);
  if (bCanRedo == VARIANT_TRUE)
    pFileDocument->Redo();
}

Sample implementation of the Redo method

public void Redo(IFileDocument fdoc)
{
  if (fdoc.CanRedo) 
    fdoc.Redo();
}

CanUndo

readonly CanUndo: boolean;
bool CanUndo { get; }
VARIANT_BOOL CanUndo;  // get 

Determine if you can call the IFileDocument.Undo method.

Sample implementation of the Undo method

void Undo(IFileDocument *pFileDocument)
{
  VARIANT_BOOL bCanUndo;
  
  pFileDocument->get_CanUndo(&bCanUndo);
  if (bCanUndo == VARIANT_TRUE)
    pFileDocument->Undo();
}

Sample implementation of the Undo method

public void Undo(IFileDocument fdoc)
{
  if (fdoc.CanUndo) 
    fdoc.Undo();
}

CanPaste

readonly CanPaste: boolean;
bool CanPaste { get; }
VARIANT_BOOL CanPaste;  // get 

Determine if you can paste data from the Clipboard.

// pFileDocument is initialized elsewhere
VARIANT_BOOL bCanPaste;
pFileDocument->get_CanPaste(&bCanPaste);
if (bCanPaste != VARIANT_FALSE)
{
  // Clipboard contains compatible data
} else
{
  // Clipboard contains incompatible data
}

IFileDocument Methods

Close

Close(): void;
void Close();
HRESULT Close();

Discard document's operation history and close the document. You may subsequently call the IFileDocument.New or IFileDocument.Open method for this document.

Complexity: constant-time.

Reusing document objects

var fdoc = new FileDocumentLib.FileDocument();
fdoc.Open(@"c:\temp\file1");
// perform modifications to the file and save it
fdoc.Save(false);

// prepare the object to work with a next document
fdoc.Close();
fdoc.Open(@"c:\temp\file2");
// ...

New

New(): void;
void New();
HRESULT New();

Creates a new, empty document.

Complexity: constant-time.

Open

Open(Name: string, ReadOnly: boolean): void;
void Open(string Name, bool ReadOnly);
HRESULT Open(_bstr_t Name, VARIANT_BOOL ReadOnly);
Name
Full path to the opened file.
ReadOnly
Force read-only mode (the IFileDocument.Save method is disabled).

Opens an existing document. Hex Editor Neo tries to get a read-only access to the file. It also denies write access to all future open attempts, until the file is closed.

Complexity: constant-time.

If supported by the file system, the name may be actually the name of the alternate data stream. Hex Editor Neo fully supports NTFS alternate data streams. You may use any method provided by the object after opening the file stream. Note however, that there are few limitations that are described in the IFileDocument.Save method section.

Opening a document

var fdoc = new FileDocumentLib.FildDocument();
fdoc.Open(@"\\server\share\somefile.bin", false);

OpenPhysicalDisk

OpenPhysicalDisk(PhysicalDiskName: string, FriendlyName: string, ReadOnly: boolean): void;
void OpenPhysicalDisk(string PhysicalDiskName, string FriendlyName, bool ReadOnly);
HRESULT OpenPhysicalDisk(_bstr_t PhysicalDiskName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
PhysicalDiskName
The string of form \\.\PhysicalDriveN, where N is a physical disk number (starting from 0).
FriendlyName
Friendly name. Used only in the editor. You may pass an empty string to this parameter.
ReadOnly
Specify true to open a disk as read-only, or false otherwise.

Open physical disk.

OpenProcess

OpenProcess(ProcessId: number, Start: number, Size: number, ReadOnly: boolean): void;
void OpenProcess(uint ProcessId, long Start, ulong Size, bool ReadOnly);
HRESULT OpenProcess(unsigned long ProcessId, long long Start, unsigned long long Size, VARIANT_BOOL ReadOnly);
ProcessId
Process Identifier
Start
Starting memory address
Size
Size of the range to open
ReadOnly
true to disable the Save command, false otherwise.

Open process memory.

OpenVolume

OpenVolume(VolumeName: string, FriendlyName: string, ReadOnly: boolean): void;
void OpenVolume(string VolumeName, string FriendlyName, bool ReadOnly);
HRESULT OpenVolume(_bstr_t VolumeName, _bstr_t FriendlyName, VARIANT_BOOL ReadOnly);
VolumeName
The name of the volume to open. May be a string of form \\.\c: to open a drive letter, or a full volume mount point name.
FriendlyName
The friendly name. Used only in the editor. You may pass an empty string in this parameter.
ReadOnly
Specify true to open a volume as read-only, or false otherwise.

Open a volume (logical disk).

Save

Save(ForceBackup: boolean): void;
void Save(bool ForceBackup);
HRESULT Save(VARIANT_BOOL ForceBackup);
ForceBackup
Force creation of backup copy of the file.

Saves all document's changes and drop document's operation history. IFileDocument.FileName property must not be empty to successfully call this method. In particular, the Save method may not be called after the IFileDocument.New method. IFileDocument.SaveAs method always set the IFileDocument.FileName property, so you may call the Save method after the SaveAs method was once called for a document.

ForceBackup parameter is ignored (assumed to be false) if the current object represents the NTFS alternate data stream, physical disk, volume, process virtual memory or physical memory.

SaveAs

SaveAs(FileName: string): void;
void SaveAs(string FileName);
HRESULT SaveAs(_bstr_t FileName);
FileName
Full name of the file to write

Saves the file with a different name. The Save As command does not drop a document's operation history. Passing the name of an NTFS alternate data stream to this method is an error and leads to undefined behavior.

To save a document to alternate data stream, first create a stream (this function is outside the scope of this library), open the File Document Object for created stream and use the IFileDocument.Copy and IFileDocument.Paste methods to copy the contents. Then call the created object's IFileDocument.Save method to apply changes.

GetModifiedSel

GetModifiedSel(Selection: ${IMultiSelection}): void;
void GetModifiedSel(${IMultiSelection} Selection);
HRESULT GetModifiedSel(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Multiple Selection object to be filled with modified ranges.

Fills a provided Multiple Selection object with ranges that describe the changed data in the document. The method clears the given multiple selection object before execution.

Complexity: linear-time, depending on the number of document modifications.

Using GetModifiedSel method

var fdoc = new FileDocumentLib.FileDocument();
fdoc.Open(@"c:\temp\file.bin");
fdoc.${FillByte#IFileDocument.FillByte}(0x35, 100, 20);
fdoc.FillByte(0x36, 200, 30);
var msel = fdoc.${CreateEmptySelection#IFileDocument.CreateEmptySelection}();
fdoc.GetModifiedSel(msel);
// msel is now: [100..120) U [200..230)

Decrypt

Decrypt(Provider: string,
    ProviderType: number,
    AlgoID: number,
    Password: string,
    Selection: ${IMultiSelection},
    KeyLength?: number): void;
void Decrypt(string Provider,
    uint ProviderType,
    uint AlgoID,
    string Password,
    ${IMultiSelection} Selection,
    uint KeyLength);
HRESULT Decrypt(_bstr_t Provider,
    unsigned long ProviderType,
    unsigned long AlgoID,
    _bstr_t Password,
    ${IMultiSelectionPtr#IMultiSelection} Selection,
    _variant_t KeyLength);
Provider
The name of the encryption provider. Consult the Microsoft Cryptography API documentation for more information.
ProviderType
The provider type. Consult the Microsoft Cryptography API documentation for more information.
AlgoID
Algortihm identifier.
Password
String containing a password.
Selection
Multiple selection object specifying data to encrypt.
KeyLength
Key length, for supported algorithms.

Decrypt the contents of the document.

Delete

Delete(Offset: number, Size: number): void;
void Delete(ulong Offset, ulong Size);
HRESULT Delete(unsigned long long Offset, unsigned long long Size);
Offset
Range offset.
Size
Range size.

Deletes the given range from the document.

Complexity: constant-time.

Deleting document's data

CComPtr<IFileDocument> pFileDocument;
if (SUCCEEDED(pFileDocument.CoCreateInstance(L"FileDocument.FileDocument")))
{
  if (SUCCEEDED(pFileDocument->${Open#IFileDocument.Open}(L"c:\\temp\\file.bin", VARIANT_FALSE)))
  {
    pFileDocument->Delete(0x50, 0x2a);
    pFileDocument->${Save#IFileDocument.Save}(false);
  }
}

DeleteMulti

DeleteMulti(Selection: ${IMultiSelection}): void;
void DeleteMulti(${IMultiSelection} Selection);
HRESULT DeleteMulti(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Multiple selection object, which describes the ranges to remove from the document.

Deletes the given multiple selection from the document.

Complexity: linear-time, depending on the selection's complexity.

Deleting document's data

CComPtr<IFileDocument> pFileDocument;
if (SUCCEEDED(pFileDocument.CoCreateInstance(L"FileDocument.FileDocument")))
{
  if (SUCCEEDED(pFileDocument->Open(L"c:\\temp\\file.bin", VARIANT_FALSE)))
  {
    CComPtr<IMultiSelection> pMultiSelection;
    if (SUCCEEDED(pFileDocument->CreateEmptySelection(&pMultiSelection)))
    {
      pMultiSelection->${AddRange#IMultiSelection.AddRange}(100, 20);
      pMultiSelection->${AddRange#IMultiSelection.AddRange}(200, 30);
      pFileDocument->DeleteMulti(pMultiSelection);
      pFileDocument->Save(false);
    }
  }
}

Encrypt

Encrypt(Provider: string,
    ProviderType: number,
    AlgoID: number,
    Password: string,
    Selection: ${IMultiSelection},
    KeyLength?: number): void;
void Encrypt(string Provider,
    uint ProviderType,
    uint AlgoID,
    string Password,
    ${IMultiSelection} Selection,
    uint KeyLength);
HRESULT Encrypt(_bstr_t Provider,
    unsigned long ProviderType,
    unsigned long AlgoID,
    _bstr_t Password,
    ${IMultiSelectionPtr#IMultiSelection} Selection,
    _variant_t KeyLength);
Provider
The name of the encryption provider. Consult the Microsoft Cryptography API documentation for more information.
ProviderType
The provider type. Consult the Microsoft Cryptography API documentation for more information.
AlgoID
Algortihm identifier.
Password
String containing a password.
Selection
Multiple selection object specifying data to encrypt.
KeyLength
Key length, for supported algorithms.

Decrypt the contents of the document.

Fill

// This method is not available in scripting environment
void Fill(ref byte Pattern,
    uint PatternSize,
    ulong Offset,
    ulong Size);
HRESULT Fill(unsigned char * Pattern,
    unsigned long PatternSize,
    unsigned long long Offset,
    unsigned long long Size);
Pattern
Pointer to a pattern.
PatternSize
Pattern size, in bytes.
Offset
Range starting offset.
Size
Range size.

Fills a given range with a given pattern. A pattern is repeated until the required number of bytes is written to the file. If file is shorter than the filling range, the file's size is increased.

Complexity: constant-time.

Filling a range with a simple pattern

// pFileDocument is initialized elsewhere
unsigned char Pattern[]="Simple Pattern";
HRESULT hRes = pFileDocument->Fill(Pattern, sizeof(Pattern) - 1, 0x10000i64, 0x10ffi64);

FillByte

FillByte(FillValue: number, Offset: number, Size: number): void;
void FillByte(byte FillValue, ulong Offset, ulong Size);
HRESULT FillByte(unsigned char FillValue, unsigned long long Offset, unsigned long long Size);
FillValue
The byte to put in the range.
Offset
Range offset.
Size
Range size.

Fills a given range with a single byte value.

Complexity: constant-time.

Filling a range with a single byte

// fdoc is initialized elsewhere
fdoc.FillByte(0x34, 1000, 200);

FillByteMulti

FillByteMulti(FillValue: number, Selection: ${IMultiSelection}): void;
void FillByteMulti(byte FillValue, ${IMultiSelection} Selection);
HRESULT FillByteMulti(unsigned char FillValue, ${IMultiSelectionPtr#IMultiSelection} Selection);
FillValue
The byte to put in the selection.
Selection
The multiple selection object, which contains the ranges to fill in the document.

Fills a given multiple selection with a single byte value.

Complexity: linear-time, depending on the selection's complexity.

Filling a range with a single byte

// fdoc is initialized elsewhere
var msel = fdoc.${CreateEmptySelection#IFileDocument.CreateEmptySelection}();
msel.${AddRange#IMultiSelection.AddRange}(100, 20);
msel.${AddRange#IMultiSelection.AddRange}(200, 30);
fdoc.FillByteMulti(0x35, msel);

FillMulti

// This method is not available in scripting environment
void FillMulti(ref byte Pattern, uint PatternSize, ${IMultiSelection} Selection,  Continue);
HRESULT FillMulti(unsigned char * Pattern, unsigned long PatternSize, ${IMultiSelectionPtr#IMultiSelection} Selection,  Continue);
Pattern
Pointer to a pattern
PatternSize
Pattern Size
Selection
The multiple selection object, which contains the ranges to fill in the document.
Continue
True to continue filling in a new range and False to start from the beginning of the pattern. See the description of the “Transparent fill” flag in the Fill user-interface command for more information.

Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. bCont parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.

Complexity: linear-time, depending on the selection's complexity.

Filling a range with a single byte

// fdoc is initialized elsewhere
var msel = fdoc.CreateEmptySelection();
msel.${AddRange#IMultiSelection.AddRange}(100, 20);
msel.${AddRange#IMultiSelection.AddRange}(200, 30);
byte[] pattern = new byte[] { 0x31, 0x32, 0x33 };
fdoc.FillMulti(ref pattern[0], pattern.Length, msel, false);

Insert

// This method is not available in scripting environment
void Insert(ref byte Data, ulong Offset, uint InsertSize);
HRESULT Insert(unsigned char * Data, unsigned long long Offset, unsigned long InsertSize);
Data
Pointer to a pattern.
Offset
Insert offset.
InsertSize
Pattern size.

Inserts a pattern into the document. Insert command shifts file's data to free up the space to fit an inserted pattern.

Complexity: constant-time.

Inserting a pattern

// fdoc is initialized elsewhere
byte[] pattern = new byte[] { 0x0d, 0x0a };
fdoc.Insert(ref pattern[0], 100, pattern.Length);  // insert a given pattern at the offset 100

InsertByte

InsertByte(ByteFill: number, Offset: number, Size: number): void;
void InsertByte(byte ByteFill, ulong Offset, ulong Size);
HRESULT InsertByte(unsigned char ByteFill, unsigned long long Offset, unsigned long long Size);
ByteFill
The byte value to insert.
Offset
Insert offset.
Size
Insert size.

Inserts a block of a given size into the document and fill it with a given byte value.

Complexity: constant-time.

Inserting a pattern

// fdoc is initialized elsewhere
fdoc.InsertByte('#', 100, 10000);

InsertPattern

// This method is not available in scripting environment
void InsertPattern(ref byte Pattern,
    uint PatternSize,
    ulong Offset,
    ulong Size);
HRESULT InsertPattern(unsigned char * Pattern,
    unsigned long PatternSize,
    unsigned long long Offset,
    unsigned long long Size);
Pattern
Pointer to a pattern.
PatternSize
Pattern Size.
Offset
Insert offset.
Size
Insert size.

Inserts a given pattern into the document, repeating it to fill the given size. Insert command shifts file's data to free up the space to fit an inserted pattern.

Complexity: constant-time.

Inserting a pattern

// fdoc is initialized elsewhere
byte[] pattern = new byte[] { 0x0d, 0x0a };
fdoc.InsertPattern(ref pattern[0], pattern.Length, 100, 1000);

PutFile

PutFile(FileName: string, Offset: , InsertMode: boolean): void;
void PutFile(string FileName, ulong Offset, bool InsertMode);
HRESULT PutFile(_bstr_t FileName, unsigned long long Offset, VARIANT_BOOL InsertMode);
FileName
The full path name of the file.
Offset
Insert offset.
InsertMode
true to insert a file's contents, false to overwrite the current document's data with data from the file.

Writes or inserts the contents of the file into the current document. InsertMode parameter governs the behavior of the function.

Complexity: constant-time.

Concatenating Files

var fdoc = new ActiveXObject("FileDocument.FileDocument");
fdoc.Open("c:\\temp\\file1.bin");
fdoc.PutFile("c:\\temp\\file2.bin", fdoc.FileSize, false);
fdoc.Save(false);

Read

// This method is not available in scripting environment
void Read(ref byte Data, ulong Offset, uint ReadSize);
HRESULT Read(unsigned char * Data, unsigned long long Offset, unsigned long ReadSize);
Data
A pointer to the buffer that receives the data read from a file
Offset
Read offset.
ReadSize
Total number of bytes to read.

Reads data from a document. If requested data exceeds the current document's size, any excess bytes are filled with zeros.

Complexity: constant-time.

Reading Data

// pFileDocument is initialized elsewhere
unsigned char data[256];
pFileDocument->Read(data, 1000, 256);

Write

// This method is not available in scripting environment
void Write(ref byte Data, ulong Offset, uint WriteSize);
HRESULT Write(unsigned char * Data, unsigned long long Offset, unsigned long WriteSize);
Data
Pointer to the buffer containing the data to be written to the file.
Offset
Write offset.
WriteSize
Total number of bytes to write.

Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.

Complexity: constant-time.

Writing Data

// pFileDocument is initialized elsewhere
unsigned char data[256];
pFileDocument->Write(data, 1000, 256);

CreatePatch

CreatePatch(PatchName: string, Options: ${PatchOptions}, PathToStubFile?: string): void;
void CreatePatch(string PatchName, ${PatchOptions} Options, string PathToStubFile);
HRESULT CreatePatch(_bstr_t PatchName, ${PatchOptions} Options, _variant_t PathToStubFile);
PatchName
The full path of the patch file. If file already exists, it is overwritten.
Options
Patch options. See [PatchOptions] enumeration for possible values.
PathToStubFile
An optional path to an executable stub file. Should be a full path to either PatchApply32.exe or PatchApply64.exe application, installed with the Hex Editor Neo.

Creates a patch file. See the Patch Creation section for more information on patches.

Complexity: linear-time, depending on the number and complexity of operations in document's operation history.

Creating patch

// fdoc is initialized elsewhere
// Perform a modification to the file
fdoc.FillByte(0, 100, 20);
fdoc.CreatePatch(@"c:\patch.hexpatch", FileDocumentLib.PatchOptions.PatchCalculateHash | FileDocumentLib.PatchOptions.PatchSaveFileName, null);

LoadHistory

// This method is not available in scripting environment
void LoadHistory(IStream Stream);
HRESULT LoadHistory(IStream * Stream);
Stream
Pointer to a stream object from which to load history.

Loads a document's operation history from a file.

Complexity: linear-time, depending on the saved history's complexity.

Purge

Purge(Level: ${HistoryPurgeLevel}): void;
void Purge(${HistoryPurgeLevel} Level);
HRESULT Purge(${HistoryPurgeLevel} Level);
Level
Purge level. Can be one of the values described in the HistoryPurgeLevel topic.

Purges a document's operation history. See Purging History section for more information.

Complexity: constant-time for all purge levels except HistoryPurgeAllButCurrent and linear-time for HistoryPurgeAllButCurrent.

Purging history

// fdoc is initialized elsewhere
fdoc.FillByte(0x35, 100, 40);
// ...
fdoc.Purge(FileDocumentLib.HistoryPurgeLevel.HistoryPurgeAll);  // discard all operations

Redo

Redo(Steps?: number): void;
void Redo(uint Steps);
HRESULT Redo(_variant_t Steps);
Steps
Optional number of operations to redo. If omitted, one operation is redone.

Redoes Steps recently undone operations.

Complexity: constant-time.

SaveHistory

// This method is not available in scripting environment
void SaveHistory(IStream Stream);
HRESULT SaveHistory(IStream * Stream);
Stream
Pointer to a stream object to write history to.

Saves the document's operation history to a given stream object.

Complexity: linear-time, depending on the history's complexity.

Undo

Undo(Steps?: number): void;
void Undo(uint Steps);
HRESULT Undo(_variant_t Steps);
Steps
Optional number of operations to undo. If omitted, one operation is undone.

Undoes last Steps operations.

Complexity: constant-time.

Copy

Copy(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
void Copy(${IMultiSelection} Selection, bool MergeBlocks);
HRESULT Copy(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
Selection
The multiple selection object.
MergeBlocks
true to merge selection blocks, false to leave them as is

Copies the given selection to the Clipboard.

Complexity: linear-time, depending on the selection's complexity.

Placing document's data to the Clipboard

// fdoc is defined and obtained elsewhere
var msel = fdoc.CreateEmptySelection(); // create an empty selection object
msel.AddRange(100, 20); // add a first range to the selection
msel.AddRange(200, 20); // add a second range to the selection
fdoc.Copy(msel, false); // place data to the clipboard

Cut

Cut(Selection: ${IMultiSelection}, MergeBlocks: boolean): void;
void Cut(${IMultiSelection} Selection, bool MergeBlocks);
HRESULT Cut(${IMultiSelectionPtr#IMultiSelection} Selection, VARIANT_BOOL MergeBlocks);
Selection
The multiple selection object.
MergeBlocks
true to merge selection blocks, false to leave them as is

Copies the given selection to the Clipboard and removes it from the document.

Complexity: linear-time, depending on the selection's complexity.

Cutting document's data to the Clipboard

// fdoc is defined and obtained elsewhere
var msel = fdoc.CreateEmptySelection(); // create an empty selection object
msel.AddRange(100, 20); // add a first range to the selection
msel.AddRange(200, 20); // add a second range to the selection
fdoc.Cut(msel, false); // place data to the clipboard

Paste

Paste(Offset: number, InsertMode: boolean): void;
void Paste(ulong Offset, bool InsertMode);
HRESULT Paste(unsigned long long Offset, VARIANT_BOOL InsertMode);
Offset
Paste offset
InsertMode
true to insert data, false to overwrite data.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

This method is superseded by IFileDocument.Paste2 method, but is still supported.

Using Paste

var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();

msel.AddRange(0, 10);
fdoc.Copy(msel, false);

fdoc.Paste(20, true); // Equivalent to fdoc.Paste2(20, TypeHexByte, true);
fdoc.Paste(100, false); // Equivalent to fdoc.Paste2(100, TypeHexByte, false);

Paste2

Paste2(Offset: number, Type: ${TextType}, InsertMode: boolean): void;
void Paste2(ulong Offset, ${TextType} Type, bool InsertMode);
HRESULT Paste2(unsigned long long Offset, ${TextType} Type, VARIANT_BOOL InsertMode);
Offset
Paste offset
Type
Type of text in the Clipboard. Used only if Clipboard contains textual data, otherwise ignored. Can be one of the values from TextType enumeration. A number may be prefixed by the 0x prefix which forces it to be in base 16.
InsertMode
true to insert data, false to overwrite data.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Using Paste

var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();

msel.AddRange(0, 10);
fdoc.Copy(msel, false);

fdoc.Paste2(20, TextType.TypeHexByte, true);
fdoc.Paste2(100, TextType.TypeHexByte, false);

Paste3

Paste3(Offset: number, Type: ${TextType}, Flags: ${Paste3Flags}): void;
void Paste3(ulong Offset, ${TextType} Type, ${Paste3Flags} Flags);
HRESULT Paste3(unsigned long long Offset, ${TextType} Type, ${Paste3Flags} Flags);
Offset
Paste offset
Type
Type of text in the Clipboard. Used only if Clipboard contains textual data, otherwise ignored. Can be one of the values from TextType enumeration. A number may be prefixed by the 0x prefix which forces it to be in base 16.
Flags
Pasting flags. Can be one or more values from the Paste3Flags enumeration.

Pastes data from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode flag in Flags parameter.

PasteText

PasteText(Offset: number, Unicode: boolean, InsertMode: boolean): void;
void PasteText(ulong Offset, bool Unicode, bool InsertMode);
HRESULT PasteText(unsigned long long Offset, VARIANT_BOOL Unicode, VARIANT_BOOL InsertMode);
Offset
Paste offset
Unicode
Paste text as Unicode (true) or ANSI (false).
InsertMode
true to insert data, false to overwrite data.

Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Unicode parameter tells the Hex Editor Neo to interpret the text in the Clipboard as UNICODE or ANSI. If Unicode is true, each character occupies two bytes, otherwise, it occupies a single byte.

PasteText2

PasteText2(Offset: number, CodePage: number, InsertMode: boolean): void;
void PasteText2(ulong Offset, uint CodePage, bool InsertMode);
HRESULT PasteText2(unsigned long long Offset, unsigned long CodePage, VARIANT_BOOL InsertMode);
Offset
Paste offset
CodePage
The code page to convert text to. Set to CP_UNICODE (hardcoded as -5) to specify UTF-16 encoding.
InsertMode
True to insert data, False to overwrite data.

Pastes text from the Clipboard to the given position. Pasted data either overwrites the current document's data, or is inserted into the document, shifting existing data forward, depending on the InsertMode parameter.

Hex Editor Neo uses the CodePage to convert the text in the Clipboard. Pass the CP_UNICODE (hardcoded as -5) to specify the UTF-16 encoding.

This method requires the CF_UNICODETEXT format to be present in the Clipboard in order to convert to the given encoding. If only CF_TEXT is available, than it operates exactly like the IFileDocument.PasteText method.

Find

// This method is not available in scripting environment
ulong Find(ref byte DataToFind,
    uint DataSize,
    ${IMultiSelection} Selection,
    ulong StartFrom,
    bool SearchUp,
    bool ignore_case);
unsigned long long Find(unsigned char * DataToFind,
    unsigned long DataSize,
    ${IMultiSelectionPtr#IMultiSelection} Selection,
    unsigned long long StartFrom,
    VARIANT_BOOL SearchUp,
    VARIANT_BOOL ignore_case);
DataToFind
Pointer to a pattern.
DataSize
Pattern size.
Selection
Multiple selection object, which contains ranges in which you want to locate a pattern.
StartFrom
Offset from which you want to start searching.
SearchUp
true to search backwards and false to search forward.
ignore_case
true to ignore case and false to perform exact matching.

Offset of the located pattern or -1 if pattern was not found.

Searches for a pattern within a given selection. This method returns the offset of the matched pattern. To continue searching, call this method again, adjusting StartFrom parameter appropriately. If pattern is not found in the specified range, -1 is returned.

Complexity: linear-time, depending on the file's size and selection's complexity.

Searching for a pattern

var fdoc = new FileDocumentLib.FileDocument();
var msec = fdoc.CreateEmptySelection();

fdoc.Open(@"c:\temp\file.txt");
msec.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

byte[] pattern = new byte[] { 0x0d, 0x0a }; // EOL pattern
ulong EOL_Offset = fdoc.Find(ref pattern[0], pattern.Length, msel, 0, false, false);
// ...
// continue searching
EOL_Offset = fdoc.Find(ref pattern[0], pattern.Length, msel, EOL_Offset + 1, false, false);

FindRegExp

// This method is not available in scripting environment
void FindRegExp(string RegExp,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ulong StartFrom,
    ulong Size,
    ref ulong FoundOffset,
    ref ulong MatchSize);
HRESULT FindRegExp(_bstr_t RegExp,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long StartFrom,
    unsigned long long Size,
    unsigned long long * FoundOffset,
    unsigned long long * MatchSize);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of values from RegExpFlags enumeration.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.
FoundOffset
On output, the found offset is stored in this parameter.
MatchSize
On output, the match's size is stored in this parameter.

Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom field appropriately. If a pattern is not found in the specified range, this method returns an error.

Complexity: depends on the range's size and regular expression complexity.

If regular expression syntax is invalid, the method returns (or throws) an error E_INVALIDARG. A IFileDocument.RegExpSyntaxError property contains the description of the syntax error.

When match is not found, the method returns (or throws) a NOT_FOUND error.

This function is obsolete. Use the IFileDocument.FindRegExp2 instead.

FindRegExp2

// This method is not available in scripting environment
void FindRegExp2(string RegExp,
    uint CodePage,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ulong StartFrom,
    ulong Size,
    ref ulong FoundOffset,
    ref ulong MatchSize);
HRESULT FindRegExp2(_bstr_t RegExp,
    unsigned long CodePage,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long StartFrom,
    unsigned long long Size,
    unsigned long long * FoundOffset,
    unsigned long long * MatchSize);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
CodePage
Code page for regular expression pattern encoding or CP_UNICODE (-5) for UTF-16.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be a combination of values from the RegExpFlags enumeration.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.
FoundOffset
On output, the found offset is stored in this parameter.
MatchSize
On output, the match's size is stored in this parameter.

Searches for an occurrence of a regular expression within a given range. To continue searching, call this method again, adjusting StartFrom field appropriately. If a pattern is not found in the specified range, this method returns an error.

Complexity: depends on the range's size and regular expression complexity.

If regular expression syntax is invalid, the method returns (or throws) an error E_INVALIDARG. A IFileDocument.RegExpSyntaxError property contains the description of the syntax error.

When match is not found, the method returns (or throws) a NOT_FOUND error.

FindAll

// This method is not available in scripting environment
void FindAll(ref byte DataToFind,
    uint DataSize,
    ${IMultiSelection} Selection,
    bool IgnoreCase,
    ${IMultiSelection} Found);
HRESULT FindAll(unsigned char * DataToFind,
    unsigned long DataSize,
    ${IMultiSelectionPtr#IMultiSelection} Selection,
    VARIANT_BOOL IgnoreCase,
    ${IMultiSelectionPtr#IMultiSelection} Found);
DataToFind
Pointer to a pattern.
DataSize
Pattern size
Selection
Multiple Selection object, which contains ranges in which a pattern need to be located.
IgnoreCase
true to ignore case, false to perform exact matching.
Found
Multiple Selection object, which contains, on method's return, all located ranges.

Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection Object Found, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: linear-time, depending on the file's size and selection's complexity.

Searching all pattern occurrences

var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();
var mselOutput = fdoc.CreateEmptySelection();

fdoc.Open(@"c:\temp\file.txt");
msel.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

byte[] pattern = new byte[] { 0x0d, 0x0a }; // EOL pattern
fdoc.FindAll(ref pattern[0], pattern.Length, msel, false, mselOutput);
if (!mselOutput.Empty) // check if there are any matches
  fdoc.Copy(mselOutput,false);  // copy them to the Clipboard

FindAllRegExp

FindAllRegExp(RegExp: string,
    SubExpression: number,
    Flags: ${RegExpFlags},
    StartFrom: number,
    Size: number,
    Found: ${IMultiSelection}): void;
void FindAllRegExp(string RegExp,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ulong StartFrom,
    ulong Size,
    ${IMultiSelection} Found);
HRESULT FindAllRegExp(_bstr_t RegExp,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long StartFrom,
    unsigned long long Size,
    ${IMultiSelectionPtr#IMultiSelection} Found);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more values from the RegExpFlags enumeration.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.
Found
Multiple Selection object, which contains, on method's return, all located ranges.

A number of occurrences

Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection Object Found, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: depends on the range's size and regular expression complexity.

This method is obsolete. Use the IFileDocument.FindAllRegExp2 instead.

FindAllRegExp2

FindAllRegExp2(RegExp: string,
    CodePage: number,
    SubExpression: number,
    Flags: ${RegExpFlags},
    StartFrom: number,
    Size: number,
    Found: ${IMultiSelection}): void;
void FindAllRegExp2(string RegExp,
    uint CodePage,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ulong StartFrom,
    ulong Size,
    ${IMultiSelection} Found);
HRESULT FindAllRegExp2(_bstr_t RegExp,
    unsigned long CodePage,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long StartFrom,
    unsigned long long Size,
    ${IMultiSelectionPtr#IMultiSelection} Found);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
CodePage
Code page for regular expression pattern encoding or CP_UNICODE (-5) for UTF-16.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more values from the RegExpFlags enumeration.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpTypeUNICODE flag is specified.
Found
Multiple Selection object, which contains, on method's return, all located ranges.

A number of occurrences.

Locates all matches of a given regular expression in a given range. You provide the function with an output Multiple Selection Object Found, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: depends on the range's size and regular expression complexity.

Replace

// This method is not available in scripting environment
void Replace(ulong Offset,
    uint SizeFrom,
    ref byte To,
    uint SizeTo);
HRESULT Replace(unsigned long long Offset,
    unsigned long SizeFrom,
    unsigned char * To,
    unsigned long SizeTo);
Offset
Replace offset.
SizeFrom
Size of the original pattern.
To
Pointer to a replace pattern.
SizeTo
Size of the replace pattern

Replaces the given block with a pattern. This method replaces a range described by Offset and SizeFrom parameters with a pattern.

Complexity: constant-time.

Replacing a pattern

var fdoc = new FileDocumentLib.FileDocument();
var msec = fdoc.CreateEmptySelection();

fdoc.Open(@"c:\temp\file.txt");
msec.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

byte[] pattern1 = new byte[] { 0x0d, 0x0a }; // EOL pattern
byte[] pattern2 = new byte[] { 0x0d, 0x0a, 0x0d, 0x0a }; // Double-EOL pattern
ulong EOL_Offset = fdoc.Find(ref pattern1[0], pattern1.Length, msel, 0, false, false);
if (EOL_Offset != -1)
  fdoc.Replace(EOL_Offset, pattern1.Length, ref pattern2[0], pattern2.Length);

ReplaceAll

// This method is not available in scripting environment
void ReplaceAll(ref byte From,
    uint SizeFrom,
    ref byte To,
    uint SizeTo,
    bool IgnoreCase,
    ${IMultiSelection} Selection);
HRESULT ReplaceAll(unsigned char * From,
    unsigned long SizeFrom,
    unsigned char * To,
    unsigned long SizeTo,
    VARIANT_BOOL IgnoreCase,
    ${IMultiSelectionPtr#IMultiSelection} Selection);
From
Pointer to a search pattern.
SizeFrom
Search pattern size.
To
Pointer to a replace pattern.
SizeTo
Replace pattern size.
IgnoreCase
true to ignore case, false to perform exact matching.
Selection
Multiple Selection Object, describing the ranges in which to perform search and replace.

A number of replacements done.

Finds and replaces all occurrences of the given pattern with another pattern.

Complexity: varying.

Searching all pattern occurrences

var fdoc = new FileDocumentLib.FileDocument();
var msel = fdoc.CreateEmptySelection();

fdoc.Open(@"c:\temp\file.txt");
msel.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

byte[] pattern1 = new byte[] { 0x0d, 0x0a }; // EOL pattern
byte[] pattern2 = new byte[] { 0x0d, 0x0a, 0x0d, 0x0a }; // Double-EOL pattern
ulong nReplacements = fdoc.ReplaceAll(ref pattern1[0], pattern1.Length, ref pattern2[0], pattern2.Length, false, msel);

ReplaceAllRegExp

// This method is not available in scripting environment
void ReplaceAllRegExp(string RegExp,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ref byte To,
    uint SizeTo,
    ulong StartFrom,
    ulong Size);
HRESULT ReplaceAllRegExp(_bstr_t RegExp,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned char To,
    unsigned long SizeTo,
    unsigned long long StartFrom,
    unsigned long long Size);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from RegExpFlags enumeration.
To
Pointer to a replace pattern.
SizeTo
Replace pattern size.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

A number of occurrences.

Finds and replaces all occurrences of regular expression matches with a given pattern.

Complexity: varying.

This method is obsolete. Use the IFileDocument.ReplaceAllRegExp2 instead.

ReplaceAllRegExp2

// This method is not available in scripting environment
void ReplaceAllRegExp2(string RegExp,
    uint CodePage,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ref byte To,
    uint SizeTo,
    ulong StartFrom,
    ulong Size);
HRESULT ReplaceAllRegExp2(_bstr_t RegExp,
    unsigned long CodePage,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned char * To,
    unsigned long SizeTo,
    unsigned long long StartFrom,
    unsigned long long Size);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
CodePage
Code page for regular expression pattern encoding or CP_UNICODE (-5) for UTF-16.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from the RegExpFlags enumeration.
To
Pointer to a replace pattern.
SizeTo
Replace pattern size.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

A number of occurrences.

Finds and replaces all occurrences of regular expression matches with a given pattern.

Complexity: varying.

ReplaceAllRegExpWithRegExp

ReplaceAllRegExpWithRegExp(RegExp: string,
    ReplacePattern: string,
    CodePage: number,
    Flags: ${RegExpFlags},
    StartFrom: number,
    Size: number): void;
void ReplaceAllRegExpWithRegExp(string RegExp,
    string ReplacePattern,
    uint CodePage,
    ${RegExpFlags} Flags,
    ulong StartFrom,
    ulong Size);
HRESULT ReplaceAllRegExpWithRegExp(_bstr_t RegExp,
    _bstr_t ReplacePattern,
    unsigned long CodePage,
    ${RegExpFlags} Flags,
    unsigned long long StartFrom,
    unsigned long long Size);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
ReplacePattern
A string that contains a replace regular expression.
CodePage
Code page for both regular expression patterns encoding or CP_UNICODE (-5) for UTF-16.
Flags
Flags that change the behavior of the function. May be one or more of the values from RegExpFlags enumeration.
StartFrom
A start offset of the range. Must be a multiple of 2 if UTF-16 encoding is used.
Size
Range's size. Must be a multiply of 2 if UTF-16 encoding is used.

A number of occurrences.

Finds and replaces all occurrences of regular expression matches with a given regular expression pattern.

Complexity: varying.

Gap

Gap(pSelection: ${IMultiSelection}): void;
void Gap(${IMultiSelection} pSelection);
void Gap(${IMultiSelection} pSelection);
pSelection
The multi-selection object that specifies which regions to gap.

“Gaps” specified regions, that is, marks them as “absent”. Currently persisted only in encoded binary formats, like Intel HEX or Motorola S-records.

ArithmeticOp

ArithmeticOp(Selection: ${IMultiSelection},
    Type: ${ArithmeticOpType},
    OpSize: ${OperandSizeType},
    Operand?: any): void;
void ArithmeticOp(${IMultiSelection} Selection,
    ${ArithmeticOpType} Type,
    ${OperandSizeType} OpSize,
    object Operand);
HRESULT ArithmeticOp(${IMultiSelectionPtr#IMultiSelection} Selection,
    ${ArithmeticOpType} Type,
    ${OperandSizeType} OpSize,
    _variant_t Operand);
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from the ArithmeticOpType enumeration.
OpSize
Specifies the operand size. Can be one of the values from the OperandSizeType enumeration.
Operand
Second operand. Ignored for ArithmeticOpNegation operation type.

Performs an arithmetic operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

BitwiseOp

// This method is not available in scripting environment
void BitwiseOp(${IMultiSelection} Selection, ${BitwiseOpType} Type, ref byte Data, uint DataSize);
HRESULT BitwiseOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${BitwiseOpType} Type, unsigned char * Data, unsigned long DataSize);
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from the BitwiseOpType enumeration.
Data
Pointer to an operand pattern.
DataSize
Operand pattern size in bytes. Must be zero for BitwiseOpNOT operation type.

Performs a bitwise operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

CaseOp

CaseOp(Selection: ${IMultiSelection},
    Type: ${CaseOpType},
    Unicode: boolean,
    CodePage?: number): void;
void CaseOp(${IMultiSelection} Selection,
    ${CaseOpType} Type,
    bool Unicode,
    object CodePage);
HRESULT CaseOp(${IMultiSelectionPtr#IMultiSelection} Selection,
    ${CaseOpType} Type,
    VARIANT_BOOL Unicode,
    _variant_t CodePage);
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from CaseOpType enumeration.
Unicode
true to treat selection data as UNICODE, false otherwise. If this parameter is true, all blocks in a given selection must have alignment of 2 bytes.
CodePage
Optional code page that describes the encoding used in the selection. Ignored if Unicode parameter is True.

Performs a case change operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

ShiftOp

ShiftOp(Selection: ${IMultiSelection}, Type: ${ShiftOpType}, OpSize: , Bits: number): void;
void ShiftOp(${IMultiSelection} Selection, ${ShiftOpType} Type,  OpSize, uint Bits);
HRESULT ShiftOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${ShiftOpType} Type,  OpSize, unsigned long Bits);
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from ShiftOpType enumeration.
OpSize
Specifies the operand size. Can be one of the values from OperandSizeType enumeration.
Bits
The number of bits to shift.

Performs a shift operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

ReverseOp

ReverseOp(Selection: ${IMultiSelection}, Type: ${ReverseOpType}, OpSize: ${OperandSizeType}): void;
void ReverseOp(${IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
HRESULT ReverseOp(${IMultiSelectionPtr#IMultiSelection} Selection, ${ReverseOpType} Type, ${OperandSizeType} OpSize);
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from ReverseOpType enumeration.
OpSize
Specifies the operand size. Can be one of the values from OperandSizeType enumeration.

Performs a bit or byte reverse operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

GatherStatistics

// This method is not available in scripting environment
ulong[] GatherStatistics(${IMultiSelection} Selection);
unsigned long long[256] GatherStatistics(${IMultiSelectionPtr#IMultiSelection} Selection);
Selection
Multiple Selection object that describing ranges, in which you want to calculate statistics.

Statistics array.

Calculates file statistics. See the General Statistics section for more information. On method return, each of 256 elements in an array contains the number of corresponding byte occurrences.

Complexity: linear-time, depending on the file's size.

Calculating General Statistics

// pFileDocument and pMultiSelection are initialized elsewhere
unsigned long long data[256];
pFileDocument->GatherStatistics(pMultiSelection, data);

PatternStatistics

// This method is not available in scripting environment
void PatternStatistics(ref byte Pattern,
    uint DataSize,
    bool IgnoreCase,
    ref ulong DataBuffer,
    uint Blocks,
    ${IMultiSelection} Selection);
HRESULT PatternStatistics(unsigned char * Pattern,
    unsigned long DataSize,
    VARIANT_BOOL IgnoreCase,
    unsigned long long * DataBuffer,
    unsigned long Blocks,
    ${IMultiSelectionPtr#IMultiSelection} Selection);
Pattern
Pointer to a pattern.
DataSize
Pattern Size.
IgnoreCase
true to ignore case, false to perform exact matching.
DataBuffer
Pointer to the statistics buffer.
Blocks
Number of blocks.
Selection
Multiple Selection Object, containing ranges in which you want to calculate statistics.

Calculates file statistics. See the Pattern Statistics section for more information. On method return, the DataBuffer buffer is filled with calculated statistics values.

Complexity: linear-time, depending on the file's size.

Calculating Pattern Statistics

// pFileDocument and pMultiSelection are initialized elsewhere
unsigned __int64 data[1024];
unsigned char pattern[] = { 0x0d, 0x0a };
pFileDocument->PatternStatistics(pattern, sizeof(pattern), false, data, 1024, pMultiSelection);

PatternStatisticsRegExp

// This method is not available in scripting environment
void PatternStatisticsRegExp(string RegExp,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ref ulong DataBuffer,
    uint Blocks,
    ulong StartFrom,
    ulong Size);
HRESULT PatternStatisticsRegExp(_bstr_t RegExp,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long * DataBuffer,
    unsigned long Blocks,
    unsigned long long StartFrom,
    unsigned long long Size);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from the RegExpFlags enumeration.
DataBuffer
Pointer to the statistics buffer.
Blocks
Number of blocks.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

Calculates file statistics for a given regular expression. See the Pattern Statistics section for more information. On method return, the DataBuffer buffer is filled with calculated statistics values.

Complexity: linear-time, depending on the file's size and regular expression complexity.

This method is obsolete. Use the IFileDocument.PatternStatisticsRegExp2 instead.

PatternStatisticsRegExp2

// This method is not available in scripting environment
void PatternStatisticsRegExp2(string RegExp,
    uint CodePage,
    uint SubExpression,
    ${RegExpFlags} Flags,
    ref ulong DataBuffer,
    uint Blocks,
    ulong StartFrom,
    ulong Size);
HRESULT PatternStatisticsRegExp2(_bstr_t RegExp,
    unsigned long CodePage,
    unsigned long SubExpression,
    ${RegExpFlags} Flags,
    unsigned long long * DataBuffer,
    unsigned long Blocks,
    unsigned long long StartFrom,
    unsigned long long Size);
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
CodePage
Code page for regular expression pattern encoding or CP_UNICODE (-5) for UTF-16.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from RegExpFlags enumeration.
DataBuffer
Pointer to the statistics buffer.
Blocks
Number of blocks.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

Calculates file statistics for a given regular expression. See the Pattern Statistics section for more information. On method return, the DataBuffer buffer is filled with calculated statistics values.

Complexity: linear-time, depending on the file's size and regular expression complexity.

CreateEmptySelection

CreateEmptySelection(): ${IMultiSelection};
${IMultiSelection} CreateEmptySelection();
${IMultiSelectionPtr#IMultiSelection} CreateEmptySelection();

Returns the newly created Multiple Selection Object.

Sel Pointer to a variable that receives a pointer to the IMultiSelection interface of created multiple selection object.

Creates an empty selection object. Complexity: constant-time.

Creating an empty selection object

// pFileDocument is obtained elsewhere
IMultiSelection *pMultiSelection {};
if (SUCCEEDED(pFileDocument->CreateEmptySelection(&pMultiSelection)))
{
  // work with a selection
  pMultiSelection->Release(); // release object
}

CreateSequence

CreateSequence(): ${ISequence};
${ISequence} CreateSequence();
${ISequencePtr#ISequence} CreateSequence();

Create an empty Sequence Object.

BitwiseOpS

BitwiseOpS(Selection: ${IMultiSelection}, Type: ${BitwiseOpType}, Sequence: ${ISequence}): void;
// This method is not available in managed environment
// This method is not available in native environment
Selection
The multiple selection object which contains ranges for this operation to work on.
Type
The operation to perform. Can be one of the values from BitwiseOpType enumeration.
Sequence
Sequence object containing operand.

Performs a bitwise operation on a given selection.

Complexity: linear-time, depending on selection's complexity.

This method is a replacement for IFileDocument.BitwiseOp when used in scripting languages.

FillMultiS

FillMultiS(Sequence: ${ISequence}, Selection: ${IMultiSelection}, Continue: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object containing the data to fill.
Selection
The multiple selection object, which contains the ranges to fill in the document.
Continue
True to continue filling in a new range and False to start from the beginning of the pattern. See the description of the “Transparent fill” flag in the Fill user-interface command for more information.

Fills a given multiple selection with a specified pattern. The pattern is repeated until all given range(s) are filled. Continue parameter specifies whether to continue filling a new range from the previous range, or from the beginning of the pattern.

Complexity: linear-time, depending on the selection's complexity.

This method is a replacement for IFileDocument.FillMulti when used in scripting languages.

Filling a range with a single byte

// fdoc is initialized elsewhere
var msel = fdoc.CreateEmptySelection();
msel.AddRange(100, 20);
msel.AddRange(200, 30);
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x31, 0x32, 0x33);
fdoc.FillMultiS(pattern, msel, false);

FillS

FillS(Sequence: ${ISequence}, Offset: number, Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence containing data to fill.
Offset
Range starting offset
Size
Range size

Fills a given range with a given pattern. A pattern is repeated until the required number of bytes is written to the file. If file is shorter than the filling range, the file's size is increased.

Complexity: constant-time.

This method is a replacement for IFileDocument.Fill when used in scripting languages.

Filling a range with a simple pattern

// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddText("Simple Pattern", false);
fdoc.FillS(pattern, 0x10000, 0x10ff);

FindAllS

FindAllS(Sequence: ${ISequence},
    Selection: ${IMultiSelection},
    IgnoreCase: boolean,
    Found: ${IMultiSelection}): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object containing a find pattern.
Selection
Multiple Selection object, which contains ranges in which a pattern need to be located
IgnoreCase
true to ignore case, false to perform exact matching.
Found
Multiple Selection Object, which contains, on method's return, all located ranges.

Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection Object Found, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences.

Complexity: linear-time, depending on the file's size and selection's complexity.

This method is a replacement for IFileDocument.FindAll when used in scripting languages.

Searching all pattern occurrences

var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msel = fdoc.CreateEmptySelection();
var mselOutput = fdoc.CreateEmptySelection();

fdoc.Open("c:\\temp\\file.txt");
msel.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
fdoc.FindAllS(pattern, msel, false, mselOutput);
if (!mselOutput.Empty) // check if there are any matches
  fdoc.Copy(mselOutput,false);  // copy them to the Clipboard

FindS

FindS(Sequence: ${ISequence},
    Selection: ${IMultiSelection},
    StartFrom: number,
    SearchUp: boolean,
    IgnoreCase: boolean): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object containing a find pattern.
Selection
Multiple selection object, which contains ranges in which you want to locate a pattern.
StartFrom
Offset from which you want to start searching.
SearchUp
true to search backwards and false to search forward.
IgnoreCase
true to ignore case and false to perform exact matching.

Offset of the located pattern or -1 if pattern was not found.

Searches for a pattern within a given selection. This method returns the offset of the matched pattern. To continue searching, call this method again, adjusting StartFrom field appropriately. If pattern is not found in the specified range, -1 is returned.

Complexity: linear-time, depending on the file's size and selection's complexity.

This method is a replacement for IFileDocument.Find when used in scripting languages.

Searching for a pattern

var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msec = fdoc.CreateEmptySelection();

fdoc.Open("c:\\temp\\file.txt");
msec.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
var EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern, msel, 0, false, false));
// ...
// continue searching
EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern, msel, EOL_Offset + 1, false, false));

InsertPatternS

InsertPatternS(Sequence: ${ISequence}, Offset: number, Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object containing data to insert.
Offset
Insert offset.
Size
Insert size.

Inserts a given pattern into the document, repeating it to fill the given size. Insert command shifts file's data to free up the space to fit an inserted pattern.

Complexity: constant-time.

This method is a replacement for IFileDocument.InsertPattern when used in scripting languages.

Inserting a pattern

// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a);
fdoc.InsertPatternS(pattern, 100, 1000);

InsertS

InsertS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object containing the data to insert.
Offset
Insert offset.

Inserts a pattern into the document. Insert command shifts file's data to free up the space to fit an inserted pattern.

Complexity: constant-time.

This method is a replacement for IFileDocument.Insert when used in scripting languages.

Inserting a pattern

// fdoc is initialized elsewhere
var pattern = fdoc.CreateSequence();
pattern.AddData(HexBytes, 0x0d, 0x0a);
fdoc.InsertS(pattern, 100);  // insert a given pattern at the offset 100

ReadS

ReadS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object into which data is read.
Offset
Read offset

Reads data from a document. If requested data exceeds the current document's size, any excess bytes are filled with zeros.

Complexity: constant-time.

This method is a replacement for IFileDocument.Read when used in scripting languages.

Reading Data

// fdoc is initialized elsewhere
var seq = fdoc.CreateSequence();
fdoc.Length = 256;
fdoc.ReadS(seq, 1000);

ReplaceAllRegExpS

ReplaceAllRegExpS(RegExp: string,
    SubExpression: number,
    Flags: ${RegExpFlags},
    Sequence: ${ISequence},
    StartFrom: number,
    Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from the RegExpFlags enumeration.
Sequence
Sequence object containing replace pattern.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

A number of occurrences.

Finds and replaces all occurrences of regular expression matches with a given pattern.

Complexity: varying.

This method is a replacement for IFileDocument.ReplaceAllRegExp when used in scripting languages. This method is obsolete. Use the IFileDocument.ReplaceAllRegExp2S instead.

ReplaceAllRegExp2S

ReplaceAllRegExp2S(RegExp: string,
    CodePage: number,
    SubExpression: number,
    Flags: ${RegExpFlags},
    Sequence: ${ISequence},
    StartFrom: number,
    Size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
RegExp
A string that contains a regular expression. A regular expression must by in ECMAScript syntax.
CodePage
Code page for regular expression pattern encoding or CP_UNICODE (-5) for UTF-16.
SubExpression
The number of sub-match to search for. 0 means the entire expression.
Flags
Flags that change the behavior of the function. May be one or more of the values from the RegExpFlags enumeration.
Sequence
Sequence object containing replace pattern.
StartFrom
A start offset of the range. Must be a multiple of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.
Size
Range's size. Must be a multiply of 2 if RegExpFlags.RegExpTypeUNICODE flag is specified.

A number of occurrences.

Finds and replaces all occurrences of regular expression matches with a given pattern.

Complexity: varying.

This method is a replacement for IFileDocument.ReplaceAllRegExp2 when used in scripting languages.

ReplaceAllS

ReplaceAllS(SequenceFrom: ${ISequence},
    SequenceTo: ${ISequence},
    IgnoreCase: boolean,
    Selection: ${IMultiSelection}): void;
// This method is not available in managed environment
// This method is not available in native environment
SequenceFrom
Sequence object containing a find pattern.
SequenceTo
Sequence object containing a replace pattern.
IgnoreCase
true to ignore case, false to perform exact matching.
Selection
Multiple Selection object, describing the ranges in which to perform search and replace

A number of replacements done.

Finds and replaces all occurrences of the given pattern with another pattern.

Complexity: varying.

This method is a replacement for IFileDocument.ReplaceAll when used in scripting languages.

Searching all pattern occurrences

var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msel = fdoc.CreateEmptySelection();

fdoc.Open("c:\\temp\\file.txt");
msel.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

var pattern1 = fdoc.CreateSequence();
var pattern2 = fdoc.CreateSequence();
pattern1.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
pattern2.AddData(HexBytes, 0x0d, 0x0a, 0x0d, 0x0a); // Double-EOL pattern
var nReplacements = fdoc.ToNumber(fdoc.ReplaceAllS(pattern1, pattern2, false, msel);

ReplaceS

ReplaceS(Offset: number, Size: number, Sequence: ${ISequence}): void;
// This method is not available in managed environment
// This method is not available in native environment
Offset
Replace offset.
Size
Size of the original pattern.
Sequence
Sequence object containing the pattern to replace.

Replaces the given block with a pattern. This method replaces a range described by Offset and Size parameters with a pattern.

Complexity: constant-time.

This method is a replacement for IFileDocument.Replace when used in scripting languages.

Replacing a pattern

var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msec = fdoc.CreateEmptySelection();

fdoc.Open("c:\\temp\\file.txt");
msec.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

var pattern1 = fdoc.CreateSequence();
var pattern2 = fdoc.CreateSequence();

pattern1.AddData(HexBytes,0x0d,0x0a);  // EOL pattern
pattern2.AddDate(HexBytes,0x0d,0x0a,0x0d,0x0a);  // Double-EOL pattern
var EOL_Offset = fdoc.ToNumber(fdoc.FindS(pattern1, msel, 0, false, false));
if (EOL_Offset != -1)
  fdoc.ReplaceS(EOL_Offset, pattern1.Length, pattern2);

ToNumber

ToNumber(Value: any): number;
// This method is not available in managed environment
// This method is not available in native environment
Value
A value to convert.

Value, converted to decimal type.

Converts 64-bit integer into scripting compatible integer. Hex Editor Neo extensively uses 64-bit integer numbers. Scripting languages do not directly support such values, so this method may be used to convert them to supported decimal type.

Value conversion

// document1 and document2 are defined elsewhere
document1.FileSize = document2.FileSize;    // valid, no processing in Javascript. 
// Passing 64-bit integers is supported

document1.FileSize = document2.FileSize / 2; // invalid, "Not a Number" exception is thrown
document1.FileSize = document2.ToNumber(document2.FileSize) / 2;  // valid

WriteS

WriteS(Sequence: ${ISequence}, Offset: number): void;
// This method is not available in managed environment
// This method is not available in native environment
Sequence
Sequence object that contains the data to write.
Offset
Write offset

Writes data to a document. The written data overwrites document's existing data and may also increase the file's size if it overlaps the current file's size. Write always creates a new operation in document's operation history.

Complexity: constant-time.

This method is a replacement for IFileDocument.Write when used in scripting languages.

Writing Data

// fdoc is initialized elsewhere
var seq = fdoc.CreateSequence();
fdoc.AddData(HexBytes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
fdoc.WriteS(seq, 1000);