News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

RegGetValue not working ?

Started by Slugsnack, May 17, 2009, 01:09:23 AM

Previous topic - Next topic

Slugsnack

MASM does not let me use this function so I tried to use it via GetProcAddress/GetModuleHandle.  GetModuleHandle correctly returns the base of advapi32.dll but then GetProcAddress returns null with error ERROR_PROC_NOT_FOUND.  Any clue what's happened ?!  I'm on Server 2008 SP2 so that function should exist..

MichaelW

Did you try RegGetValueA or RegGetValueW?
eschew obfuscation

Slugsnack

oh crap yeah that was it.  is there anyway i can use it without this method though ?  the proto can be easily added to the inc file, not sure what can be done with the lib file though :/

Tedd

Use RegQueryValueEx :wink
(Paired with RegSetValueEx)
No snowflake in an avalanche feels responsible.

Slugsnack

using that now since i guess reggetvalue doesn't work with winxp, etc. at least from what i read

ecube

to load dynamic you can

.data
Advapi32 byte 'advapi32.dll',0
RegGetValueAx byte 'RegGetValueA',0

.data?
RegGetValueAm dd ?

.code
start:
invoke LoadLibrary,addr Advapi32
.if eax
    invoke GetProcAddress,eax,addr RegGetValueAx
   .if eax
       mov RegGetValueAm,eax
       etc...
       push arg2
       push arg1
       call RegGetValueAm
   .endif
.endif

invoke ExitProcess,0
end start


or better

this attempts to get a handle to the dll you want and if it's already loaded then it gets the proc address, if the dll isn't
loaded then it loads it and then gets the proc addr.

returns 0 on error, otherwise the func addr

LoadLib proto :DWORD,:DWORD

.code
LoadLib proc iDll,iFunc
invoke GetModuleHandle, iDll
.if eax==NULL
  invoke LoadLibrary,iDll
  .if eax==NULL
     ret
.endif
.endif
   invoke GetProcAddress,eax,iFunc

ret
LoadLib endp

UtillMasm

post a tester, we can run it on our XPs. and see what's happed.