flat assembler
Message board for the users of flat assembler.

Index > Windows > Registry (RegOpenKeyEx,RegQueryValueEx)

Author
Thread Post new topic Reply to topic
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex
Good day. I haven't been here for a long time. Here's my problem.

I have the following "variables":

key db "SOFTWARE\\Skype\\Phone",0
value db "SkypePath",0
path dd ?
skyhand dd ?

And the following code:

invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,key,0,KEY_READ,skyhand
invoke RegQueryValueEx,[skyhand],value,0,0,[path],50

All else is correct (imports, errors etc.)
When I execute the code, path is still 0. I can't seem to grasp what my problem is. What am I doing incorrect?
Post 16 Jun 2007, 11:52
View user's profile Send private message Reply with quote
handyman



Joined: 04 Jun 2007
Posts: 40
Location: USA - KS
handyman
jumpex wrote:
Quote:

invoke RegQueryValueEx,[skyhand],value,0,0,[path],50


I think you should be sure you are using address pointers where address pointers are supposed to be used.
i.e.: the last two parameters (5 & 6) need to be address pointers to the data buffer and buffer size variables instead of being the actual data values. 'path' contains a pointer, but '50' does not. The last parameter is also used by the function to send data back.
Post 16 Jun 2007, 13:27
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex
Thank you for your quick responce. Really - thanks.
Nevertheless, I changed what you said to this:

(temp dd ?)

mov [temp],50
invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,key,0,KEY_READ,skyhand
invoke RegQueryValueEx,[skyhand],value,0,0,[path],[temp]

The variable 'path' is still empty after the operation. Is anything else out of order?
Post 16 Jun 2007, 14:33
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex
Problem solved. I had to remove the DOUBLE '\' lines and put single ones (unlike so many other HL programming langugages).
Post 16 Jun 2007, 19:15
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
fasm doesn't perform any interpretation on strings, it just wait for ' or " (depending of which one you used to start the string), to close the string.
Post 16 Jun 2007, 19:30
View user's profile Send private message Reply with quote
handyman



Joined: 04 Jun 2007
Posts: 40
Location: USA - KS
handyman
Just an addition thought since pointers are involved here,
you should probably use

invoke RegQueryValueEx,[skyhand],value,0,0,[path],temp

because I assume that you are filling [path] with a an address value that points to the path string whereas [temp] is just filled with a value, not a pointer. You have to be sure that any function requiring a pointer parameters do not point somewhere you do not want it to, especially if the function wants to change that memory area. in your example '[temp]' will still point it to memory location 50 whereas 'temp' will point to wherever 'temp' is located and that will receive one of pieces of return data that the 'RegQueryValueEx' function returns.

Even though the function seems to work now, what is the value in '[temp]' on return? The function definition says that it returns the 'path' length here. if the 'path' string length ends up in 'temp' then the call is working OK. On the otherhand, if the value in 'temp' is still 50 when the string length in 'path' is not 50 then the function call may have altered some memory somewhere that probably should not be altered, location 50 in this case.

Be sure to make sure that returned 'path' string length is not the same as what you set 'temp' to when you call the function otherwise you won't learn anything on testing the function call. You should be able to see that the value in temp is different after the call.
Post 17 Jun 2007, 12:55
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex
Hey, thanks. I've learned a lot from this call alone. And I'll test that when I get home. I've had to 0 temp after the call, otherwise 'path' had an apostrophe in the end. I'm not sure why. Maybe it was because of what you are saying. Thank you for the responce. Smile
Post 17 Jun 2007, 16:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.