flat assembler
Message board for the users of flat assembler.
Index
> Windows > Reading a REG_DWORD from the registry.. |
Author |
|
revolution 19 Dec 2016, 15:57
Firstly, your data buffer is only 4 bytes long so you might consider putting lpcbData as only 4 to match, or alternatively define lpData as "lpData rb 1024"
Secondly, when you print the value with wsprintf you are in fact printing the address of lpData, not the contents. Try using "cinvoke wsprintf,buf,MainStr,[lpData]" |
|||
19 Dec 2016, 15:57 |
|
jochenvnltn 19 Dec 2016, 16:05
revolution wrote: Firstly, your data buffer is only 4 bytes long so you might consider putting lpcbData as only 4 to match, or alternatively define lpData as "lpData rb 1024" With: lpcbData rb 4 cinvoke wsprintf,buf,MainStr,[lpData] The return value = 0 With: lpData rb 1024 lpcbData rb 4 cinvoke wsprintf,buf,MainStr,lpData Im getting the wrong value again .. |
|||
19 Dec 2016, 16:05 |
|
revolution 19 Dec 2016, 16:19
lpcbData must define the length, so you have to use an initialised value. "lpcbData dd 4". dd not rb
|
|||
19 Dec 2016, 16:19 |
|
revolution 19 Dec 2016, 16:20
Note that you don't get to define the lpType, it comes from the registry. So "lpType dd ?" is all that is needed for reading values. The API fills in the type.
|
|||
19 Dec 2016, 16:20 |
|
jochenvnltn 19 Dec 2016, 16:32
revolution wrote: Note that you don't get to define the lpType, it comes from the registry. So "lpType dd ?" is all that is needed for reading values. The API fills in the type. Works now !! Thanks Revolution!! Code: include "win32ax.inc" lpSubKey db 'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System',0; lpValueName db 'ConsentPromptBehaviorAdmin',0 MainStr db "The value is %d",0 buf rb 256 lpcbData dd 4 lpType dd ? lpData dd ? pKey dd ? start: invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE, lpSubKey, 0, KEY_READ, pKey; cmp eax,0 jne finish invoke RegQueryValueEx,[pKey],lpValueName,0,lpType,lpData,lpcbData invoke RegCloseKey,[pKey] cinvoke wsprintf,buf,MainStr,[lpData] invoke MessageBox,0,buf,lpSubKey,MB_OK; a MessageBox for now .. finish: invoke ExitProcess,0 .end start |
|||
19 Dec 2016, 16:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.