diff --git a/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp b/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp index fdc8746..6638514 100644 --- a/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp +++ b/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp @@ -1,4 +1,99 @@ +#define CINTERFACE + +#include +#include <../km/d3dkmthk.h> + #include "CompatD3dDdiDeviceCallbacks.h" +#include "DDrawLog.h" +#include "Hook.h" + +std::ostream& operator<<(std::ostream& os, const D3DDDI_ALLOCATIONINFO& data) +{ + return Compat::LogStruct(os) + << Compat::hex(data.hAllocation) + << data.pSystemMem + << data.pPrivateDriverData + << data.PrivateDriverDataSize + << data.VidPnSourceId + << Compat::hex(data.Flags.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_ALLOCATE& data) +{ + return Compat::LogStruct(os) + << data.pPrivateDriverData + << data.PrivateDriverDataSize + << data.hResource + << Compat::hex(data.hKMResource) + << data.NumAllocations + << Compat::array(data.pAllocationInfo, data.NumAllocations); +} + +std::ostream& operator<<(std::ostream& os, const D3DKMT_CREATEALLOCATION& data) +{ + return Compat::LogStruct(os) + << Compat::hex(data.hDevice) + << Compat::hex(data.hResource) + << Compat::hex(data.hGlobalShare) + << data.pPrivateRuntimeData + << data.PrivateRuntimeDataSize + << data.pPrivateDriverData + << data.PrivateDriverDataSize + << data.NumAllocations + << Compat::array(data.pAllocationInfo, data.NumAllocations) + << Compat::hex(*reinterpret_cast(&data.Flags)) + << data.hPrivateRuntimeResourceHandle; +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_DEALLOCATE& data) +{ + return Compat::LogStruct(os) + << data.hResource + << data.NumAllocations + << Compat::hex(Compat::array(data.HandleList, data.NumAllocations)); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_DEALLOCATE2& data) +{ + return Compat::LogStruct(os) + << data.hResource + << data.NumAllocations + << Compat::hex(Compat::array(data.HandleList, data.NumAllocations)) + << Compat::hex(data.Flags.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_LOCK& data) +{ + return Compat::LogStruct(os) + << Compat::hex(data.hAllocation) + << data.PrivateDriverData + << data.NumPages + << Compat::array(data.pPages, data.NumPages) + << data.pData + << Compat::hex(data.Flags.Value) + << Compat::hex(data.GpuVirtualAddress); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_LOCK2& data) +{ + return Compat::LogStruct(os) + << Compat::hex(data.hAllocation) + << Compat::hex(data.Flags.Value) + << data.pData; +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK& data) +{ + return Compat::LogStruct(os) + << data.NumAllocations + << Compat::hex(Compat::array(data.phAllocations, data.NumAllocations)); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK2& data) +{ + return Compat::LogStruct(os) + << Compat::hex(data.hAllocation); +} void CompatD3dDdiDeviceCallbacks::setCompatVtable(D3DDDI_DEVICECALLBACKS& /*vtable*/) { diff --git a/DDrawCompat/CompatD3dDdiDeviceCallbacks.h b/DDrawCompat/CompatD3dDdiDeviceCallbacks.h index 81095aa..0f9c260 100644 --- a/DDrawCompat/CompatD3dDdiDeviceCallbacks.h +++ b/DDrawCompat/CompatD3dDdiDeviceCallbacks.h @@ -3,6 +3,15 @@ #include "CompatVtable.h" #include "D3dDdiDeviceCallbacksVisitor.h" +std::ostream& operator<<(std::ostream& os, const D3DDDI_ALLOCATIONINFO& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_ALLOCATE& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_DEALLOCATE& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_DEALLOCATE2& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_LOCK& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_LOCK2& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK& data); +std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK2& data); + class CompatD3dDdiDeviceCallbacks : public CompatVtable { public: diff --git a/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp b/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp index 736f7cf..95fd517 100644 --- a/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp +++ b/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp @@ -1,5 +1,104 @@ #include "CompatD3dDdiDeviceFuncs.h" +std::ostream& operator<<(std::ostream& os, const D3DDDI_RATIONAL& val) +{ + return Compat::LogStruct(os) + << val.Numerator + << val.Denominator; +} + +std::ostream& operator<<(std::ostream& os, const D3DDDI_SURFACEINFO& val) +{ + return Compat::LogStruct(os) + << val.Width + << val.Height + << val.Depth + << val.pSysMem + << val.SysMemPitch + << val.SysMemSlicePitch; +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_CREATERESOURCE& val) +{ + return Compat::LogStruct(os) + << val.Format + << val.Pool + << val.MultisampleType + << val.MultisampleQuality + << Compat::array(val.pSurfList, val.SurfCount) + << val.SurfCount + << val.MipLevels + << val.Fvf + << val.VidPnSourceId + << val.RefreshRate + << val.hResource + << Compat::hex(val.Flags.Value) + << val.Rotation; +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_CREATERESOURCE2& val) +{ + return Compat::LogStruct(os) + << val.Format + << val.Pool + << val.MultisampleType + << val.MultisampleQuality + << Compat::array(val.pSurfList, val.SurfCount) + << val.SurfCount + << val.MipLevels + << val.Fvf + << val.VidPnSourceId + << val.RefreshRate + << val.hResource + << Compat::hex(val.Flags.Value) + << val.Rotation + << Compat::hex(val.Flags2.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_LOCK& val) +{ + return Compat::LogStruct(os) + << val.hResource + << val.SubResourceIndex + << val.Box + << val.pSurfData + << val.Pitch + << val.SlicePitch + << Compat::hex(val.Flags.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_OPENRESOURCE& val) +{ + return Compat::LogStruct(os) + << val.NumAllocations + << Compat::array(val.pOpenAllocationInfo, val.NumAllocations) + << Compat::hex(val.hKMResource) + << val.pPrivateDriverData + << val.PrivateDriverDataSize + << val.hResource + << val.Rotation + << Compat::hex(val.Flags.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_UNLOCK& val) +{ + return Compat::LogStruct(os) + << val.hResource + << val.SubResourceIndex + << Compat::hex(val.Flags.Value); +} + +std::ostream& operator<<(std::ostream& os, const D3DDDIBOX& box) +{ + return Compat::LogStruct(os) + << box.Left + << box.Top + << box.Right + << box.Bottom + << box.Front + << box.Back; +} + void CompatD3dDdiDeviceFuncs::setCompatVtable(D3DDDI_DEVICEFUNCS& /*vtable*/) { } diff --git a/DDrawCompat/CompatD3dDdiDeviceFuncs.h b/DDrawCompat/CompatD3dDdiDeviceFuncs.h index b4ee404..af68244 100644 --- a/DDrawCompat/CompatD3dDdiDeviceFuncs.h +++ b/DDrawCompat/CompatD3dDdiDeviceFuncs.h @@ -3,6 +3,15 @@ #include "CompatVtable.h" #include "D3dDdiDeviceFuncsVisitor.h" +std::ostream& operator<<(std::ostream& os, const D3DDDI_RATIONAL& val); +std::ostream& operator<<(std::ostream& os, const D3DDDI_SURFACEINFO& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_CREATERESOURCE& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_CREATERESOURCE2& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_LOCK& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_OPENRESOURCE& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_UNLOCK& val); +std::ostream& operator<<(std::ostream& os, const D3DDDIBOX& val); + class CompatD3dDdiDeviceFuncs : public CompatVtable { public: diff --git a/DDrawCompat/D3dDdiHooks.cpp b/DDrawCompat/D3dDdiHooks.cpp index f44fab1..ff30c8c 100644 --- a/DDrawCompat/D3dDdiHooks.cpp +++ b/DDrawCompat/D3dDdiHooks.cpp @@ -12,6 +12,17 @@ HRESULT APIENTRY OpenAdapter(D3DDDIARG_OPENADAPTER*) { return 0; } +std::ostream& operator<<(std::ostream& os, const D3DDDIARG_OPENADAPTER& data) +{ + return Compat::LogStruct(os) + << data.hAdapter + << data.Interface + << data.Version + << data.pAdapterCallbacks + << data.pAdapterFuncs + << data.DriverVersion; +} + namespace { UINT g_ddiVersion = 0; diff --git a/DDrawCompat/DDrawLog.h b/DDrawCompat/DDrawLog.h index 925c28a..ce97588 100644 --- a/DDrawCompat/DDrawLog.h +++ b/DDrawCompat/DDrawLog.h @@ -62,6 +62,20 @@ namespace Compat template Hex hex(Num val) { return Hex(val); } + template + struct Array + { + Array(const Elem* elem, const unsigned long size) : elem(elem), size(size) {} + const Elem* elem; + const unsigned long size; + }; + + template + Array array(const Elem* elem, const unsigned long size) + { + return Array(elem, size); + } + class Log { public: @@ -187,3 +201,18 @@ std::ostream& operator<<(std::ostream& os, Compat::Hex hex) os << "0x" << std::hex << hex.val << std::dec; return os; } + +template +std::ostream& operator<<(std::ostream& os, Compat::Array array) +{ + os << '['; + if (0 != array.size) + { + os << array.elem[0]; + } + for (unsigned long i = 1; i < array.size; ++i) + { + os << ',' << array.elem[i]; + } + return os << ']'; +}