Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a DLL that loads msvcr80.dll and exposes the free()-function

I have a third-party DLL that depends on MSVCR80 and allocates resources that I need to cleanup. The library does not expose a free-function for doing this. Instead, I need to load the same runtime library and manually call the free function.

As a workaround I'm trying to write a "wrapper" DLL that loads the correct runtime and exposes the free function. This DLL is created using Visual Studio 2010 and is dependent on a separate runtime library. Doing LoadLibrary("msvcr80.dll") fails with error R6034 which I guess is because of manifest issues.

Is it even possible to load msvcr80.dll using LoadLibrary? Do I need to create a manifest, embed it into the DLL and store msvcr80.dll in the same directory as my wrapper DLL?

I realize that this is a flaw in the third-party library, but I'm pretty much stuck with this version. Getting the vendor to fix this is most likely not an option.

like image 249
larsmoa Avatar asked Sep 14 '11 16:09

larsmoa


1 Answers

Probably there are better solutions, but in case everything else failed you could find somewhere a copy of VC++ 2005 Express Edition (=free, no piracy is needed ;) ), which uses the version 8.0 of the compiler, and thus the same runtime of the defective dll.

Then you would build your wrapper dll with it, which would just call the free provided by its CRT (double check that you're using the dll version!).

like image 115
Matteo Italia Avatar answered Oct 27 '22 20:10

Matteo Italia