Read a string from an e.g. exe or dll file
From NSIS Wiki
Jump to navigationJump to search
Author: Afrow UK (talk, contrib) |
Description
This is a simple script to read a string of a selected length from a byte file.
Usage
Push "500" ;output string length Push "$TEMP\file.dll" ;file to read from Call ReadByteFile Pop $0 ;output string (StrLen=500)
The Function
Function ReadByteFile Exch $0 ;file Exch Exch $1 ;group-up count Push $2 Push $3 Push $4 ClearErrors FileOpen $0 $0 r IfErrors error StrCpy $2 0 StrCpy $3 "" loop_read: ClearErrors FileReadByte $0 $4 IfErrors exit IntFmt $4 "%c" $4 StrCpy $3 $3$4 IntOp $2 $2 + 1 StrCmp $2 $1 exit Goto loop_read error: DetailPrint "Error: Input file not found" exit: FileClose $0 StrCpy $0 $3 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 ;output string FunctionEnd
-Stu (Afrow UK)