Skip to content

Commit

Permalink
Fea Chuyu-Team#29, 消除Chrome中Win7不支持的API
Browse files Browse the repository at this point in the history
* EventSetInformation
* BluetoothGATTGetCharacteristicValue
* BluetoothGATTGetCharacteristics
* BluetoothGATTGetDescriptors
* BluetoothGATTGetServices
* BluetoothGATTRegisterEvent
* BluetoothGATTSetCharacteristicValue
* BluetoothGATTSetDescriptorValue
* MFCreateDXGIDeviceManager
* MFCreateDXGISurfaceBuffer
* MFLockDXGIDeviceManager
* MFUnlockDXGIDeviceManager
* NetGetAadJoinInformation
* NetFreeAadJoinInformation
  • Loading branch information
mingkuang-Chuyu committed Mar 12, 2023
1 parent 0241e2b commit 6b04220
Show file tree
Hide file tree
Showing 9 changed files with 632 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
| RegDeleteTreeW(A) | 调用SHDeleteKeyW(A)。
| RegGetValueW(A) | 不存在时,调用RegQueryValueExW(A)。
| RegCopyTreeW(A) | 不存在时,调用SHCopyKeyW(A)。
| EventSetInformation | 不存在时,返回ERROR_NOT_SUPPORTED。

## bcrypt.dll
| 函数 | Fallback
Expand All @@ -79,6 +80,17 @@
| BCryptCloseAlgorithmProvider | 内部实现。
| BCryptGenRandom | 不存在时调用,RtlGenRandom。

## bluetoothapis.dll
| 函数 | Fallback
| ---- | -----------
| BluetoothGATTGetCharacteristicValue | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTGetCharacteristics | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTGetDescriptors | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTGetServices | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTRegisterEvent | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTSetCharacteristicValue | 不存在时,返回ERROR_NOT_SUPPORTED。
| BluetoothGATTSetDescriptorValue | 不存在时,返回ERROR_NOT_SUPPORTED。

## iphlpapi.dll
| 函数 | Fallback
| ---- | -----------
Expand Down Expand Up @@ -263,6 +275,20 @@
| ReclaimVirtualMemory | 不存在时,返回ERROR_SUCCESS。
| PrefetchVirtualMemory | 不存在时,返回ERROR_SUCCESS。

## mfplat.dll
| 函数 | Fallback
| ---- | -----------
| MFCreateDXGIDeviceManager | 不存在时,返回E_NOTIMPL。
| MFCreateDXGISurfaceBuffer | 不存在时,返回E_NOTIMPL。
| MFLockDXGIDeviceManager | 不存在时,返回E_NOTIMPL。
| MFUnlockDXGIDeviceManager | 不存在时,返回E_NOTIMPL。

## netapi32.dll
| 函数 | Fallback
| ---- | -----------
| NetGetAadJoinInformation | 不存在时,始终认为没有加入 Azure AD 帐户 账号。
| NetFreeAadJoinInformation | 不存在时,什么也不做。

## ole32.dll
| 函数 | Fallback
| ---- | -----------
Expand Down Expand Up @@ -329,6 +355,15 @@
| AdjustWindowRectExForDpi | 不存在时,调用AdjustWindowRectEx。
| SystemParametersInfoForDpi | 不存在时,调用SystemParametersInfoW。

## userenv.dll
| 函数 | Fallback
| ---- | -----------
| CreateAppContainerProfile | 不存在时,返回E_NOTIMPL。
| DeleteAppContainerProfile | 不存在时,返回E_NOTIMPL。
| DeriveAppContainerSidFromAppContainerName | 不存在时,返回E_NOTIMPL。
| GetAppContainerFolderPath | 不存在时,返回E_NOTIMPL。
| GetAppContainerRegistryLocation | 不存在时,返回E_NOTIMPL。

## version.dll
| 函数 | Fallback
| ---- | -----------
Expand Down
4 changes: 4 additions & 0 deletions src/Thunks/YY_Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
_APPLY(setupapi, "setupapi" , 0 ) \
_APPLY(ole32, "ole32" , 0 ) \
_APPLY(iphlpapi, "iphlpapi" , 0 ) \
_APPLY(userenv, "userenv" , 0 ) \
_APPLY(mfplat, "mfplat" , 0 ) \
_APPLY(bluetoothapis, "bluetoothapis" , 0 ) \
_APPLY(netapi32, "netapi32" , 0 ) \
_APPLY(api_ms_win_core_winrt_l1_1_0, "api-ms-win-core-winrt-l1-1-0" , 0 ) \
_APPLY(api_ms_win_core_winrt_string_l1_1_0, "api-ms-win-core-winrt-string-l1-1-0", 0 ) \
_APPLY(api_ms_win_core_winrt_error_l1_1_0, "api-ms-win-core-winrt-error-l1-1-0" , 0 ) \
Expand Down
35 changes: 35 additions & 0 deletions src/Thunks/api-ms-win-eventing-provider.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if (YY_Thunks_Support_Version < NTDDI_WIN8)
#include <evntprov.h>
#endif

namespace YY
{
namespace Thunks
{

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8 [桌面应用|UWP 应用]
// 最低受支持的服务器 Windows Server 2012[桌面应用 | UWP 应用]
__DEFINE_THUNK(
advapi32,
20,
ULONG,
__stdcall,
EventSetInformation,
_In_ REGHANDLE _hRegHandle,
_In_ EVENT_INFO_CLASS _eInformationClass,
_In_reads_bytes_(_cbInformationLength) PVOID _pEventInformation,
_In_ ULONG _cbInformationLength
)
{
if (auto const _pfnEventSetInformation = try_get_EventSetInformation())
{
return _pfnEventSetInformation(_hRegHandle, _eInformationClass, _pEventInformation, _cbInformationLength);
}

return ERROR_NOT_SUPPORTED;
}
#endif
}
}
225 changes: 225 additions & 0 deletions src/Thunks/bluetoothapis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
#if (YY_Thunks_Support_Version < NTDDI_WIN8)
#include <bluetoothleapis.h>
#endif

namespace YY
{
namespace Thunks
{
#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
24,
HRESULT,
WINAPI,
BluetoothGATTGetCharacteristicValue,
_In_ HANDLE _hDevice,
_In_ PBTH_LE_GATT_CHARACTERISTIC _pCharacteristic,
_In_ ULONG _cbCharacteristicValueDataSize,
_Out_opt_ PBTH_LE_GATT_CHARACTERISTIC_VALUE _pCharacteristicValue,
_Out_opt_ USHORT* _pCharacteristicValueSizeRequired,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTGetCharacteristicValue = try_get_BluetoothGATTGetCharacteristicValue())
{
return _pfnBluetoothGATTGetCharacteristicValue(_hDevice, _pCharacteristic, _cbCharacteristicValueDataSize, _pCharacteristicValue, _pCharacteristicValueSizeRequired, _fFlags);
}

if (_pCharacteristicValueSizeRequired)
*_pCharacteristicValueSizeRequired = 0;

if (_pCharacteristicValue && _cbCharacteristicValueDataSize >= sizeof(DWORD))
_pCharacteristicValue->DataSize = 0;

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
24,
HRESULT,
WINAPI,
BluetoothGATTGetCharacteristics,
_In_ HANDLE _hDevice,
_In_opt_ PBTH_LE_GATT_SERVICE _pService,
_In_ USHORT _uCharacteristicsBufferCount,
_Out_writes_to_opt_(_uCharacteristicsBufferCount, *_puCharacteristicsBufferActual) PBTH_LE_GATT_CHARACTERISTIC _pCharacteristicsBuffer,
_Out_ USHORT* _puCharacteristicsBufferActual,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTGetCharacteristics = try_get_BluetoothGATTGetCharacteristics())
{
return _pfnBluetoothGATTGetCharacteristics(_hDevice, _pService, _uCharacteristicsBufferCount, _pCharacteristicsBuffer, _puCharacteristicsBufferActual, _fFlags);
}

if (_puCharacteristicsBufferActual)
*_puCharacteristicsBufferActual = 0;

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
24,
HRESULT,
WINAPI,
BluetoothGATTGetDescriptors,
_In_ HANDLE _hDevice,
_In_ PBTH_LE_GATT_CHARACTERISTIC _pCharacteristic,
_In_ USHORT _uDescriptorsBufferCount,
_Out_writes_to_opt_(_uDescriptorsBufferCount, *_puDescriptorsBufferActual) PBTH_LE_GATT_DESCRIPTOR _pDescriptorsBuffer,
_Out_ USHORT* _puDescriptorsBufferActual,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTGetDescriptors = try_get_BluetoothGATTGetDescriptors())
{
return _pfnBluetoothGATTGetDescriptors(_hDevice, _pCharacteristic, _uDescriptorsBufferCount, _pDescriptorsBuffer, _puDescriptorsBufferActual, _fFlags);
}

if (_puDescriptorsBufferActual)
*_puDescriptorsBufferActual = 0;

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
20,
HRESULT,
WINAPI,
BluetoothGATTGetServices,
_In_ HANDLE _hDevice,
_In_ USHORT _uServicesBufferCount,
_Out_writes_to_opt_(_uServicesBufferCount, *_puServicesBufferActual) PBTH_LE_GATT_SERVICE _pServicesBuffer,
_Out_ USHORT* _puServicesBufferActual,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTGetServices = try_get_BluetoothGATTGetServices())
{
return _pfnBluetoothGATTGetServices(_hDevice, _uServicesBufferCount, _pServicesBuffer, _puServicesBufferActual, _fFlags);
}

if (_puServicesBufferActual)
*_puServicesBufferActual = 0;

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
28,
HRESULT,
WINAPI,
BluetoothGATTRegisterEvent,
_In_ HANDLE _hService,
_In_ BTH_LE_GATT_EVENT_TYPE _eEventType,
_In_ PVOID _pEventParameterIn,
_In_ PFNBLUETOOTH_GATT_EVENT_CALLBACK _pfnCallback,
_In_opt_ PVOID _pCallbackContext,
_Out_ BLUETOOTH_GATT_EVENT_HANDLE * _pEventHandle,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTRegisterEvent = try_get_BluetoothGATTRegisterEvent())
{
return _pfnBluetoothGATTRegisterEvent(_hService, _eEventType, _pEventParameterIn, _pfnCallback, _pCallbackContext, _pEventHandle, _fFlags);
}

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
24,
HRESULT,
WINAPI,
BluetoothGATTSetCharacteristicValue,
_In_ HANDLE _hDevice,
_In_ PBTH_LE_GATT_CHARACTERISTIC _pCharacteristic,
_In_ PBTH_LE_GATT_CHARACTERISTIC_VALUE _pCharacteristicValue,
_In_opt_ BTH_LE_GATT_RELIABLE_WRITE_CONTEXT _ReliableWriteContext,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTSetCharacteristicValue = try_get_BluetoothGATTSetCharacteristicValue())
{
return _pfnBluetoothGATTSetCharacteristicValue(_hDevice, _pCharacteristic, _pCharacteristicValue, _ReliableWriteContext, _fFlags);
}

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
16,
HRESULT,
WINAPI,
BluetoothGATTSetDescriptorValue,
_In_ HANDLE _hDevice,
_In_ PBTH_LE_GATT_DESCRIPTOR _pDescriptor,
_In_ PBTH_LE_GATT_DESCRIPTOR_VALUE _pDescriptorValue,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTSetDescriptorValue = try_get_BluetoothGATTSetDescriptorValue())
{
return _pfnBluetoothGATTSetDescriptorValue(_hDevice, _pDescriptor, _pDescriptorValue, _fFlags);
}

return ERROR_NOT_SUPPORTED;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

// 最低受支持的客户端 Windows 8及更高版本的 Windows 中受支持。
__DEFINE_THUNK(
bluetoothapis,
8,
HRESULT,
WINAPI,
BluetoothGATTUnregisterEvent,
_In_ BLUETOOTH_GATT_EVENT_HANDLE _hEventHandle,
_In_ ULONG _fFlags
)
{
if (const auto _pfnBluetoothGATTUnregisterEvent = try_get_BluetoothGATTUnregisterEvent())
{
return _pfnBluetoothGATTUnregisterEvent(_hEventHandle, _fFlags);
}

return ERROR_NOT_SUPPORTED;
}
#endif
}
}
Loading

0 comments on commit 6b04220

Please sign in to comment.