2017-02-07 76 views
0

我一直在試圖用寫在NSIS一個QWORD的Registry Plug-inNSIS寫作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

數據需要正好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 
+0

這真是棒極了!非常感謝! – qmo