2013-04-27 12:19:14 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <dxdiag.h>
|
|
|
|
#include "dxwnd.h"
|
|
|
|
#include "dxwcore.hpp"
|
|
|
|
|
|
|
|
// COM generic types
|
|
|
|
typedef HRESULT (WINAPI *QueryInterface_Type)(void *, REFIID, LPVOID *);
|
|
|
|
|
|
|
|
// DxDiag IDxDiagProvider
|
|
|
|
typedef HRESULT (WINAPI *Initialize_Type) (void *, DXDIAG_INIT_PARAMS *);
|
|
|
|
typedef HRESULT (WINAPI *GetRootContainer_Type) (void *, IDxDiagContainer **);
|
|
|
|
// DxDiag IDxDiagContainer
|
|
|
|
typedef HRESULT (WINAPI *GetNumberOfChildContainers_Type) (void *, DWORD *);
|
|
|
|
typedef HRESULT (WINAPI *EnumChildContainerNames_Type) (void *, DWORD, LPWSTR, DWORD);
|
|
|
|
typedef HRESULT (WINAPI *GetChildContainer_Type) (void *, LPCWSTR, IDxDiagContainer **);
|
|
|
|
typedef HRESULT (WINAPI *GetNumberOfProps_Type) (void *, DWORD *);
|
|
|
|
typedef HRESULT (WINAPI *EnumPropNames_Type) (void *, DWORD, LPWSTR, DWORD);
|
|
|
|
typedef HRESULT (WINAPI *GetProp_Type) (void *, LPCWSTR, VARIANT *);
|
|
|
|
|
|
|
|
typedef HRESULT (WINAPI *Initialize_Type)(void *, DXDIAG_INIT_PARAMS *);
|
|
|
|
typedef HRESULT (WINAPI *GetRootContainer_Type)(void *, IDxDiagContainer **);
|
|
|
|
|
|
|
|
HRESULT WINAPI extInitializeDD(void *, DXDIAG_INIT_PARAMS *);
|
|
|
|
HRESULT WINAPI extGetRootContainer(void *, IDxDiagContainer **);
|
|
|
|
HRESULT WINAPI extGetNumberOfChildContainers(void *, DWORD *);
|
|
|
|
HRESULT WINAPI extQueryInterfaceDD(void *, REFIID, LPVOID *);
|
|
|
|
HRESULT WINAPI extGetProp(void *, LPCWSTR, VARIANT *);
|
|
|
|
|
|
|
|
Initialize_Type pInitializeDD;
|
|
|
|
GetRootContainer_Type pGetRootContainer;
|
|
|
|
GetNumberOfChildContainers_Type pGetNumberOfChildContainers;
|
|
|
|
EnumChildContainerNames_Type pEnumChildContainerNames;
|
|
|
|
GetChildContainer_Type pGetChildContainer;
|
|
|
|
GetNumberOfProps_Type pGetNumberOfProps;
|
|
|
|
EnumPropNames_Type pEnumPropNames;
|
|
|
|
GetProp_Type pGetProp;
|
|
|
|
QueryInterface_Type pQueryInterfaceDD;
|
|
|
|
|
|
|
|
HRESULT HookDxDiag(REFIID riid, LPVOID FAR* ppv)
|
|
|
|
{
|
|
|
|
HMODULE dxdlib;
|
|
|
|
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("CoCreateInstance: CLSID_DxDiagProvider object\n");
|
2013-04-27 12:19:14 -04:00
|
|
|
dxdlib=(*pLoadLibraryA)("dxdiagn.dll");
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("CoCreateInstance: dxdiagn lib handle=%x\n", dxdlib);
|
2013-04-27 12:19:14 -04:00
|
|
|
extern void HookModule(HMODULE, int);
|
|
|
|
HookModule(dxdlib, 0);
|
|
|
|
|
|
|
|
switch (*(DWORD *)&riid){
|
|
|
|
case 0x9C6B4CB0:
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("CoCreateInstance: IID_DxDiagProvider RIID\n");
|
2013-04-27 12:19:14 -04:00
|
|
|
// IID_DxDiagProvider::QueryInterface
|
|
|
|
SetHook((void *)(**(DWORD **)ppv), extQueryInterfaceDD, (void **)&pQueryInterfaceDD, "QueryInterface(DxDiag)");
|
|
|
|
// IID_DxDiagProvider::Initialize
|
|
|
|
SetHook((void *)(**(DWORD **)ppv + 12), extInitializeDD, (void **)&pInitializeDD, "Initialize(DxDiag)");
|
|
|
|
// IID_DxDiagProvider::Initialize
|
|
|
|
SetHook((void *)(**(DWORD **)ppv + 16), extGetRootContainer, (void **)&pGetRootContainer, "GetRootContainer(DxDiag)");
|
|
|
|
break;
|
|
|
|
case 0x7D0F462F:
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("CoCreateInstance: IID_IDxDiagContainer RIID\n");
|
2013-04-27 12:19:14 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI extInitializeDD(void *th, DXDIAG_INIT_PARAMS *pParams)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::Initialize Params=%x\n", pParams);
|
2013-04-27 12:19:14 -04:00
|
|
|
res=(*pInitializeDD)(th, pParams);
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::Initialize res=%x\n", res);
|
2013-04-27 12:19:14 -04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI extGetRootContainer(void *th, IDxDiagContainer **ppInstance)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetRootContainer pInstance=%x\n", *ppInstance);
|
2013-04-27 12:19:14 -04:00
|
|
|
res=(*pGetRootContainer)(th, ppInstance);
|
|
|
|
// IID_IDxDiagContainer::GetNumberOfChildContainers
|
|
|
|
SetHook((void *)(**(DWORD **)ppInstance + 12), extGetNumberOfChildContainers, (void **)&pGetNumberOfChildContainers, "GetNumberOfChildContainers(DxDiag)");
|
|
|
|
// IID_IDxDiagContainer::GetProp
|
|
|
|
SetHook((void *)(**(DWORD **)ppInstance + 32), extGetProp, (void **)&pGetProp, "GetProp(DxDiag)");
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetRootContainer res=%x\n", res);
|
2013-04-27 12:19:14 -04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI extGetNumberOfChildContainers(void *th, DWORD *pdwCount)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetNumberOfChildContainers\n");
|
2013-04-27 12:19:14 -04:00
|
|
|
res=(*pGetNumberOfChildContainers)(th, pdwCount);
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetNumberOfChildContainers res=%x Count=%d\n", res, *pdwCount);
|
2013-04-27 12:19:14 -04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI extQueryInterfaceDD(void *th, REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::QueryInterface ref=%x\n");
|
2013-04-27 12:19:14 -04:00
|
|
|
res=(*pQueryInterfaceDD)(th, riid, ppvObj);
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::QueryInterface res=%x\n", res);
|
2013-04-27 12:19:14 -04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI extGetProp(void *th, LPCWSTR pwszPropName, VARIANT *pvarProp)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetProp PropName=%ls\n", pwszPropName);
|
2013-04-27 12:19:14 -04:00
|
|
|
res=(*pGetProp)(th, pwszPropName, pvarProp);
|
|
|
|
if(res)
|
|
|
|
OutTraceE("DxDiag::GetProp ERROR res=%x\n", res);
|
|
|
|
|
|
|
|
if (!wcsncmp(L"dwDirectXVersionMajor", pwszPropName, sizeof(L"dwDirectXVersionMajor"))){
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetProp DirectXVersionMajor=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
//*(DWORD *)pvarProp=10;
|
2013-12-22 11:38:36 -05:00
|
|
|
//OutTraceDW("DxDiag::GetProp fixed DirectXVersionMajor=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
}
|
|
|
|
if (!wcsncmp(L"dwDirectXVersionMinor", pwszPropName, sizeof(L"dwDirectXVersionMinor"))){
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetProp DirectXVersionMinor=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
//*(DWORD *)pvarProp=10;
|
2013-12-22 11:38:36 -05:00
|
|
|
//OutTraceDW("DxDiag::GetProp fixed dwDirectXVersionMinor=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
}
|
|
|
|
if (!wcsncmp(L"szDirectXVersionLetter", pwszPropName, sizeof(L"szDirectXVersionLetter"))){
|
2013-12-22 11:38:36 -05:00
|
|
|
OutTraceDW("DxDiag::GetProp DirectXVersionLetter=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
//*(DWORD *)pvarProp=9;
|
2013-12-22 11:38:36 -05:00
|
|
|
//OutTraceDW("DxDiag::GetProp fixed szDirectXVersionLetter=%d\n", *pvarProp);
|
2013-04-27 12:19:14 -04:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
STDMETHOD(GetNumberOfChildContainers) (THIS_ DWORD *pdwCount) PURE;
|
|
|
|
STDMETHOD(EnumChildContainerNames) (THIS_ DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) PURE;
|
|
|
|
STDMETHOD(GetChildContainer) (THIS_ LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) PURE;
|
|
|
|
STDMETHOD(GetNumberOfProps) (THIS_ DWORD *pdwCount) PURE;
|
|
|
|
STDMETHOD(EnumPropNames) (THIS_ DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) PURE;
|
|
|
|
STDMETHOD(GetProp) (THIS_ LPCWSTR pwszPropName, VARIANT *pvarProp) PURE;
|
|
|
|
*/
|