mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed a crash in IAT hooking when encountering imports by ordinals
See issue #149.
This commit is contained in:
parent
7a59458d58
commit
19899f81c9
@ -70,12 +70,13 @@ namespace
|
|||||||
auto origThunk = reinterpret_cast<PIMAGE_THUNK_DATA>(moduleBase + desc->OriginalFirstThunk);
|
auto origThunk = reinterpret_cast<PIMAGE_THUNK_DATA>(moduleBase + desc->OriginalFirstThunk);
|
||||||
while (0 != thunk->u1.AddressOfData && 0 != origThunk->u1.AddressOfData)
|
while (0 != thunk->u1.AddressOfData && 0 != origThunk->u1.AddressOfData)
|
||||||
{
|
{
|
||||||
auto origImport = reinterpret_cast<PIMAGE_IMPORT_BY_NAME>(
|
if (!(origThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG))
|
||||||
moduleBase + origThunk->u1.AddressOfData);
|
|
||||||
|
|
||||||
if (0 == strcmp(origImport->Name, procName))
|
|
||||||
{
|
{
|
||||||
return reinterpret_cast<FARPROC*>(&thunk->u1.Function);
|
auto origImport = reinterpret_cast<PIMAGE_IMPORT_BY_NAME>(moduleBase + origThunk->u1.AddressOfData);
|
||||||
|
if (0 == strcmp(origImport->Name, procName))
|
||||||
|
{
|
||||||
|
return reinterpret_cast<FARPROC*>(&thunk->u1.Function);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++thunk;
|
++thunk;
|
||||||
|
@ -416,11 +416,6 @@ namespace D3dDdi
|
|||||||
|
|
||||||
void installHooks()
|
void installHooks()
|
||||||
{
|
{
|
||||||
g_origSubmitPresentBltToHwQueue = reinterpret_cast<decltype(&D3DKMTSubmitPresentBltToHwQueue)>(
|
|
||||||
GetProcAddress(GetModuleHandle("gdi32"), "D3DKMTSubmitPresentBltToHwQueue"));
|
|
||||||
g_origSubmitPresentToHwQueue = reinterpret_cast<decltype(&D3DKMTSubmitPresentToHwQueue)>(
|
|
||||||
GetProcAddress(GetModuleHandle("gdi32"), "D3DKMTSubmitPresentToHwQueue"));
|
|
||||||
|
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "CreateDCA", ddrawCreateDcA);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "CreateDCA", ddrawCreateDcA);
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTCloseAdapter", closeAdapter);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTCloseAdapter", closeAdapter);
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTCreateDCFromMemory", createDcFromMemory);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTCreateDCFromMemory", createDcFromMemory);
|
||||||
@ -431,7 +426,21 @@ namespace D3dDdi
|
|||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTReleaseProcessVidPnSourceOwners", releaseProcessVidPnSourceOwners);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTReleaseProcessVidPnSourceOwners", releaseProcessVidPnSourceOwners);
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSetGammaRamp", setGammaRamp);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSetGammaRamp", setGammaRamp);
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSetVidPnSourceOwner", setVidPnSourceOwner);
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSetVidPnSourceOwner", setVidPnSourceOwner);
|
||||||
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSubmitPresentToHwQueue", submitPresentToHwQueue);
|
|
||||||
|
auto gdi32 = GetModuleHandle("gdi32");
|
||||||
|
g_origSubmitPresentBltToHwQueue = reinterpret_cast<decltype(&D3DKMTSubmitPresentBltToHwQueue)>(
|
||||||
|
GetProcAddress(gdi32, "D3DKMTSubmitPresentBltToHwQueue"));
|
||||||
|
if (g_origSubmitPresentBltToHwQueue)
|
||||||
|
{
|
||||||
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSubmitPresentBltToHwQueue", submitPresentBltToHwQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_origSubmitPresentToHwQueue = reinterpret_cast<decltype(&D3DKMTSubmitPresentToHwQueue)>(
|
||||||
|
GetProcAddress(gdi32, "D3DKMTSubmitPresentToHwQueue"));
|
||||||
|
if (g_origSubmitPresentToHwQueue)
|
||||||
|
{
|
||||||
|
Compat::hookIatFunction(Dll::g_origDDrawModule, "D3DKMTSubmitPresentToHwQueue", submitPresentToHwQueue);
|
||||||
|
}
|
||||||
|
|
||||||
Dll::createThread(&vsyncThreadProc, nullptr, THREAD_PRIORITY_TIME_CRITICAL);
|
Dll::createThread(&vsyncThreadProc, nullptr, THREAD_PRIORITY_TIME_CRITICAL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user