mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed hooking of delay-loaded DLL functions
Fixes blank intro videos in Midtown Madness 1. See issue #99.
This commit is contained in:
parent
f1d8dbd1cb
commit
97f56131ac
@ -128,11 +128,12 @@ namespace
|
|||||||
|
|
||||||
void hookFunction(void*& origFuncPtr, void* newFuncPtr, const char* funcName)
|
void hookFunction(void*& origFuncPtr, void* newFuncPtr, const char* funcName)
|
||||||
{
|
{
|
||||||
BYTE* targetFunc = reinterpret_cast<BYTE*>(origFuncPtr);
|
BYTE* targetFunc = static_cast<BYTE*>(origFuncPtr);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
#ifdef DEBUGLOGS
|
#ifdef DEBUGLOGS
|
||||||
oss << Compat::funcPtrToStr(targetFunc) << ' ';
|
oss << Compat::funcPtrToStr(targetFunc) << ' ';
|
||||||
|
#endif
|
||||||
|
|
||||||
char origFuncPtrStr[20] = {};
|
char origFuncPtrStr[20] = {};
|
||||||
if (!funcName)
|
if (!funcName)
|
||||||
@ -142,8 +143,6 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto prevTargetFunc = targetFunc;
|
auto prevTargetFunc = targetFunc;
|
||||||
#endif
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
unsigned instructionSize = 0;
|
unsigned instructionSize = 0;
|
||||||
@ -161,6 +160,11 @@ namespace
|
|||||||
{
|
{
|
||||||
instructionSize = 6;
|
instructionSize = 6;
|
||||||
targetFunc = **reinterpret_cast<BYTE***>(targetFunc + 2);
|
targetFunc = **reinterpret_cast<BYTE***>(targetFunc + 2);
|
||||||
|
if (Compat::getModuleHandleFromAddress(targetFunc) == Compat::getModuleHandleFromAddress(prevTargetFunc))
|
||||||
|
{
|
||||||
|
targetFunc = prevTargetFunc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -168,8 +172,8 @@ namespace
|
|||||||
}
|
}
|
||||||
#ifdef DEBUGLOGS
|
#ifdef DEBUGLOGS
|
||||||
oss << Compat::hexDump(prevTargetFunc, instructionSize) << " -> " << Compat::funcPtrToStr(targetFunc) << ' ';
|
oss << Compat::hexDump(prevTargetFunc, instructionSize) << " -> " << Compat::funcPtrToStr(targetFunc) << ' ';
|
||||||
prevTargetFunc = targetFunc;
|
|
||||||
#endif
|
#endif
|
||||||
|
prevTargetFunc = targetFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Compat::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
|
if (Compat::getModuleHandleFromAddress(targetFunc) == Dll::g_currentModule)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user