-
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.
Fea #94, 为Windows Runtime String (HSTRING)提供内部实现 - 补充 WindowsCreateString - 补充 WindowsCreateStringReference - 补充 WindowsDeleteString - 补充 WindowsDuplicateString - 补充 WindowsGetStringLen - 补充 WindowsGetStringRawBuffer - 补充 WindowsIsStringEmpty - 补充 WindowsStringHasEmbeddedNull - 补充 WindowsCompareStringOrdinal
- Loading branch information
1 parent
bee5f7c
commit 8cca78f
Showing
8 changed files
with
810 additions
and
181 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
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 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.