Skip to content

Commit 33a488a

Browse files
Fea #138, 添加CreateFile3
1 parent 80886b5 commit 33a488a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

ThunksList.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010
| WriteFile | 允许_puNumberOfBytesWritten、_pOverlapped同时为nullptr。
1111
| ReadFile | 允许_puNumberOfBytesRead、_pOverlapped同时为nullptr。
1212

13+
## api-ms-win-core-file-l1-2-5.dll
14+
| 函数 | Fallback
15+
| ---- | -----------
16+
| CreateFile3 | 调用CreateFile2。
17+
1318
## api-ms-win-core-file-l2-1-0.dll
1419
| 函数 | Fallback
1520
| ---- | -----------
1621
| CopyFile2 | 调用CopyFileExW。
1722

23+
1824
## api-ms-win-core-handle-l1-1-0.dll
1925
| 函数 | Fallback
2026
| ---- | -----------

src/Shared/SharedDefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
// Windows Server 2022(FE)
9898
#define __WindowsNT10_20348 __Version(10, 0, 20348, 0)
9999

100+
// Windows 11 24H2、Windows Server 2025
101+
#define __WindowsNT10_26100 __Version(10, 0, 26100, 0)
102+
100103
#if defined(_M_IX86)
101104
#define __WindowsMinTarget __WindowsNT5
102105
#elif defined(_M_AMD64)

src/Thunks/api-ms-win-core-file.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,41 @@ namespace YY::Thunks
10141014
#endif
10151015

10161016

1017+
#if (YY_Thunks_Target < __WindowsNT10_26100)
1018+
1019+
// 最低支持的客户端 Windows 11 24H2 [桌面应用 |UWP 应用]
1020+
// 支持的最低服务器 Windows Server 2025[桌面应用 | UWP 应用]
1021+
__DEFINE_THUNK(
1022+
kernel32,
1023+
20,
1024+
HANDLE,
1025+
WINAPI,
1026+
CreateFile3,
1027+
_In_z_ LPCWSTR _szFileName,
1028+
_In_ DWORD _uDesiredAccess,
1029+
_In_ DWORD _uShareMode,
1030+
_In_ DWORD _uCreationDisposition,
1031+
_In_opt_ LPCREATEFILE3_EXTENDED_PARAMETERS _pCreateExParams
1032+
)
1033+
{
1034+
if (const auto _pfnCreateFile3 = try_get_CreateFile3())
1035+
{
1036+
return _pfnCreateFile3(_szFileName, _uDesiredAccess, _uShareMode, _uCreationDisposition, _pCreateExParams);
1037+
}
1038+
1039+
static_assert(sizeof(CREATEFILE3_EXTENDED_PARAMETERS) == sizeof(CREATEFILE2_EXTENDED_PARAMETERS), "");
1040+
static_assert(UFIELD_OFFSET (CREATEFILE3_EXTENDED_PARAMETERS, dwSize) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, dwSize), "");
1041+
static_assert(UFIELD_OFFSET (CREATEFILE3_EXTENDED_PARAMETERS, dwFileAttributes) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, dwFileAttributes), "");
1042+
static_assert(UFIELD_OFFSET(CREATEFILE3_EXTENDED_PARAMETERS, dwFileFlags) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, dwFileFlags), "");
1043+
static_assert(UFIELD_OFFSET(CREATEFILE3_EXTENDED_PARAMETERS, dwSecurityQosFlags) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, dwSecurityQosFlags), "");
1044+
static_assert(UFIELD_OFFSET(CREATEFILE3_EXTENDED_PARAMETERS, lpSecurityAttributes) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, lpSecurityAttributes), "");
1045+
static_assert(UFIELD_OFFSET(CREATEFILE3_EXTENDED_PARAMETERS, hTemplateFile) == UFIELD_OFFSET(CREATEFILE2_EXTENDED_PARAMETERS, hTemplateFile), "");
1046+
1047+
return CreateFile2(_szFileName, _uDesiredAccess, _uShareMode, _uCreationDisposition, reinterpret_cast<LPCREATEFILE2_EXTENDED_PARAMETERS>(_pCreateExParams));
1048+
}
1049+
#endif
1050+
1051+
10171052
#if (YY_Thunks_Target < __WindowsNT6)
10181053

10191054
//Windows Vista [desktop apps only]

0 commit comments

Comments
 (0)