From 335d093cb9c8648386647422be858c5286b135e0 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 11 Mar 2018 18:42:06 +0100 Subject: [PATCH] Fixed palette issues with GetDC on primary surface --- DDrawCompat/D3dDdi/KernelModeThunks.cpp | 20 +++++++++++++++++++ .../D3dDdi/Log/KernelModeThunksLog.cpp | 13 ++++++++++++ DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h | 1 + 3 files changed, 34 insertions(+) diff --git a/DDrawCompat/D3dDdi/KernelModeThunks.cpp b/DDrawCompat/D3dDdi/KernelModeThunks.cpp index 39f81a7..4430acd 100644 --- a/DDrawCompat/D3dDdi/KernelModeThunks.cpp +++ b/DDrawCompat/D3dDdi/KernelModeThunks.cpp @@ -80,6 +80,25 @@ namespace return result; } + NTSTATUS APIENTRY createDcFromMemory(D3DKMT_CREATEDCFROMMEMORY* pData) + { + Compat::LogEnter("D3DKMTCreateDCFromMemory", pData); + NTSTATUS result = 0; + if (pData && D3DDDIFMT_P8 == pData->Format && !pData->pColorTable && + DDraw::PrimarySurface::s_palette) + { + pData->pColorTable = DDraw::PrimarySurface::s_paletteEntries; + result = CALL_ORIG_FUNC(D3DKMTCreateDCFromMemory)(pData); + pData->pColorTable = nullptr; + } + else + { + result = CALL_ORIG_FUNC(D3DKMTCreateDCFromMemory)(pData); + } + Compat::LogLeave("D3DKMTCreateDCFromMemory", pData) << result; + return result; + } + NTSTATUS APIENTRY destroyContext(const D3DKMT_DESTROYCONTEXT* pData) { Compat::LogEnter("D3DKMTDestroyContext", pData); @@ -250,6 +269,7 @@ namespace D3dDdi { HOOK_FUNCTION(gdi32, D3DKMTCreateContext, createContext); HOOK_FUNCTION(gdi32, D3DKMTCreateDevice, createDevice); + HOOK_FUNCTION(gdi32, D3DKMTCreateDCFromMemory, createDcFromMemory); HOOK_FUNCTION(gdi32, D3DKMTDestroyContext, destroyContext); HOOK_FUNCTION(gdi32, D3DKMTDestroyDevice, destroyDevice); HOOK_FUNCTION(gdi32, D3DKMTQueryAdapterInfo, queryAdapterInfo); diff --git a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.cpp b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.cpp index c1cde2b..3a51284 100644 --- a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.cpp +++ b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.cpp @@ -34,6 +34,19 @@ std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXTVIRTUAL& da << Compat::hex(data.hContext); } +std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDCFROMMEMORY& data) +{ + return Compat::LogStruct(os) + << data.pMemory + << data.Width + << data.Height + << data.Pitch + << data.hDeviceDc + << data.pColorTable + << Compat::out(data.hDc) + << Compat::out(data.hBitmap); +} + std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDEVICE& data) { return Compat::LogStruct(os) diff --git a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h index f2af804..b64583d 100644 --- a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h +++ b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h @@ -10,6 +10,7 @@ std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXT& data); std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATECONTEXTVIRTUAL& data); +std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDCFROMMEMORY& data); std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEDEVICE& data); std::ostream& operator<<(std::ostream& os, const D3DKMT_DESTROYCONTEXT& data); std::ostream& operator<<(std::ostream& os, const D3DKMT_DESTROYDEVICE& data);