NSIS ReadCustomerdata编号d

2024-09-29 06:25:06 发布

您现在位置:Python中文网/ 问答频道 /正文

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

  FileOpen $1 $EXEPATH r

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

  StrLen $4 $R1

  IntOp $5 $4 / 2
  StrCpy $6 $R1 $5


loop:
  FileSeek $1 $2 END
  FileRead $1 $3 $4
  StrCmpS $3 $R1 found

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

  StrCpy $R1 ""
  goto fin

found:
  IntOp $2 $2 + $4
  FileSeek $1 $2 END
  FileRead $1 $3
  StrCpy $R1 $3

fin:
  Pop $7
  Pop $6
  Pop $5
  Pop $4
  Pop $3
  Pop $2
  Pop $1
  Exch $R1
FunctionEnd

当我运行这个文件时,我没有任何数据找到了。我的问题是 1.如何编辑 2然后重新检查数据。什么我可以推送什么样的数据以及如何推送。你知道吗

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

提前多谢了 感谢stackoverflow


Tags: oftheloopdataokmbpoppush
1条回答
网友
1楼 · 发布于 2024-09-29 06:25:06

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

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

相关问题 更多 >