i am trying to retrieve data from the registry. im just trying to get a normal string, not a dword or anything - yet. this is my code: push offset lpdwDisposition push offset phkResult push 0 push 1F0000h + 1 + 2h push 0 push 0 push 0 push offset lpSubKey push hKey call RegCreateKeyExA ; --------------------------------------------- push hKey push offset lpValueName push 0 push type push offset regstring push noread call RegQueryValueExA cmp eax,ERROR_SUCCESS jz err ; ---------------------------------------------- push 0 call RegCloseKey if anyone would be good enough as to explain to me why this is not working. also; what is the ERROR_SUCESS equ -?- ie. what should go where the "-?-" is??? this is preventing me seeing if it fails or not ...
Posted on 2001-04-01 13:35:00 by skud
Hi you can write it like: call RegCreateKeyExA,80000002h,offset regstring,0,0,0,0000F003Fh,0,offset zehandle,offset zeresult call RegSetValueExA,zehandle,offset namereg,0,1,offset newvalue,6 80000002h= local machine ,80000001h = current user.... offset regstring = location= software/blabla/blabla 6=size offset namereg = keyname 1 = string offset newvalue= new key value cu
Posted on 2001-04-02 04:21:00 by EASYCODE
Hi for the error_sucess...... open windows.inc and look inside for the asnwer :) cu
Posted on 2001-04-02 04:22:00 by EASYCODE
what? i dont get that. you can read the data in a value using RegSetValueExA ??? why is it called Set then ? i tried the :- call RegSetValueExA,zehandle,offset namereg,0,1,offset newvalue,6 thing. didnt work :) plz help. more info !!!!!!!!!!!!!!
Posted on 2001-04-02 13:01:00 by skud
UPS !!! Hi ,sorry...while posting the source ,i open the wrong sample code. the one i post is for setting a regkey. for reading try: RegOpenKeyEx RegQueryValueEx cu
Posted on 2001-04-03 04:14:00 by EASYCODE
i know you need to use regquerykey look at my first message - the source i have been playing with it and have changed some code here it is: push hKey push offset lpValueName push 0 push REG_SZ push offset regstring push offset noread call RegQueryValueExA cmp eax,ERROR_SUCCESS jz ok i made it jump to error if it returned error_success before. oops. also, if this helps: regstring db 100 dup (0) noread dd 100 is that right? it is just a normal value (i am trying to get the homepage for IE - HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\Start Page) is REG_SZ correct for this??? please help me. this is starting to make me lose sleep. grrr.
Posted on 2001-04-03 13:45:00 by skud
i have also tried this: push offset noread push offset regstring push offset lpSubKey push hKey call RegQueryValueA regstring db 100 dup (0) noread dd 100 what the hell is wrong? the function succeeds but no string is in either buffer. grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.
Posted on 2001-04-03 15:43:00 by skud
I had a similar problem, but reading Ernies Registry source helped.. I believe it may be a missing call to RegQueryInfoKey

mov eax,REG_BINARY
mov Disp,eax
invoke RegQueryInfoKey,hRegKey,0,0,0,0,0,0,0,0,ADDR szRegMaxLen,0,0
invoke RegQueryValueEx,hRegKey,ADDR szBuffer,NULL,\
            ADDR Disp,ADDR szTemp,ADDR szRegMaxLen
Posted on 2001-04-03 15:53:00 by JimmyClif
this is in tasm btw. so i cant invoke anything :) if you can just tell me what is wrong with my code and how to correct it then that would be great. i am sure it is just some stupid little thing i have missed out as the function isnt actually failing (RegQueryValueA). however RegQueryValueExA is failing. this all has me very confused. anyway, please help if you can. skud
Posted on 2001-04-03 16:47:00 by skud
skud, I thought tasm was only to push the stuff (which I put behind the commas after the api) the other way 'round :P ? Come on... a little bit of good will and you are able to read masm syntax too :rolleyes:
Posted on 2001-04-03 17:03:00 by JimmyClif
i have no idea what you are talking about. i am a stupid newb. i have added you to my msn messanger. here is my latest code. plz tell me why this isnt working :) .386 locals jumps .model flat,STDCALL extrn ExitProcess : Proc extrn RegOpenKeyExA : Proc extrn RegCloseKey : Proc extrn RegQueryValueExA : Proc extrn MessageBoxA : Proc extrn RegQueryValueA : Proc extrn lstrlen : Proc REG_SZ equ 1 ERROR_SUCCESS equ 0 KEY_QUERY_VALUE equ 1h .data hKey dd 80000001h ; HKEY_CURRENT_USER lpValueName db 'Start Page',0 ; lpData + 6 lpSubKey db 'SOFTWARE\Microsoft\Internet Explorer\Main', 0 phkResult dd 0 lpdwDisposition dd 0 regstring db 100 dup (0) noread dd 100 caption db 'String that was read ...', 0 error db 'ERROR!', 0 .code Start: push offset phkResult ; address of handle of open key push KEY_QUERY_VALUE ; security access mask push 0 ; reserved push offset lpSubKey ; address of name of subkey to open push hKey ; handle of open key call RegOpenKeyExA cmp eax,0 jne err push offset noread push offset regstring push REG_SZ push 0 push offset lpValueName push hKey call RegQueryValueExA cmp eax,0 jz ok err: push 00h push offset caption push offset error push 0 call MessageBoxA jmp Exit ok: push 00h push offset caption push offset regstring push 0 call MessageBoxA Exit: push 0 call RegCloseKey push 0 call ExitProcess End Start
Posted on 2001-04-03 17:43:00 by skud
Alright... I'll go for the try. (I have no Win32.hlp beside me, so I assume your RegOpenKey works)

.386
locals
jumps
.model flat,STDCALL

extrn ExitProcess : Proc
extrn RegOpenKeyExA : Proc
extrn RegCloseKey : Proc
extrn RegQueryInfoKey : Proc
extrn RegQueryValueExA : Proc
extrn MessageBoxA : Proc
extrn RegQueryValueA : Proc
extrn lstrlen : Proc

REG_SZ equ 1
ERROR_SUCCESS equ 0
KEY_QUERY_VALUE equ 1h

.data
hKey dd 80000001h ; HKEY_CURRENT_USER
lpValueName db 'Start Page',0 ; lpData + 6
lpSubKey db 'SOFTWARE\Microsoft\Internet Explorer\Main', 0
lpdwDisposition dd 0

regstring db 100 dup (0)
noread dd 100
caption db 'String that was read ...', 0
error db 'ERROR!', 0

.data?

Disp dd ?
RegMaxLen dd ?
phkResult dd ?

.code
start:

mov eax,REG_SZ
mov Disp,eax

push offset phkResult ; address of handle of open key 
push KEY_QUERY_VALUE ; security access mask 
push 0 ; reserved 
push offset lpSubKey ; address of name of subkey to open 
push hKey ; handle of open key 
call RegOpenKeyExA
cmp eax,0
jne err

xor eax,eax
push eax
push eax
push Offset RegMaxLen
push eax
push eax
push eax
push eax
push eax
push eax
push eax
push eax
push phkResult
call RegQueryInfoKey
or eax,eax
j err <- find out what is the return value if error and jump there then

push OFFSET szRegMaxLen
push OFFSET regstring
push OFFSET Disp
push 0
push OFFSET lpValueName
push phkResult
call RegQueryValueEx
or eax,eax
jz ok

err:
push 00h
push offset caption
push offset error
push 0
call MessageBoxA

jmp Exit

ok:

push 0
push offset caption
push offset regstring
push 0
call MessageBoxA

Exit:

push 0
call RegCloseKey   ;I don't know.. is there no need to push the handle to the regkey too?

push 0
call ExitProcess

End start
As said, I have no win32.hlp next to me right now, I never ever programmed in tasm either. I replaced every ADDR by OFFSET (it seems to me the tasm way) and I give no garantie that this works. It's worth a try, tho. Jimmy
Posted on 2001-04-04 02:43:00 by JimmyClif