NSIS写作QWORD HEX VALUE

时间:2017-02-07 01:05:32

标签: registry nsis

我一直在尝试使用Registry Plug-in

在NSIS中编写QWORD
!define REG "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\some.exe"
!define REG_VALUE "MitigationOptions"
!define REG_DATA 0x2000000000000

 ${registry::Write} "HKLM\${REG}" "${REG_VALUE}" ${REG_DATA} "REG_QWORD" $R0

安装后检查注册表时,它总是显示为(无效的QWORD(64位)值)

我试过“0002000000000000”,“2000000000000”和2000000000000但是没有工作。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

数据需要长度为16个十六进制字符,没有0x前缀。

!include "Registry.nsh"
Section
${registry::Write} "HKCU\Software\NSIS\Test" "Test DW64" "112233445566aabb" "REG_QWORD" $R0
DetailPrint $R0
SectionEnd

数据似乎被解释为字节而不是64位数字,这有点不方便,所以你需要反转字符串:

Function StrRev
Exch $0
Push $1
Push $2
Push $3
StrCpy $3 ""
StrCpy $1 0
loop:
    StrCpy $2 $0 1 $1
    StrCmp $2 "" done
    IntOp $1 $1 + 1
    StrCpy $3 $2$3
    Goto loop
done:
StrCpy $0 $3
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd

Section
Push "112233445566aabb"
Call StrRev
Pop $0
${registry::Write} "HKCU\Software\NSIS\Test" "Test DW64" "$0" "REG_QWORD" $R0
SectionEnd