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…') |
mNo edit summary |
||
Line 17: | Line 17: | ||
<pre> | <pre> | ||
nsisFile::BinToHex <string> | nsisFile::BinToHex <string> | ||
Convert a string into an hexadecimal string representing the equivalent ANSI | Convert a string into an hexadecimal string representing the equivalent ANSI character bytes | ||
character bytes | |||
No terminating NUL (00) character and no formatting characters are added. | No terminating NUL (00) character and no formatting characters are added. | ||
nsisFile::HexToBin <hex string> | nsisFile::HexToBin <hex string> | ||
Convert an hexadecimal string representing ANSI characters bytes into the | 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. | The string might be truncated to the first NUL (00) character encoutered. | ||
Eventual formatting characters are ignored. | Eventual formatting characters are ignored. | ||
Line 35: | Line 33: | ||
nsisFile::FileFindBytes <file handle> <hex string> <length> | nsisFile::FileFindBytes <file handle> <hex string> <length> | ||
Search the given file for the bytes sequence, given as hexadecimal string. | 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 | 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. | Use -1 as <length> to search the whole file. | ||
The result is -1 if not found, or the file offset found. (File pointer is | The result is -1 if not found, or the file offset found. (File pointer is automatically positionned to this offset) | ||
automatically positionned to this offset) | |||
nsisFile::FileTruncate <file handle> | nsisFile::FileTruncate <file handle> | ||
Truncate the given opened file at the current file pointer (as positionned by NSIS | Truncate the given opened file at the current file pointer (as positionned by NSIS "FileSeek") | ||
"FileSeek") | |||
Revision as of 13:01, 14 June 2010
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 positionned to this offset) nsisFile::FileTruncate <file handle> Truncate the given opened file at the current file pointer (as positionned 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