-
Notifications
You must be signed in to change notification settings - Fork 797
Open
Description
I have a library named a.dll, a.dll has a reference b.dll.
When I want to use MemoryLoadLibrary to load a.dll, the default references loader is LoadLibraryA, when I changed the loader to my own loader like the code below, it crashed. How to change the return value of MemoryLoadLibraryEx to a value like the return value of LoadLibraryA?
HCUSTOMMODULE LoadLibrary_R(LPCSTR filename, void* userdata)
{
bool isFound = false;
for(auto it: names)
{
if (strcmp(it, filename) == 0) {
isFound = true;
break;
}
}
if (isFound) {
size_t size;
auto buffer = readFileToBuffer(filename, &size);
auto t = (HMODULE)((PMEMORYMODULE)MemoryLoadLibraryEx(buffer, LoadLibrary_R, _GetProcAddress, _FreeLibrary, NULL))->codeBase;
//still wrong
//auto t = (HMODULE)MemoryLoadLibraryEx(buffer, LoadLibrary_R, _GetProcAddress, _FreeLibrary, NULL));
return t;
}
else {
HMODULE result = LoadLibraryA(filename);
if (result == NULL) {
return NULL;
}
return (HCUSTOMMODULE)result;
}
}
Metadata
Metadata
Assignees
Labels
No labels