The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Lightman on February 25, 2008, 01:51:57 PM

Title: Having problems reading keys from the Registry
Post by: Lightman on February 25, 2008, 01:51:57 PM
Hi Everybody,

I have been writing a bit of code to practice reading from the system registry.  I collected a number of examples from this forum and the example files that came with Masm and had a go at my own.  I wanted to open a registry key and then read a value from it.  There is no real objective here; I am just learning the ropes.

In this case I am trying read from the registry. I can open the key OK, but the registry key comes out as being empty. RegEdit tells me otherwise; when I check for myself there is a value there. I am puzzled. Can anyone have a quick look and tell me where I am going wrong?

Attached is my code, It's a RadASM project.

Regards,

Lightman

[attachment deleted by admin]
Title: Re: Having problems reading keys from the Registry
Post by: ToutEnMasm on February 25, 2008, 02:12:42 PM

Many files here,perhaps a little piece of code , a proc with a buffer to receive the key will be less difficult to read.
Title: Re: Having problems reading keys from the Registry
Post by: MichaelW on February 25, 2008, 02:53:20 PM
The attachment is an example that reads the value of:

HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\Identifier

In case it's not clear, the Microsoft documentation refers to the lpValueName parameter of RegQueryValueEx, in this case "Identifier", as the name of the value, and "AT/AT COMPATIBLE" is the value.


[attachment deleted by admin]
Title: Re: Having problems reading keys from the Registry
Post by: sebart7 on February 25, 2008, 04:07:43 PM
You did 2 small mistakes.
Here is Your code fixed and commented to lets You understand where and why You did mistakes.


[attachment deleted by admin]
Title: Re: Having problems reading keys from the Registry
Post by: Lightman on February 26, 2008, 09:49:28 AM
Thanks Guys,

Now that I have a working version, it's clear where I have been making the mistakes...

I was carefully saving the value returned in eax without realising this is the same register I am checking to see if an error occoured..  :dazzled:

Well, you live and learn...


Regards,

Lightman