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..
Did you try RegGetValueA or RegGetValueW?
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 :/
Use RegQueryValueEx :wink
(Paired with RegSetValueEx)
using that now since i guess reggetvalue doesn't work with winxp, etc. at least from what i read
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
post a tester, we can run it on our XPs. and see what's happed.