1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Improved debug logging of GDI function calls and window messages

This commit is contained in:
narzoul 2016-02-28 17:40:50 +01:00
parent 2f85be8952
commit fa69ef4a17
5 changed files with 40 additions and 8 deletions

View File

@ -2,6 +2,7 @@
#include "CompatGdiDc.h"
#include "CompatGdiFunctions.h"
#include "DDrawLog.h"
#include "RealPrimarySurface.h"
#include <detours.h>
@ -57,15 +58,33 @@ namespace
template <typename OrigFuncPtr, OrigFuncPtr origFunc, typename Result, typename... Params>
Result WINAPI compatGdiFunc(Params... params)
{
if (!hasDisplayDcArg(params...) || !CompatGdi::beginGdiRendering())
{
return CompatGdi::getOrigFuncPtr<OrigFuncPtr, origFunc>()(params...);
}
#ifdef _DEBUG
Compat::LogEnter(CompatGdi::g_funcNames[origFunc], params...);
#endif
if (!hasDisplayDcArg(params...) || !CompatGdi::beginGdiRendering())
{
Result result = CompatGdi::getOrigFuncPtr<OrigFuncPtr, origFunc>()(params...);
#ifdef _DEBUG
if (!hasDisplayDcArg(params...))
{
Compat::Log() << "Skipping redirection since there is no display DC argument";
}
else if (!RealPrimarySurface::isFullScreen())
{
Compat::Log() << "Skipping redirection due to windowed mode";
}
else
{
Compat::Log() << "Skipping redirection since the primary surface could not be locked";
}
Compat::LogLeave(CompatGdi::g_funcNames[origFunc], params...) << result;
#endif
return result;
}
Result result = CompatGdi::getOrigFuncPtr<OrigFuncPtr, origFunc>()(replaceDc(params)...);
releaseDc(params...);
CompatGdi::endGdiRendering();

View File

@ -25,9 +25,11 @@ namespace
LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)
{
auto ret = reinterpret_cast<CWPRETSTRUCT*>(lParam);
Compat::LogEnter("callWndRetProc", nCode, wParam, ret);
if (HC_ACTION == nCode)
{
auto ret = reinterpret_cast<CWPRETSTRUCT*>(lParam);
if (WM_CREATE == ret->message)
{
disableDwmAttributes(ret->hwnd);
@ -75,7 +77,9 @@ namespace
}
}
return CallNextHookEx(nullptr, nCode, wParam, lParam);
LRESULT result = CallNextHookEx(nullptr, nCode, wParam, lParam);
Compat::LogLeave("callWndRetProc", nCode, wParam, ret) << result;
return result;
}
void disableDwmAttributes(HWND hwnd)

View File

@ -72,6 +72,14 @@ std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd)
sd.lpSurface << "," << sd.ddpfPixelFormat << "," << sd.ddsCaps << "," << sd.dwTextureStage << ')';
}
std::ostream& operator<<(std::ostream& os, const CWPRETSTRUCT& cwrp)
{
RECT wr = {};
GetWindowRect(cwrp.hwnd, &wr);
return os << "CWRP(" << std::hex << cwrp.message << "," << cwrp.hwnd << ":" << std::dec << wr << "," <<
std::hex << cwrp.wParam << "," << cwrp.lParam << "," << cwrp.lResult << std::dec << ")";
}
namespace Compat
{
Log::Log()

View File

@ -21,6 +21,7 @@ std::ostream& operator<<(std::ostream& os, const DDSCAPS2& caps);
std::ostream& operator<<(std::ostream& os, const DDPIXELFORMAT& pf);
std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC& sd);
std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd);
std::ostream& operator<<(std::ostream& os, const CWPRETSTRUCT& cwrp);
template <typename T>
typename std::enable_if<std::is_class<T>::value && !std::is_same<T, std::string>::value, std::ostream&>::type

View File

@ -55,7 +55,7 @@ namespace
HDC converterDc = nullptr;
origVtable.GetDC(g_paletteConverterSurface, &converterDc);
result = TRUE == BitBlt(destDc, 0, 0,
result = TRUE == CALL_ORIG_GDI(BitBlt)(destDc, 0, 0,
RealPrimarySurface::s_surfaceDesc.dwWidth, RealPrimarySurface::s_surfaceDesc.dwHeight,
converterDc, 0, 0, SRCCOPY);