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

Added logging for some DDI structs

This commit is contained in:
narzoul 2016-08-21 18:44:11 +02:00
parent 08fb2fc9b4
commit a078ea4be0
6 changed files with 252 additions and 0 deletions

View File

@ -1,4 +1,99 @@
#define CINTERFACE
#include <Windows.h>
#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<const DWORD*>(&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*/)
{

View File

@ -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<CompatD3dDdiDeviceCallbacks, D3dDdiDeviceCallbacksIntf>
{
public:

View File

@ -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*/)
{
}

View File

@ -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<CompatD3dDdiDeviceFuncs, D3dDdiDeviceFuncsIntf>
{
public:

View File

@ -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;

View File

@ -62,6 +62,20 @@ namespace Compat
template <typename Num> Hex<Num> hex(Num val) { return Hex<Num>(val); }
template <typename Elem>
struct Array
{
Array(const Elem* elem, const unsigned long size) : elem(elem), size(size) {}
const Elem* elem;
const unsigned long size;
};
template <typename Elem>
Array<Elem> array(const Elem* elem, const unsigned long size)
{
return Array<Elem>(elem, size);
}
class Log
{
public:
@ -187,3 +201,18 @@ std::ostream& operator<<(std::ostream& os, Compat::Hex<Num> hex)
os << "0x" << std::hex << hex.val << std::dec;
return os;
}
template <typename Elem>
std::ostream& operator<<(std::ostream& os, Compat::Array<Elem> 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 << ']';
}