18#pragma warning(disable: 4505)
24template<
class _Traits,
class _Ax>
25static DWORD
GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<char, _Traits, _Ax> &sValue)
noexcept
33 if (dwResult < _countof(szStackBuffer)) {
35 sValue.assign(szStackBuffer, dwResult);
40 std::unique_ptr<char[]> szBuffer(
new char[dwCapacity]);
42 if (dwResult < dwCapacity) {
43 sValue.assign(szBuffer.get(), dwResult);
55template<
class _Traits,
class _Ax>
56static DWORD
GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
noexcept
62 if (dwResult < _countof(szStackBuffer)) {
64 sValue.assign(szStackBuffer, dwResult);
69 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[dwCapacity]);
71 if (dwResult < dwCapacity) {
72 sValue.assign(szBuffer.get(), dwResult);
80template<
class _Traits,
class _Ax>
81static _Success_(
return != 0) int
GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<
char, _Traits, _Ax> &sValue) noexcept
88 iResult = ::GetWindowTextLengthA(hWnd);
94 sValue.assign(szBuffer, iResult);
97 std::unique_ptr<char[]> szBuffer(
new char[++iResult]);
99 sValue.assign(szBuffer.get(), iResult);
113template<
class _Traits,
class _Ax>
114static _Success_(
return != 0) int
GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sValue) noexcept
121 iResult = ::GetWindowTextLengthW(hWnd);
127 sValue.assign(szBuffer, iResult);
130 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[++iResult]);
132 sValue.assign(szBuffer.get(), iResult);
142template<
class _Ty,
class _Ax>
143static _Success_(
return != 0) BOOL
GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept
148 DWORD dwVerInfoSize = ::GetFileVersionInfoSizeA(lptstrFilename, &dwHandle);
149 if (dwVerInfoSize != 0) {
151 aValue.resize((dwVerInfoSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
152 return ::GetFileVersionInfoA(lptstrFilename, dwHandle, dwVerInfoSize, aValue.data());
162template<
class _Ty,
class _Ax>
163static _Success_(
return != 0) BOOL
GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept
168 DWORD dwVerInfoSize = ::GetFileVersionInfoSizeW(lptstrFilename, &dwHandle);
169 if (dwVerInfoSize != 0) {
171 aValue.resize((dwVerInfoSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
172 return ::GetFileVersionInfoW(lptstrFilename, dwHandle, dwVerInfoSize, aValue.data());
178template<
class _Traits,
class _Ax>
179static _Success_(
return != 0) DWORD
ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<
char, _Traits, _Ax> &sValue) noexcept
183 for (DWORD dwSizeOut = (DWORD)strlen(lpSrc) + 0x100;;) {
184 DWORD dwSizeIn = dwSizeOut;
185 std::unique_ptr<char[]> szBuffer(
new char[(
size_t)dwSizeIn + 2]);
187 if (dwSizeOut == 0) {
190 }
else if (dwSizeOut <= dwSizeIn) {
192 sValue.assign(szBuffer.get(), dwSizeOut - 1);
206template<
class _Traits,
class _Ax>
207static _Success_(
return != 0) DWORD
ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sValue) noexcept
209 for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) {
210 DWORD dwSizeIn = dwSizeOut;
211 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[(
size_t)dwSizeIn + 1]);
213 if (dwSizeOut == 0) {
216 }
else if (dwSizeOut <= dwSizeIn) {
218 sValue.assign(szBuffer.get(), dwSizeOut - 1);
228template<
class _Traits,
class _Ax>
229static VOID
GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<char, _Traits, _Ax> &str)
noexcept
233 sprintf(str,
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
237 lpGuid->Data4[0], lpGuid->Data4[1],
238 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
247template<
class _Traits,
class _Ax>
248static VOID
GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &str)
noexcept
252 sprintf(str, L
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
256 lpGuid->Data4[0], lpGuid->Data4[1],
257 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
262#define GuidToString GuidToStringW
264#define GuidToString GuidToStringA
268static _Success_(
return) BOOL
StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd = NULL)
noexcept
273 unsigned long long ullTmp;
275 if (!lpszGuid || !lpGuid || *lpszGuid !=
'{')
return FALSE;
278 g.Data1 = strtoul(lpszGuid, &lpszEnd, 16);
279 if (errno == ERANGE)
return FALSE;
282 if (*lpszGuid !=
'-')
return FALSE;
285 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
286 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
287 g.Data2 =
static_cast<unsigned short>(ulTmp);
290 if (*lpszGuid !=
'-')
return FALSE;
293 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
294 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
295 g.Data3 =
static_cast<unsigned short>(ulTmp);
298 if (*lpszGuid !=
'-')
return FALSE;
301 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
302 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
303 g.Data4[0] =
static_cast<unsigned char>((ulTmp >> 8) & 0xff);
304 g.Data4[1] =
static_cast<unsigned char>( ulTmp & 0xff);
307 if (*lpszGuid !=
'-')
return FALSE;
310 ullTmp = _strtoui64(lpszGuid, &lpszEnd, 16);
311 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF)
return FALSE;
312 g.Data4[2] =
static_cast<unsigned char>((ullTmp >> 40) & 0xff);
313 g.Data4[3] =
static_cast<unsigned char>((ullTmp >> 32) & 0xff);
314 g.Data4[4] =
static_cast<unsigned char>((ullTmp >> 24) & 0xff);
315 g.Data4[5] =
static_cast<unsigned char>((ullTmp >> 16) & 0xff);
316 g.Data4[6] =
static_cast<unsigned char>((ullTmp >> 8) & 0xff);
317 g.Data4[7] =
static_cast<unsigned char>( ullTmp & 0xff);
320 if (*lpszGuid !=
'}')
return FALSE;
324 *lpszGuidEnd = lpszGuid;
341static _Success_(
return) BOOL
StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd = NULL)
noexcept
346 unsigned long long ullTmp;
348 if (!lpszGuid || !lpGuid || *lpszGuid !=
'{')
return FALSE;
351 g.Data1 = wcstoul(lpszGuid, &lpszEnd, 16);
352 if (errno == ERANGE)
return FALSE;
355 if (*lpszGuid !=
'-')
return FALSE;
358 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
359 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
360 g.Data2 =
static_cast<unsigned short>(ulTmp);
363 if (*lpszGuid !=
'-')
return FALSE;
366 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
367 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
368 g.Data3 =
static_cast<unsigned short>(ulTmp);
371 if (*lpszGuid !=
'-')
return FALSE;
374 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
375 if (errno == ERANGE || ulTmp > 0xFFFF)
return FALSE;
376 g.Data4[0] =
static_cast<unsigned char>((ulTmp >> 8) & 0xff);
377 g.Data4[1] =
static_cast<unsigned char>( ulTmp & 0xff);
380 if (*lpszGuid !=
'-')
return FALSE;
383 ullTmp = _wcstoui64(lpszGuid, &lpszEnd, 16);
384 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF)
return FALSE;
385 g.Data4[2] =
static_cast<unsigned char>((ullTmp >> 40) & 0xff);
386 g.Data4[3] =
static_cast<unsigned char>((ullTmp >> 32) & 0xff);
387 g.Data4[4] =
static_cast<unsigned char>((ullTmp >> 24) & 0xff);
388 g.Data4[5] =
static_cast<unsigned char>((ullTmp >> 16) & 0xff);
389 g.Data4[6] =
static_cast<unsigned char>((ullTmp >> 8) & 0xff);
390 g.Data4[7] =
static_cast<unsigned char>( ullTmp & 0xff);
393 if (*lpszGuid !=
'}')
return FALSE;
397 *lpszGuidEnd = lpszGuid;
405#define StringToGuid StringToGuidW
407#define StringToGuid StringToGuidA
428template<
class _Traits,
class _Ax>
429static LSTATUS
RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<char, _Traits, _Ax> &sValue)
noexcept
433 DWORD dwSize =
sizeof(aStackBuffer), dwType;
437 if (lResult == ERROR_SUCCESS) {
438 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
440 dwSize /=
sizeof(CHAR);
441 sValue.assign(
reinterpret_cast<LPCSTR
>(aStackBuffer), dwSize &&
reinterpret_cast<LPCSTR
>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
442 }
else if (dwType == REG_EXPAND_SZ) {
445 lResult = ::GetLastError();
448 lResult = ERROR_INVALID_DATA;
450 }
else if (lResult == ERROR_MORE_DATA) {
451 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
453 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[dwSize /
sizeof(CHAR)]);
454 if ((lResult =
::RegQueryValueExA(hReg, pszName, NULL, NULL,
reinterpret_cast<LPBYTE
>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
455 dwSize /=
sizeof(CHAR);
456 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
458 }
else if (dwType == REG_EXPAND_SZ) {
460 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[dwSize /
sizeof(CHAR)]);
461 if ((lResult =
::RegQueryValueExA(hReg, pszName, NULL, NULL,
reinterpret_cast<LPBYTE
>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
463 lResult = ::GetLastError();
467 lResult = ERROR_INVALID_DATA;
492template<
class _Traits,
class _Ax>
493static LSTATUS
RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
noexcept
497 DWORD dwSize =
sizeof(aStackBuffer), dwType;
501 if (lResult == ERROR_SUCCESS) {
502 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
504 dwSize /=
sizeof(WCHAR);
505 sValue.assign(
reinterpret_cast<LPCWSTR
>(aStackBuffer), dwSize &&
reinterpret_cast<LPCWSTR
>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
506 }
else if (dwType == REG_EXPAND_SZ) {
509 lResult = ::GetLastError();
512 lResult = ERROR_INVALID_DATA;
514 }
else if (lResult == ERROR_MORE_DATA) {
515 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
517 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[dwSize /
sizeof(WCHAR)]);
518 if ((lResult =
::RegQueryValueExW(hReg, pszName, NULL, NULL,
reinterpret_cast<LPBYTE
>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
519 dwSize /=
sizeof(WCHAR);
520 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
522 }
else if (dwType == REG_EXPAND_SZ) {
524 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[dwSize /
sizeof(WCHAR)]);
525 if ((lResult =
::RegQueryValueExW(hReg, pszName, NULL, NULL,
reinterpret_cast<LPBYTE
>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
527 lResult = ::GetLastError();
531 lResult = ERROR_INVALID_DATA;
539template<
class _Ty,
class _Ax>
540static LSTATUS
RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData)
noexcept
544 DWORD dwSize =
sizeof(aStackBuffer);
547 lResult =
RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
548 if (lResult == ERROR_SUCCESS) {
550 aData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
551 memcpy(aData.data(), aStackBuffer, dwSize);
552 }
else if (lResult == ERROR_MORE_DATA) {
554 aData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
555 lResult =
RegQueryValueExA(hKey, lpValueName, lpReserved, NULL,
reinterpret_cast<LPBYTE
>(aData.data()), &dwSize);
566template<
class _Ty,
class _Ax>
567static LSTATUS
RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData)
noexcept
571 DWORD dwSize =
sizeof(aStackBuffer);
574 lResult =
RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
575 if (lResult == ERROR_SUCCESS) {
577 aData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
578 memcpy(aData.data(), aStackBuffer, dwSize);
579 }
else if (lResult == ERROR_MORE_DATA) {
581 aData.resize((dwSize +
sizeof(_Ty) - 1) /
sizeof(_Ty));
582 lResult =
RegQueryValueExW(hKey, lpValueName, lpReserved, NULL,
reinterpret_cast<LPBYTE
>(aData.data()), &dwSize);
588#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
591template<
class _Traits,
class _Ax>
592static LSTATUS
RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string<char, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory)
noexcept
597 return ERROR_CALL_NOT_IMPLEMENTED;
605template<
class _Traits,
class _Ax>
606static LSTATUS
RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory)
noexcept
612 Flags &= ~REG_MUI_STRING_TRUNCATE;
615 lResult =
RegLoadMUIStringW(hKey, pszValue, szStackBuffer,
sizeof(szStackBuffer), &dwSize, Flags, pszDirectory);
616 if (lResult == ERROR_SUCCESS) {
618 sOut.assign(szStackBuffer, wcsnlen(szStackBuffer, dwSize/
sizeof(
wchar_t)));
619 }
else if (lResult == ERROR_MORE_DATA) {
621 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[(dwSize +
sizeof(
wchar_t) - 1)/
sizeof(
wchar_t)]);
622 sOut.assign(szBuffer.get(), (lResult =
RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? wcsnlen(szBuffer.get(), dwSize/
sizeof(
wchar_t)) : 0);
635template<
class _Traits,
class _Ax>
636static _Success_(
return != 0) int
WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_
int cchWideChar, _Out_ std::basic_string<
char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
641 int cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
644 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
645 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
647 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
648 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[cch]);
649 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
650 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
662static _Success_(
return != 0) int
WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_
int cchWideChar, _Out_ std::vector<
char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
667 int cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
670 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
671 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
673 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
674 sMultiByteStr.resize(cch);
675 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
686template<
class _Traits1,
class _Ax1,
class _Traits2,
class _Ax2>
687static _Success_(
return != 0) int
WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ std::basic_string<
wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<
char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
692 int cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
695 sMultiByteStr.assign(szStackBuffer, cch);
696 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
698 cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
699 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[cch]);
700 cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
701 sMultiByteStr.assign(szBuffer.get(), cch);
714template<
class _Traits,
class _Ax>
715static _Success_(
return != 0) int
SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_
int cchWideChar, _Out_ std::basic_string<
char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
720 int cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
723 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
724 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
726 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
727 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[cch]);
728 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
729 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
730 SecureZeroMemory(szBuffer.get(),
sizeof(CHAR)*cch);
733 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
746static _Success_(
return != 0) int
SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_
int cchWideChar, _Out_ std::vector<
char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
751 int cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
754 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
755 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
757 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
758 sMultiByteStr.resize(cch);
759 cch =
::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
762 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
774template<
class _Traits1,
class _Ax1,
class _Traits2,
class _Ax2>
775static _Success_(
return != 0) int
SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _Out_ std::basic_string<
wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<
char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
780 int cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
783 sMultiByteStr.assign(szStackBuffer, cch);
784 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
786 cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
787 std::unique_ptr<CHAR[]> szBuffer(
new CHAR[cch]);
788 cch =
::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (
int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
789 sMultiByteStr.assign(szBuffer.get(), cch);
790 SecureZeroMemory(szBuffer.get(),
sizeof(CHAR)*cch);
793 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
803template<
class _Traits,
class _Ax>
804static _Success_(
return != 0) int
MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_
int cbMultiByte, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sWideCharStr) noexcept
809 int cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
812 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
813 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
816 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
818 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
830static _Success_(
return != 0) int
MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_
int cbMultiByte, _Out_ std::vector<
wchar_t, _Ax> &sWideCharStr) noexcept
835 int cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
838 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
839 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
842 sWideCharStr.resize(cch);
843 cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
854template<
class _Traits1,
class _Ax1,
class _Traits2,
class _Ax2>
855static _Success_(
return != 0) int
MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<
char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<
wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept
860 int cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
863 sWideCharStr.assign(szStackBuffer, cch);
864 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
866 cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), NULL, 0);
867 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
868 cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), szBuffer.get(), cch);
869 sWideCharStr.assign(szBuffer.get(), cch);
882template<
class _Traits,
class _Ax>
883static _Success_(
return != 0) int
SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_
int cbMultiByte, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sWideCharStr) noexcept
888 int cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
891 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
892 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
895 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
897 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
898 SecureZeroMemory(szBuffer.get(),
sizeof(WCHAR)*cch);
901 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
914static _Success_(
return != 0) int
SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_
int cbMultiByte, _Out_ std::vector<
wchar_t, _Ax> &sWideCharStr) noexcept
919 int cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
922 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
923 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
926 sWideCharStr.resize(cch);
927 cch =
::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
930 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
942template<
class _Traits1,
class _Ax1,
class _Traits2,
class _Ax2>
943static _Success_(
return != 0) int
SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<
char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<
wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept
948 int cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
951 sWideCharStr.assign(szStackBuffer, cch);
952 }
else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
954 cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), NULL, 0);
955 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
956 cch =
::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (
int)sMultiByteStr.length(), szBuffer.get(), cch);
957 sWideCharStr.assign(szBuffer.get(), cch);
958 SecureZeroMemory(szBuffer.get(),
sizeof(WCHAR)*cch);
961 SecureZeroMemory(szStackBuffer,
sizeof(szStackBuffer));
971template<
class _Traits,
class _Ax>
972static _Success_(
return > 0) int
NormalizeString(_In_ NORM_FORM NormForm, _In_ LPCWSTR lpSrcString, _In_
int cwSrcLength, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sDstString) noexcept
977 int cch =
::NormalizeString(NormForm, lpSrcString, cwSrcLength, szStackBuffer, _countof(szStackBuffer));
980 sDstString.assign(szStackBuffer, cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
982 switch (::GetLastError()) {
983 case ERROR_INSUFFICIENT_BUFFER:
984 for (
int i = 10; i--;) {
987 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
988 cch =
::NormalizeString(NormForm, lpSrcString, cwSrcLength, szBuffer.get(), cch);
990 sDstString.assign(szBuffer.get(), cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
993 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1014template<
class _Traits1,
class _Ax1,
class _Traits2,
class _Ax2>
1015static _Success_(
return > 0) int
NormalizeString(_In_ NORM_FORM NormForm, _In_ const std::basic_string<
wchar_t, _Traits1, _Ax1> &sSrcString, _Out_ std::basic_string<
wchar_t, _Traits2, _Ax2> &sDstString) noexcept
1020 int cch =
::NormalizeString(NormForm, sSrcString.c_str(), (
int)sSrcString.length(), szStackBuffer, _countof(szStackBuffer));
1023 sDstString.assign(szStackBuffer, cch);
1025 switch (::GetLastError()) {
1026 case ERROR_INSUFFICIENT_BUFFER:
1027 for (
int i = 10; i--;) {
1030 std::unique_ptr<WCHAR[]> szBuffer(
new WCHAR[cch]);
1031 cch =
::NormalizeString(NormForm, sSrcString.c_str(), (
int)sSrcString.length(), szBuffer.get(), cch);
1033 sDstString.assign(szBuffer.get(), cch);
1036 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1053template<
class _Traits,
class _Ax>
1054static _Success_(
return != 0) int WINAPI
LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<
char, _Traits, _Ax> &sBuffer) noexcept
1058 int i =
LoadStringA(hInstance, uID,
reinterpret_cast<LPSTR
>(&pszStr), 0);
1060 sBuffer.assign(pszStr, i);
1071template<
class _Traits,
class _Ax>
1072static _Success_(
return != 0) int WINAPI
LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sBuffer) noexcept
1076 int i =
LoadStringW(hInstance, uID,
reinterpret_cast<LPWSTR
>(&pszStr), 0);
1078 sBuffer.assign(pszStr, i);
1092 try {
vsprintf(str, lpOutputString, arg); }
catch (...) {
return; }
1093 OutputDebugStringA(str.c_str());
1104 try {
vsprintf(str, lpOutputString, arg); }
catch (...) {
return; }
1105 OutputDebugStringW(str.c_str());
1116 va_start(arg, lpOutputString);
1129 va_start(arg, lpOutputString);
1135template<
class _Traits,
class _Ax>
1136static _Success_(
return != 0) int
GetDateFormatA(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCSTR lpFormat, _Out_ std::basic_string<
char, _Traits, _Ax> &sDate) noexcept
1138 int iResult =
GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
1141 std::unique_ptr<char[]> szBuffer(
new char[iResult]);
1142 iResult =
GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
1143 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
1155template<
class _Traits,
class _Ax>
1156static _Success_(
return != 0) int
GetDateFormatW(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCWSTR lpFormat, _Out_ std::basic_string<
wchar_t, _Traits, _Ax> &sDate) noexcept
1158 int iResult =
GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
1161 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[iResult]);
1162 iResult =
GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
1163 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
1171template<
class _Traits,
class _Ax>
1172static _Success_(
return != 0) BOOL
LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<
char, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<
char, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept
1176 DWORD dwNameLen = 0, dwRefDomainLen = 0;
1180 NULL, &dwRefDomainLen,
1184 if (sName ) sName ->clear();
1185 if (sReferencedDomainName) sReferencedDomainName->clear();
1187 }
else if (GetLastError() == ERROR_MORE_DATA) {
1189 std::unique_ptr<char[]> bufName (
new char[dwNameLen ]);
1190 std::unique_ptr<char[]> bufRefDomain(
new char[dwRefDomainLen]);
1192 bufName .get(), &dwNameLen ,
1193 bufRefDomain.get(), &dwRefDomainLen,
1196 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
1197 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
1210template<
class _Traits,
class _Ax>
1211static _Success_(
return != 0) BOOL
LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<
wchar_t, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<
wchar_t, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept
1215 DWORD dwNameLen = 0, dwRefDomainLen = 0;
1219 NULL, &dwRefDomainLen,
1223 if (sName ) sName ->clear();
1224 if (sReferencedDomainName) sReferencedDomainName->clear();
1226 }
else if (GetLastError() == ERROR_MORE_DATA) {
1228 std::unique_ptr<wchar_t[]> bufName (
new wchar_t[dwNameLen ]);
1229 std::unique_ptr<wchar_t[]> bufRefDomain(
new wchar_t[dwRefDomainLen]);
1231 bufName .get(), &dwNameLen ,
1232 bufRefDomain.get(), &dwRefDomainLen,
1235 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
1236 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
1249static _Success_(
return != FALSE) BOOL
CreateWellKnownSid(_In_ WELL_KNOWN_SID_TYPE WellKnownSidType, _In_opt_ PSID DomainSid, _Inout_ std::unique_ptr<SID> &Sid)
1252 DWORD dwSize =
sizeof(szStackBuffer);
1256 Sid.reset((SID*)
new BYTE[dwSize]);
1257 memcpy(Sid.get(), szStackBuffer, dwSize);
1259 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
1261 Sid.reset((SID*)
new BYTE[dwSize]);
1273static _Success_(
return != 0) BOOL
GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) noexcept
1278 if (
GetTokenInformation(TokenHandle, TokenInformationClass, szStackBuffer,
sizeof(szStackBuffer), &dwSize)) {
1280 TokenInformation.reset((_Ty*)(
new BYTE[dwSize]));
1281 memcpy(TokenInformation.get(), szStackBuffer, dwSize);
1283 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
1285 TokenInformation.reset((_Ty*)(
new BYTE[dwSize]));
1286 return GetTokenInformation(TokenHandle, TokenInformationClass, TokenInformation.get(), dwSize, &dwSize);
1296template<
class _Traits,
class _Ax>
1297static _Success_(
return != 0) BOOL
QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<
char, _Traits, _Ax>& sExeName)
1300 DWORD dwSize = _countof(szStackBuffer);
1305 sExeName.assign(szStackBuffer, dwSize);
1308 for (DWORD dwCapacity = 2 *
WINSTD_STACK_BUFFER_BYTES /
sizeof(
char); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
1310 std::unique_ptr<char[]> szBuffer(
new char[dwCapacity]);
1311 dwSize = dwCapacity;
1313 sExeName.assign(szBuffer.get(), dwSize);
1325template<
class _Traits,
class _Ax>
1326static _Success_(
return != 0) BOOL
QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<
wchar_t, _Traits, _Ax>& sExeName)
1329 DWORD dwSize = _countof(szStackBuffer);
1334 sExeName.assign(szStackBuffer, dwSize);
1337 for (DWORD dwCapacity = 2 *
WINSTD_STACK_BUFFER_BYTES /
sizeof(
wchar_t); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
1339 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[dwCapacity]);
1340 dwSize = dwCapacity;
1342 sExeName.assign(szBuffer.get(), dwSize);
1361 template<HANDLE INVALID>
1481 if (!UnmapViewOfFile(_Ptr))
1503 if (!UnmapViewOfFile(_Ptr))
1510 template<
class _Other>
1513 if (!UnmapViewOfFile(_Ptr))
1542 InitializeCriticalSection(&
m_data);
1552 DeleteCriticalSection(&
m_data);
1560 operator LPCRITICAL_SECTION() noexcept
1639 PROCESS_HEAP_ENTRY e;
1641 while (HeapWalk(
m_h, &e) != FALSE) {
1642 if ((e.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) {
1644 _T(
"Allocated block%s%s\n")
1645 _T(
" Data portion begins at: %#p\n Size: %d bytes\n")
1646 _T(
" Overhead: %d bytes\n Region index: %d\n"),
1647 (e.wFlags & PROCESS_HEAP_ENTRY_MOVEABLE) != 0 ?
tstring_printf(_T(
", movable with HANDLE %#p"), e.Block.hMem).c_str() : _T(
""),
1648 (e.wFlags & PROCESS_HEAP_ENTRY_DDESHARE) != 0 ? _T(
", DDESHARE") : _T(
""),
1658 const DWORD dwResult = GetLastError();
1659 if (dwResult != ERROR_NO_MORE_ITEMS)
1684 template <
class _Ty>
1701 template <
class _Other>
1722 template <
class _Other>
1748 UNREFERENCED_PARAMETER(size);
1750 HeapFree(
m_heap, 0, ptr);
1761 ::new ((
void*)ptr) _Ty(val);
1772 ::new ((
void*)ptr) _Ty(std::forward<_Ty>(val));
1815 if (!ActivateActCtx(hActCtx, &
m_cookie))
1883 m_cookie = hToken && ImpersonateLoggedOnUser(hToken);
1901 TOKEN_PRIVILEGES privileges = { 1, {{{ 0, 0 }, SE_PRIVILEGE_ENABLED }} };
1902 if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &privileges.Privileges[0].Luid) ||
1903 !ImpersonateSelf(SecurityImpersonation))
1908 if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES, FALSE, &h))
1911 if (!AdjustTokenPrivileges(thread_token, FALSE, &privileges,
sizeof(privileges), NULL, NULL))
1916 PROCESSENTRY32 entry = {
sizeof(PROCESSENTRY32) };
1919 while (_tcsicmp(entry.szExeFile, TEXT(
"winlogon.exe")) != 0)
1922 process winlogon_process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, entry.th32ProcessID);
1923 if (!winlogon_process)
1925 if (!
OpenProcessToken(winlogon_process, TOKEN_IMPERSONATE | TOKEN_DUPLICATE, &h))
1928 if (!DuplicateToken(winlogon_token, SecurityImpersonation, &h))
1931 if (!SetThreadToken(NULL, duplicated_token))
1939 DWORD dwResult = GetLastError();
1941 SetLastError(dwResult);
1974 SetConsoleCtrlHandler(
m_handler, FALSE);
2015 m_proc(std::move(h.m_proc)),
2028 VirtualFreeEx(
m_proc,
m_h, 0, MEM_RELEASE);
2038 if (
this != std::addressof(other)) {
2040 m_proc = std::move(other.m_proc);
2071 _In_ HANDLE hProcess,
2072 _In_opt_ LPVOID lpAddress,
2074 _In_ DWORD flAllocationType,
2075 _In_ DWORD flProtect)
noexcept
2077 handle_type h = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect);
2093 VirtualFreeEx(
m_proc,
m_h, 0, MEM_RELEASE);
2135 s = RegDeleteKey(
m_h, szSubkey);
2136 if (s == ERROR_SUCCESS || s == ERROR_FILE_NOT_FOUND)
2142 s = RegOpenKeyEx(
m_h, szSubkey, 0, KEY_ENUMERATE_SUB_KEYS, &h);
2143 if (s == ERROR_SUCCESS)
2150 TCHAR szName[MAX_PATH];
2151 DWORD dwSize = _countof(szName);
2152 s = RegEnumKeyEx(k, 0, szName, &dwSize, NULL, NULL, NULL, NULL);
2153 if (s == ERROR_SUCCESS)
2155 else if (s == ERROR_NO_MORE_ITEMS)
2164 s = RegDeleteKey(
m_h, szSubkey);
2165 if (s == ERROR_SUCCESS)
2230 hProcess = INVALID_HANDLE_VALUE;
2231 hThread = INVALID_HANDLE_VALUE;
2241 #pragma warning(push)
2242 #pragma warning(disable: 6001)
2244 if (hProcess != INVALID_HANDLE_VALUE)
2245 CloseHandle(hProcess);
2247 if (hThread != INVALID_HANDLE_VALUE)
2248 CloseHandle(hThread);
2250 #pragma warning(pop)
2283 DeregisterEventSource(
m_h);
2314 CloseServiceHandle(
m_h);
2324#pragma warning(push)
2325#pragma warning(disable: 4505)
2330 _In_ LPCSTR lpSubKey,
2331 _Reserved_ DWORD Reserved,
2332 _In_opt_ LPSTR lpClass,
2333 _In_ DWORD dwOptions,
2334 _In_ REGSAM samDesired,
2335 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
2337 _Out_opt_ LPDWORD lpdwDisposition)
2340 LSTATUS s =
RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
2341 if (s == ERROR_SUCCESS)
2353 _In_ LPCWSTR lpSubKey,
2354 _Reserved_ DWORD Reserved,
2355 _In_opt_ LPWSTR lpClass,
2356 _In_ DWORD dwOptions,
2357 _In_ REGSAM samDesired,
2358 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
2360 _Out_opt_ LPDWORD lpdwDisposition)
2363 LSTATUS s =
RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
2364 if (s == ERROR_SUCCESS)
2372 _In_opt_ LPCSTR lpSubKey,
2373 _In_opt_ DWORD ulOptions,
2374 _In_ REGSAM samDesired,
2378 LSTATUS s =
RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, &h);
2379 if (s == ERROR_SUCCESS)
2391 _In_opt_ LPCWSTR lpSubKey,
2392 _In_opt_ DWORD ulOptions,
2393 _In_ REGSAM samDesired,
2397 LSTATUS s =
RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, &h);
2398 if (s == ERROR_SUCCESS)
2412 TokenHandle.attach(h);
2423static BOOL
DuplicateTokenEx(_In_ HANDLE hExistingToken, _In_ DWORD dwDesiredAccess, _In_opt_ LPSECURITY_ATTRIBUTES lpTokenAttributes, _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, _In_ TOKEN_TYPE TokenType, _Inout_
winstd::win_handle<NULL> &NewToken)
2426 if (
DuplicateTokenEx(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, &h)) {
2438static BOOL
AllocateAndInitializeSid(_In_ PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, _In_ BYTE nSubAuthorityCount, _In_ DWORD nSubAuthority0, _In_ DWORD nSubAuthority1, _In_ DWORD nSubAuthority2, _In_ DWORD nSubAuthority3, _In_ DWORD nSubAuthority4, _In_ DWORD nSubAuthority5, _In_ DWORD nSubAuthority6, _In_ DWORD nSubAuthority7, _Inout_
winstd::security_id& Sid)
2441 if (
AllocateAndInitializeSid(pIdentifierAuthority, nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, &h)) {
2452 DWORD dwResult =
SetEntriesInAclA(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
2453 if (dwResult == ERROR_SUCCESS)
2455 return ERROR_SUCCESS;
2466 DWORD dwResult =
SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
2467 if (dwResult == ERROR_SUCCESS)
2469 return ERROR_SUCCESS;
Activates given activation context in constructor and deactivates it in destructor.
Definition Win.h:1801
actctx_activator(HANDLE hActCtx) noexcept
Construct the activator and activates the given activation context.
Definition Win.h:1813
virtual ~actctx_activator()
Deactivates activation context and destructs the activator.
Definition Win.h:1824
ULONG_PTR m_cookie
Cookie for context deactivation.
Definition Win.h:1831
Base template class to support string formatting using printf() style templates.
Definition Common.h:1141
Console control handler stack management.
Definition Win.h:1949
console_ctrl_handler(PHANDLER_ROUTINE HandlerRoutine) noexcept
Construct the console control handler object and pushes the given handler to the console control hand...
Definition Win.h:1961
virtual ~console_ctrl_handler()
Pops console control handler from the console control handler stack.
Definition Win.h:1971
PHANDLER_ROUTINE m_handler
Pointer to console control handler.
Definition Win.h:1979
BOOL m_cookie
Did pushing the console control handler succeed?
Definition Win.h:1978
Critical section wrapper.
Definition Win.h:1530
critical_section() noexcept
Construct the object and initializes a critical section object.
Definition Win.h:1540
CRITICAL_SECTION m_data
Critical section struct.
Definition Win.h:1566
virtual ~critical_section()
Releases all resources used by an unowned critical section object.
Definition Win.h:1550
Event log handle wrapper.
Definition Win.h:2260
void free_internal() noexcept override
Closes an event log handle.
Definition Win.h:2281
virtual ~event_log()
Closes an event log handle.
Definition Win.h:2269
Find-file handle wrapper.
Definition Win.h:1575
virtual ~find_file()
Closes a file search handle.
Definition Win.h:1584
void free_internal() noexcept override
Closes a file search handle.
Definition Win.h:1596
Base abstract template class to support generic object handle keeping.
Definition Common.h:635
LPVOID handle_type
Datatype of the object handle this template class handles.
Definition Common.h:640
handle_type m_h
Object handle.
Definition Common.h:889
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:852
HeapAlloc allocator.
Definition Win.h:1686
SIZE_T size_type
An unsigned integral type that can represent the length of any sequence that an object of template cl...
Definition Win.h:1695
_Ty value_type
A type that is managed by the allocator.
Definition Win.h:1688
heap_allocator(const heap_allocator< _Other > &other)
Constructs allocator from another type.
Definition Win.h:1723
HANDLE m_heap
Heap handle.
Definition Win.h:1794
pointer allocate(size_type count)
Allocates a new memory block.
Definition Win.h:1734
ptrdiff_t difference_type
A signed integral type that can represent the difference between values of pointers to the type of ob...
Definition Win.h:1696
heap_allocator(HANDLE heap)
Constructs allocator.
Definition Win.h:1713
_Ty & reference
A type that provides a reference to the type of object managed by the allocator.
Definition Win.h:1691
void construct(pointer ptr, _Ty &&val)
Calls moving constructor for the element.
Definition Win.h:1770
void deallocate(pointer ptr, size_type size)
Frees memory block.
Definition Win.h:1746
size_type max_size() const
Returns maximum memory block size.
Definition Win.h:1788
void construct(pointer ptr, const _Ty &val)
Calls copying constructor for the element.
Definition Win.h:1759
const _Ty & const_reference
A type that provides a constant reference to type of object managed by the allocator.
Definition Win.h:1693
const _Ty * const_pointer
A type that provides a constant pointer to the type of object managed by the allocator.
Definition Win.h:1692
_Ty * pointer
A type that provides a pointer to the type of object managed by the allocator.
Definition Win.h:1690
void destroy(pointer ptr)
Calls destructor for the element.
Definition Win.h:1780
Heap handle wrapper.
Definition Win.h:1608
bool enumerate() noexcept
Enumerates allocated heap blocks using OutputDebugString()
Definition Win.h:1630
void free_internal() noexcept override
Destroys the heap.
Definition Win.h:1674
virtual ~heap()
Destroys the heap.
Definition Win.h:1617
Base class for thread impersonation of another security context.
Definition Win.h:1838
virtual ~impersonator()
Reverts to current user and destructs the impersonator.
Definition Win.h:1850
impersonator() noexcept
Construct the impersonator.
Definition Win.h:1843
BOOL m_cookie
Did impersonation succeed?
Definition Win.h:1862
Module handle wrapper.
Definition Win.h:1396
void free_internal() noexcept override
Frees the module.
Definition Win.h:1417
virtual ~library()
Frees the module.
Definition Win.h:1405
Registry key wrapper class.
Definition Win.h:2107
void free_internal() noexcept override
Closes a handle to the registry key.
Definition Win.h:2179
bool delete_subkey(LPCTSTR szSubkey)
Deletes the specified registry subkey.
Definition Win.h:2131
virtual ~reg_key()
Closes a handle to the registry key.
Definition Win.h:2116
SC_HANDLE wrapper class.
Definition Win.h:2291
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:2312
virtual ~sc_handle()
Closes an open object handle.
Definition Win.h:2300
SID wrapper class.
Definition Win.h:2189
void free_internal() noexcept override
Closes a handle to the SID.
Definition Win.h:2210
virtual ~security_id()
Closes a handle to the SID.
Definition Win.h:2198
Lets the calling thread impersonate the security context of the SYSTEM user.
Definition Win.h:1891
system_impersonator() noexcept
Construct the impersonator and impersonates the SYSTEM user.
Definition Win.h:1899
Lets the calling thread impersonate the security context of a logged-on user.
Definition Win.h:1869
user_impersonator(HANDLE hToken) noexcept
Construct the impersonator and impersonates the given user.
Definition Win.h:1881
Memory in virtual address space of a process handle wrapper.
Definition Win.h:1986
vmemory & operator=(vmemory &&other) noexcept
Move assignment.
Definition Win.h:2036
bool alloc(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) noexcept
Reserves, commits, or changes the state of a region of memory within the virtual address space of a s...
Definition Win.h:2070
void free_internal() noexcept override
Frees the memory.
Definition Win.h:2091
void attach(HANDLE proc, handle_type h) noexcept
Sets a new memory handle for the class.
Definition Win.h:2053
virtual ~vmemory()
Frees the memory.
Definition Win.h:2025
vmemory(handle_type h, HANDLE proc) noexcept
Initializes a new class instance with an already available object handle.
Definition Win.h:2003
vmemory() noexcept
Initializes a new class instance with the memory handle set to INVAL.
Definition Win.h:1993
vmemory(vmemory &&h) noexcept
Move constructor.
Definition Win.h:2014
HANDLE m_proc
Handle of memory's process.
Definition Win.h:2097
Windows HANDLE wrapper class.
Definition Win.h:1363
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:1384
virtual ~win_handle()
Closes an open object handle.
Definition Win.h:1372
Windows runtime error.
Definition Common.h:1074
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:93
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:74
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:163
static const HANDLE invalid
Invalid handle value.
Definition Common.h:645
static int NormalizeString(NORM_FORM NormForm, LPCWSTR lpSrcString, int cwSrcLength, std::basic_string< wchar_t, _Traits, _Ax > &sDstString) noexcept
Normalizes characters of a text string according to Unicode 4.0 TR#15.
Definition Win.h:972
static int SecureWideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily f...
Definition Win.h:715
static DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
Expands environment-variable strings, replaces them with the values defined for the current user,...
Definition Win.h:179
static BOOL StringToGuidA(LPCSTR lpszGuid, LPGUID lpGuid, LPCSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:268
static int GetWindowTextA(HWND hWnd, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
Copies the text of the specified window's title bar (if it has one) into a std::wstring string.
Definition Win.h:81
static LSTATUS RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, winstd::reg_key &result, LPDWORD lpdwDisposition)
Creates the specified registry key. If the key already exists, the function opens it.
Definition Win.h:2351
static int WINAPI LoadStringA(HINSTANCE hInstance, UINT uID, std::basic_string< char, _Traits, _Ax > &sBuffer) noexcept
Loads a string resource from the executable file associated with a specified module.
Definition Win.h:1054
win_handle< INVALID_HANDLE_VALUE > file
File handle wrapper.
Definition Win.h:1450
static BOOL GetFileVersionInfoA(LPCSTR lptstrFilename, __reserved DWORD dwHandle, std::vector< _Ty, _Ax > &aValue) noexcept
Retrieves version information for the specified file and stores it in a std::vector buffer.
Definition Win.h:143
static int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necess...
Definition Win.h:804
static LSTATUS RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, winstd::reg_key &result, LPDWORD lpdwDisposition)
Creates the specified registry key. If the key already exists, the function opens it.
Definition Win.h:2328
static LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2370
static LSTATUS RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2389
static VOID GuidToStringA(LPCGUID lpGuid, std::basic_string< char, _Traits, _Ax > &str) noexcept
Formats GUID and stores it in a std::wstring string.
Definition Win.h:229
static BOOL StringToGuidW(LPCWSTR lpszGuid, LPGUID lpGuid, LPCWSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:341
static LSTATUS RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, std::basic_string< wchar_t, _Traits, _Ax > &sOut, DWORD Flags, LPCWSTR pszDirectory) noexcept
Loads the specified string from the specified key and subkey, and stores it in a std::wstring string.
Definition Win.h:606
static BOOL OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, winstd::win_handle< NULL > &TokenHandle)
Opens the access token associated with a process.
Definition Win.h:2408
static DWORD SetEntriesInAclW(ULONG cCountOfExplicitEntries, PEXPLICIT_ACCESS_W pListOfExplicitEntries, PACL OldAcl, std::unique_ptr< ACL, winstd::LocalFree_delete< ACL > > &Acl)
Creates a new access control list (ACL) by merging new access control or audit control information in...
Definition Win.h:2463
static BOOL LookupAccountSidA(LPCSTR lpSystemName, PSID lpSid, std::basic_string< char, _Traits, _Ax > *sName, std::basic_string< char, _Traits, _Ax > *sReferencedDomainName, PSID_NAME_USE peUse) noexcept
Retrieves the name of the account for this SID and the name of the first domain on which this SID is ...
Definition Win.h:1172
static DWORD GetModuleFileNameW(HMODULE hModule, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
Retrieves the fully qualified path for the file that contains the specified module and stores it in a...
Definition Win.h:56
static BOOL LookupAccountSidW(LPCWSTR lpSystemName, PSID lpSid, std::basic_string< wchar_t, _Traits, _Ax > *sName, std::basic_string< wchar_t, _Traits, _Ax > *sReferencedDomainName, PSID_NAME_USE peUse) noexcept
Retrieves the name of the account for this SID and the name of the first domain on which this SID is ...
Definition Win.h:1211
static BOOL AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, winstd::security_id &Sid)
Allocates and initializes a security identifier (SID) with up to eight subauthorities.
Definition Win.h:2438
win_handle< INVALID_HANDLE_VALUE > process_snapshot
Process snapshot handle wrapper.
Definition Win.h:1442
static DWORD GetModuleFileNameA(HMODULE hModule, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
Retrieves the fully qualified path for the file that contains the specified module and stores it in a...
Definition Win.h:25
static int GetDateFormatW(LCID Locale, DWORD dwFlags, const SYSTEMTIME *lpDate, LPCWSTR lpFormat, std::basic_string< wchar_t, _Traits, _Ax > &sDate) noexcept
Formats a date as a date string for a locale specified by the locale identifier. The function formats...
Definition Win.h:1156
static BOOL CreateWellKnownSid(WELL_KNOWN_SID_TYPE WellKnownSidType, PSID DomainSid, std::unique_ptr< SID > &Sid)
Creates a SID for predefined aliases.
Definition Win.h:1249
static int WINAPI LoadStringW(HINSTANCE hInstance, UINT uID, std::basic_string< wchar_t, _Traits, _Ax > &sBuffer) noexcept
Loads a string resource from the executable file associated with a specified module.
Definition Win.h:1072
static BOOL GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, std::unique_ptr< _Ty > &TokenInformation) noexcept
Retrieves a specified type of information about an access token. The calling process must have approp...
Definition Win.h:1273
static BOOL DuplicateTokenEx(HANDLE hExistingToken, DWORD dwDesiredAccess, LPSECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, winstd::win_handle< NULL > &NewToken)
Creates a new access token that duplicates an existing token. This function can create either a prima...
Definition Win.h:2423
static DWORD SetEntriesInAclA(ULONG cCountOfExplicitEntries, PEXPLICIT_ACCESS_A pListOfExplicitEntries, PACL OldAcl, std::unique_ptr< ACL, winstd::LocalFree_delete< ACL > > &Acl)
Creates a new access control list (ACL) by merging new access control or audit control information in...
Definition Win.h:2449
static LSTATUS RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, __reserved LPDWORD lpReserved, LPDWORD lpType, std::vector< _Ty, _Ax > &aData) noexcept
Retrieves the type and data for the specified value name associated with an open registry key and sto...
Definition Win.h:567
static BOOL GetFileVersionInfoW(LPCWSTR lptstrFilename, __reserved DWORD dwHandle, std::vector< _Ty, _Ax > &aValue) noexcept
Retrieves version information for the specified file and stores it in a std::vector buffer.
Definition Win.h:163
win_handle< NULL > event
Event handle wrapper.
Definition Win.h:1524
static LSTATUS RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, std::basic_string< char, _Traits, _Ax > &sOut, DWORD Flags, LPCSTR pszDirectory) noexcept
Loads the specified string from the specified key and subkey, and stores it in a std::wstring string.
Definition Win.h:592
static VOID OutputDebugStr(LPCSTR lpOutputString,...) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:1113
static BOOL QueryFullProcessImageNameA(HANDLE hProcess, DWORD dwFlags, std::basic_string< char, _Traits, _Ax > &sExeName)
Retrieves the full name of the executable image for the specified process.
Definition Win.h:1297
win_handle< NULL > file_mapping
File mapping.
Definition Win.h:1457
static int SecureMultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necess...
Definition Win.h:883
static int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily f...
Definition Win.h:636
static BOOL QueryFullProcessImageNameW(HANDLE hProcess, DWORD dwFlags, std::basic_string< wchar_t, _Traits, _Ax > &sExeName)
Retrieves the full name of the executable image for the specified process.
Definition Win.h:1326
win_handle< NULL > process
Process handle wrapper.
Definition Win.h:1428
static LSTATUS RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, __reserved LPDWORD lpReserved, LPDWORD lpType, std::vector< _Ty, _Ax > &aData) noexcept
Retrieves the type and data for the specified value name associated with an open registry key and sto...
Definition Win.h:540
static LSTATUS RegQueryStringValue(HKEY hReg, LPCSTR pszName, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
Queries for a string value in the registry and stores it in a std::string string.
Definition Win.h:429
static int GetWindowTextW(HWND hWnd, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
Copies the text of the specified window's title bar (if it has one) into a std::wstring string.
Definition Win.h:114
static int GetDateFormatA(LCID Locale, DWORD dwFlags, const SYSTEMTIME *lpDate, LPCSTR lpFormat, std::basic_string< char, _Traits, _Ax > &sDate) noexcept
Formats a date as a date string for a locale specified by the locale identifier. The function formats...
Definition Win.h:1136
static DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
Expands environment-variable strings, replaces them with the values defined for the current user,...
Definition Win.h:207
static VOID GuidToStringW(LPCGUID lpGuid, std::basic_string< wchar_t, _Traits, _Ax > &str) noexcept
Formats GUID and stores it in a std::wstring string.
Definition Win.h:248
static VOID OutputDebugStrV(LPCSTR lpOutputString, va_list arg) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:1089
win_handle< NULL > thread
Thread handle wrapper.
Definition Win.h:1435
Deleter for unique_ptr using LocalFree.
Definition Common.h:346
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1496
void operator()(_Other *) const
Delete a pointer of another type.
Definition Win.h:1511
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1501
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1491
Deleter for unique_ptr using UnmapViewOfFile.
Definition Win.h:1463
UnmapViewOfFile_delete(const UnmapViewOfFile_delete< _Ty2 > &)
Construct from another UnmapViewOfFile_delete.
Definition Win.h:1474
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1479
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1464
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1469
A structure that enables an allocator for objects of one type to allocate storage for objects of anot...
Definition Win.h:1703
heap_allocator< _Other > other
Other allocator type.
Definition Win.h:1704