0
votes

I'm trying to write a DWORD to registry, I do like this:

 WSTR keyvalue,"0"

       invoke RegCreateKeyExW,HKEY_LOCAL_MACHINE,offset keylocation,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,offset hIDKey,NULL 
      .IF eax==ERROR_SUCCESS
        invoke lstrlenW,offset keyvalue
        add eax,eax
        add eax,2
        invoke RegSetValueExW,hIDKey,offset keyname,NULL,REG_DWORD,offset keyvalue,eax 
        invoke RegFlushKey,hIDKey
        .ENDIF 

keyvalue is 0, so I'm expecting a 0 in the registry for the key, but instead it writes "38". What am I doing wrong ?

1

1 Answers

1
votes

Character 0 is 0x38, and you reserve a wide string (WSTR keyvalue), so it is to be expected. You need the dword value 0 (which has a fixed size, so you don't need _wcslen). Something like:

keyvalue DD 0
....
mov eax,4
....