Skip to content

Commit

Permalink
Fea #71, 添加一些QT缺失的接口
Browse files Browse the repository at this point in the history
  - 添加 CreateDXGIFactory2
  - 添加 InitializeTouchInjection
  - 添加 InjectTouchInput
  - 添加 GetCurrentPackageFullName
  - 添加 GetProcessDpiAwareness
  - 添加 GetAwarenessFromDpiAwarenessContext
  - 添加 AreDpiAwarenessContextsEqual
  - 添加 EnableNonClientDpiScaling
  • Loading branch information
BH2WFR authored and mingkuang committed Aug 28, 2024
1 parent ac63103 commit 563b0b4
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 31 deletions.
12 changes: 10 additions & 2 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@
## dxgi.dll
| 函数 | Fallback
| ---- | -----------
| CreateDXGIFactory1 | 不存在时,返回 `DXGI_ERROR_UNSUPPORTED`
| CreateDXGIFactory | 不存在时,返回 `DXGI_ERROR_UNSUPPORTED`
| CreateDXGIFactory | 返回 `DXGI_ERROR_UNSUPPORTED`
| CreateDXGIFactory1 | 调用 CreateDXGIFactory。
| CreateDXGIFactory2 | 调用 CreateDXGIFactory1。

## dxva2.dll
| 函数 | Fallback
Expand Down Expand Up @@ -540,6 +541,7 @@
| WerUnregisterRuntimeExceptionModule | 不存在时,返回S_OK。
| Wow64GetThreadContext | 不存在时,调用GetThreadContext或者返回ERROR_INVALID_PARAMETER。
| SetDefaultDllDirectories | 不存在时,手工控制LoadLibrary加载顺序。
| GetCurrentPackageFullName | 返回 APPMODEL_ERROR_NO_PACKAGE。

## mfplat.dll
| 函数 | Fallback
Expand Down Expand Up @@ -647,6 +649,7 @@
| 函数 | Fallback
| ---- | -----------
| GetDpiForMonitor | 不存在时,调用GetDeviceCaps。
| GetProcessDpiAwareness | 调用 IsProcessDPIAware。
| SetProcessDpiAwareness | 不存在时,调用SetProcessDPIAware。
| SetProcessDPIAware | 不存在时,直接返回 TRUE。

Expand Down Expand Up @@ -725,6 +728,11 @@
| GetPointerDevice | 不存在时,假装没有触摸设备。
| GetPointerPenInfo | 不存在时,假装没有触摸设备。
| GetPointerType | 不存在时,假装没有触摸设备。
| InitializeTouchInjection | 报告错误 ERROR_INVALID_PARAMETER。
| InjectTouchInput | 报告错误 ERROR_INVALID_PARAMETER。
| GetAwarenessFromDpiAwarenessContext | 内部实现。
| AreDpiAwarenessContextsEqual | 内部实现。
| EnableNonClientDpiScaling | 假装成功。

## userenv.dll
| 函数 | Fallback
Expand Down
68 changes: 49 additions & 19 deletions src/Thunks/dxgi.hpp
Original file line number Diff line number Diff line change
@@ -1,55 +1,85 @@
#if (YY_Thunks_Target < __WindowsNT6_SP2)
#include <dxgi.h>
#if (YY_Thunks_Target < __WindowsNT6_3)
#include <dxgi1_3.h>
#endif

#if (YY_Thunks_Target < __WindowsNT6_3) && !defined(__Comment_Lib_dxgi)
#define __Comment_Lib_dxgi
#pragma comment(lib, "DXGI.lib")
#endif

namespace YY::Thunks
{
#if (YY_Thunks_Target < __WindowsNT6)

// Minimum supported client Windows Vista
// Minimum supported server Windows Server 2008
__DEFINE_THUNK(
dxgi,
8,
HRESULT,
STDAPICALLTYPE,
CreateDXGIFactory,
REFIID _IID,
_COM_Outptr_ void** _ppFactory
)
{
if (auto const _pfnCreateDXGIFactory = try_get_CreateDXGIFactory())
{
return _pfnCreateDXGIFactory(_IID, _ppFactory);
}

if (_ppFactory)
*_ppFactory = nullptr;
return DXGI_ERROR_UNSUPPORTED;
}
#endif


#if (YY_Thunks_Target < __WindowsNT6_SP2)

// 最低受支持的客户端 Windows 7 [桌面应用 |UWP 应用]
// 最低受支持的服务器 Windows Server 2008 R2[桌面应用 | UWP 应用]
__DEFINE_THUNK(
dxgi,
8,
HRESULT,
WINAPI,
CreateDXGIFactory1,
REFIID riid,
REFIID _IID,
_COM_Outptr_ void ** _ppFactory
)
{
if (const auto _pfnCreateDXGIFactory1 = try_get_CreateDXGIFactory1())
{
return _pfnCreateDXGIFactory1(riid, _ppFactory);
return _pfnCreateDXGIFactory1(_IID, _ppFactory);
}

if (_ppFactory)
*_ppFactory = nullptr;
return DXGI_ERROR_UNSUPPORTED;
return CreateDXGIFactory(_IID, _ppFactory);
}
#endif


#if (YY_Thunks_Target < __WindowsNT6)
#if (YY_Thunks_Target < __WindowsNT6_3)

// Minimum supported client Windows Vista
// Minimum supported server Windows Server 2008
// Minimum supported client Windows 8.1
// Minimum supported server Windows Server 2012 R2
__DEFINE_THUNK(
dxgi,
8,
12,
HRESULT,
STDAPICALLTYPE,
CreateDXGIFactory,
REFIID riid,
CreateDXGIFactory2,
UINT _fFlags,
REFIID _IID,
_COM_Outptr_ void** _ppFactory
)
{
if (auto const _pfnCreateDXGIFactory = try_get_CreateDXGIFactory())
if (auto const _pfnCreateDXGIFactory2 = try_get_CreateDXGIFactory2())
{
return _pfnCreateDXGIFactory(riid, _ppFactory);
return _pfnCreateDXGIFactory2(_fFlags, _IID, _ppFactory);
}

if (_ppFactory)
*_ppFactory = nullptr;
return DXGI_ERROR_UNSUPPORTED;

return CreateDXGIFactory1(_IID, _ppFactory);
}
#endif
}
50 changes: 50 additions & 0 deletions src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,54 @@
return FALSE;
}
#endif


#if (YY_Thunks_Target < __WindowsNT6_2)

// 最低受支持的客户端 Windows 8 [仅限桌面应用]
// 最低受支持的服务器 Windows Server 2012 [仅限桌面应用]
__DEFINE_THUNK(
user32,
8,
BOOL,
WINAPI,
InitializeTouchInjection,
_In_ UINT32 _uMaxCount,
_In_ DWORD _udwMode
)
{
if (const auto _pfnInitializeTouchInjection = try_get_InitializeTouchInjection())
{
return _pfnInitializeTouchInjection(_uMaxCount, _udwMode);
}

SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
#endif


#if (YY_Thunks_Target < __WindowsNT6_2)

// 最低受支持的客户端 Windows 8 [仅限桌面应用]
// 最低受支持的服务器 Windows Server 2012 [仅限桌面应用]
__DEFINE_THUNK(
user32,
8,
BOOL,
WINAPI,
InjectTouchInput,
_In_ UINT32 _cCount,
_In_ const POINTER_TOUCH_INFO* _pContacts
)
{
if (const auto _pfnInjectTouchInput = try_get_InjectTouchInput())
{
return _pfnInjectTouchInput(_cCount, _pContacts);
}

SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
#endif
}
28 changes: 27 additions & 1 deletion src/Thunks/kernel32.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

#if (YY_Thunks_Target < __WindowsNT6_2)
#include <appmodel.h>
#endif

namespace YY::Thunks
{
Expand Down Expand Up @@ -502,4 +504,28 @@ namespace YY::Thunks
return DEP_SYSTEM_POLICY_TYPE::DEPPolicyAlwaysOff;
}
#endif // (YY_Thunks_Target < __WindowsNT6_SP1)


#if (YY_Thunks_Target < __WindowsNT6_2)

// 最低受支持的客户端 Windows 8 [仅限桌面应用]
// 最低受支持的服务器 Windows Server 2012 [仅限桌面应用]
__DEFINE_THUNK(
kernel32,
8,
LONG,
WINAPI,
GetCurrentPackageFullName,
_Inout_ UINT32* _pcPackageFullNameLength,
_Out_writes_opt_(*_pcPackageFullNameLength) PWSTR _szPackageFullName
)
{
if (const auto _pfnGetCurrentPackageFullName = try_get_GetCurrentPackageFullName())
{
return _pfnGetCurrentPackageFullName(_pcPackageFullNameLength, _szPackageFullName);
}

return APPMODEL_ERROR_NO_PACKAGE;
}
#endif // (YY_Thunks_Target < __WindowsNT6_2)
}
50 changes: 44 additions & 6 deletions src/Thunks/shcore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,66 @@ namespace YY::Thunks

#if (YY_Thunks_Target < __WindowsNT6_3)

//Windows 8.1 [desktop apps only]
//Windows Server 2012 R2 [desktop apps only]
// Windows 8.1 [desktop apps only]
// Windows Server 2012 R2 [desktop apps only]
__DEFINE_THUNK(
shcore,
4,
HRESULT,
STDAPICALLTYPE,
SetProcessDpiAwareness,
_In_ PROCESS_DPI_AWARENESS value
_In_ PROCESS_DPI_AWARENESS _eValue
)
{
if (auto const pSetProcessDpiAwareness = try_get_SetProcessDpiAwareness())
if (auto const _pfnSetProcessDpiAwareness = try_get_SetProcessDpiAwareness())
{
return pSetProcessDpiAwareness(value);
return _pfnSetProcessDpiAwareness(_eValue);
}

if (value != PROCESS_DPI_UNAWARE)
switch (_eValue)
{
case PROCESS_DPI_UNAWARE:
return S_OK;
case PROCESS_SYSTEM_DPI_AWARE:
case PROCESS_PER_MONITOR_DPI_AWARE:
return SetProcessDPIAware() ? S_OK : E_FAIL;
default:
return E_INVALIDARG;
}
}
#endif


#if (YY_Thunks_Target < __WindowsNT6_3)

// Windows 8.1 [desktop apps only]
// Windows Server 2012 R2 [desktop apps only]
__DEFINE_THUNK(
shcore,
8,
HRESULT,
STDAPICALLTYPE,
GetProcessDpiAwareness,
_In_ HANDLE _hProcess,
_Out_ PROCESS_DPI_AWARENESS* _peValue
)
{
if (auto const _pfnGetProcessDpiAwareness = try_get_GetProcessDpiAwareness())
{
return _pfnGetProcessDpiAwareness(_hProcess, _peValue);
}

if (_hProcess == NULL || _hProcess == NtCurrentProcess()
|| GetProcessId(_hProcess) == (ULONG)NtCurrentTeb()->ClientId.UniqueProcess)
{
*_peValue = IsProcessDPIAware() ? PROCESS_SYSTEM_DPI_AWARE : PROCESS_DPI_UNAWARE;
}
else
{
*_peValue = PROCESS_DPI_UNAWARE;
}
return S_OK;
}
#endif

} //namespace YY::Thunks
Loading

0 comments on commit 563b0b4

Please sign in to comment.