• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1587
  • Last Modified:

GetProcAddress fails to load a function from a dll with ERROR_PROC_NOT_FOUND when try to load from a diffrent path

I am try to load a function from a dll in run time.
I want to avoid the old version dll that is located first in the path and to load the newer version of the dll.
I am trying
      fnGetProcImFile = (LPFN_GETPROCIMAGEFILENAME)GetProcAddress(
                  GetModuleHandle("<PATH_4_Newer_LIB>\\psapi.dll"), "GetProcessImageFileNameA");

It is keep failing.
What should I do ?

10x
Assaf
0
Assaf_Gantz
Asked:
Assaf_Gantz
  • 2
  • 2
2 Solutions
 
AlexFMCommented:
Try first to load psapi.dll using LoadLibrary function, then use library handle in GetProcAddress. Your current code contains actually two operations and it is difficult to understand what is wrong.
GetModuleHandle returns handle to library which is already mapped to current process memory. Possibly this is not version that you need.
0
 
Assaf_GantzAuthor Commented:
I verified and the GetModuleHandle is failing
I think it is due to the fact that this dll is already in use in the binary.
My main issue is that the dll that is being use is older and I need one of the newer function.

Is there any way to get this function from the newer dll that is located in a different location?

Please advise
0
 
AlexFMCommented:
Did you try LoadLibrary with full Dll path?
0
 
Assaf_GantzAuthor Commented:
Thank you it seems to do the trick
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now