flat assembler
Message board for the users of flat assembler.

Index > Windows > i fail to make RegQueryValueEx works :(

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
i am stuck in getting the RegQueryValueEx API to functions :(
i already used 6 hours to make it functions but still unable to success :(
i wish somebody could point me :)

Code:
format PE console 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
    conHandleOut    dd  ?
    
    regHandle       dd  ?
    regKeySub       db  'Software\Microsoft\Internet Explorer\Main',0
    regItem         db  'Display Inline Images',0
    regItemValue:   times 10 db 0
    
    noticePass      db  13,10,'Passed',0
    noticeFail      db  13,10,'Failed',0

section '.code' code readable executable
    start:
        invoke  RegOpenKey,HKEY_CURRENT_USER,regKeySub,regHandle
        invoke  RegQueryValueEx,[regHandle],regItem,0,REG_SZ,[regItemValue],3
                cmp eax,0
                jne notice_fail

    notice_pass:
        stdcall console_print,regItemValue
        stdcall console_print,noticePass
                jmp exit
        
    notice_fail:
        stdcall console_print,noticeFail
    
    exit:
        invoke  ExitProcess,0

    proc    console_print,txt
                txtBuffer   dd  ?
                txtLength   dd  ?
            enter
                invoke  GetStdHandle,STD_OUTPUT_HANDLE
                        mov [conHandleOut],eax
                invoke  lstrlen,[txt]
                        mov [txtLength],eax
                        lea eax,[txtBuffer]
                invoke  WriteFile,[conHandleOut],[txt],[txtLength],eax,NULL
                        mov eax,[txtBuffer]
            return
    endp

section '.idata' import data readable writeable
    library kernel32,'KERNEL32.DLL',\
            advapi32,'ADVAPI32.DLL'
    
    import  kernel32,\
            lstrlen,        'lstrlenA',\
            GetStdHandle,   'GetStdHandle',\
            WriteFile,      'WriteFile',\
            ExitProcess,    'ExitProcess'
    
    import  advapi32,\
            RegOpenKey,                 'RegOpenKeyA',\
            RegQueryValueEx,            'RegQueryValueExA'
    


sincerely,
vbVeryBeginner d(7-0)b
Post 19 Aug 2004, 15:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Add the two variables to your data section:
Code:
valueType dd ?
bufferSize dd 10    

and use RegQueryValueEx this way:
Code:
invoke  RegQueryValueEx,[regHandle],regItem,0,valueType,regItemValue,bufferSize    

This function fills the [valueType] variable with the type of value (REG_SZ or other), and the [bufferSize] variable with size of copied data (this variable should contain the actual size of buffer before you call this function).
Post 19 Aug 2004, 15:27
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
oh man, you are GREAT Smile thanks Smile Smile privalov
you just save my another six hours Smile

anyone please confirm my understanding Smile (coz i know you are busy)

does this mean, when using WinAPI, we must NOT fill the function parameters that are able to [in,out] or [out] with direct value. coz if i change the valueType to REG_SZ, i get passed but regItemValue == nothing?

i really appreciate your help. thank you very much d( 0 )b

sincerely,
vbVeryBeginner d(0*0)b
Post 19 Aug 2004, 15:46
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.