LoadLibrary File Win32 bit dll

Ehad Akeila 1 Reputation point


I'm working on an old project that was built on VS2013. So I installed VS2013 on my Windows 10 machine (which is 64 bit). The project builds libraries targeting Win32 bits platform. It seems that there are nested library calls from one library to another. The project structure is

Main App ==> Calls a Win32 Lib_A , LoadLibrary ==> Win32 Lib_B

The main issue now is that LoadLibrary in LibA is failing to load Lib_B with error code 126(ERROR_MOD_NOT_FOUND)

I'm relatively new to using dll and loading them so here is what I did to debug the issue:

  1. I initially got error 126. After using Process Monitor, I found a few missing dependencies on Lib_B. I fixed all of these missing dlls until the Process Monitor couldnot find anymore missing ones.
  2. I ran the project again and I got error 193 (ERROR_BAD_EXE_FORMAT). From reading, this seems to be related to using 64-bit app to call 32-bit libraries
  3. Then I changed the MainApp to 0x86 and ran the project. I got error 126 again. I checked Process Monitor and it couldnt find anything wrong with the dependencies
  4. Now this is where I got stuck, I dont know what's still missing on my machine to load Lib_B from Lib_A. I tried a few things
    • Tried to change the target platform on Lib_A and Lib_B from Win32 to 0x86. However, VS2013 doenst show this in the dropdown menu. It only has Win32 and 0x64. The 0x64 is not an option since the app needs to work on old machines
    • I used LoadLibraryEx with LOAD_LIBRARY_AS_DATAFILE
    hLibBExt = LoadLibraryEx(L"hLibB", NULL, LOAD_LIBRARY_AS_DATAFILE);
    Error = GetLastError(); //No error
    hrsrc_tmp = FindResource(hLibBExt , L"hLibB", RT_RCDATA);
    Error = GetLastError();//Error 1813

The first call to LoadLibraryEx returned something (hLibBExt is not NULL), but FindResource gives me error 1813

I'm not sure what to do next to fix this issue......

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,291 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,328 questions
{count} votes