diff --git a/OptiScaler/Source.def b/OptiScaler/Source.def index e76a372f..63cb0c08 100644 --- a/OptiScaler/Source.def +++ b/OptiScaler/Source.def @@ -17,12 +17,27 @@ D3D12PIXReportCounter = _D3D12PIXReportCounter @115 PRIVATE D3D12SerializeRootSignature = _D3D12SerializeRootSignatureExport @116 PRIVATE D3D12SerializeVersionedRootSignature = _D3D12SerializeVersionedRootSignatureExport @117 PRIVATE -EXPORTS +EXPORTS CreateDXGIFactory = _CreateDXGIFactory CreateDXGIFactory1 = _CreateDXGIFactory1 -CreateDXGIFactory2 = _CreateDXGIFactory2 -DXGIDeclareAdapterRemovalSupport = _DXGIDeclareAdapterRemovalSupport -DXGIGetDebugInterface1 = _DXGIGetDebugInterface1 +CreateDXGIFactory2 = _CreateDXGIFactory2 +DXGIDeclareAdapterRemovalSupport = _DXGIDeclareAdapterRemovalSupport +DXGIGetDebugInterface1 = _DXGIGetDebugInterface1 +ApplyCompatResolutionQuirking = _ApplyCompatResolutionQuirking +CompatString = _CompatString +CompatValue = _CompatValue +DXGIDisableVBlankVirtualization = _DXGIDisableVBlankVirtualization +DXGIDumpJournal = _DXGIDumpJournal +DXGIReportAdapterConfiguration = _DXGIReportAdapterConfiguration +DXGID3D10CreateDevice = _DXGID3D10CreateDevice +DXGID3D10CreateLayeredDevice = _DXGID3D10CreateLayeredDevice +DXGID3D10GetLayeredDeviceSize = _DXGID3D10GetLayeredDeviceSize +DXGID3D10RegisterLayers = _DXGID3D10RegisterLayers +PIXBeginCapture = _PIXBeginCapture +PIXEndCapture = _PIXEndCapture +PIXGetCaptureState = _PIXGetCaptureState +SetAppCompatStringPointer = _SetAppCompatStringPointer +UpdateHMDEmulationStatus = _UpdateHMDEmulationStatus EXPORTS AppCacheCheckManifest = _AppCacheCheckManifest diff --git a/OptiScaler/exports/dxgi.h b/OptiScaler/exports/dxgi.h index 5ee3ac25..7313e1cb 100644 --- a/OptiScaler/exports/dxgi.h +++ b/OptiScaler/exports/dxgi.h @@ -9,152 +9,262 @@ struct dxgi_dll { HMODULE dll = nullptr; - FARPROC ApplyCompatResolutionQuirking = nullptr; - FARPROC CompatString = nullptr; - FARPROC CompatValue = nullptr; - FARPROC D3D10CreateDevice = nullptr; - FARPROC D3D10CreateLayeredDevice = nullptr; - FARPROC D3D10GetLayeredDeviceSize = nullptr; - FARPROC D3D10RegisterLayers = nullptr; - FARPROC D3D10ETWRundown = nullptr; - FARPROC DumpJournal = nullptr; - FARPROC ReportAdapterConfiguration = nullptr; - FARPROC PIXBeginCapture = nullptr; - FARPROC PIXEndCapture = nullptr; - FARPROC PIXGetCaptureState = nullptr; - FARPROC SetAppCompatStringPointer = nullptr; - FARPROC UpdateHMDEmulationStatus = nullptr; + using PFN_ApplyCompatResolutionQuirking = HRESULT(WINAPI*)(void* p1, void* p2); + using PFN_CompatString = BOOL(WINAPI*)(LPCSTR szName, ULONG* pSize, LPSTR lpData, bool flag); + using PFN_CompatValue = BOOL(WINAPI*)(LPCSTR szName, UINT64* pValue); + using PFN_DXGIDisableVBlankVirtualization = HRESULT(WINAPI*)(); + using PFN_DXGIDumpJournal = HRESULT(WINAPI*)(ULONG_PTR p1); + using PFN_DXGIReportAdapterConfiguration = HRESULT(WINAPI*)(ULONG_PTR p1); + using PFN_DXGID3D10CreateDevice = HRESULT(WINAPI*)(HMODULE hModule, IDXGIFactory* pFactory, IDXGIAdapter* pAdapter, + UINT flags, void* pUnknown, void** ppDevice); + using PFN_DXGID3D10CreateLayeredDevice = HRESULT(WINAPI*)(IDXGIAdapter* pAdapter, UINT flags, void* pUnknown, + REFIID riid, void** ppDevice); + using PFN_DXGID3D10GetLayeredDeviceSize = SIZE_T(WINAPI*)(const void* pLayers, UINT numLayers); + using PFN_DXGID3D10RegisterLayers = HRESULT(WINAPI*)(const void* pLayers, UINT numLayers); + using PFN_DXGID3D10ETWRundown = void(WINAPI*)(); + using PFN_PIXBeginCapture = HRESULT(WINAPI*)(DWORD captureFlags, const void* captureParameters); + using PFN_PIXEndCapture = HRESULT(WINAPI*)(BOOL discard); + using PFN_PIXGetCaptureState = DWORD(WINAPI*)(); + using PFN_SetAppCompatStringPointer = HRESULT(WINAPI*)(ULONG_PTR p1, ULONG_PTR p2); + using PFN_UpdateHMDEmulationStatus = HRESULT(WINAPI*)(ULONG_PTR p1); + + PFN_ApplyCompatResolutionQuirking ApplyCompatResolutionQuirking = nullptr; + PFN_CompatString CompatString = nullptr; + PFN_CompatValue CompatValue = nullptr; + + PFN_DXGID3D10CreateDevice D3D10CreateDevice = nullptr; + PFN_DXGID3D10CreateLayeredDevice D3D10CreateLayeredDevice = nullptr; + PFN_DXGID3D10GetLayeredDeviceSize D3D10GetLayeredDeviceSize = nullptr; + PFN_DXGID3D10RegisterLayers D3D10RegisterLayers = nullptr; + PFN_DXGID3D10ETWRundown D3D10ETWRundown = nullptr; + + PFN_DXGIDumpJournal DumpJournal = nullptr; + PFN_DXGIReportAdapterConfiguration ReportAdapterConfiguration = nullptr; + + PFN_PIXBeginCapture PIXBeginCapture = nullptr; + PFN_PIXEndCapture PIXEndCapture = nullptr; + PFN_PIXGetCaptureState PIXGetCaptureState = nullptr; + + PFN_SetAppCompatStringPointer SetAppCompatStringPointer = nullptr; + PFN_UpdateHMDEmulationStatus UpdateHMDEmulationStatus = nullptr; + + PFN_DXGIDisableVBlankVirtualization DisableVBlankVirtualization = nullptr; void LoadOriginalLibrary(HMODULE module) { dll = module; - ApplyCompatResolutionQuirking = KernelBaseProxy::GetProcAddress_()(module, "ApplyCompatResolutionQuirking"); - CompatString = KernelBaseProxy::GetProcAddress_()(module, "CompatString"); - CompatValue = KernelBaseProxy::GetProcAddress_()(module, "CompatValue"); - D3D10CreateDevice = KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10CreateDevice"); - D3D10CreateLayeredDevice = KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10CreateLayeredDevice"); - D3D10GetLayeredDeviceSize = KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10GetLayeredDeviceSize"); - D3D10RegisterLayers = KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10RegisterLayers"); - D3D10ETWRundown = KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10ETWRundown"); - DumpJournal = KernelBaseProxy::GetProcAddress_()(module, "DXGIDumpJournal"); - ReportAdapterConfiguration = KernelBaseProxy::GetProcAddress_()(module, "DXGIReportAdapterConfiguration"); - PIXBeginCapture = KernelBaseProxy::GetProcAddress_()(module, "PIXBeginCapture"); - PIXEndCapture = KernelBaseProxy::GetProcAddress_()(module, "PIXEndCapture"); - PIXGetCaptureState = KernelBaseProxy::GetProcAddress_()(module, "PIXGetCaptureState"); - SetAppCompatStringPointer = KernelBaseProxy::GetProcAddress_()(module, "SetAppCompatStringPointer"); - UpdateHMDEmulationStatus = KernelBaseProxy::GetProcAddress_()(module, "UpdateHMDEmulationStatus"); + ApplyCompatResolutionQuirking = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "ApplyCompatResolutionQuirking")); + CompatString = reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "CompatString")); + CompatValue = reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "CompatValue")); + D3D10CreateDevice = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10CreateDevice")); + D3D10CreateLayeredDevice = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10CreateLayeredDevice")); + D3D10GetLayeredDeviceSize = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10GetLayeredDeviceSize")); + D3D10RegisterLayers = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10RegisterLayers")); + D3D10ETWRundown = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGID3D10ETWRundown")); + DumpJournal = + reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "DXGIDumpJournal")); + ReportAdapterConfiguration = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGIReportAdapterConfiguration")); + PIXBeginCapture = + reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "PIXBeginCapture")); + PIXEndCapture = + reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "PIXEndCapture")); + PIXGetCaptureState = + reinterpret_cast(KernelBaseProxy::GetProcAddress_()(module, "PIXGetCaptureState")); + SetAppCompatStringPointer = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "SetAppCompatStringPointer")); + UpdateHMDEmulationStatus = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "UpdateHMDEmulationStatus")); + DisableVBlankVirtualization = reinterpret_cast( + KernelBaseProxy::GetProcAddress_()(module, "DXGIDisableVBlankVirtualization")); } } dxgi; -HRESULT _CreateDXGIFactory(REFIID riid, IDXGIFactory** ppFactory) +HRESULT WINAPI _CreateDXGIFactory(REFIID riid, IDXGIFactory** ppFactory) { return DxgiProxy::CreateDxgiFactory_()(riid, ppFactory); } -HRESULT _CreateDXGIFactory1(REFIID riid, IDXGIFactory1** ppFactory) +HRESULT WINAPI _CreateDXGIFactory1(REFIID riid, IDXGIFactory1** ppFactory) { return DxgiProxy::CreateDxgiFactory1_()(riid, ppFactory); } -HRESULT _CreateDXGIFactory2(UINT Flags, REFIID riid, IDXGIFactory2** ppFactory) +HRESULT WINAPI _CreateDXGIFactory2(UINT flags, REFIID riid, IDXGIFactory2** ppFactory) { - return DxgiProxy::CreateDxgiFactory2_Hooked()(Flags, riid, ppFactory); + return DxgiProxy::CreateDxgiFactory2_Hooked()(flags, riid, ppFactory); } -HRESULT _DXGIDeclareAdapterRemovalSupport() { return DxgiProxy::DeclareAdepterRemovalSupport_()(); } +HRESULT WINAPI _DXGIDeclareAdapterRemovalSupport() { return DxgiProxy::DeclareAdepterRemovalSupport_()(); } -HRESULT _DXGIGetDebugInterface1(UINT Flags, REFIID riid, void** pDebug) +HRESULT WINAPI _DXGIGetDebugInterface1(UINT flags, REFIID riid, void** pDebug) { - return DxgiProxy::GetDebugInterface_()(Flags, riid, pDebug); + return DxgiProxy::GetDebugInterface_()(flags, riid, pDebug); } -void _ApplyCompatResolutionQuirking() +HRESULT WINAPI _DXGIDisableVBlankVirtualization() { LOG_FUNC(); - dxgi.ApplyCompatResolutionQuirking(); + + if (dxgi.DisableVBlankVirtualization == nullptr) + return E_NOTIMPL; + + return dxgi.DisableVBlankVirtualization(); } -void _CompatString() +HRESULT WINAPI _ApplyCompatResolutionQuirking(void* p1, void* p2) { LOG_FUNC(); - dxgi.CompatString(); + + if (dxgi.ApplyCompatResolutionQuirking == nullptr) + return E_NOTIMPL; + + return dxgi.ApplyCompatResolutionQuirking(p1, p2); } -void _CompatValue() +BOOL WINAPI _CompatString(LPCSTR szName, ULONG* pSize, LPSTR lpData, bool flag) { LOG_FUNC(); - dxgi.CompatValue(); + + if (dxgi.CompatString == nullptr) + return FALSE; + + return dxgi.CompatString(szName, pSize, lpData, flag); } -void _DXGID3D10CreateDevice() +BOOL WINAPI _CompatValue(LPCSTR szName, UINT64* pValue) { LOG_FUNC(); - dxgi.D3D10CreateDevice(); + + if (dxgi.CompatValue == nullptr) + return FALSE; + + return dxgi.CompatValue(szName, pValue); } -void _DXGID3D10CreateLayeredDevice() +HRESULT WINAPI _DXGID3D10CreateDevice(HMODULE hModule, IDXGIFactory* pFactory, IDXGIAdapter* pAdapter, UINT flags, + void* pUnknown, void** ppDevice) { LOG_FUNC(); - dxgi.D3D10CreateLayeredDevice(); + + if (dxgi.D3D10CreateDevice == nullptr) + return E_NOTIMPL; + + return dxgi.D3D10CreateDevice(hModule, pFactory, pAdapter, flags, pUnknown, ppDevice); } -void _DXGID3D10GetLayeredDeviceSize() +HRESULT WINAPI _DXGID3D10CreateLayeredDevice(IDXGIAdapter* pAdapter, UINT flags, void* pUnknown, REFIID riid, + void** ppDevice) { LOG_FUNC(); - dxgi.D3D10GetLayeredDeviceSize(); + + if (dxgi.D3D10CreateLayeredDevice == nullptr) + return E_NOTIMPL; + + return dxgi.D3D10CreateLayeredDevice(pAdapter, flags, pUnknown, riid, ppDevice); } -void _DXGID3D10RegisterLayers() +SIZE_T WINAPI _DXGID3D10GetLayeredDeviceSize(const void* pLayers, UINT numLayers) { LOG_FUNC(); - dxgi.D3D10RegisterLayers(); + + if (dxgi.D3D10GetLayeredDeviceSize == nullptr) + return 0; + + return dxgi.D3D10GetLayeredDeviceSize(pLayers, numLayers); } -void _DXGID3D10ETWRundown() +HRESULT WINAPI _DXGID3D10RegisterLayers(const void* pLayers, UINT numLayers) { LOG_FUNC(); - dxgi.D3D10ETWRundown(); + + if (dxgi.D3D10RegisterLayers == nullptr) + return E_NOTIMPL; + + return dxgi.D3D10RegisterLayers(pLayers, numLayers); } -void _DXGIDumpJournal() +void WINAPI _DXGID3D10ETWRundown() { LOG_FUNC(); - dxgi.DumpJournal(); + + if (dxgi.D3D10ETWRundown != nullptr) + dxgi.D3D10ETWRundown(); } -void _DXGIReportAdapterConfiguration() +HRESULT WINAPI _DXGIDumpJournal(ULONG_PTR p1) { LOG_FUNC(); - dxgi.ReportAdapterConfiguration(); + + if (dxgi.DumpJournal == nullptr) + return E_NOTIMPL; + + return dxgi.DumpJournal(p1); } -void _PIXBeginCapture() +HRESULT WINAPI _DXGIReportAdapterConfiguration(ULONG_PTR p1) { LOG_FUNC(); - dxgi.PIXBeginCapture(); + + if (dxgi.ReportAdapterConfiguration == nullptr) + return E_NOTIMPL; + + return dxgi.ReportAdapterConfiguration(p1); } -void _PIXEndCapture() +HRESULT WINAPI _PIXBeginCapture(DWORD captureFlags, const void* captureParameters) { LOG_FUNC(); - dxgi.PIXEndCapture(); + + if (dxgi.PIXBeginCapture == nullptr) + return E_NOTIMPL; + + return dxgi.PIXBeginCapture(captureFlags, captureParameters); } -void _PIXGetCaptureState() +HRESULT WINAPI _PIXEndCapture(BOOL discard) { LOG_FUNC(); - dxgi.PIXGetCaptureState(); + + if (dxgi.PIXEndCapture == nullptr) + return E_NOTIMPL; + + return dxgi.PIXEndCapture(discard); } -void _SetAppCompatStringPointer() +DWORD WINAPI _PIXGetCaptureState() { LOG_FUNC(); - dxgi.SetAppCompatStringPointer(); + + if (dxgi.PIXGetCaptureState == nullptr) + return 0; + + return dxgi.PIXGetCaptureState(); } -void _UpdateHMDEmulationStatus() +HRESULT WINAPI _SetAppCompatStringPointer(ULONG_PTR p1, ULONG_PTR p2) { LOG_FUNC(); - dxgi.UpdateHMDEmulationStatus(); + + if (dxgi.SetAppCompatStringPointer == nullptr) + return E_NOTIMPL; + + return dxgi.SetAppCompatStringPointer(p1, p2); +} + +HRESULT WINAPI _UpdateHMDEmulationStatus(ULONG_PTR p1) +{ + LOG_FUNC(); + + if (dxgi.UpdateHMDEmulationStatus == nullptr) + return E_NOTIMPL; + + return dxgi.UpdateHMDEmulationStatus(p1); }