qmo
qmo

Reputation: 3198

NSIS Writing QWORD HEX VALUE

I've been trying to write a QWORD in NSIS using the Registry Plug-in

!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

When I check the registry after installation, it always shows as (invalid QWORD (64-bit) value)

I have tried "0002000000000000", "2000000000000" and 2000000000000 but non worked. Any idea?

Upvotes: 0

Views: 601

Answers (1)

Anders
Anders

Reputation: 101736

The data needs to be exactly 16 hex characters long, no 0x prefix.

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

The data seems to be interpreted as bytes and not as a 64-bit number and that is a bit inconvenient so you need to reverse the string:

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

Upvotes: 1

Related Questions