NSIS ReadCustomerdata 无数据错误

NSIS ReadCustomerdata no data error

; Example:
;   Push "CUSTDATA:"
;   Call ReadCustomerData
;   Pop 
;   StrCmp  "" 0 +3
;   MessageBox MB_OK "No data found"
;   Abort
;   MessageBox MB_OK "Customer data: ''"
!include LogicLib.nsh
!include StrLoc.nsi
Section
   Push "CUSTDATA:"
   Call ReadCustomerData
   Pop 
   StrCmp  "" 0 +3
   MessageBox MB_OK "No data found"
   Abort
   MessageBox MB_OK "Customer data: ''"
SectionEnd
Function ReadCustomerData
  ; arguments
  Exch $R1            ; customer data magic value
  ; locals
  Push              ; file name or (later) file handle
  Push              ; current trial offset
  Push              ; current trial string (which will match $R1 when customer data is found)
  Push              ; length of $R1
  Push              ; half length of $R1
  Push              ; first half of $R1
  Push              ; tmp

  FileOpen  $EXEPATH r

; change 4096 here to, e.g., 2048 to scan just the last 2Kb of EXE file
  IntOp  0 - 4096

  StrLen  $R1

  IntOp   / 2
  StrCpy  $R1 


loop:
  FileSeek   END
  FileRead   
  StrCmpS  $R1 found

  ${StrLoc}    ">"
  StrCmpS  "" NotFound
    IntCmp  0 FoundAtStart
      ; We can jump forwards to the position at which we found the partial match
      IntOp   + 
      IntCmp  0 loop loop
FoundAtStart:
    ; We should make progress
    IntOp   + 1
    IntCmp  0 loop loop
NotFound:
    ; We can safely jump forward half the length of the magic
    IntOp   + 
    IntCmp  0 loop loop

  StrCpy $R1 ""
  goto fin

found:
  IntOp   + 
  FileSeek   END
  FileRead  
  StrCpy $R1 

fin:
  Pop 
  Pop 
  Pop 
  Pop 
  Pop 
  Pop 
  Pop 
  Exch $R1
FunctionEnd

当我运行这个文件我没有数据found.My问题是 1 .我该如何编辑 2. 并检索我可以推送的 data.what 种数据以及推送方式。

  1. 我还想使用 python 推送数据,我该如何实现
  2. 如何使用 python 编辑 exe 文件 前两个问题对我很重要

提前致谢 感谢 Whosebug

你没有添加数据怎么找得到?您可以添加任何您想要的数据,但是 ReadCustomerData 函数不能处理二进制数据,只能处理字符串。您可以使用任何可用的方法来写入数据,只需以 CUSTDATA::

开头
makensis Test.nsi
>>"Test.exe" echo.CUSTDATA:Hello World
start Test.exe