MemoryModule icon indicating copy to clipboard operation
MemoryModule copied to clipboard

Loading side-by-side assembly dependencies of modules

Open dismantl opened this issue 10 years ago • 0 comments

I recently tried to load a DLL that had a dependency on a Windows Side-by-side assembly, specifically MSVCRT90.DLL. Due to the way that WinSxS assemblies are loaded from the assembly cache by the Windows loader, the LoadLibrary() call for MSVCRT90.DLL in BuildImportTable() returned NULL.

I'm looking into a way this could be resolved, and right now it appears one solution is to extract and parse a DLL's manifest to look for WinSxS dependencies, set the activation context, call LoadLibrary(), then unset the activation context[1][2]. The only problem with that is that you need to write a temporary file to disk in order to set the activation context, which kind of defeats the memory-only purpose of MemoryModule. And I suppose another problem with this solution is that the OS must have the specific version of the WinSxS dependency installed in the assembly cache.

I'll see if I can find another solution, but I just wanted to flag this issue for now.

[1] http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-28901 [2] https://stackoverflow.com/questions/11175430/resolving-pe-sxs-imports-windows

dismantl avatar Oct 03 '15 13:10 dismantl