23 inline bool Write(
void* in_pAddress,
const T& in_rData, size_t in_count)
28 uint32_t oldProtectionFlags{};
30 ASSERT_RETURN_FALSE(Protect(in_pAddress,
sizeof(in_rData), GetProtectionFlags(PageProtection::RW), &oldProtectionFlags));
32 for (size_t i = 0; i < in_count; i++)
33 ((T*)in_pAddress)[i] = in_rData;
35 ASSERT_RETURN_FALSE(Protect(in_pAddress,
sizeof(in_rData), oldProtectionFlags));
41 inline bool Write(
void* in_pAddress,
const std::vector<T>& in_rData)
46 const auto length =
sizeof(T) * in_rData.size();
48 uint32_t oldProtectionFlags{};
50 ASSERT_RETURN_FALSE(Protect(in_pAddress, length, GetProtectionFlags(PageProtection::RW), &oldProtectionFlags));
51 ASSERT_RETURN_FALSE(memcpy_s(in_pAddress, length, in_rData.data(), length) == 0);
52 ASSERT_RETURN_FALSE(Protect(in_pAddress, length, oldProtectionFlags));
74 using TChar = hedgedev::csl::ut::expr::GetCharType_t<T>;
76 auto view = std::basic_string_view<TChar>(in_rStr);
78 auto srcLength = in_length;
79 auto dstLength = srcLength;
84 if (!*(TChar*)in_pAddress)
87 dstLength = std::basic_string_view<TChar>((
const TChar*)in_pAddress).size() *
sizeof(TChar);
92 srcLength = view.size() *
sizeof(TChar);
99 srcLength = std::min(srcLength, dstLength);
102 uint32_t oldProtectionFlags{};
104 ASSERT_RETURN_FALSE(Protect(in_pAddress, dstLength, GetProtectionFlags(PageProtection::RW), &oldProtectionFlags));
105 ASSERT_RETURN_FALSE(memcpy_s(in_pAddress, dstLength, view.data(), srcLength) == 0);
106 memset((
char*)(size_t(in_pAddress) + srcLength), 0,
sizeof(TChar));
107 ASSERT_RETURN_FALSE(Protect(in_pAddress, dstLength, oldProtectionFlags));