-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bug,补充单元测试,并解决WindowsCreateStringReference、WindowsCompareStringOrdi…
…nal单元测试不通过。 * Bug,解决内部函数MakeNtString字符串长度错误 * Opt, 将代码按YY-Thunks风格转换,并为release也开启asan
- Loading branch information
1 parent
c059451
commit b9d5bc7
Showing
7 changed files
with
570 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* PROJECT: YY-Thunks | ||
* FILE: hstring_private.h | ||
* PURPOSE: Extra definitions for the Windows Runtime String (HSTRING) | ||
* | ||
* LICENSE: The MIT License | ||
* | ||
* MAINTAINER: MouriNaruto ([email protected]) | ||
*/ | ||
#pragma once | ||
#include <hstring.h> | ||
|
||
#include "SharedDefs.h" | ||
|
||
/* | ||
* @remark The following definitions are dumped from the debug symbol from the | ||
* Windows 10 Build 14347's combase.dll. | ||
*/ | ||
namespace YY::Thunks::internal | ||
{ | ||
namespace | ||
{ | ||
/* | ||
* @brief The flags of the Windows Runtime String. | ||
* @remark Originally it's a C/C++ enum in the debug symbols. | ||
*/ | ||
enum class RuntimeStringFlags : UINT32 | ||
{ | ||
WRHF_NONE = 0x00000000, | ||
WRHF_STRING_REFERENCE = 0x00000001, | ||
WRHF_VALID_UNICODE_FORMAT_INFO = 0x00000002, | ||
WRHF_WELL_FORMED_UNICODE = 0x00000004, | ||
WRHF_HAS_EMBEDDED_NULLS = 0x00000008, | ||
WRHF_EMBEDDED_NULLS_COMPUTED = 0x00000010, | ||
WRHF_RESERVED_FOR_PREALLOCATED_STRING_BUFFER = 0x80000000, | ||
}; | ||
YY_APPLY_ENUM_CALSS_BIT_OPERATOR(RuntimeStringFlags) | ||
|
||
/* | ||
* @brief The internal structure of Windows Runtime String header. | ||
*/ | ||
typedef struct _HSTRING_HEADER_INTERNAL | ||
{ | ||
RuntimeStringFlags Flags; | ||
UINT32 Length; | ||
UINT32 Padding1; | ||
UINT32 Padding2; | ||
PCWSTR StringRef; | ||
} HSTRING_HEADER_INTERNAL, * PHSTRING_HEADER_INTERNAL; | ||
static_assert(sizeof(HSTRING_HEADER) == sizeof(HSTRING_HEADER_INTERNAL)); | ||
|
||
/* | ||
* @brief The internal structure of heap allocated Windows Runtime String. | ||
*/ | ||
typedef struct _STRING_OPAQUE | ||
{ | ||
HSTRING_HEADER_INTERNAL Header; | ||
volatile LONG RefCount; | ||
WCHAR String[ANYSIZE_ARRAY]; | ||
} STRING_OPAQUE, * PSTRING_OPAQUE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include <type_traits> | ||
|
||
#define YY_APPLY_ENUM_CALSS_BIT_OPERATOR(_ENUM) \ | ||
inline constexpr _ENUM& operator|=(_ENUM& _eLeft, _ENUM _eRight) \ | ||
{ \ | ||
using _Type = std::underlying_type<_ENUM>::type; \ | ||
(_Type&)_eLeft |= (_Type)_eRight; \ | ||
return _eLeft; \ | ||
} \ | ||
\ | ||
inline constexpr _ENUM operator|(_ENUM _eLeft, _ENUM _eRight) \ | ||
{ \ | ||
using _Type = std::underlying_type<_ENUM>::type; \ | ||
auto _Result = (_Type)_eLeft | (_Type)_eRight; \ | ||
return _ENUM(_Result); \ | ||
} \ | ||
\ | ||
inline constexpr _ENUM operator&(_ENUM _eLeft, _ENUM _eRight) \ | ||
{ \ | ||
using _Type = std::underlying_type<_ENUM>::type; \ | ||
return _ENUM((_Type)_eLeft & (_Type)_eRight); \ | ||
} \ | ||
\ | ||
inline constexpr _ENUM operator~(_ENUM _eLeft) \ | ||
{ \ | ||
using _Type = std::underlying_type<_ENUM>::type; \ | ||
return _ENUM(~(_Type)_eLeft); \ | ||
} \ | ||
\ | ||
inline constexpr bool HasFlags(_ENUM _eLeft, _ENUM _eRight) \ | ||
{ \ | ||
using _Type = std::underlying_type<_ENUM>::type; \ | ||
return (_Type)_eLeft & (_Type)_eRight; \ | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.