NsisFile plug-in: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Created page with '{{PageAuthor|Wizou}} == Links == [http://wiz0u.free.fr/prog/nsisFile/ nsisFile Plugin Homepage] == Presentation == '''nsisFile''' is a small NSIS plugin that manipulate file c…') |
(→Usage: beautify with mediawiki syntax, interwikis Reference/FileOpen Reference/FileSeek Pop) |
||
(One intermediate revision by one other user not shown) | |||
Line 15: | Line 15: | ||
The following is taken from the readme file in the downloadable zip file: | The following is taken from the readme file in the downloadable zip file: | ||
< | ;<nowiki>nsisFile::BinToHex <string></nowiki> | ||
nsisFile::BinToHex <string> | :Convert a string into an hexadecimal string representing the equivalent ANSI character bytes | ||
:No terminating NUL (00) character and no formatting characters are added. | |||
character bytes | |||
nsisFile::HexToBin <hex string> | ;<nowiki>nsisFile::HexToBin <hex string></nowiki> | ||
:Convert an hexadecimal string representing ANSI characters bytes into the equivalent string | |||
equivalent string | :The string might be truncated to the first NUL (00) character encoutered. | ||
:Eventual formatting characters are ignored. | |||
nsisFile::FileReadBytes <file handle> <length> | ;<nowiki>nsisFile::FileReadBytes <file handle> <length></nowiki> | ||
:Read <length> bytes from the given file and return them as an hexadecimal string | |||
nsisFile::FileWriteBytes <file handle> <hex string> | ;<nowiki>nsisFile::FileWriteBytes <file handle> <hex string></nowiki> | ||
:Write to the given file the bytes sequence, given as hexadecimal string | |||
nsisFile::FileFindBytes <file handle> <hex string> <length> | ;<nowiki>nsisFile::FileFindBytes <file handle> <hex string> <length></nowiki> | ||
:Search the given file for the bytes sequence, given as hexadecimal string. | |||
:The search is done over <length> bytes from the file (this value should include the length of the bytes sequence) | |||
length of the bytes sequence) | :Use -1 as <length> to search the whole file. | ||
:The result is -1 if not found, or the file offset found. (File pointer is automatically positioned to this offset) | |||
automatically | |||
nsisFile::FileTruncate <file handle> | ;<nowiki>nsisFile::FileTruncate <file handle></nowiki> | ||
:Truncate the given opened file at the current file pointer (as positioned by NSIS [[Reference/FileSeek|FileSeek]]) | |||
Notes: | |||
* File handle is the value returned by NSIS [[Reference/FileOpen|FileOpen]] function | |||
* Function result is returned on NSIS stack (use [[Reference/Pop|Pop]] to retrieve it) | |||
* File handle is the value returned by NSIS | * You can use NSIS [[Reference/FileSeek|FileSeek]] function to move to a specific offset before calling these functions to specify where to start the operation | ||
* Function result is returned on NSIS stack (use | |||
* You can use NSIS | |||
these functions to specify where to start the operation | |||
== Download == | == Download == |
Latest revision as of 10:09, 12 May 2017
Author: Wizou (talk, contrib) |
Links
Presentation
nsisFile is a small NSIS plugin that manipulate file content, especially binary data.
You can typically use it to:
- search for binary patterns in file
- read or write (patch) binary data from/to binary files
Usage
The following is taken from the readme file in the downloadable zip file:
- nsisFile::BinToHex <string>
- Convert a string into an hexadecimal string representing the equivalent ANSI character bytes
- No terminating NUL (00) character and no formatting characters are added.
- nsisFile::HexToBin <hex string>
- Convert an hexadecimal string representing ANSI characters bytes into the equivalent string
- The string might be truncated to the first NUL (00) character encoutered.
- Eventual formatting characters are ignored.
- nsisFile::FileReadBytes <file handle> <length>
- Read <length> bytes from the given file and return them as an hexadecimal string
- nsisFile::FileWriteBytes <file handle> <hex string>
- Write to the given file the bytes sequence, given as hexadecimal string
- nsisFile::FileFindBytes <file handle> <hex string> <length>
- Search the given file for the bytes sequence, given as hexadecimal string.
- The search is done over <length> bytes from the file (this value should include the length of the bytes sequence)
- Use -1 as <length> to search the whole file.
- The result is -1 if not found, or the file offset found. (File pointer is automatically positioned to this offset)
- nsisFile::FileTruncate <file handle>
- Truncate the given opened file at the current file pointer (as positioned by NSIS FileSeek)
Notes:
- File handle is the value returned by NSIS FileOpen function
- Function result is returned on NSIS stack (use Pop to retrieve it)
- You can use NSIS FileSeek function to move to a specific offset before calling these functions to specify where to start the operation
Download
ZIP archive contains the plug-in DLLs (ANSI & Unicode NSIS) as well as documentation, source code and sample script