I want to replace the LoadLibrary functions to prevent the loading of blacklisted dlls that might be injected.
I copied the sample code from _win32.cpp for the LoadLibrary functions I will need. I used LoadLibraryW, LoadLibraryExW, LoadLibraryA and LoadLibraryExA. Only showing one call as they are all the same but the function name.
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
LONG l = DetourDetach(&(PVOID&)Real_LoadLibraryA, Mine_LoadLibraryA);
if (l != 0)
{
__debugbreak();
}
PVOID* ppbFailedPointer = nullptr;
LONG error = DetourTransactionCommitEx(&ppbFailedPointer);
if (error != 0)
{
__debugbreak();
}
DetourDetach always returns ERROR_INVALID_BLOCK. I can run the samples fine, but they are all examples of injecting code using a dll.