basically this code isnt working and i have no idea why. can you help me?? i have done this before in TASM and it worked fine - like most things i do in MASM :) heres the code: hKey dd 80000001h ; HKEY_CURRENT_USER lpValueName db 'Start Page',0 lpSubKey db 'Software\Microsoft\Internet Explorer\Main', 0 homepage db 256 dup (0) phkResult dd ? noread dd ? typeof dd ? invoke RegOpenKeyEx,hKey,ADDR lpSubKey,0,KEY_QUERY_VALUE,ADDR phkResult invoke RegQueryValueEx,ADDR phkResult,ADDR lpValueName,0,ADDR typeof,ADDR homepage,noread invoke RegCloseKey,0 --------------> please help. skud.
Posted on 2001-05-17 09:27:00 by skud
skud, i try to give some ideas: 1 can you, with a debugger, see what of the two functions fail looking to the return code in eax ? 2 on RegQueryValueEx, the last value that you put as 'noread' sghouldn't be address of data buffer size (a ponter to a 256 value in your case) ? hope it help angelo
Posted on 2001-05-17 18:03:00 by angelo
angelo... 1.) It is RegQueryValueEx that is failing. It is not returning 0 (ERROR_SUCCESS). 2.) ok. do you mean like this: sizeofit dd 256 invoke RegQueryValueEx,ADDR phkResult,ADDR lpValueName,0,ADDR typeof,ADDR homepage,ADDR sizeofit ??? this doesnt work. :D thanks anyway. more help ...
Posted on 2001-05-18 06:33:00 by skud
HI SKUD !! :) ok, here we go ... the error is you're using ADDR phkResult instade of phkResult You have to use the habdle value in phkResult, not the offset value of it !! here is my working code in TASM :)

.386
 locals
 jumps
.model flat,stdcall


extrn           RegOpenKeyExA           :proc
extrn           RegQueryValueExA        :proc
extrn           RegCloseKey             :proc

.const

KEY_QUERY_VALUE         equ     01h
HKEY_CURRENT_USER       equ     80000001h  

ERROR_SUCCESS           equ     0

.data
  
lpValueName     db      'Start Page',0
lpSubKey        db      'Software\Microsoft\Internet Explorer\Main', 0

homepage        db      256 dup (0)
sizeofit        dd      256

phkResult       dd      ?
noread          dd      ?
typeof          dd      ?


.code
Main:
                call    RegOpenKeyExA, HKEY_CURRENT_USER, offset lpSubKey, 0, KEY_QUERY_VALUE, offset phkResult 
                call    RegQueryValueExA, phkResult, offset lpValueName, 0, offset typeof, offset homepage, offset sizeofit
                call    RegCloseKey, 0
                
                end     Main 


the issue should be solved. :) bye
Posted on 2001-05-18 08:16:00 by angelo
thanks a lot angelo! i didn't understand that you had to use "ADDR phkResult" with RegOpenKeyEx and just "phkResult" with RegQueryValueEx. thanks again. skud.
Posted on 2001-05-18 11:48:00 by skud