Skip to content

Commit

Permalink
临时提交,稍后与之前的合并
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Oct 18, 2024
1 parent 0e1358a commit d058565
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Thunks/WS2_32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,11 +1463,11 @@ namespace YY::Thunks
}
#endif


#if (YY_Thunks_Target < __WindowsNT6_1_SP1)
#ifndef WSA_FLAG_NO_HANDLE_INHERIT
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
#endif

// Windows XP
// 虽然Windows XP支持这个API,但是Windows 7 SP1开始才支持 WSA_FLAG_NO_HANDLE_INHERIT 标记
__DEFINE_THUNK(
ws2_32,
24,
Expand Down
14 changes: 9 additions & 5 deletions src/Thunks/YY_Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,23 +292,27 @@ namespace YY::Thunks::internal
#endif
}

__forceinline constexpr DWORD __fastcall MakeVersion(_In_ DWORD _uMajorVersion, _In_ DWORD _uMinorVersion)
__forceinline constexpr uint64_t __fastcall MakeVersion(_In_ uint16_t _uMajor, _In_ uint16_t _uMinor, uint16_t _uBuild = 0, UINT16 _uRevision = 0)
{
return (_uMajorVersion << 16) | _uMinorVersion;
uint64_t _uVersion = uint64_t(_uMajor) << 48;
_uVersion |= uint64_t(_uMinor) << 32;
_uVersion |= uint64_t(_uBuild) << 16;
_uVersion |= _uRevision;
return _uVersion;
}

#ifdef __YY_Thunks_Unit_Test
EXTERN_C DWORD g_uSystemVersion = 0;
EXTERN_C uint64_t g_uSystemVersion = 0;
#endif

__forceinline DWORD __fastcall GetSystemVersion()
__forceinline uint64_t __fastcall GetSystemVersion()
{
#ifdef __YY_Thunks_Unit_Test
if (g_uSystemVersion)
return g_uSystemVersion;
#endif
const auto _pPeb = ((TEB*)NtCurrentTeb())->ProcessEnvironmentBlock;
return internal::MakeVersion(_pPeb->OSMajorVersion, _pPeb->OSMinorVersion);
return internal::MakeVersion(_pPeb->OSMajorVersion, _pPeb->OSMinorVersion,);
}

const SYSTEM_INFO& GetNativeSystemInfo()
Expand Down

0 comments on commit d058565

Please sign in to comment.