Skip to content

Commit d3431d9

Browse files
HIllya51mingkuang-Chuyu
authored andcommitted
Fea, 添加CreateRandomAccessStreamOverStream(PR #141)
1 parent b60aa50 commit d3431d9

File tree

2 files changed

+147
-112
lines changed

2 files changed

+147
-112
lines changed

ThunksList.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@
661661
| GetProcessDpiAwareness | 调用 IsProcessDPIAware。
662662
| SetProcessDpiAwareness | 调用SetProcessDPIAware。
663663
| SetProcessDPIAware | 直接返回 TRUE。
664+
| CreateRandomAccessStreamOverStream | 返回 E_NOTIMPL。
664665

665666
## shell32.dll
666667
| 函数 | Fallback

src/Thunks/shcore.hpp

Lines changed: 146 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,146 @@
1-
#if (YY_Thunks_Target < __WindowsNT6_3)
2-
#include <ShellScalingAPI.h>
3-
#endif
4-
5-
#if (YY_Thunks_Target < __WindowsNT6_3) && !defined(__Comment_Lib_user32)
6-
#define __Comment_Lib_user32
7-
#pragma comment(lib, "User32.lib")
8-
#endif
9-
10-
namespace YY::Thunks
11-
{
12-
#if (YY_Thunks_Target < __WindowsNT6_3)
13-
14-
//Windows 8.1 [desktop apps only]
15-
//Windows Server 2012 R2 [desktop apps only]
16-
__DEFINE_THUNK(
17-
shcore,
18-
16,
19-
HRESULT,
20-
STDAPICALLTYPE,
21-
GetDpiForMonitor,
22-
_In_ HMONITOR hmonitor,
23-
_In_ MONITOR_DPI_TYPE dpiType,
24-
_Out_ UINT* dpiX,
25-
_Out_ UINT* dpiY
26-
)
27-
{
28-
if (auto const pGetDpiForMonitor = try_get_GetDpiForMonitor())
29-
{
30-
return pGetDpiForMonitor(hmonitor, dpiType, dpiX, dpiY);
31-
}
32-
33-
if (dpiX == nullptr || dpiY == nullptr)
34-
{
35-
return __HRESULT_FROM_WIN32(ERROR_INVALID_ADDRESS);
36-
}
37-
38-
auto DpiForSystem = internal::GetDpiForSystemDownlevel();
39-
40-
*dpiX = DpiForSystem;
41-
*dpiY = DpiForSystem;
42-
43-
return S_OK;
44-
}
45-
#endif
46-
47-
48-
#if (YY_Thunks_Target < __WindowsNT6_3)
49-
50-
// Windows 8.1 [desktop apps only]
51-
// Windows Server 2012 R2 [desktop apps only]
52-
__DEFINE_THUNK(
53-
shcore,
54-
4,
55-
HRESULT,
56-
STDAPICALLTYPE,
57-
SetProcessDpiAwareness,
58-
_In_ PROCESS_DPI_AWARENESS _eValue
59-
)
60-
{
61-
if (auto const _pfnSetProcessDpiAwareness = try_get_SetProcessDpiAwareness())
62-
{
63-
return _pfnSetProcessDpiAwareness(_eValue);
64-
}
65-
66-
switch (_eValue)
67-
{
68-
case PROCESS_DPI_UNAWARE:
69-
return S_OK;
70-
case PROCESS_SYSTEM_DPI_AWARE:
71-
case PROCESS_PER_MONITOR_DPI_AWARE:
72-
return SetProcessDPIAware() ? S_OK : E_FAIL;
73-
default:
74-
return E_INVALIDARG;
75-
}
76-
}
77-
#endif
78-
79-
80-
#if (YY_Thunks_Target < __WindowsNT6_3)
81-
82-
// Windows 8.1 [desktop apps only]
83-
// Windows Server 2012 R2 [desktop apps only]
84-
__DEFINE_THUNK(
85-
shcore,
86-
8,
87-
HRESULT,
88-
STDAPICALLTYPE,
89-
GetProcessDpiAwareness,
90-
_In_ HANDLE _hProcess,
91-
_Out_ PROCESS_DPI_AWARENESS* _peValue
92-
)
93-
{
94-
if (auto const _pfnGetProcessDpiAwareness = try_get_GetProcessDpiAwareness())
95-
{
96-
return _pfnGetProcessDpiAwareness(_hProcess, _peValue);
97-
}
98-
99-
if (_hProcess == NULL || _hProcess == NtCurrentProcess()
100-
|| GetProcessId(_hProcess) == (ULONG)NtCurrentTeb()->ClientId.UniqueProcess)
101-
{
102-
*_peValue = IsProcessDPIAware() ? PROCESS_SYSTEM_DPI_AWARE : PROCESS_DPI_UNAWARE;
103-
}
104-
else
105-
{
106-
*_peValue = PROCESS_DPI_UNAWARE;
107-
}
108-
return S_OK;
109-
}
110-
#endif
111-
112-
} //namespace YY::Thunks
1+
#if (YY_Thunks_Target < __WindowsNT6_3)
2+
#include <ShellScalingAPI.h>
3+
#endif
4+
5+
#if (YY_Thunks_Target < __WindowsNT6_3) && !defined(__Comment_Lib_user32)
6+
#define __Comment_Lib_user32
7+
#pragma comment(lib, "User32.lib")
8+
#endif
9+
10+
#if (YY_Thunks_Target < __WindowsNT6_2)
11+
#include <shcore.h>
12+
#endif
13+
14+
namespace YY::Thunks
15+
{
16+
#if (YY_Thunks_Target < __WindowsNT6_3)
17+
18+
//Windows 8.1 [desktop apps only]
19+
//Windows Server 2012 R2 [desktop apps only]
20+
__DEFINE_THUNK(
21+
shcore,
22+
16,
23+
HRESULT,
24+
STDAPICALLTYPE,
25+
GetDpiForMonitor,
26+
_In_ HMONITOR hmonitor,
27+
_In_ MONITOR_DPI_TYPE dpiType,
28+
_Out_ UINT* dpiX,
29+
_Out_ UINT* dpiY
30+
)
31+
{
32+
if (auto const pGetDpiForMonitor = try_get_GetDpiForMonitor())
33+
{
34+
return pGetDpiForMonitor(hmonitor, dpiType, dpiX, dpiY);
35+
}
36+
37+
if (dpiX == nullptr || dpiY == nullptr)
38+
{
39+
return __HRESULT_FROM_WIN32(ERROR_INVALID_ADDRESS);
40+
}
41+
42+
auto DpiForSystem = internal::GetDpiForSystemDownlevel();
43+
44+
*dpiX = DpiForSystem;
45+
*dpiY = DpiForSystem;
46+
47+
return S_OK;
48+
}
49+
#endif
50+
51+
52+
#if (YY_Thunks_Target < __WindowsNT6_3)
53+
54+
// Windows 8.1 [desktop apps only]
55+
// Windows Server 2012 R2 [desktop apps only]
56+
__DEFINE_THUNK(
57+
shcore,
58+
4,
59+
HRESULT,
60+
STDAPICALLTYPE,
61+
SetProcessDpiAwareness,
62+
_In_ PROCESS_DPI_AWARENESS _eValue
63+
)
64+
{
65+
if (auto const _pfnSetProcessDpiAwareness = try_get_SetProcessDpiAwareness())
66+
{
67+
return _pfnSetProcessDpiAwareness(_eValue);
68+
}
69+
70+
switch (_eValue)
71+
{
72+
case PROCESS_DPI_UNAWARE:
73+
return S_OK;
74+
case PROCESS_SYSTEM_DPI_AWARE:
75+
case PROCESS_PER_MONITOR_DPI_AWARE:
76+
return SetProcessDPIAware() ? S_OK : E_FAIL;
77+
default:
78+
return E_INVALIDARG;
79+
}
80+
}
81+
#endif
82+
83+
84+
#if (YY_Thunks_Target < __WindowsNT6_3)
85+
86+
// Windows 8.1 [desktop apps only]
87+
// Windows Server 2012 R2 [desktop apps only]
88+
__DEFINE_THUNK(
89+
shcore,
90+
8,
91+
HRESULT,
92+
STDAPICALLTYPE,
93+
GetProcessDpiAwareness,
94+
_In_ HANDLE _hProcess,
95+
_Out_ PROCESS_DPI_AWARENESS* _peValue
96+
)
97+
{
98+
if (auto const _pfnGetProcessDpiAwareness = try_get_GetProcessDpiAwareness())
99+
{
100+
return _pfnGetProcessDpiAwareness(_hProcess, _peValue);
101+
}
102+
103+
if (_hProcess == NULL || _hProcess == NtCurrentProcess()
104+
|| GetProcessId(_hProcess) == (ULONG)NtCurrentTeb()->ClientId.UniqueProcess)
105+
{
106+
*_peValue = IsProcessDPIAware() ? PROCESS_SYSTEM_DPI_AWARE : PROCESS_DPI_UNAWARE;
107+
}
108+
else
109+
{
110+
*_peValue = PROCESS_DPI_UNAWARE;
111+
}
112+
return S_OK;
113+
}
114+
#endif
115+
116+
117+
#if (YY_Thunks_Target < __WindowsNT6_2)
118+
119+
// 最低受支持的客户端 Windows 8 [桌面应用 |UWP 应用]
120+
// 最低受支持的服务器 Windows Server 2012[桌面应用 | UWP 应用]
121+
__DEFINE_THUNK(
122+
shcore,
123+
16,
124+
HRESULT,
125+
STDAPICALLTYPE,
126+
CreateRandomAccessStreamOverStream,
127+
_In_ IStream* _pStream,
128+
_In_ BSOS_OPTIONS _eOptions,
129+
_In_ REFIID _riid,
130+
_COM_Outptr_ void** _ppv
131+
)
132+
{
133+
if (auto const _pfnCreateRandomAccessStreamOverStream = try_get_CreateRandomAccessStreamOverStream())
134+
{
135+
return _pfnCreateRandomAccessStreamOverStream(_pStream, _eOptions, _riid, _ppv);
136+
}
137+
138+
if (!_ppv)
139+
return E_POINTER;
140+
141+
*_ppv = nullptr;
142+
return E_NOTIMPL;
143+
}
144+
#endif
145+
146+
} //namespace YY::Thunks

0 commit comments

Comments
 (0)