Sunday, 15 September 2013

dll - GetProcAddress returning NULL -



dll - GetProcAddress returning NULL -

i'm trying load dll using loadlibrary , getprocaddress. loadlibrary returns valid handle calls getprocaddress homecoming null. phone call getlasterror returns 87 error_invalid_parameter. verified function name i'm passing getprocaddress same returned when running dumpbin /exports on dll. unfortuantely work can't include actual code. here editted version give thought of i'm doing.

hinstance hdll = null; hdll = loadlibrary(l"<path dll>"); if (hdll == null) { // error handling code } g_var1 = (var1_type) getprocaddress(hdll, l"function1name"); g_var2 = (var2_type) getprocaddress(hdll, l"function2name"); if (!g_var1 || !g_var2 ) { // error handling code }

i've looked @ number of related questions on , other forums typically issue due c++ name mangling. since i'm using same name dumpbin shows don't think problem. ideas?

update

i think may have narrowed downwards issue. there existing older version of dll on target (this embedded wince solution). need utilize newer version of dll has function need; unfortuanatley can't update old dll. new dll , application using dll packed cab file loaded onto target. tried getprocaddress couple of functions in old dll , worked. seems though i'm calling loadlibrary path new dll it's loading dll on target. can confirm happen?

answer previous question

when windows ce loads dll, path info ignored when determining if dll loaded. means dll same name different path can loaded once. in addition, module ending extension .cpl treated if extension .dll.

source: http://msdn.microsoft.com/en-us/library/ms886736.aspx

yes, that's mutual pitfall. if don't provide total path dll, loadlibrary homecoming handle loaded dll of same name.

from msdn:

if lpfilename not include path , there more 1 loaded module same base of operations name , extension, function returns handle module loaded first.

i believe can exact dll want providing absolute path loadlibrary.

dll windows-ce getprocaddress

No comments:

Post a Comment