mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed crash at startup in Anno 1503 AD
This commit is contained in:
parent
34c5c28cec
commit
cb35ee4beb
@ -215,8 +215,6 @@ namespace
|
|||||||
}
|
}
|
||||||
g_isDbgEngInitialized = true;
|
g_isDbgEngInitialized = true;
|
||||||
|
|
||||||
CoInitialize(nullptr);
|
|
||||||
|
|
||||||
HRESULT result = S_OK;
|
HRESULT result = S_OK;
|
||||||
if (FAILED(result = DebugCreate(IID_IDebugClient, reinterpret_cast<void**>(&g_debugClient))) ||
|
if (FAILED(result = DebugCreate(IID_IDebugClient, reinterpret_cast<void**>(&g_debugClient))) ||
|
||||||
FAILED(result = g_debugClient->QueryInterface(IID_IDebugControl, reinterpret_cast<void**>(&g_debugControl))) ||
|
FAILED(result = g_debugClient->QueryInterface(IID_IDebugControl, reinterpret_cast<void**>(&g_debugControl))) ||
|
||||||
|
@ -38,20 +38,13 @@ namespace
|
|||||||
|
|
||||||
void installHooks();
|
void installHooks();
|
||||||
|
|
||||||
template <FARPROC(Dll::Procs::* origFunc), typename Result, typename FirstParam, typename... Params>
|
template <FARPROC(Dll::Procs::* origFunc), typename OrigFuncPtrType, typename FirstParam, typename... Params>
|
||||||
Result WINAPI directDrawFunc(FirstParam firstParam, Params... params)
|
HRESULT WINAPI directDrawFunc(FirstParam firstParam, Params... params)
|
||||||
{
|
{
|
||||||
LOG_FUNC(getFuncName<origFunc>(), firstParam, params...);
|
LOG_FUNC(getFuncName<origFunc>(), firstParam, params...);
|
||||||
installHooks();
|
installHooks();
|
||||||
suppressEmulatedDirectDraw(firstParam);
|
suppressEmulatedDirectDraw(firstParam);
|
||||||
return LOG_RESULT(reinterpret_cast<FuncPtr<Result, FirstParam, Params...>>(Dll::g_origProcs.*origFunc)(
|
return LOG_RESULT(reinterpret_cast<OrigFuncPtrType>(Dll::g_origProcs.*origFunc)(firstParam, params...));
|
||||||
firstParam, params...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <FARPROC(Dll::Procs::* origFunc), typename Result, typename... Params>
|
|
||||||
FuncPtr<Result, Params...> getDirectDrawFuncPtr(FuncPtr<Result, Params...>)
|
|
||||||
{
|
|
||||||
return &directDrawFunc<origFunc, Result, Params...>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getDirName(const std::string& path)
|
std::string getDirName(const std::string& path)
|
||||||
@ -190,7 +183,7 @@ namespace
|
|||||||
#define HOOK_DDRAW_PROC(proc) \
|
#define HOOK_DDRAW_PROC(proc) \
|
||||||
Compat::hookFunction( \
|
Compat::hookFunction( \
|
||||||
reinterpret_cast<void*&>(Dll::g_origProcs.proc), \
|
reinterpret_cast<void*&>(Dll::g_origProcs.proc), \
|
||||||
getDirectDrawFuncPtr<&Dll::Procs::proc>(static_cast<decltype(&proc)>(nullptr)), \
|
static_cast<decltype(&proc)>(&directDrawFunc<&Dll::Procs::proc, decltype(&proc)>), \
|
||||||
#proc);
|
#proc);
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
|
@ -459,7 +459,6 @@ namespace Gdi
|
|||||||
HOOK_FUNCTION(user32, UpdateLayeredWindow, updateLayeredWindow);
|
HOOK_FUNCTION(user32, UpdateLayeredWindow, updateLayeredWindow);
|
||||||
HOOK_FUNCTION(user32, UpdateLayeredWindowIndirect, updateLayeredWindowIndirect);
|
HOOK_FUNCTION(user32, UpdateLayeredWindowIndirect, updateLayeredWindowIndirect);
|
||||||
|
|
||||||
CoInitialize(nullptr);
|
|
||||||
SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE,
|
SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE,
|
||||||
Dll::g_currentModule, &objectCreateEvent, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
|
Dll::g_currentModule, &objectCreateEvent, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
|
||||||
SetWinEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE,
|
SetWinEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user