Reputation: 31
I have a DLL written in C# that uses Robert Giesecke's UnmanagedExports library and exports functions with [DllExport]
.
I can load it fine with LoadLibrary
, and call its exported functions. When I tried to load it into memory using BTMemoryModule
, the call of entry point (DllMain - DLL_PROCESS_ATTACH) TDllEntryProc
(in function BTMemoryLoadLibary
) returns false. How can I load such a DLL using BTMemoryModule
.
Upvotes: 1
Views: 199
Reputation: 613302
Loading DLLs from memory is not unsupported. Any code that does this is using unsupported hacks to do so. The system provides LoadLibrary
, LoadLibraryEx
etc. to perform this task, and they require the DLL to be present on disk.
Your DLL is a mixed mode .net assembly, and it requires special treatment by the loader. The system loader, as invoked by calls to LoadLibrary
, LoadLibraryEx
etc. knows how to perform the actions needed to load a mixed mode .net assembly. The BTMemoryModule code does not perform these special actions.
If you are going to be able to load such a module from memory, you will need to either find a library that supports such modules, or write your own loader code. Frankly, I doubt that such a library exists. More realistically you should load the DLL from disk.
Upvotes: 1