From e44b53dcf6dc489efead250a932a10a104500473 Mon Sep 17 00:00:00 2001 From: rozmansi Date: Wed, 18 Oct 2023 10:37:22 +0000 Subject: [PATCH] deploy: f9090e02f44d67a1ea9223cb807cda3d603dc145 --- _c_o_m_8h_source.html | 1869 ++++----- _common_8h_source.html | 2861 +++++++------- _cred_8h_source.html | 4 +- _crypt_8h_source.html | 1126 +++--- _e_a_p_8h_source.html | 18 +- _e_t_w_8h_source.html | 22 +- _g_d_i_8h_source.html | 16 +- _m_s_i_8h_source.html | 4 +- _s_d_d_l_8h_source.html | 4 +- _sec_8h_source.html | 20 +- _setup_a_p_i_8h_source.html | 14 +- _shell_8h_source.html | 2 +- _w_l_a_n_8h_source.html | 236 +- _win_8h_source.html | 3374 +++++++++-------- _win_h_t_t_p_8h_source.html | 10 +- _win_sock2_8h_source.html | 18 +- _win_trust_8h_source.html | 8 +- annotated.html | 2 +- classes.html | 2 +- classwinstd_1_1actctx__activator-members.html | 2 +- classwinstd_1_1actctx__activator.html | 2 +- classwinstd_1_1addrinfo-members.html | 2 +- classwinstd_1_1addrinfo.html | 2 +- ...winstd_1_1basic__string__guid-members.html | 2 +- classwinstd_1_1basic__string__guid.html | 2 +- ...swinstd_1_1basic__string__msg-members.html | 2 +- classwinstd_1_1basic__string__msg.html | 2 +- ...nstd_1_1basic__string__printf-members.html | 2 +- classwinstd_1_1basic__string__printf.html | 2 +- classwinstd_1_1bstr-members.html | 2 +- classwinstd_1_1bstr.html | 2 +- ...instd_1_1cert__chain__context-members.html | 2 +- classwinstd_1_1cert__chain__context.html | 2 +- classwinstd_1_1cert__context-members.html | 2 +- classwinstd_1_1cert__context.html | 2 +- classwinstd_1_1cert__store-members.html | 2 +- classwinstd_1_1cert__store.html | 2 +- classwinstd_1_1clipboard__opener-members.html | 2 +- classwinstd_1_1clipboard__opener.html | 2 +- classwinstd_1_1com__initializer-members.html | 2 +- classwinstd_1_1com__initializer.html | 2 +- classwinstd_1_1com__obj-members.html | 2 +- classwinstd_1_1com__obj.html | 2 +- ...winstd_1_1com__runtime__error-members.html | 2 +- classwinstd_1_1com__runtime__error.html | 2 +- ...std_1_1console__ctrl__handler-members.html | 2 +- classwinstd_1_1console__ctrl__handler.html | 2 +- classwinstd_1_1critical__section-members.html | 2 +- classwinstd_1_1critical__section.html | 2 +- classwinstd_1_1crypt__hash-members.html | 2 +- classwinstd_1_1crypt__hash.html | 2 +- classwinstd_1_1crypt__key-members.html | 2 +- classwinstd_1_1crypt__key.html | 2 +- classwinstd_1_1crypt__prov-members.html | 2 +- classwinstd_1_1crypt__prov.html | 2 +- classwinstd_1_1data__blob-members.html | 2 +- classwinstd_1_1data__blob.html | 2 +- classwinstd_1_1dc-members.html | 2 +- classwinstd_1_1dc.html | 2 +- classwinstd_1_1dc__selector-members.html | 2 +- classwinstd_1_1dc__selector.html | 2 +- classwinstd_1_1dplhandle-members.html | 2 +- classwinstd_1_1dplhandle.html | 2 +- classwinstd_1_1eap__attr-members.html | 2 +- classwinstd_1_1eap__attr.html | 2 +- ...d_1_1eap__method__info__array-members.html | 2 +- classwinstd_1_1eap__method__info__array.html | 2 +- classwinstd_1_1eap__method__prop-members.html | 2 +- classwinstd_1_1eap__method__prop.html | 2 +- classwinstd_1_1eap__packet-members.html | 2 +- classwinstd_1_1eap__packet.html | 2 +- ...winstd_1_1eap__runtime__error-members.html | 2 +- classwinstd_1_1eap__runtime__error.html | 2 +- classwinstd_1_1event__data-members.html | 2 +- classwinstd_1_1event__data.html | 2 +- classwinstd_1_1event__fn__auto-members.html | 2 +- classwinstd_1_1event__fn__auto.html | 2 +- ...instd_1_1event__fn__auto__ret-members.html | 2 +- classwinstd_1_1event__fn__auto__ret.html | 2 +- classwinstd_1_1event__log-members.html | 2 +- classwinstd_1_1event__log.html | 2 +- classwinstd_1_1event__provider-members.html | 2 +- classwinstd_1_1event__provider.html | 2 +- classwinstd_1_1event__rec-members.html | 2 +- classwinstd_1_1event__rec.html | 2 +- classwinstd_1_1event__session-members.html | 2 +- classwinstd_1_1event__session.html | 2 +- classwinstd_1_1event__trace-members.html | 2 +- classwinstd_1_1event__trace.html | 2 +- ...nstd_1_1event__trace__enabler-members.html | 2 +- classwinstd_1_1event__trace__enabler.html | 2 +- classwinstd_1_1find__file-members.html | 2 +- classwinstd_1_1find__file.html | 2 +- classwinstd_1_1gdi__handle-members.html | 2 +- classwinstd_1_1gdi__handle.html | 2 +- ...winstd_1_1globalmem__accessor-members.html | 2 +- classwinstd_1_1globalmem__accessor.html | 2 +- classwinstd_1_1handle-members.html | 2 +- classwinstd_1_1handle.html | 2 +- classwinstd_1_1heap-members.html | 2 +- classwinstd_1_1heap.html | 2 +- classwinstd_1_1heap__allocator-members.html | 2 +- classwinstd_1_1heap__allocator.html | 2 +- classwinstd_1_1http-members.html | 2 +- classwinstd_1_1http.html | 2 +- classwinstd_1_1icon-members.html | 2 +- classwinstd_1_1icon.html | 2 +- classwinstd_1_1impersonator-members.html | 2 +- classwinstd_1_1impersonator.html | 2 +- classwinstd_1_1library-members.html | 2 +- classwinstd_1_1library.html | 2 +- ...winstd_1_1num__runtime__error-members.html | 2 +- classwinstd_1_1num__runtime__error.html | 2 +- ...instd_1_1process__information-members.html | 2 +- classwinstd_1_1process__information.html | 2 +- classwinstd_1_1ref__unique__ptr-members.html | 2 +- classwinstd_1_1ref__unique__ptr.html | 2 +- ...01___ty_0f_0e_00_01___dx_01_4-members.html | 2 +- ...__ptr_3_01___ty_0f_0e_00_01___dx_01_4.html | 2 +- classwinstd_1_1reg__key-members.html | 2 +- classwinstd_1_1reg__key.html | 2 +- classwinstd_1_1safearray-members.html | 2 +- classwinstd_1_1safearray.html | 2 +- ...winstd_1_1safearray__accessor-members.html | 2 +- classwinstd_1_1safearray__accessor.html | 2 +- ...nstd_1_1sanitizing__allocator-members.html | 2 +- classwinstd_1_1sanitizing__allocator.html | 2 +- classwinstd_1_1sanitizing__blob-members.html | 2 +- classwinstd_1_1sanitizing__blob.html | 2 +- classwinstd_1_1sc__handle-members.html | 2 +- classwinstd_1_1sc__handle.html | 2 +- classwinstd_1_1sec__buffer__desc-members.html | 2 +- classwinstd_1_1sec__buffer__desc.html | 2 +- classwinstd_1_1sec__context-members.html | 2 +- classwinstd_1_1sec__context.html | 2 +- classwinstd_1_1sec__credentials-members.html | 2 +- classwinstd_1_1sec__credentials.html | 2 +- ...winstd_1_1sec__runtime__error-members.html | 2 +- classwinstd_1_1sec__runtime__error.html | 2 +- ...instd_1_1security__attributes-members.html | 2 +- classwinstd_1_1security__attributes.html | 2 +- classwinstd_1_1security__id-members.html | 2 +- classwinstd_1_1security__id.html | 2 +- ..._1_1setup__device__info__list-members.html | 2 +- classwinstd_1_1setup__device__info__list.html | 2 +- ...__driver__info__list__builder-members.html | 2 +- ...1_1setup__driver__info__list__builder.html | 2 +- classwinstd_1_1string__guid-members.html | 2 +- classwinstd_1_1string__guid.html | 2 +- ...instd_1_1system__impersonator-members.html | 2 +- classwinstd_1_1system__impersonator.html | 2 +- ...swinstd_1_1user__impersonator-members.html | 2 +- classwinstd_1_1user__impersonator.html | 2 +- classwinstd_1_1variant-members.html | 2 +- classwinstd_1_1variant.html | 2 +- classwinstd_1_1vmemory-members.html | 2 +- classwinstd_1_1vmemory.html | 2 +- classwinstd_1_1waddrinfo-members.html | 2 +- classwinstd_1_1waddrinfo.html | 2 +- classwinstd_1_1win__handle-members.html | 2 +- classwinstd_1_1win__handle.html | 2 +- ...winstd_1_1win__runtime__error-members.html | 2 +- classwinstd_1_1win__runtime__error.html | 2 +- classwinstd_1_1window__dc-members.html | 2 +- classwinstd_1_1window__dc.html | 2 +- classwinstd_1_1wintrust-members.html | 2 +- classwinstd_1_1wintrust.html | 2 +- classwinstd_1_1wlan__handle-members.html | 2 +- classwinstd_1_1wlan__handle.html | 2 +- ...winstd_1_1ws2__runtime__error-members.html | 2 +- classwinstd_1_1ws2__runtime__error.html | 2 +- classwinstd_1_1wstring__guid-members.html | 2 +- classwinstd_1_1wstring__guid.html | 2 +- dir_4be4f7b278e009bf0f1906cf31fb73bd.html | 2 +- dir_6f50bb204833d887b928571856c82fbe.html | 2 +- dir_d44c64559bbebec7f509842c48db8b23.html | 2 +- files.html | 2 +- functions.html | 2 +- functions_a.html | 2 +- functions_b.html | 2 +- functions_c.html | 2 +- functions_d.html | 2 +- functions_e.html | 2 +- functions_f.html | 2 +- functions_func.html | 2 +- functions_func_b.html | 2 +- functions_func_c.html | 2 +- functions_func_d.html | 2 +- functions_func_e.html | 2 +- functions_func_f.html | 2 +- functions_func_g.html | 2 +- functions_func_h.html | 2 +- functions_func_i.html | 2 +- functions_func_l.html | 2 +- functions_func_m.html | 2 +- functions_func_n.html | 2 +- functions_func_o.html | 2 +- functions_func_p.html | 2 +- functions_func_q.html | 2 +- functions_func_r.html | 2 +- functions_func_s.html | 2 +- functions_func_t.html | 2 +- functions_func_u.html | 2 +- functions_func_v.html | 2 +- functions_func_w.html | 2 +- functions_func_~.html | 2 +- functions_g.html | 2 +- functions_h.html | 2 +- functions_i.html | 2 +- functions_l.html | 2 +- functions_m.html | 2 +- functions_n.html | 2 +- functions_o.html | 2 +- functions_p.html | 2 +- functions_q.html | 2 +- functions_r.html | 2 +- functions_s.html | 2 +- functions_t.html | 2 +- functions_type.html | 2 +- functions_u.html | 2 +- functions_v.html | 2 +- functions_vars.html | 2 +- functions_w.html | 2 +- functions_~.html | 2 +- group___setup_a_p_i.html | 2 +- group___win_sock2_a_p_i.html | 2 +- group___win_std_c_o_m.html | 2 +- group___win_std_cred_a_p_i.html | 2 +- group___win_std_crypto_a_p_i.html | 2 +- group___win_std_e_a_p_a_p_i.html | 2 +- group___win_std_e_t_w_a_p_i.html | 2 +- group___win_std_exceptions.html | 2 +- group___win_std_gdi_a_p_i.html | 2 +- group___win_std_general.html | 2 +- group___win_std_m_s_i_a_p_i.html | 2 +- group___win_std_mem_sanitize.html | 2 +- group___win_std_s_d_d_l.html | 2 +- group___win_std_security_a_p_i.html | 2 +- group___win_std_shell_w_a_p_i.html | 2 +- group___win_std_str_format.html | 4 +- group___win_std_sys_handles.html | 2 +- group___win_std_w_l_a_n_a_p_i.html | 2 +- group___win_std_win_a_p_i.html | 30 +- group___win_std_win_h_t_t_p.html | 2 +- group___win_trust_a_p_i.html | 2 +- hierarchy.html | 2 +- index.html | 10 +- md__s_e_c_u_r_i_t_y.html | 2 +- pages.html | 2 +- pch_8h_source.html | 2 +- search/all_5.js | 4 +- search/functions_4.js | 4 +- ..._1_1_co_task_mem_free__delete-members.html | 2 +- ...ctwinstd_1_1_co_task_mem_free__delete.html | 2 +- ...twinstd_1_1_cred_free__delete-members.html | 2 +- structwinstd_1_1_cred_free__delete.html | 2 +- ...ree__delete_3_01___ty_0f_0e_4-members.html | 2 +- ...1_cred_free__delete_3_01___ty_0f_0e_4.html | 2 +- ...t_peer_free_eap_error__delete-members.html | 2 +- ..._eap_host_peer_free_eap_error__delete.html | 2 +- ...eer_free_error_memory__delete-members.html | 2 +- ...p_host_peer_free_error_memory__delete.html | 2 +- ...host_peer_free_memory__delete-members.html | 2 +- ...1_1_eap_host_peer_free_memory__delete.html | 2 +- ...r_free_runtime_memory__delete-members.html | 2 +- ...host_peer_free_runtime_memory__delete.html | 2 +- ...instd_1_1_global_free__delete-members.html | 2 +- structwinstd_1_1_global_free__delete.html | 2 +- ...winstd_1_1_local_free__delete-members.html | 2 +- structwinstd_1_1_local_free__delete.html | 2 +- ...ree__delete_3_01___ty_0f_0e_4-members.html | 2 +- ..._local_free__delete_3_01___ty_0f_0e_4.html | 2 +- ..._1_unmap_view_of_file__delete-members.html | 2 +- ...winstd_1_1_unmap_view_of_file__delete.html | 2 +- ...ile__delete_3_01___ty_0f_0e_4-members.html | 2 +- ...iew_of_file__delete_3_01___ty_0f_0e_4.html | 2 +- ..._1_1_wlan_free_memory__delete-members.html | 2 +- ...ctwinstd_1_1_wlan_free_memory__delete.html | 2 +- ...ory__delete_3_01___ty_0f_0e_4-members.html | 2 +- ...free_memory__delete_3_01___ty_0f_0e_4.html | 2 +- ..._1_1heap__allocator_1_1rebind-members.html | 2 +- ...ctwinstd_1_1heap__allocator_1_1rebind.html | 2 +- ...nitizing__allocator_1_1rebind-members.html | 2 +- ...td_1_1sanitizing__allocator_1_1rebind.html | 2 +- topics.html | 2 +- 285 files changed, 5118 insertions(+), 5066 deletions(-) diff --git a/_c_o_m_8h_source.html b/_c_o_m_8h_source.html index 3507609d..680deb5e 100644 --- a/_c_o_m_8h_source.html +++ b/_c_o_m_8h_source.html @@ -250,860 +250,861 @@ $(document).ready(function() { init_codefold(0); });
226 bstr(_In_ const std::basic_string<OLECHAR, _Traits, _Ax> &src)
227 {
-
228 if (src.length() >= UINT_MAX)
-
229 throw std::invalid_argument("String too long");
-
230 m_h = SysAllocStringLen(src.c_str(), (UINT)src.length());
-
231 if (!m_h)
-
232 throw std::bad_alloc();
-
233 }
-
-
234
-
-
240 virtual ~bstr()
-
241 {
-
242 if (m_h != invalid)
- -
244 }
-
-
245
-
-
251 UINT length() const noexcept
-
252 {
-
253 return SysStringLen(m_h);
-
254 }
-
-
255
-
256 protected:
-
-
262 void free_internal() noexcept override
-
263 {
-
264 SysFreeString(m_h);
-
265 }
-
-
266
-
- -
277 {
-
278 handle_type h_new = SysAllocStringLen(h, SysStringLen(h));
-
279 if (h_new != invalid)
-
280 return h_new;
-
281 throw std::bad_alloc();
-
282 }
-
-
283 };
- -
284
-
288 #pragma warning(push)
-
289 #pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
-
-
290 class variant : public VARIANT
-
291 {
-
292 public:
-
-
296 variant() noexcept
-
297 {
-
298 VariantInit(this);
-
299 }
-
-
300
-
-
304 variant(_In_ const VARIANT& varSrc)
-
305 {
-
306 vt = VT_EMPTY;
-
307 const HRESULT hr = VariantCopy(this, &varSrc);
-
308 if (FAILED(hr))
-
309 throw winstd::com_runtime_error(hr, "VariantCopy failed");
-
310 }
-
-
311
-
315 #pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy()
-
-
316 variant(_Inout_ VARIANT&& varSrc) noexcept
-
317 {
-
318 memcpy(this, &varSrc, sizeof(VARIANT));
-
319 varSrc.vt = VT_EMPTY;
-
320 }
-
-
321
-
-
325 variant(_In_ bool bSrc) noexcept
-
326 {
-
327 vt = VT_BOOL;
-
328 boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
-
329 }
-
-
330
-
-
334 variant(_In_ char cSrc) noexcept
-
335 {
-
336 vt = VT_I1;
-
337 cVal = cSrc;
-
338 }
-
-
339
-
-
343 variant(_In_ unsigned char nSrc) noexcept
-
344 {
-
345 vt = VT_UI1;
-
346 bVal = nSrc;
-
347 }
-
-
348
-
-
352 variant(_In_ short nSrc) noexcept
-
353 {
-
354 vt = VT_I2;
-
355 iVal = nSrc;
-
356 }
-
-
357
-
-
361 variant(_In_ unsigned short nSrc) noexcept
-
362 {
-
363 vt = VT_UI2;
-
364 uiVal = nSrc;
-
365 }
-
-
366
-
-
370 variant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
-
371 {
-
372 assert(vtSrc == VT_I4 || vtSrc == VT_INT);
-
373 vt = vtSrc;
-
374 intVal = nSrc;
-
375 }
-
-
376
-
-
380 variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) noexcept
-
381 {
-
382 assert(vtSrc == VT_UI4 || vtSrc == VT_UINT);
-
383 vt = vtSrc;
-
384 uintVal= nSrc;
-
385 }
-
-
386
-
-
390 variant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
-
391 {
-
392 assert(vtSrc == VT_I4 || vtSrc == VT_ERROR);
-
393 vt = vtSrc;
-
394 lVal = nSrc;
-
395 }
-
-
396
-
-
400 variant(_In_ unsigned long nSrc) noexcept
-
401 {
-
402 vt = VT_UI4;
-
403 ulVal = nSrc;
-
404 }
-
-
405
-
-
409 variant(_In_ float fltSrc) noexcept
-
410 {
-
411 vt = VT_R4;
-
412 fltVal = fltSrc;
-
413 }
-
-
414
-
-
418 variant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) noexcept
-
419 {
-
420 assert(vtSrc == VT_R8 || vtSrc == VT_DATE);
-
421 vt = vtSrc;
-
422 dblVal = dblSrc;
-
423 }
-
-
424
-
-
428 variant(_In_ long long nSrc) noexcept
-
429 {
-
430 vt = VT_I8;
-
431 llVal = nSrc;
-
432 }
-
-
433
-
-
437 variant(_In_ unsigned long long nSrc) noexcept
-
438 {
-
439 vt = VT_UI8;
-
440 ullVal = nSrc;
-
441 }
-
-
442
-
-
446 variant(_In_ CY cySrc) noexcept
-
447 {
-
448 vt = VT_CY;
-
449 cyVal.Hi = cySrc.Hi;
-
450 cyVal.Lo = cySrc.Lo;
-
451 }
-
-
452
-
-
456 variant(_In_z_ LPCOLESTR lpszSrc) noexcept
-
457 {
-
458 vt = VT_EMPTY;
-
459 *this = lpszSrc;
-
460 }
-
-
461
-
-
465 variant(_In_z_ BSTR bstr) noexcept
-
466 {
-
467 vt = VT_EMPTY;
-
468 *this = bstr;
-
469 }
-
-
470
-
-
474 variant(_In_opt_ IDispatch* pSrc)
-
475 {
-
476 vt = VT_DISPATCH;
-
477 pdispVal = pSrc;
-
478
-
479 if (pdispVal != NULL)
-
480 pdispVal->AddRef();
-
481 }
-
-
482
-
-
486 variant(_In_opt_ IUnknown* pSrc)
-
487 {
-
488 vt = VT_UNKNOWN;
-
489 punkVal = pSrc;
-
490
-
491 if (punkVal != NULL)
-
492 punkVal->AddRef();
-
493 }
-
-
494
-
-
498 variant(_In_ const SAFEARRAY *pSrc)
-
499 {
-
500 assert(pSrc != NULL);
-
501
-
502 LPSAFEARRAY pCopy;
-
503 const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
-
504 if (FAILED(hr))
-
505 throw winstd::com_runtime_error(hr, "SafeArrayCopy failed");
-
506
-
507 SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
-
508 vt |= VT_ARRAY;
-
509 parray = pCopy;
-
510 }
-
-
511
-
-
515 virtual ~variant()
-
516 {
-
517 VariantClear(this);
-
518 }
-
-
519
-
-
523 variant& operator=(_In_ const VARIANT& varSrc)
-
524 {
-
525 if (this != &varSrc) {
-
526 const HRESULT hr = VariantCopy(this, &varSrc);
-
527 if (FAILED(hr))
-
528 throw winstd::com_runtime_error(hr, "VariantCopy failed");
-
529 }
-
530 return *this;
-
531 }
-
-
532
-
-
536 variant& operator=(_Inout_ VARIANT&& varSrc) noexcept
-
537 {
-
538 if (this != &varSrc) {
-
539 VariantClear(this);
-
540 memcpy(this, &varSrc, sizeof(VARIANT));
-
541 varSrc.vt = VT_EMPTY;
-
542 }
-
543 return *this;
-
544 }
-
-
545
-
-
549 variant& operator=(_In_ bool bSrc) noexcept
-
550 {
-
551 if (vt != VT_BOOL) {
-
552 VariantClear(this);
-
553 vt = VT_BOOL;
-
554 }
-
555 boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
-
556 return *this;
-
557 }
-
-
558
-
-
562 variant& operator=(_In_ char cSrc) noexcept
-
563 {
-
564 if (vt != VT_I1) {
-
565 VariantClear(this);
-
566 vt = VT_I1;
-
567 }
-
568 cVal = cSrc;
-
569 return *this;
-
570 }
-
-
571
-
-
575 variant& operator=(_In_ unsigned char nSrc) noexcept
-
576 {
-
577 if (vt != VT_UI1) {
-
578 VariantClear(this);
-
579 vt = VT_UI1;
-
580 }
-
581 bVal = nSrc;
-
582 return *this;
-
583 }
-
-
584
-
-
588 variant& operator=(_In_ short nSrc) noexcept
-
589 {
-
590 if (vt != VT_I2) {
-
591 VariantClear(this);
-
592 vt = VT_I2;
-
593 }
-
594 iVal = nSrc;
-
595 return *this;
-
596 }
-
-
597
-
-
601 variant& operator=(_In_ unsigned short nSrc) noexcept
-
602 {
-
603 if (vt != VT_UI2) {
-
604 VariantClear(this);
-
605 vt = VT_UI2;
-
606 }
-
607 uiVal = nSrc;
-
608 return *this;
-
609 }
-
-
610
-
-
614 variant& operator=(_In_ int nSrc) noexcept
-
615 {
-
616 if (vt != VT_I4) {
-
617 VariantClear(this);
-
618 vt = VT_I4;
-
619 }
-
620 intVal = nSrc;
-
621 return *this;
-
622 }
-
-
623
-
-
627 variant& operator=(_In_ unsigned int nSrc) noexcept
-
628 {
-
629 if (vt != VT_UI4) {
-
630 VariantClear(this);
-
631 vt = VT_UI4;
-
632 }
-
633 uintVal= nSrc;
-
634 return *this;
-
635 }
-
-
636
-
-
640 variant& operator=(_In_ long nSrc) noexcept
-
641 {
-
642 if (vt != VT_I4) {
-
643 VariantClear(this);
-
644 vt = VT_I4;
-
645 }
-
646 lVal = nSrc;
-
647 return *this;
-
648 }
-
-
649
-
-
653 variant& operator=(_In_ unsigned long nSrc) noexcept
-
654 {
-
655 if (vt != VT_UI4) {
-
656 VariantClear(this);
-
657 vt = VT_UI4;
-
658 }
-
659 ulVal = nSrc;
-
660 return *this;
-
661 }
-
-
662
-
-
666 variant& operator=(_In_ long long nSrc) noexcept
-
667 {
-
668 if (vt != VT_I8) {
-
669 VariantClear(this);
-
670 vt = VT_I8;
-
671 }
-
672 llVal = nSrc;
-
673 return *this;
-
674 }
-
-
675
-
-
679 variant& operator=(_In_ unsigned long long nSrc) noexcept
-
680 {
-
681 if (vt != VT_UI8) {
-
682 VariantClear(this);
-
683 vt = VT_UI8;
-
684 }
-
685 ullVal = nSrc;
-
686
-
687 return *this;
-
688 }
-
-
689
-
-
693 variant& operator=(_In_ float fltSrc) noexcept
-
694 {
-
695 if (vt != VT_R4) {
-
696 VariantClear(this);
-
697 vt = VT_R4;
-
698 }
-
699 fltVal = fltSrc;
-
700 return *this;
-
701 }
-
-
702
-
-
706 variant& operator=(_In_ double dblSrc) noexcept
-
707 {
-
708 if (vt != VT_R8) {
-
709 VariantClear(this);
-
710 vt = VT_R8;
-
711 }
-
712 dblVal = dblSrc;
-
713 return *this;
-
714 }
-
-
715
-
-
719 variant& operator=(_In_ CY cySrc) noexcept
-
720 {
-
721 if (vt != VT_CY) {
-
722 VariantClear(this);
-
723 vt = VT_CY;
-
724 }
-
725 cyVal.Hi = cySrc.Hi;
-
726 cyVal.Lo = cySrc.Lo;
-
727 return *this;
-
728 }
-
-
729
-
-
733 variant& operator=(_In_z_ LPCOLESTR lpszSrc) noexcept
-
734 {
-
735 VariantClear(this);
-
736 vt = VT_BSTR;
-
737 bstrVal = SysAllocString(lpszSrc);
-
738 return *this;
-
739 }
-
-
740
-
-
744 variant& operator=(_Inout_opt_ IDispatch* pSrc)
-
745 {
-
746 VariantClear(this);
-
747 vt = VT_DISPATCH;
-
748 pdispVal = pSrc;
-
749 if (pdispVal != NULL)
-
750 pdispVal->AddRef();
-
751 return *this;
-
752 }
-
-
753
-
-
757 variant& operator=(_Inout_opt_ IUnknown* pSrc)
-
758 {
-
759 VariantClear(this);
-
760 vt = VT_UNKNOWN;
-
761 punkVal = pSrc;
-
762 if (punkVal != NULL)
-
763 punkVal->AddRef();
-
764 return *this;
-
765 }
-
-
766
-
-
770 variant& operator=(_In_ unsigned char* pbSrc) noexcept
-
771 {
-
772 if (vt != (VT_UI1|VT_BYREF)) {
-
773 VariantClear(this);
-
774 vt = VT_UI1|VT_BYREF;
-
775 }
-
776 pbVal = pbSrc;
-
777 return *this;
-
778 }
-
-
779
-
-
783 variant& operator=(_In_ short* pnSrc) noexcept
-
784 {
-
785 if (vt != (VT_I2|VT_BYREF)) {
-
786 VariantClear(this);
-
787 vt = VT_I2|VT_BYREF;
-
788 }
-
789 piVal = pnSrc;
-
790 return *this;
-
791 }
-
-
792
-
-
796 variant& operator=(_In_ unsigned short* pnSrc) noexcept
-
797 {
-
798 if (vt != (VT_UI2|VT_BYREF)) {
-
799 VariantClear(this);
-
800 vt = VT_UI2|VT_BYREF;
-
801 }
-
802 puiVal = pnSrc;
-
803 return *this;
-
804 }
-
-
805
-
-
809 variant& operator=(_In_ int* pnSrc) noexcept
-
810 {
-
811 if (vt != (VT_I4|VT_BYREF)) {
-
812 VariantClear(this);
-
813 vt = VT_I4|VT_BYREF;
-
814 }
-
815 pintVal = pnSrc;
-
816 return *this;
-
817 }
-
-
818
-
-
822 variant& operator=(_In_ unsigned int* pnSrc) noexcept
-
823 {
-
824 if (vt != (VT_UI4|VT_BYREF)) {
-
825 VariantClear(this);
-
826 vt = VT_UI4|VT_BYREF;
-
827 }
-
828 puintVal = pnSrc;
-
829 return *this;
-
830 }
-
-
831
-
-
835 variant& operator=(_In_ long* pnSrc) noexcept
-
836 {
-
837 if (vt != (VT_I4|VT_BYREF)) {
-
838 VariantClear(this);
-
839 vt = VT_I4|VT_BYREF;
-
840 }
-
841 plVal = pnSrc;
-
842 return *this;
-
843 }
-
-
844
-
-
848 variant& operator=(_In_ unsigned long* pnSrc) noexcept
-
849 {
-
850 if (vt != (VT_UI4|VT_BYREF)) {
-
851 VariantClear(this);
-
852 vt = VT_UI4|VT_BYREF;
-
853 }
-
854 pulVal = pnSrc;
-
855 return *this;
-
856 }
-
-
857
-
-
861 variant& operator=(_In_ long long* pnSrc) noexcept
-
862 {
-
863 if (vt != (VT_I8|VT_BYREF)) {
-
864 VariantClear(this);
-
865 vt = VT_I8|VT_BYREF;
-
866 }
-
867 pllVal = pnSrc;
-
868 return *this;
-
869 }
-
-
870
-
-
874 variant& operator=(_In_ unsigned long long* pnSrc) noexcept
-
875 {
-
876 if (vt != (VT_UI8|VT_BYREF)) {
-
877 VariantClear(this);
-
878 vt = VT_UI8|VT_BYREF;
-
879 }
-
880 pullVal = pnSrc;
-
881 return *this;
-
882 }
-
-
883
-
-
887 variant& operator=(_In_ float* pfSrc) noexcept
-
888 {
-
889 if (vt != (VT_R4|VT_BYREF)) {
-
890 VariantClear(this);
-
891 vt = VT_R4|VT_BYREF;
-
892 }
-
893 pfltVal = pfSrc;
-
894 return *this;
-
895 }
-
-
896
-
-
900 variant& operator=(_In_ double* pfSrc) noexcept
-
901 {
-
902 if (vt != (VT_R8|VT_BYREF)) {
-
903 VariantClear(this);
-
904 vt = VT_R8|VT_BYREF;
-
905 }
-
906 pdblVal = pfSrc;
-
907 return *this;
-
908 }
-
-
909
-
-
913 variant& operator=(_In_ const SAFEARRAY *pSrc)
-
914 {
-
915 assert(pSrc != NULL);
-
916 VariantClear(this);
-
917
-
918 LPSAFEARRAY pCopy;
-
919 const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
-
920 if (SUCCEEDED(hr)) {
-
921 SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
-
922 vt |= VT_ARRAY;
-
923 parray = pCopy;
-
924 return *this;
-
925 }
-
926 throw com_runtime_error(hr, "SafeArrayCopy failed");
-
927 }
-
-
928
-
929 public:
-
-
938 bool operator==(_In_ const VARIANT& varSrc) const noexcept
-
939 {
-
940 if (vt == VT_NULL && varSrc.vt == VT_NULL) return true;
-
941 if (vt != varSrc.vt) return false;
-
942 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ);
-
943 }
-
-
944
-
-
953 bool operator!=(_In_ const VARIANT& varSrc) const noexcept
-
954 {
-
955 return !operator==(varSrc);
-
956 }
-
-
957
-
-
966 bool operator<(_In_ const VARIANT& varSrc) const noexcept
-
967 {
-
968 if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
-
969 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_LT);
-
970 }
-
-
971
-
-
980 bool operator>(_In_ const VARIANT& varSrc) const noexcept
-
981 {
-
982 if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
-
983 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_GT);
-
984 }
-
-
985
-
-
994 bool operator<=(_In_ const VARIANT& varSrc) const noexcept
-
995 {
-
996 return !operator>(varSrc);
-
997 }
-
-
998
-
-
1007 bool operator>=(_In_ const VARIANT& varSrc) const noexcept
-
1008 {
-
1009 return !operator<(varSrc);
-
1010 }
-
-
1011
-
-
1017 HRESULT change_type(_In_ VARTYPE _vt, _In_opt_ USHORT wFlags = 0) noexcept
-
1018 {
-
1019 return VariantChangeType(this, this, wFlags, _vt);
-
1020 }
-
-
1021
-
1022 private:
-
1024 HRESULT compare(_In_ const VARIANT &varLeft, _In_ const VARIANT &varRight, _In_ LCID lcid, _In_ ULONG dwFlags) const noexcept
-
1025 {
-
1026 switch(vt) {
-
1027 case VT_I1: return varLeft.cVal == varRight.cVal ? VARCMP_EQ : varLeft.cVal > varRight.cVal ? VARCMP_GT : VARCMP_LT;
-
1028 case VT_UI2: return varLeft.uiVal == varRight.uiVal ? VARCMP_EQ : varLeft.uiVal > varRight.uiVal ? VARCMP_GT : VARCMP_LT;
-
1029 case VT_UI4: return varLeft.uintVal == varRight.uintVal ? VARCMP_EQ : varLeft.uintVal > varRight.uintVal ? VARCMP_GT : VARCMP_LT;
-
1030 case VT_UI8: return varLeft.ullVal == varRight.ullVal ? VARCMP_EQ : varLeft.ullVal > varRight.ullVal ? VARCMP_GT : VARCMP_LT;
-
1031 default: return VarCmp(const_cast<LPVARIANT>(&varLeft), const_cast<LPVARIANT>(&varRight), lcid, dwFlags);
-
1032 }
-
1033 }
-
1035 };
-
-
1036 #pragma warning(pop)
-
1037
-
-
1041 class safearray : public dplhandle<SAFEARRAY*, NULL>
-
1042 {
- -
1044
-
1045 public:
-
-
1051 virtual ~safearray()
-
1052 {
-
1053 if (m_h != invalid)
-
1054 free_internal();
-
1055 }
-
-
1056
-
1057 protected:
-
-
1063 void free_internal() noexcept override
-
1064 {
-
1065 SafeArrayDestroy(m_h);
-
1066 }
-
-
1067
-
- -
1078 {
-
1079 handle_type h_new;
-
1080 HRESULT hr = SafeArrayCopy(h, &h_new);
-
1081 if (SUCCEEDED(hr))
-
1082 return h_new;
-
1083 throw com_runtime_error(hr, "SafeArrayCopy failed");
-
1084 }
-
-
1085 };
-
-
1086
-
1090 template <class T>
-
- -
1092 {
- - -
1095
-
1096 public:
-
-
1102 safearray_accessor(_In_ SAFEARRAY* psa) : m_sa(psa)
-
1103 {
-
1104 HRESULT hr = SafeArrayAccessData(psa, (void HUGEP**)&m_data);
-
1105 if (FAILED(hr))
-
1106 throw com_runtime_error(hr, "SafeArrayAccessData failed");
-
1107 }
-
-
1108
-
- -
1115 {
-
1116 SafeArrayUnaccessData(m_sa);
-
1117 }
-
-
1118
-
-
1122 T HUGEP* data() const noexcept
-
1123 {
-
1124 return m_data;
-
1125 }
-
-
1126
-
1127 protected:
-
1128 SAFEARRAY* m_sa;
-
1129 T HUGEP* m_data;
-
1130 };
-
-
1131
-
- -
1136 {
- - -
1139
-
1140 public:
-
-
1146 com_initializer(_In_opt_ LPVOID pvReserved) noexcept
-
1147 {
-
1148 m_result = CoInitialize(pvReserved);
-
1149 }
-
-
1150
-
-
1156 com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit) noexcept
-
1157 {
-
1158 m_result = CoInitializeEx(pvReserved, dwCoInit);
-
1159 }
-
-
1160
-
- -
1167 {
-
1168 if (SUCCEEDED(m_result))
-
1169 CoUninitialize();
-
1170 }
-
-
1171
-
-
1177 HRESULT status() const noexcept
-
1178 {
-
1179 return m_result;
-
1180 }
-
-
1181
-
1182 protected:
-
1183 HRESULT m_result;
-
1184 };
-
-
1185
-
1187}
-
1188
-
1191
-
1197template <class T>
-
-
1198static _Check_return_ HRESULT CoCreateInstance(_In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _Inout_ winstd::com_obj<T> &v)
-
1199{
-
1200 T* ppv;
-
1201 HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (LPVOID*)&ppv);
-
1202 if (SUCCEEDED(hr))
-
1203 v.attach(ppv);
-
1204 return hr;
-
1205}
-
-
1206
-
1212template <class T>
-
-
1213static _Check_return_ HRESULT CoGetObject(_In_ LPCWSTR pszName, _In_opt_ BIND_OPTS* pBindOptions, _In_ REFIID riid, _Inout_ winstd::com_obj<T>& v)
-
1214{
-
1215 T* ppv;
-
1216 HRESULT hr = CoGetObject(pszName, pBindOptions, riid, (LPVOID*)&ppv);
-
1217 if (SUCCEEDED(hr))
-
1218 v.attach(ppv);
-
1219 return hr;
-
1220}
-
-
1221
+
228 size_t len = src.length();
+
229 if (len > UINT_MAX)
+
230 throw std::invalid_argument("string too long");
+
231 m_h = SysAllocStringLen(src.c_str(), static_cast<UINT>(len));
+
232 if (!m_h)
+
233 throw std::bad_alloc();
+
234 }
+ +
235
+
+
241 virtual ~bstr()
+
242 {
+
243 if (m_h != invalid)
+ +
245 }
+
+
246
+
+
252 UINT length() const noexcept
+
253 {
+
254 return SysStringLen(m_h);
+
255 }
+
+
256
+
257 protected:
+
+
263 void free_internal() noexcept override
+
264 {
+
265 SysFreeString(m_h);
+
266 }
+
+
267
+
+ +
278 {
+
279 handle_type h_new = SysAllocStringLen(h, SysStringLen(h));
+
280 if (h_new != invalid)
+
281 return h_new;
+
282 throw std::bad_alloc();
+
283 }
+
+
284 };
+ +
285
+
289 #pragma warning(push)
+
290 #pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
+
+
291 class variant : public VARIANT
+
292 {
+
293 public:
+
+
297 variant() noexcept
+
298 {
+
299 VariantInit(this);
+
300 }
+
+
301
+
+
305 variant(_In_ const VARIANT& varSrc)
+
306 {
+
307 vt = VT_EMPTY;
+
308 const HRESULT hr = VariantCopy(this, &varSrc);
+
309 if (FAILED(hr))
+
310 throw winstd::com_runtime_error(hr, "VariantCopy failed");
+
311 }
+
+
312
+
316 #pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy()
+
+
317 variant(_Inout_ VARIANT&& varSrc) noexcept
+
318 {
+
319 memcpy(this, &varSrc, sizeof(VARIANT));
+
320 varSrc.vt = VT_EMPTY;
+
321 }
+
+
322
+
+
326 variant(_In_ bool bSrc) noexcept
+
327 {
+
328 vt = VT_BOOL;
+
329 boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
+
330 }
+
+
331
+
+
335 variant(_In_ char cSrc) noexcept
+
336 {
+
337 vt = VT_I1;
+
338 cVal = cSrc;
+
339 }
+
+
340
+
+
344 variant(_In_ unsigned char nSrc) noexcept
+
345 {
+
346 vt = VT_UI1;
+
347 bVal = nSrc;
+
348 }
+
+
349
+
+
353 variant(_In_ short nSrc) noexcept
+
354 {
+
355 vt = VT_I2;
+
356 iVal = nSrc;
+
357 }
+
+
358
+
+
362 variant(_In_ unsigned short nSrc) noexcept
+
363 {
+
364 vt = VT_UI2;
+
365 uiVal = nSrc;
+
366 }
+
+
367
+
+
371 variant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
+
372 {
+
373 assert(vtSrc == VT_I4 || vtSrc == VT_INT);
+
374 vt = vtSrc;
+
375 intVal = nSrc;
+
376 }
+
+
377
+
+
381 variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) noexcept
+
382 {
+
383 assert(vtSrc == VT_UI4 || vtSrc == VT_UINT);
+
384 vt = vtSrc;
+
385 uintVal= nSrc;
+
386 }
+
+
387
+
+
391 variant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
+
392 {
+
393 assert(vtSrc == VT_I4 || vtSrc == VT_ERROR);
+
394 vt = vtSrc;
+
395 lVal = nSrc;
+
396 }
+
+
397
+
+
401 variant(_In_ unsigned long nSrc) noexcept
+
402 {
+
403 vt = VT_UI4;
+
404 ulVal = nSrc;
+
405 }
+
+
406
+
+
410 variant(_In_ float fltSrc) noexcept
+
411 {
+
412 vt = VT_R4;
+
413 fltVal = fltSrc;
+
414 }
+
+
415
+
+
419 variant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) noexcept
+
420 {
+
421 assert(vtSrc == VT_R8 || vtSrc == VT_DATE);
+
422 vt = vtSrc;
+
423 dblVal = dblSrc;
+
424 }
+
+
425
+
+
429 variant(_In_ long long nSrc) noexcept
+
430 {
+
431 vt = VT_I8;
+
432 llVal = nSrc;
+
433 }
+
+
434
+
+
438 variant(_In_ unsigned long long nSrc) noexcept
+
439 {
+
440 vt = VT_UI8;
+
441 ullVal = nSrc;
+
442 }
+
+
443
+
+
447 variant(_In_ CY cySrc) noexcept
+
448 {
+
449 vt = VT_CY;
+
450 cyVal.Hi = cySrc.Hi;
+
451 cyVal.Lo = cySrc.Lo;
+
452 }
+
+
453
+
+
457 variant(_In_z_ LPCOLESTR lpszSrc) noexcept
+
458 {
+
459 vt = VT_EMPTY;
+
460 *this = lpszSrc;
+
461 }
+
+
462
+
+
466 variant(_In_z_ BSTR bstr) noexcept
+
467 {
+
468 vt = VT_EMPTY;
+
469 *this = bstr;
+
470 }
+
+
471
+
+
475 variant(_In_opt_ IDispatch* pSrc)
+
476 {
+
477 vt = VT_DISPATCH;
+
478 pdispVal = pSrc;
+
479
+
480 if (pdispVal != NULL)
+
481 pdispVal->AddRef();
+
482 }
+
+
483
+
+
487 variant(_In_opt_ IUnknown* pSrc)
+
488 {
+
489 vt = VT_UNKNOWN;
+
490 punkVal = pSrc;
+
491
+
492 if (punkVal != NULL)
+
493 punkVal->AddRef();
+
494 }
+
+
495
+
+
499 variant(_In_ const SAFEARRAY *pSrc)
+
500 {
+
501 assert(pSrc != NULL);
+
502
+
503 LPSAFEARRAY pCopy;
+
504 const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
+
505 if (FAILED(hr))
+
506 throw winstd::com_runtime_error(hr, "SafeArrayCopy failed");
+
507
+
508 SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
+
509 vt |= VT_ARRAY;
+
510 parray = pCopy;
+
511 }
+
+
512
+
+
516 virtual ~variant()
+
517 {
+
518 VariantClear(this);
+
519 }
+
+
520
+
+
524 variant& operator=(_In_ const VARIANT& varSrc)
+
525 {
+
526 if (this != &varSrc) {
+
527 const HRESULT hr = VariantCopy(this, &varSrc);
+
528 if (FAILED(hr))
+
529 throw winstd::com_runtime_error(hr, "VariantCopy failed");
+
530 }
+
531 return *this;
+
532 }
+
+
533
+
+
537 variant& operator=(_Inout_ VARIANT&& varSrc) noexcept
+
538 {
+
539 if (this != &varSrc) {
+
540 VariantClear(this);
+
541 memcpy(this, &varSrc, sizeof(VARIANT));
+
542 varSrc.vt = VT_EMPTY;
+
543 }
+
544 return *this;
+
545 }
+
+
546
+
+
550 variant& operator=(_In_ bool bSrc) noexcept
+
551 {
+
552 if (vt != VT_BOOL) {
+
553 VariantClear(this);
+
554 vt = VT_BOOL;
+
555 }
+
556 boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
+
557 return *this;
+
558 }
+
+
559
+
+
563 variant& operator=(_In_ char cSrc) noexcept
+
564 {
+
565 if (vt != VT_I1) {
+
566 VariantClear(this);
+
567 vt = VT_I1;
+
568 }
+
569 cVal = cSrc;
+
570 return *this;
+
571 }
+
+
572
+
+
576 variant& operator=(_In_ unsigned char nSrc) noexcept
+
577 {
+
578 if (vt != VT_UI1) {
+
579 VariantClear(this);
+
580 vt = VT_UI1;
+
581 }
+
582 bVal = nSrc;
+
583 return *this;
+
584 }
+
+
585
+
+
589 variant& operator=(_In_ short nSrc) noexcept
+
590 {
+
591 if (vt != VT_I2) {
+
592 VariantClear(this);
+
593 vt = VT_I2;
+
594 }
+
595 iVal = nSrc;
+
596 return *this;
+
597 }
+
+
598
+
+
602 variant& operator=(_In_ unsigned short nSrc) noexcept
+
603 {
+
604 if (vt != VT_UI2) {
+
605 VariantClear(this);
+
606 vt = VT_UI2;
+
607 }
+
608 uiVal = nSrc;
+
609 return *this;
+
610 }
+
+
611
+
+
615 variant& operator=(_In_ int nSrc) noexcept
+
616 {
+
617 if (vt != VT_I4) {
+
618 VariantClear(this);
+
619 vt = VT_I4;
+
620 }
+
621 intVal = nSrc;
+
622 return *this;
+
623 }
+
+
624
+
+
628 variant& operator=(_In_ unsigned int nSrc) noexcept
+
629 {
+
630 if (vt != VT_UI4) {
+
631 VariantClear(this);
+
632 vt = VT_UI4;
+
633 }
+
634 uintVal= nSrc;
+
635 return *this;
+
636 }
+
+
637
+
+
641 variant& operator=(_In_ long nSrc) noexcept
+
642 {
+
643 if (vt != VT_I4) {
+
644 VariantClear(this);
+
645 vt = VT_I4;
+
646 }
+
647 lVal = nSrc;
+
648 return *this;
+
649 }
+
+
650
+
+
654 variant& operator=(_In_ unsigned long nSrc) noexcept
+
655 {
+
656 if (vt != VT_UI4) {
+
657 VariantClear(this);
+
658 vt = VT_UI4;
+
659 }
+
660 ulVal = nSrc;
+
661 return *this;
+
662 }
+
+
663
+
+
667 variant& operator=(_In_ long long nSrc) noexcept
+
668 {
+
669 if (vt != VT_I8) {
+
670 VariantClear(this);
+
671 vt = VT_I8;
+
672 }
+
673 llVal = nSrc;
+
674 return *this;
+
675 }
+
+
676
+
+
680 variant& operator=(_In_ unsigned long long nSrc) noexcept
+
681 {
+
682 if (vt != VT_UI8) {
+
683 VariantClear(this);
+
684 vt = VT_UI8;
+
685 }
+
686 ullVal = nSrc;
+
687
+
688 return *this;
+
689 }
+
+
690
+
+
694 variant& operator=(_In_ float fltSrc) noexcept
+
695 {
+
696 if (vt != VT_R4) {
+
697 VariantClear(this);
+
698 vt = VT_R4;
+
699 }
+
700 fltVal = fltSrc;
+
701 return *this;
+
702 }
+
+
703
+
+
707 variant& operator=(_In_ double dblSrc) noexcept
+
708 {
+
709 if (vt != VT_R8) {
+
710 VariantClear(this);
+
711 vt = VT_R8;
+
712 }
+
713 dblVal = dblSrc;
+
714 return *this;
+
715 }
+
+
716
+
+
720 variant& operator=(_In_ CY cySrc) noexcept
+
721 {
+
722 if (vt != VT_CY) {
+
723 VariantClear(this);
+
724 vt = VT_CY;
+
725 }
+
726 cyVal.Hi = cySrc.Hi;
+
727 cyVal.Lo = cySrc.Lo;
+
728 return *this;
+
729 }
+
+
730
+
+
734 variant& operator=(_In_z_ LPCOLESTR lpszSrc) noexcept
+
735 {
+
736 VariantClear(this);
+
737 vt = VT_BSTR;
+
738 bstrVal = SysAllocString(lpszSrc);
+
739 return *this;
+
740 }
+
+
741
+
+
745 variant& operator=(_Inout_opt_ IDispatch* pSrc)
+
746 {
+
747 VariantClear(this);
+
748 vt = VT_DISPATCH;
+
749 pdispVal = pSrc;
+
750 if (pdispVal != NULL)
+
751 pdispVal->AddRef();
+
752 return *this;
+
753 }
+
+
754
+
+
758 variant& operator=(_Inout_opt_ IUnknown* pSrc)
+
759 {
+
760 VariantClear(this);
+
761 vt = VT_UNKNOWN;
+
762 punkVal = pSrc;
+
763 if (punkVal != NULL)
+
764 punkVal->AddRef();
+
765 return *this;
+
766 }
+
+
767
+
+
771 variant& operator=(_In_ unsigned char* pbSrc) noexcept
+
772 {
+
773 if (vt != (VT_UI1|VT_BYREF)) {
+
774 VariantClear(this);
+
775 vt = VT_UI1|VT_BYREF;
+
776 }
+
777 pbVal = pbSrc;
+
778 return *this;
+
779 }
+
+
780
+
+
784 variant& operator=(_In_ short* pnSrc) noexcept
+
785 {
+
786 if (vt != (VT_I2|VT_BYREF)) {
+
787 VariantClear(this);
+
788 vt = VT_I2|VT_BYREF;
+
789 }
+
790 piVal = pnSrc;
+
791 return *this;
+
792 }
+
+
793
+
+
797 variant& operator=(_In_ unsigned short* pnSrc) noexcept
+
798 {
+
799 if (vt != (VT_UI2|VT_BYREF)) {
+
800 VariantClear(this);
+
801 vt = VT_UI2|VT_BYREF;
+
802 }
+
803 puiVal = pnSrc;
+
804 return *this;
+
805 }
+
+
806
+
+
810 variant& operator=(_In_ int* pnSrc) noexcept
+
811 {
+
812 if (vt != (VT_I4|VT_BYREF)) {
+
813 VariantClear(this);
+
814 vt = VT_I4|VT_BYREF;
+
815 }
+
816 pintVal = pnSrc;
+
817 return *this;
+
818 }
+
+
819
+
+
823 variant& operator=(_In_ unsigned int* pnSrc) noexcept
+
824 {
+
825 if (vt != (VT_UI4|VT_BYREF)) {
+
826 VariantClear(this);
+
827 vt = VT_UI4|VT_BYREF;
+
828 }
+
829 puintVal = pnSrc;
+
830 return *this;
+
831 }
+
+
832
+
+
836 variant& operator=(_In_ long* pnSrc) noexcept
+
837 {
+
838 if (vt != (VT_I4|VT_BYREF)) {
+
839 VariantClear(this);
+
840 vt = VT_I4|VT_BYREF;
+
841 }
+
842 plVal = pnSrc;
+
843 return *this;
+
844 }
+
+
845
+
+
849 variant& operator=(_In_ unsigned long* pnSrc) noexcept
+
850 {
+
851 if (vt != (VT_UI4|VT_BYREF)) {
+
852 VariantClear(this);
+
853 vt = VT_UI4|VT_BYREF;
+
854 }
+
855 pulVal = pnSrc;
+
856 return *this;
+
857 }
+
+
858
+
+
862 variant& operator=(_In_ long long* pnSrc) noexcept
+
863 {
+
864 if (vt != (VT_I8|VT_BYREF)) {
+
865 VariantClear(this);
+
866 vt = VT_I8|VT_BYREF;
+
867 }
+
868 pllVal = pnSrc;
+
869 return *this;
+
870 }
+
+
871
+
+
875 variant& operator=(_In_ unsigned long long* pnSrc) noexcept
+
876 {
+
877 if (vt != (VT_UI8|VT_BYREF)) {
+
878 VariantClear(this);
+
879 vt = VT_UI8|VT_BYREF;
+
880 }
+
881 pullVal = pnSrc;
+
882 return *this;
+
883 }
+
+
884
+
+
888 variant& operator=(_In_ float* pfSrc) noexcept
+
889 {
+
890 if (vt != (VT_R4|VT_BYREF)) {
+
891 VariantClear(this);
+
892 vt = VT_R4|VT_BYREF;
+
893 }
+
894 pfltVal = pfSrc;
+
895 return *this;
+
896 }
+
+
897
+
+
901 variant& operator=(_In_ double* pfSrc) noexcept
+
902 {
+
903 if (vt != (VT_R8|VT_BYREF)) {
+
904 VariantClear(this);
+
905 vt = VT_R8|VT_BYREF;
+
906 }
+
907 pdblVal = pfSrc;
+
908 return *this;
+
909 }
+
+
910
+
+
914 variant& operator=(_In_ const SAFEARRAY *pSrc)
+
915 {
+
916 assert(pSrc != NULL);
+
917 VariantClear(this);
+
918
+
919 LPSAFEARRAY pCopy;
+
920 const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
+
921 if (SUCCEEDED(hr)) {
+
922 SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
+
923 vt |= VT_ARRAY;
+
924 parray = pCopy;
+
925 return *this;
+
926 }
+
927 throw com_runtime_error(hr, "SafeArrayCopy failed");
+
928 }
+
+
929
+
930 public:
+
+
939 bool operator==(_In_ const VARIANT& varSrc) const noexcept
+
940 {
+
941 if (vt == VT_NULL && varSrc.vt == VT_NULL) return true;
+
942 if (vt != varSrc.vt) return false;
+
943 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ);
+
944 }
+
+
945
+
+
954 bool operator!=(_In_ const VARIANT& varSrc) const noexcept
+
955 {
+
956 return !operator==(varSrc);
+
957 }
+
+
958
+
+
967 bool operator<(_In_ const VARIANT& varSrc) const noexcept
+
968 {
+
969 if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
+
970 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_LT);
+
971 }
+
+
972
+
+
981 bool operator>(_In_ const VARIANT& varSrc) const noexcept
+
982 {
+
983 if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
+
984 return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_GT);
+
985 }
+
+
986
+
+
995 bool operator<=(_In_ const VARIANT& varSrc) const noexcept
+
996 {
+
997 return !operator>(varSrc);
+
998 }
+
+
999
+
+
1008 bool operator>=(_In_ const VARIANT& varSrc) const noexcept
+
1009 {
+
1010 return !operator<(varSrc);
+
1011 }
+
+
1012
+
+
1018 HRESULT change_type(_In_ VARTYPE _vt, _In_opt_ USHORT wFlags = 0) noexcept
+
1019 {
+
1020 return VariantChangeType(this, this, wFlags, _vt);
+
1021 }
+
+
1022
+
1023 private:
+
1025 HRESULT compare(_In_ const VARIANT &varLeft, _In_ const VARIANT &varRight, _In_ LCID lcid, _In_ ULONG dwFlags) const noexcept
+
1026 {
+
1027 switch(vt) {
+
1028 case VT_I1: return varLeft.cVal == varRight.cVal ? VARCMP_EQ : varLeft.cVal > varRight.cVal ? VARCMP_GT : VARCMP_LT;
+
1029 case VT_UI2: return varLeft.uiVal == varRight.uiVal ? VARCMP_EQ : varLeft.uiVal > varRight.uiVal ? VARCMP_GT : VARCMP_LT;
+
1030 case VT_UI4: return varLeft.uintVal == varRight.uintVal ? VARCMP_EQ : varLeft.uintVal > varRight.uintVal ? VARCMP_GT : VARCMP_LT;
+
1031 case VT_UI8: return varLeft.ullVal == varRight.ullVal ? VARCMP_EQ : varLeft.ullVal > varRight.ullVal ? VARCMP_GT : VARCMP_LT;
+
1032 default: return VarCmp(const_cast<LPVARIANT>(&varLeft), const_cast<LPVARIANT>(&varRight), lcid, dwFlags);
+
1033 }
+
1034 }
+
1036 };
+
+
1037 #pragma warning(pop)
+
1038
+
+
1042 class safearray : public dplhandle<SAFEARRAY*, NULL>
+
1043 {
+ +
1045
+
1046 public:
+
+
1052 virtual ~safearray()
+
1053 {
+
1054 if (m_h != invalid)
+
1055 free_internal();
+
1056 }
+
+
1057
+
1058 protected:
+
+
1064 void free_internal() noexcept override
+
1065 {
+
1066 SafeArrayDestroy(m_h);
+
1067 }
+
+
1068
+
+ +
1079 {
+
1080 handle_type h_new;
+
1081 HRESULT hr = SafeArrayCopy(h, &h_new);
+
1082 if (SUCCEEDED(hr))
+
1083 return h_new;
+
1084 throw com_runtime_error(hr, "SafeArrayCopy failed");
+
1085 }
+
+
1086 };
+
+
1087
+
1091 template <class T>
+
+ +
1093 {
+ + +
1096
+
1097 public:
+
+
1103 safearray_accessor(_In_ SAFEARRAY* psa) : m_sa(psa)
+
1104 {
+
1105 HRESULT hr = SafeArrayAccessData(psa, (void HUGEP**)&m_data);
+
1106 if (FAILED(hr))
+
1107 throw com_runtime_error(hr, "SafeArrayAccessData failed");
+
1108 }
+
+
1109
+
+ +
1116 {
+
1117 SafeArrayUnaccessData(m_sa);
+
1118 }
+
+
1119
+
+
1123 T HUGEP* data() const noexcept
+
1124 {
+
1125 return m_data;
+
1126 }
+
+
1127
+
1128 protected:
+
1129 SAFEARRAY* m_sa;
+
1130 T HUGEP* m_data;
+
1131 };
+
+
1132
+
+ +
1137 {
+ + +
1140
+
1141 public:
+
+
1147 com_initializer(_In_opt_ LPVOID pvReserved) noexcept
+
1148 {
+
1149 m_result = CoInitialize(pvReserved);
+
1150 }
+
+
1151
+
+
1157 com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit) noexcept
+
1158 {
+
1159 m_result = CoInitializeEx(pvReserved, dwCoInit);
+
1160 }
+
+
1161
+
+ +
1168 {
+
1169 if (SUCCEEDED(m_result))
+
1170 CoUninitialize();
+
1171 }
+
+
1172
+
+
1178 HRESULT status() const noexcept
+
1179 {
+
1180 return m_result;
+
1181 }
+
+
1182
+
1183 protected:
+
1184 HRESULT m_result;
+
1185 };
+
+
1186
+
1188}
+
1189
+
1192
+
1198template <class T>
+
+
1199static _Check_return_ HRESULT CoCreateInstance(_In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _Inout_ winstd::com_obj<T> &v)
+
1200{
+
1201 T* ppv;
+
1202 HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (LPVOID*)&ppv);
+
1203 if (SUCCEEDED(hr))
+
1204 v.attach(ppv);
+
1205 return hr;
+
1206}
+
+
1207
+
1213template <class T>
+
+
1214static _Check_return_ HRESULT CoGetObject(_In_ LPCWSTR pszName, _In_opt_ BIND_OPTS* pBindOptions, _In_ REFIID riid, _Inout_ winstd::com_obj<T>& v)
+
1215{
+
1216 T* ppv;
+
1217 HRESULT hr = CoGetObject(pszName, pBindOptions, riid, (LPVOID*)&ppv);
+
1218 if (SUCCEEDED(hr))
+
1219 v.attach(ppv);
+
1220 return hr;
+
1221}
+
+
1222
BSTR string wrapper.
Definition COM.h:198
bstr(LPCOLESTR src)
Constructs BSTR from OLE string.
Definition COM.h:205
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the string.
Definition COM.h:276
-
virtual ~bstr()
Destroys the string.
Definition COM.h:240
-
void free_internal() noexcept override
Destroys the string.
Definition COM.h:262
-
UINT length() const noexcept
Returns the length of the string.
Definition COM.h:251
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the string.
Definition COM.h:277
+
virtual ~bstr()
Destroys the string.
Definition COM.h:241
+
void free_internal() noexcept override
Destroys the string.
Definition COM.h:263
+
UINT length() const noexcept
Returns the length of the string.
Definition COM.h:252
bstr(LPCOLESTR src, UINT len)
Constructs BSTR from OLE string with length.
Definition COM.h:215
bstr(const std::basic_string< OLECHAR, _Traits, _Ax > &src)
Constructs BSTR from std::basic_string.
Definition COM.h:226
-
Context scope automatic COM (un)initialization.
Definition COM.h:1136
-
com_initializer(LPVOID pvReserved, DWORD dwCoInit) noexcept
Initializes the COM library for use by the calling thread, sets the thread's concurrency model,...
Definition COM.h:1156
-
com_initializer(LPVOID pvReserved) noexcept
Initializes the COM library on the current thread and identifies the concurrency model as single-thre...
Definition COM.h:1146
-
HRESULT status() const noexcept
Return result of CoInitialize() call.
Definition COM.h:1177
-
virtual ~com_initializer()
Uninitializes COM.
Definition COM.h:1166
-
HRESULT m_result
Result of CoInitialize call.
Definition COM.h:1183
+
Context scope automatic COM (un)initialization.
Definition COM.h:1137
+
com_initializer(LPVOID pvReserved, DWORD dwCoInit) noexcept
Initializes the COM library for use by the calling thread, sets the thread's concurrency model,...
Definition COM.h:1157
+
com_initializer(LPVOID pvReserved) noexcept
Initializes the COM library on the current thread and identifies the concurrency model as single-thre...
Definition COM.h:1147
+
HRESULT status() const noexcept
Return result of CoInitialize() call.
Definition COM.h:1178
+
virtual ~com_initializer()
Uninitializes COM.
Definition COM.h:1167
+
HRESULT m_result
Result of CoInitialize call.
Definition COM.h:1184
COM object wrapper template.
Definition COM.h:83
void free_internal() noexcept override
Releases the object by decrementing reference counter.
Definition COM.h:173
com_obj(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext)
Creates a new instance of a class.
Definition COM.h:92
@@ -1116,96 +1117,96 @@ $(document).ready(function() { init_codefold(0); });
COM runtime error.
Definition COM.h:26
com_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition COM.h:34
com_runtime_error(error_type num, const char *msg=nullptr)
Constructs an exception.
Definition COM.h:44
-
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1248
-
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
Numerical runtime error.
Definition Common.h:1446
-
HRESULT error_type
Error number type.
Definition Common.h:1448
-
Context scope automatic SAFEARRAY (un)access.
Definition COM.h:1092
-
safearray_accessor(SAFEARRAY *psa)
Increments the lock count of an array, and retrieves a pointer to the array data.
Definition COM.h:1102
-
T HUGEP * data() const noexcept
Return SAFEARRAY data pointer.
Definition COM.h:1122
-
SAFEARRAY * m_sa
SAFEARRAY.
Definition COM.h:1128
-
virtual ~safearray_accessor()
Decrements the lock count of an array.
Definition COM.h:1114
-
T HUGEP * m_data
SAFEARRAY data.
Definition COM.h:1129
-
SAFEARRAY string wrapper.
Definition COM.h:1042
-
virtual ~safearray()
Destroys the array.
Definition COM.h:1051
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the array.
Definition COM.h:1077
-
void free_internal() noexcept override
Destroys the array.
Definition COM.h:1063
-
VARIANT struct wrapper.
Definition COM.h:291
-
bool operator<=(const VARIANT &varSrc) const noexcept
Is variant less than or equal to?
Definition COM.h:994
-
variant(bool bSrc) noexcept
Constructs VARIANT from bool.
Definition COM.h:325
-
variant & operator=(unsigned int nSrc) noexcept
Copy from unsigned int value.
Definition COM.h:627
-
variant & operator=(unsigned long nSrc) noexcept
Copy from unsigned long value.
Definition COM.h:653
-
variant(float fltSrc) noexcept
Constructs VARIANT from float.
Definition COM.h:409
-
variant(VARIANT &&varSrc) noexcept
Moves VARIANT from another.
Definition COM.h:316
-
variant & operator=(float fltSrc) noexcept
Copy from float value.
Definition COM.h:693
-
variant & operator=(float *pfSrc) noexcept
Copy from float reference.
Definition COM.h:887
-
variant(IDispatch *pSrc)
Constructs VARIANT from IDispatch.
Definition COM.h:474
-
variant(int nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from integer.
Definition COM.h:370
-
variant(const SAFEARRAY *pSrc)
Constructs VARIANT from SAFEARRAY.
Definition COM.h:498
-
variant & operator=(double *pfSrc) noexcept
Copy from double reference.
Definition COM.h:900
-
variant & operator=(const SAFEARRAY *pSrc)
Copy from SAFEARRAY.
Definition COM.h:913
-
variant & operator=(int *pnSrc) noexcept
Copy from int reference.
Definition COM.h:809
-
bool operator>(const VARIANT &varSrc) const noexcept
Is variant greater than?
Definition COM.h:980
-
variant & operator=(bool bSrc) noexcept
Copy from bool value.
Definition COM.h:549
-
variant & operator=(long nSrc) noexcept
Copy from long value.
Definition COM.h:640
-
HRESULT change_type(VARTYPE _vt, USHORT wFlags=0) noexcept
Converts a variant from one type to another.
Definition COM.h:1017
-
variant & operator=(IUnknown *pSrc)
Copy from IUnknown.
Definition COM.h:757
-
variant & operator=(short nSrc) noexcept
Copy from short value.
Definition COM.h:588
-
variant & operator=(unsigned char *pbSrc) noexcept
Copy from unsigned char reference.
Definition COM.h:770
-
variant & operator=(unsigned short nSrc) noexcept
Copy from unsigned short value.
Definition COM.h:601
-
variant & operator=(unsigned char nSrc) noexcept
Copy from unsigned char value.
Definition COM.h:575
-
variant & operator=(char cSrc) noexcept
Copy from char value.
Definition COM.h:562
-
variant(LPCOLESTR lpszSrc) noexcept
Constructs VARIANT from OLE string.
Definition COM.h:456
-
virtual ~variant()
Destroys VARIANT.
Definition COM.h:515
-
variant(const VARIANT &varSrc)
Constructs VARIANT from another.
Definition COM.h:304
-
variant(unsigned char nSrc) noexcept
Constructs VARIANT from byte.
Definition COM.h:343
-
variant & operator=(double dblSrc) noexcept
Copy from double value.
Definition COM.h:706
-
bool operator!=(const VARIANT &varSrc) const noexcept
Is variant not equal to?
Definition COM.h:953
-
variant & operator=(int nSrc) noexcept
Copy from int value.
Definition COM.h:614
-
variant(unsigned long nSrc) noexcept
Constructs VARIANT from unsigned long.
Definition COM.h:400
-
bool operator==(const VARIANT &varSrc) const noexcept
Is variant equal to?
Definition COM.h:938
-
variant(IUnknown *pSrc)
Constructs VARIANT from IUnknown.
Definition COM.h:486
-
variant(unsigned int nSrc, VARTYPE vtSrc=VT_UI4) noexcept
Constructs VARIANT from unsigned integer.
Definition COM.h:380
-
variant & operator=(CY cySrc) noexcept
Copy from CY value.
Definition COM.h:719
-
variant & operator=(LPCOLESTR lpszSrc) noexcept
Copy from OLE string value.
Definition COM.h:733
-
variant(long long nSrc) noexcept
Constructs VARIANT from 64-bit integer.
Definition COM.h:428
-
variant & operator=(unsigned int *pnSrc) noexcept
Copy from unsigned int reference.
Definition COM.h:822
-
variant(long nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from long.
Definition COM.h:390
-
variant & operator=(long *pnSrc) noexcept
Copy from long reference.
Definition COM.h:835
-
variant(unsigned short nSrc) noexcept
Constructs VARIANT from unsigned short.
Definition COM.h:361
-
bool operator>=(const VARIANT &varSrc) const noexcept
Is variant greater than or equal to?
Definition COM.h:1007
-
variant & operator=(short *pnSrc) noexcept
Copy from short reference.
Definition COM.h:783
-
variant() noexcept
Constructs blank VARIANT.
Definition COM.h:296
-
bool operator<(const VARIANT &varSrc) const noexcept
Is variant less than?
Definition COM.h:966
-
variant(unsigned long long nSrc) noexcept
Constructs VARIANT from unsigned integer.
Definition COM.h:437
-
variant(char cSrc) noexcept
Constructs VARIANT from character.
Definition COM.h:334
-
variant & operator=(unsigned short *pnSrc) noexcept
Copy from unsigned short reference.
Definition COM.h:796
-
variant & operator=(long long *pnSrc) noexcept
Copy from long long reference.
Definition COM.h:861
-
variant(BSTR bstr) noexcept
Constructs VARIANT from BSTR.
Definition COM.h:465
-
variant & operator=(unsigned long long *pnSrc) noexcept
Copy from unsigned long long reference.
Definition COM.h:874
-
variant(double dblSrc, VARTYPE vtSrc=VT_R8) noexcept
Constructs VARIANT from double or variant date.
Definition COM.h:418
-
variant(short nSrc) noexcept
Constructs VARIANT from short.
Definition COM.h:352
-
variant(CY cySrc) noexcept
Constructs VARIANT from CY (64-bit integer)
Definition COM.h:446
-
variant & operator=(unsigned long long nSrc) noexcept
Copy from unsigned long long value.
Definition COM.h:679
-
variant & operator=(VARIANT &&varSrc) noexcept
Moves from another VARIANT.
Definition COM.h:536
-
variant & operator=(long long nSrc) noexcept
Copy from long long value.
Definition COM.h:666
-
variant & operator=(IDispatch *pSrc)
Copy from IDispatch.
Definition COM.h:744
-
variant & operator=(unsigned long *pnSrc) noexcept
Copy from unsigned long reference.
Definition COM.h:848
-
variant & operator=(const VARIANT &varSrc)
Copy from another VARIANT.
Definition COM.h:523
-
static _Check_return_ HRESULT CoGetObject(LPCWSTR pszName, BIND_OPTS *pBindOptions, REFIID riid, winstd::com_obj< T > &v)
Converts a display name into a moniker that identifies the object named, and then binds to the object...
Definition COM.h:1213
-
static _Check_return_ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, winstd::com_obj< T > &v)
Creates and default-initializes a single object of the class associated with a specified CLSID.
Definition COM.h:1198
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
-
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:74
-
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:175
-
static const T invalid
Invalid handle value.
Definition Common.h:993
+
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1285
+
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
Numerical runtime error.
Definition Common.h:1483
+
HRESULT error_type
Error number type.
Definition Common.h:1485
+
Context scope automatic SAFEARRAY (un)access.
Definition COM.h:1093
+
safearray_accessor(SAFEARRAY *psa)
Increments the lock count of an array, and retrieves a pointer to the array data.
Definition COM.h:1103
+
T HUGEP * data() const noexcept
Return SAFEARRAY data pointer.
Definition COM.h:1123
+
SAFEARRAY * m_sa
SAFEARRAY.
Definition COM.h:1129
+
virtual ~safearray_accessor()
Decrements the lock count of an array.
Definition COM.h:1115
+
T HUGEP * m_data
SAFEARRAY data.
Definition COM.h:1130
+
SAFEARRAY string wrapper.
Definition COM.h:1043
+
virtual ~safearray()
Destroys the array.
Definition COM.h:1052
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the array.
Definition COM.h:1078
+
void free_internal() noexcept override
Destroys the array.
Definition COM.h:1064
+
VARIANT struct wrapper.
Definition COM.h:292
+
bool operator<=(const VARIANT &varSrc) const noexcept
Is variant less than or equal to?
Definition COM.h:995
+
variant(bool bSrc) noexcept
Constructs VARIANT from bool.
Definition COM.h:326
+
variant & operator=(unsigned int nSrc) noexcept
Copy from unsigned int value.
Definition COM.h:628
+
variant & operator=(unsigned long nSrc) noexcept
Copy from unsigned long value.
Definition COM.h:654
+
variant(float fltSrc) noexcept
Constructs VARIANT from float.
Definition COM.h:410
+
variant(VARIANT &&varSrc) noexcept
Moves VARIANT from another.
Definition COM.h:317
+
variant & operator=(float fltSrc) noexcept
Copy from float value.
Definition COM.h:694
+
variant & operator=(float *pfSrc) noexcept
Copy from float reference.
Definition COM.h:888
+
variant(IDispatch *pSrc)
Constructs VARIANT from IDispatch.
Definition COM.h:475
+
variant(int nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from integer.
Definition COM.h:371
+
variant(const SAFEARRAY *pSrc)
Constructs VARIANT from SAFEARRAY.
Definition COM.h:499
+
variant & operator=(double *pfSrc) noexcept
Copy from double reference.
Definition COM.h:901
+
variant & operator=(const SAFEARRAY *pSrc)
Copy from SAFEARRAY.
Definition COM.h:914
+
variant & operator=(int *pnSrc) noexcept
Copy from int reference.
Definition COM.h:810
+
bool operator>(const VARIANT &varSrc) const noexcept
Is variant greater than?
Definition COM.h:981
+
variant & operator=(bool bSrc) noexcept
Copy from bool value.
Definition COM.h:550
+
variant & operator=(long nSrc) noexcept
Copy from long value.
Definition COM.h:641
+
HRESULT change_type(VARTYPE _vt, USHORT wFlags=0) noexcept
Converts a variant from one type to another.
Definition COM.h:1018
+
variant & operator=(IUnknown *pSrc)
Copy from IUnknown.
Definition COM.h:758
+
variant & operator=(short nSrc) noexcept
Copy from short value.
Definition COM.h:589
+
variant & operator=(unsigned char *pbSrc) noexcept
Copy from unsigned char reference.
Definition COM.h:771
+
variant & operator=(unsigned short nSrc) noexcept
Copy from unsigned short value.
Definition COM.h:602
+
variant & operator=(unsigned char nSrc) noexcept
Copy from unsigned char value.
Definition COM.h:576
+
variant & operator=(char cSrc) noexcept
Copy from char value.
Definition COM.h:563
+
variant(LPCOLESTR lpszSrc) noexcept
Constructs VARIANT from OLE string.
Definition COM.h:457
+
virtual ~variant()
Destroys VARIANT.
Definition COM.h:516
+
variant(const VARIANT &varSrc)
Constructs VARIANT from another.
Definition COM.h:305
+
variant(unsigned char nSrc) noexcept
Constructs VARIANT from byte.
Definition COM.h:344
+
variant & operator=(double dblSrc) noexcept
Copy from double value.
Definition COM.h:707
+
bool operator!=(const VARIANT &varSrc) const noexcept
Is variant not equal to?
Definition COM.h:954
+
variant & operator=(int nSrc) noexcept
Copy from int value.
Definition COM.h:615
+
variant(unsigned long nSrc) noexcept
Constructs VARIANT from unsigned long.
Definition COM.h:401
+
bool operator==(const VARIANT &varSrc) const noexcept
Is variant equal to?
Definition COM.h:939
+
variant(IUnknown *pSrc)
Constructs VARIANT from IUnknown.
Definition COM.h:487
+
variant(unsigned int nSrc, VARTYPE vtSrc=VT_UI4) noexcept
Constructs VARIANT from unsigned integer.
Definition COM.h:381
+
variant & operator=(CY cySrc) noexcept
Copy from CY value.
Definition COM.h:720
+
variant & operator=(LPCOLESTR lpszSrc) noexcept
Copy from OLE string value.
Definition COM.h:734
+
variant(long long nSrc) noexcept
Constructs VARIANT from 64-bit integer.
Definition COM.h:429
+
variant & operator=(unsigned int *pnSrc) noexcept
Copy from unsigned int reference.
Definition COM.h:823
+
variant(long nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from long.
Definition COM.h:391
+
variant & operator=(long *pnSrc) noexcept
Copy from long reference.
Definition COM.h:836
+
variant(unsigned short nSrc) noexcept
Constructs VARIANT from unsigned short.
Definition COM.h:362
+
bool operator>=(const VARIANT &varSrc) const noexcept
Is variant greater than or equal to?
Definition COM.h:1008
+
variant & operator=(short *pnSrc) noexcept
Copy from short reference.
Definition COM.h:784
+
variant() noexcept
Constructs blank VARIANT.
Definition COM.h:297
+
bool operator<(const VARIANT &varSrc) const noexcept
Is variant less than?
Definition COM.h:967
+
variant(unsigned long long nSrc) noexcept
Constructs VARIANT from unsigned integer.
Definition COM.h:438
+
variant(char cSrc) noexcept
Constructs VARIANT from character.
Definition COM.h:335
+
variant & operator=(unsigned short *pnSrc) noexcept
Copy from unsigned short reference.
Definition COM.h:797
+
variant & operator=(long long *pnSrc) noexcept
Copy from long long reference.
Definition COM.h:862
+
variant(BSTR bstr) noexcept
Constructs VARIANT from BSTR.
Definition COM.h:466
+
variant & operator=(unsigned long long *pnSrc) noexcept
Copy from unsigned long long reference.
Definition COM.h:875
+
variant(double dblSrc, VARTYPE vtSrc=VT_R8) noexcept
Constructs VARIANT from double or variant date.
Definition COM.h:419
+
variant(short nSrc) noexcept
Constructs VARIANT from short.
Definition COM.h:353
+
variant(CY cySrc) noexcept
Constructs VARIANT from CY (64-bit integer)
Definition COM.h:447
+
variant & operator=(unsigned long long nSrc) noexcept
Copy from unsigned long long value.
Definition COM.h:680
+
variant & operator=(VARIANT &&varSrc) noexcept
Moves from another VARIANT.
Definition COM.h:537
+
variant & operator=(long long nSrc) noexcept
Copy from long long value.
Definition COM.h:667
+
variant & operator=(IDispatch *pSrc)
Copy from IDispatch.
Definition COM.h:745
+
variant & operator=(unsigned long *pnSrc) noexcept
Copy from unsigned long reference.
Definition COM.h:849
+
variant & operator=(const VARIANT &varSrc)
Copy from another VARIANT.
Definition COM.h:524
+
static _Check_return_ HRESULT CoGetObject(LPCWSTR pszName, BIND_OPTS *pBindOptions, REFIID riid, winstd::com_obj< T > &v)
Converts a display name into a moniker that identifies the object named, and then binds to the object...
Definition COM.h:1214
+
static _Check_return_ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, winstd::com_obj< T > &v)
Creates and default-initializes a single object of the class associated with a specified CLSID.
Definition COM.h:1199
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
+
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:176
+
static const T invalid
Invalid handle value.
Definition Common.h:1030
Deleter for unique_ptr using CoTaskMemFree.
Definition COM.h:58
void operator()(_T *_Ptr) const
Delete a pointer.
Definition COM.h:70
CoTaskMemFree_delete() noexcept
Default constructor.
Definition COM.h:62
diff --git a/_common_8h_source.html b/_common_8h_source.html index 7fa7433f..6848c4be 100644 --- a/_common_8h_source.html +++ b/_common_8h_source.html @@ -92,1563 +92,1600 @@ $(document).ready(function() { init_codefold(0); });
8
9#include <Windows.h>
10#include <assert.h>
-
11#include <stdarg.h>
-
12#include <tchar.h>
-
13#include <iostream>
-
14#include <memory>
-
15#include <stdexcept>
-
16#include <string>
-
17#include <vector>
-
18
-
35
-
38
-
42#ifndef __L
-
43#define __L(x) L ## x
-
44#endif
-
45
-
49#ifndef _L
-
50#define _L(x) __L(x)
-
51#endif
-
52
-
56#define WINSTD_STRING_IMPL(x) #x
-
57
-
61#define WINSTD_STRING(x) WINSTD_STRING_IMPL(x)
-
62
-
-
66#define WINSTD_NONCOPYABLE(C) \
-
67private: \
-
68 C (_In_ const C &h) noexcept; \
-
69 C& operator=(_In_ const C &h) noexcept;
+
11#include <intsafe.h>
+
12#include <stdarg.h>
+
13#include <tchar.h>
+
14#include <iostream>
+
15#include <memory>
+
16#include <stdexcept>
+
17#include <string>
+
18#include <vector>
+
19
+
36
+
39
+
43#ifndef __L
+
44#define __L(x) L ## x
+
45#endif
+
46
+
50#ifndef _L
+
51#define _L(x) __L(x)
+
52#endif
+
53
+
57#define WINSTD_STRING_IMPL(x) #x
+
58
+
62#define WINSTD_STRING(x) WINSTD_STRING_IMPL(x)
+
63
+
+
67#define WINSTD_NONCOPYABLE(C) \
+
68private: \
+
69 C (_In_ const C &h) noexcept; \
+
70 C& operator=(_In_ const C &h) noexcept;
-
70
-
-
74#define WINSTD_NONMOVABLE(C) \
-
75private: \
-
76 C (_Inout_ C &&h) noexcept; \
-
77 C& operator=(_Inout_ C &&h) noexcept;
+
71
+
+
75#define WINSTD_NONMOVABLE(C) \
+
76private: \
+
77 C (_Inout_ C &&h) noexcept; \
+
78 C& operator=(_Inout_ C &&h) noexcept;
-
78
-
79#ifndef WINSTD_STACK_BUFFER_BYTES
-
93#define WINSTD_STACK_BUFFER_BYTES 1024
-
94#endif
-
95
-
97
-
100
-
104#ifdef UNICODE
-
105#define PRINTF_LPTSTR "ls"
-
106#else
-
107#define PRINTF_LPTSTR "s"
-
108#endif
-
109
-
113#ifdef OLE2ANSI
-
114#define PRINTF_LPOLESTR "hs"
-
115#else
-
116#define PRINTF_LPOLESTR "ls"
-
117#endif
-
118
-
122#ifdef _UNICODE
-
123#define _tcin (std::wcin )
-
124#else
-
125#define _tcin (std::cin )
-
126#endif
-
127
-
131#ifdef _UNICODE
-
132#define _tcout (std::wcout)
-
133#else
-
134#define _tcout (std::cout)
-
135#endif
-
136
-
140#ifdef _UNICODE
-
141#define _tcerr (std::wcerr)
-
142#else
-
143#define _tcerr (std::cerr)
-
144#endif
-
145
-
149#ifdef _UNICODE
-
150#define _tclog (std::wclog)
-
151#else
-
152#define _tclog (std::clog)
-
153#endif
-
154
-
156
-
159
-
-
163#define WINSTD_HANDLE_IMPL(C, INVAL) \
-
164public: \
-
165 C ( ) noexcept { } \
-
166 C (_In_opt_ handle_type h) noexcept : handle<handle_type, INVAL>( h ) { } \
-
167 C (_Inout_ C &&h) noexcept : handle<handle_type, INVAL>(std::move(h)) { } \
-
168 C& operator=(_In_opt_ handle_type h) noexcept { handle<handle_type, INVAL>::operator=( h ); return *this; } \
-
169 C& operator=(_Inout_ C &&h) noexcept { handle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
-
170WINSTD_NONCOPYABLE(C)
+
79
+
80#ifndef WINSTD_STACK_BUFFER_BYTES
+
94#define WINSTD_STACK_BUFFER_BYTES 1024
+
95#endif
+
96
+
98
+
101
+
105#ifdef UNICODE
+
106#define PRINTF_LPTSTR "ls"
+
107#else
+
108#define PRINTF_LPTSTR "s"
+
109#endif
+
110
+
114#ifdef OLE2ANSI
+
115#define PRINTF_LPOLESTR "hs"
+
116#else
+
117#define PRINTF_LPOLESTR "ls"
+
118#endif
+
119
+
123#ifdef _UNICODE
+
124#define _tcin (std::wcin )
+
125#else
+
126#define _tcin (std::cin )
+
127#endif
+
128
+
132#ifdef _UNICODE
+
133#define _tcout (std::wcout)
+
134#else
+
135#define _tcout (std::cout)
+
136#endif
+
137
+
141#ifdef _UNICODE
+
142#define _tcerr (std::wcerr)
+
143#else
+
144#define _tcerr (std::cerr)
+
145#endif
+
146
+
150#ifdef _UNICODE
+
151#define _tclog (std::wclog)
+
152#else
+
153#define _tclog (std::clog)
+
154#endif
+
155
+
157
+
160
+
+
164#define WINSTD_HANDLE_IMPL(C, INVAL) \
+
165public: \
+
166 C ( ) noexcept { } \
+
167 C (_In_opt_ handle_type h) noexcept : handle<handle_type, INVAL>( h ) { } \
+
168 C (_Inout_ C &&h) noexcept : handle<handle_type, INVAL>(std::move(h)) { } \
+
169 C& operator=(_In_opt_ handle_type h) noexcept { handle<handle_type, INVAL>::operator=( h ); return *this; } \
+
170 C& operator=(_Inout_ C &&h) noexcept { handle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
+
171WINSTD_NONCOPYABLE(C)
-
171
-
-
175#define WINSTD_DPLHANDLE_IMPL(C, INVAL) \
-
176public: \
-
177 C ( ) noexcept { } \
-
178 C (_In_opt_ handle_type h) noexcept : dplhandle<handle_type, INVAL>( h ) { } \
-
179 C (_In_ const C &h) noexcept : dplhandle<handle_type, INVAL>(duplicate_internal(h.m_h)) { } \
-
180 C (_Inout_ C &&h) noexcept : dplhandle<handle_type, INVAL>(std::move (h )) { } \
-
181 C& operator=(_In_opt_ handle_type h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
-
182 C& operator=(_In_ const C &h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
-
183 C& operator=(_Inout_ C &&h) noexcept { dplhandle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
-
184private:
+
172
+
+
176#define WINSTD_DPLHANDLE_IMPL(C, INVAL) \
+
177public: \
+
178 C ( ) noexcept { } \
+
179 C (_In_opt_ handle_type h) noexcept : dplhandle<handle_type, INVAL>( h ) { } \
+
180 C (_In_ const C &h) noexcept : dplhandle<handle_type, INVAL>(duplicate_internal(h.m_h)) { } \
+
181 C (_Inout_ C &&h) noexcept : dplhandle<handle_type, INVAL>(std::move (h )) { } \
+
182 C& operator=(_In_opt_ handle_type h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
+
183 C& operator=(_In_ const C &h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
+
184 C& operator=(_Inout_ C &&h) noexcept { dplhandle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
+
185private:
-
185
-
187
-
188#ifndef _FormatMessage_format_string_
-
189#define _FormatMessage_format_string_ _In_z_
-
190#endif
-
191
-
193#ifndef _LPCBYTE_DEFINED
-
194#define _LPCBYTE_DEFINED
-
195typedef const BYTE *LPCBYTE;
-
196#endif
-
198
-
199#pragma warning(push)
-
200// Do not use _vsnprintf_s/_vsnwprintf_s(), since it terminates string by force even when we explicitly want to write unterminated string.
-
201// Threfore turn off compiler warning instead. ;)
-
202#pragma warning(disable: 4995)
-
203#pragma warning(disable: 4996)
-
204#pragma warning(disable: 4505) // Don't warn on unused code
-
205
-
208
-
219#if _MSC_VER <= 1600
-
-
220static int vsnprintf(_Out_z_cap_(capacity) char *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const char *format, _In_ va_list arg)
-
221{
-
222 return _vsnprintf(str, capacity, format, arg);
-
223}
+
186
+
188
+
189#ifndef _FormatMessage_format_string_
+
190#define _FormatMessage_format_string_ _In_z_
+
191#endif
+
192
+
194#ifndef _LPCBYTE_DEFINED
+
195#define _LPCBYTE_DEFINED
+
196typedef const BYTE *LPCBYTE;
+
197#endif
+
199
+
200#pragma warning(push)
+
201// Do not use _vsnprintf_s/_vsnwprintf_s(), since it terminates string by force even when we explicitly want to write unterminated string.
+
202// Threfore turn off compiler warning instead. ;)
+
203#pragma warning(disable: 4995)
+
204#pragma warning(disable: 4996)
+
205#pragma warning(disable: 4505) // Don't warn on unused code
+
206
+
207#ifdef _WIN64
+
208inline ULONGLONG ULongLongMult(ULONGLONG a, ULONGLONG b)
+
209{
+
210 ULONGLONG result;
+
211 if (SUCCEEDED(ULongLongMult(a, b, &result)))
+
212 return result;
+
213 throw std::invalid_argument("multiply overflow");
+
214}
+
215#else
+
216inline SIZE_T SIZETMult(SIZE_T a, SIZE_T b)
+
217{
+
218 SIZE_T result;
+
219 if (SUCCEEDED(SIZETMult(a, b, &result)))
+
220 return result;
+
221 throw std::invalid_argument("multiply overflow");
+
222}
+
223#endif
+
224
+
225#ifdef _WIN64
+
226inline ULONGLONG ULongLongAdd(ULONGLONG a, ULONGLONG b)
+
227{
+
228 ULONGLONG result;
+
229 if (SUCCEEDED(ULongLongAdd(a, b, &result)))
+
230 return result;
+
231 throw std::invalid_argument("add overflow");
+
232}
+
233#else
+
234inline SIZE_T SIZETAdd(SIZE_T a, SIZE_T b)
+
235{
+
236 SIZE_T result;
+
237 if (SUCCEEDED(SIZETAdd(a, b, &result)))
+
238 return result;
+
239 throw std::invalid_argument("add overflow");
+
240}
+
241#endif
+
242
+
245
+
256#if _MSC_VER <= 1600
+
+
257static int vsnprintf(_Out_z_cap_(capacity) char *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const char *format, _In_ va_list arg)
+
258{
+
259 return _vsnprintf(str, capacity, format, arg);
+
260}
-
224#endif
-
225
-
-
236static int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg) noexcept
-
237{
-
238 return _vsnwprintf(str, capacity, format, arg);
-
239}
+
261#endif
+
262
+
+
273static int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg) noexcept
+
274{
+
275 return _vsnwprintf(str, capacity, format, arg);
+
276}
-
240
-
250template<class _Elem, class _Traits, class _Ax>
-
-
251static int vsprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const _Elem *format, _In_ va_list arg)
-
252{
-
253 _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)];
-
254
-
255 // Try with stack buffer first.
-
256 int count = vsnprintf(buf, _countof(buf) - 1, format, arg);
-
257 if (count >= 0) {
-
258 // Copy from stack.
-
259 str.assign(buf, count);
-
260 } else {
-
261 for (size_t capacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; capacity *= 2) {
-
262 // Allocate on heap and retry.
-
263 auto buf_dyn = std::make_unique<_Elem[]>(capacity);
-
264 count = vsnprintf(buf_dyn.get(), capacity - 1, format, arg);
-
265 if (count >= 0) {
-
266 str.assign(buf_dyn.get(), count);
-
267 break;
-
268 }
-
269 }
-
270 }
-
271
-
272 return count;
-
273}
+
277
+
287template<class _Elem, class _Traits, class _Ax>
+
+
288static int vsprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const _Elem *format, _In_ va_list arg)
+
289{
+
290 _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)];
+
291
+
292 // Try with stack buffer first.
+
293 int count = vsnprintf(buf, _countof(buf) - 1, format, arg);
+
294 if (count >= 0) {
+
295 // Copy from stack.
+
296 str.assign(buf, count);
+
297 } else {
+
298 for (size_t capacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; capacity *= 2) {
+
299 // Allocate on heap and retry.
+
300 auto buf_dyn = std::make_unique<_Elem[]>(capacity);
+
301 count = vsnprintf(buf_dyn.get(), capacity - 1, format, arg);
+
302 if (count >= 0) {
+
303 str.assign(buf_dyn.get(), count);
+
304 break;
+
305 }
+
306 }
+
307 }
+
308
+
309 return count;
+
310}
-
274
-
283template<class _Elem, class _Traits, class _Ax>
-
-
284static int sprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const _Elem *format, ...)
-
285{
-
286 va_list arg;
-
287 va_start(arg, format);
-
288 const int res = vsprintf(str, format, arg);
-
289 va_end(arg);
-
290 return res;
-
291}
+
311
+
320template<class _Elem, class _Traits, class _Ax>
+
+
321static int sprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _Printf_format_string_ const _Elem *format, ...)
+
322{
+
323 va_list arg;
+
324 va_start(arg, format);
+
325 const int res = vsprintf(str, format, arg);
+
326 va_end(arg);
+
327 return res;
+
328}
-
292
-
298template<class _Traits, class _Ax>
-
-
299static _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
-
300{
-
301 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
-
302
-
303 // Try to convert to stack buffer first.
-
304 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
305 if (cch) {
-
306 // Copy from stack. Be careful not to include zero terminator.
-
307 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
308 }
-
309 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
310 // Query the required output size. Allocate buffer. Then convert again.
-
311 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
312 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
-
313 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
-
314 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
-
315 }
-
316
-
317 return cch;
-
318}
-
-
319
-
325template<class _Ax>
-
-
326static _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
-
327{
-
328 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
329
-
330 // Try to convert to stack buffer first.
-
331 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
332 if (cch) {
-
333 // Copy from stack.
-
334 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
-
335 }
-
336 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
337 // Query the required output size. Allocate buffer. Then convert again.
-
338 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
339 sMultiByteStr.resize(cch);
-
340 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
-
341 }
-
342
-
343 return cch;
-
344}
+
335template<class _Traits, class _Ax>
+
+
336static _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
+
337{
+
338 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
339
+
340 // Try to convert to stack buffer first.
+
341 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
342 if (cch) {
+
343 // Copy from stack. Be careful not to include zero terminator.
+
344 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
+
345 }
+
346 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
347 // Query the required output size. Allocate buffer. Then convert again.
+
348 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
349 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
+
350 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
+
351 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
+
352 }
+
353
+
354 return cch;
+
355}
-
345
-
351template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
-
-
352static _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
-
353{
-
354 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
-
355
-
356 // Try to convert to stack buffer first.
-
357 int cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
358 if (cch) {
-
359 // Copy from stack.
-
360 sMultiByteStr.assign(szStackBuffer, cch);
-
361 }
-
362 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
363 // Query the required output size. Allocate buffer. Then convert again.
-
364 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
365 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
-
366 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
-
367 sMultiByteStr.assign(szBuffer.get(), cch);
-
368 }
-
369
-
370 return cch;
-
371}
+
356
+
362template<class _Ax>
+
+
363static _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
+
364{
+
365 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
366
+
367 // Try to convert to stack buffer first.
+
368 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
369 if (cch) {
+
370 // Copy from stack.
+
371 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
+
372 }
+
373 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
374 // Query the required output size. Allocate buffer. Then convert again.
+
375 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
376 sMultiByteStr.resize(cch);
+
377 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
+
378 }
+
379
+
380 return cch;
+
381}
-
372
-
380template<class _Traits, class _Ax>
-
-
381static _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
-
382{
-
383 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
-
384
-
385 // Try to convert to stack buffer first.
-
386 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
387 if (cch) {
-
388 // Copy from stack. Be careful not to include zero terminator.
-
389 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
390 }
-
391 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
392 // Query the required output size. Allocate buffer. Then convert again.
-
393 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
394 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
-
395 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
-
396 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
-
397 SecureZeroMemory(szBuffer.get(), sizeof(CHAR) * cch);
+
382
+
388template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
+
+
389static _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
+
390{
+
391 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
392
+
393 // Try to convert to stack buffer first.
+
394 int cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
395 if (cch) {
+
396 // Copy from stack.
+
397 sMultiByteStr.assign(szStackBuffer, cch);
398 }
-
399
-
400 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
401
-
402 return cch;
-
403}
+
399 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
400 // Query the required output size. Allocate buffer. Then convert again.
+
401 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
402 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
+
403 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
+
404 sMultiByteStr.assign(szBuffer.get(), cch);
+
405 }
+
406
+
407 return cch;
+
408}
-
404
-
412template<class _Ax>
-
-
413static _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
-
414{
-
415 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
-
416
-
417 // Try to convert to stack buffer first.
-
418 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
419 if (cch) {
-
420 // Copy from stack.
-
421 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
-
422 }
-
423 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
424 // Query the required output size. Allocate buffer. Then convert again.
-
425 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
426 sMultiByteStr.resize(cch);
-
427 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
-
428 }
-
429
-
430 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
431
-
432 return cch;
-
433}
-
-
434
-
442template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
-
-
443static _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
-
444{
-
445 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
-
446
-
447 // Try to convert to stack buffer first.
-
448 int cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
-
449 if (cch) {
-
450 // Copy from stack.
-
451 sMultiByteStr.assign(szStackBuffer, cch);
-
452 }
-
453 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
454 // Query the required output size. Allocate buffer. Then convert again.
-
455 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
-
456 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
-
457 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
-
458 sMultiByteStr.assign(szBuffer.get(), cch);
-
459 SecureZeroMemory(szBuffer.get(), sizeof(CHAR) * cch);
-
460 }
-
461
-
462 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
463
-
464 return cch;
-
465}
+
409
+
417template<class _Traits, class _Ax>
+
+
418static _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
+
419{
+
420 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
421
+
422 // Try to convert to stack buffer first.
+
423 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
424 if (cch) {
+
425 // Copy from stack. Be careful not to include zero terminator.
+
426 sMultiByteStr.assign(szStackBuffer, cchWideChar != -1 ? strnlen(szStackBuffer, cch) : (size_t)cch - 1);
+
427 }
+
428 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
429 // Query the required output size. Allocate buffer. Then convert again.
+
430 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
431 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
+
432 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
+
433 sMultiByteStr.assign(szBuffer.get(), cchWideChar != -1 ? strnlen(szBuffer.get(), cch) : (size_t)cch - 1);
+
434 SecureZeroMemory(szBuffer.get(), sizeof(CHAR) * cch);
+
435 }
+
436
+
437 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
+
438
+
439 return cch;
+
440}
+
441
+
449template<class _Ax>
+
+
450static _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
+
451{
+
452 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
453
+
454 // Try to convert to stack buffer first.
+
455 int cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
456 if (cch) {
+
457 // Copy from stack.
+
458 sMultiByteStr.assign(szStackBuffer, szStackBuffer + cch);
+
459 }
+
460 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
461 // Query the required output size. Allocate buffer. Then convert again.
+
462 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
463 sMultiByteStr.resize(cch);
+
464 cch = ::WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, sMultiByteStr.data(), cch, lpDefaultChar, lpUsedDefaultChar);
+
465 }
466
-
472template<class _Traits, class _Ax>
-
-
473static _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
-
474{
-
475 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
-
476
-
477 // Try to convert to stack buffer first.
-
478 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
-
479 if (cch) {
-
480 // Copy from stack.
-
481 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
482 }
-
483 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
484 // Query the required output size. Allocate buffer. Then convert again.
-
485 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
-
486 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
487 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szBuffer.get(), cch);
-
488 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
+
467 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
+
468
+
469 return cch;
+
470}
+
+
471
+
479template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
+
+
480static _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
+
481{
+
482 CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(CHAR)];
+
483
+
484 // Try to convert to stack buffer first.
+
485 int cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szStackBuffer, _countof(szStackBuffer), lpDefaultChar, lpUsedDefaultChar);
+
486 if (cch) {
+
487 // Copy from stack.
+
488 sMultiByteStr.assign(szStackBuffer, cch);
489 }
-
490
-
491 return cch;
-
492}
+
490 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
491 // Query the required output size. Allocate buffer. Then convert again.
+
492 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), NULL, 0, lpDefaultChar, lpUsedDefaultChar);
+
493 std::unique_ptr<CHAR[]> szBuffer(new CHAR[cch]);
+
494 cch = ::WideCharToMultiByte(CodePage, dwFlags, sWideCharStr.c_str(), (int)sWideCharStr.length(), szBuffer.get(), cch, lpDefaultChar, lpUsedDefaultChar);
+
495 sMultiByteStr.assign(szBuffer.get(), cch);
+
496 SecureZeroMemory(szBuffer.get(), sizeof(CHAR) * cch);
+
497 }
+
498
+
499 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
+
500
+
501 return cch;
+
502}
-
493
-
499template<class _Ax>
-
-
500static _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
-
501{
-
502 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
503
-
504 // Try to convert to stack buffer first.
-
505 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
-
506 if (cch) {
-
507 // Copy from stack.
-
508 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
-
509 }
-
510 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
511 // Query the required output size. Allocate buffer. Then convert again.
-
512 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
-
513 sWideCharStr.resize(cch);
-
514 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
-
515 }
-
516
-
517 return cch;
-
518}
+
509template<class _Traits, class _Ax>
+
+
510static _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
+
511{
+
512 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
513
+
514 // Try to convert to stack buffer first.
+
515 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
+
516 if (cch) {
+
517 // Copy from stack.
+
518 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
+
519 }
+
520 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
521 // Query the required output size. Allocate buffer. Then convert again.
+
522 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
+
523 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
524 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szBuffer.get(), cch);
+
525 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
+
526 }
+
527
+
528 return cch;
+
529}
-
519
-
525template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
-
-
526static _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
-
527{
-
528 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
-
529
-
530 // Try to convert to stack buffer first.
-
531 int cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
-
532 if (cch) {
-
533 // Copy from stack.
-
534 sWideCharStr.assign(szStackBuffer, cch);
-
535 }
-
536 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
537 // Query the required output size. Allocate buffer. Then convert again.
-
538 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), NULL, 0);
-
539 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
540 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szBuffer.get(), cch);
-
541 sWideCharStr.assign(szBuffer.get(), cch);
-
542 }
-
543
-
544 return cch;
-
545}
+
530
+
536template<class _Ax>
+
+
537static _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
+
538{
+
539 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
540
+
541 // Try to convert to stack buffer first.
+
542 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
+
543 if (cch) {
+
544 // Copy from stack.
+
545 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
+
546 }
+
547 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
548 // Query the required output size. Allocate buffer. Then convert again.
+
549 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
+
550 sWideCharStr.resize(cch);
+
551 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
+
552 }
+
553
+
554 return cch;
+
555}
-
546
-
554template<class _Traits, class _Ax>
-
-
555static _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
-
556{
-
557 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
-
558
-
559 // Try to convert to stack buffer first.
-
560 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
-
561 if (cch) {
-
562 // Copy from stack.
-
563 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
564 }
-
565 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
566 // Query the required output size. Allocate buffer. Then convert again.
-
567 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
-
568 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
569 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szBuffer.get(), cch);
-
570 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
-
571 SecureZeroMemory(szBuffer.get(), sizeof(WCHAR) * cch);
+
556
+
562template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
+
+
563static _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
+
564{
+
565 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
566
+
567 // Try to convert to stack buffer first.
+
568 int cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
+
569 if (cch) {
+
570 // Copy from stack.
+
571 sWideCharStr.assign(szStackBuffer, cch);
572 }
-
573
-
574 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
575
-
576 return cch;
-
577}
+
573 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
574 // Query the required output size. Allocate buffer. Then convert again.
+
575 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), NULL, 0);
+
576 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
577 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szBuffer.get(), cch);
+
578 sWideCharStr.assign(szBuffer.get(), cch);
+
579 }
+
580
+
581 return cch;
+
582}
-
578
-
586template<class _Ax>
-
-
587static _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
-
588{
-
589 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
-
590
-
591 // Try to convert to stack buffer first.
-
592 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
-
593 if (cch) {
-
594 // Copy from stack.
-
595 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
-
596 }
-
597 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
598 // Query the required output size. Allocate buffer. Then convert again.
-
599 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
-
600 sWideCharStr.resize(cch);
-
601 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
-
602 }
-
603
-
604 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
605
-
606 return cch;
-
607}
-
-
608
-
616template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
-
-
617static _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
-
618{
-
619 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
-
620
-
621 // Try to convert to stack buffer first.
-
622 int cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
-
623 if (cch) {
-
624 // Copy from stack.
-
625 sWideCharStr.assign(szStackBuffer, cch);
-
626 }
-
627 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
628 // Query the required output size. Allocate buffer. Then convert again.
-
629 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), NULL, 0);
-
630 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
631 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szBuffer.get(), cch);
-
632 sWideCharStr.assign(szBuffer.get(), cch);
-
633 SecureZeroMemory(szBuffer.get(), sizeof(WCHAR) * cch);
-
634 }
-
635
-
636 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
-
637
-
638 return cch;
-
639}
+
583
+
591template<class _Traits, class _Ax>
+
+
592static _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
+
593{
+
594 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
595
+
596 // Try to convert to stack buffer first.
+
597 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
+
598 if (cch) {
+
599 // Copy from stack.
+
600 sWideCharStr.assign(szStackBuffer, cbMultiByte != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
+
601 }
+
602 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
603 // Query the required output size. Allocate buffer. Then convert again.
+
604 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
+
605 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
606 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szBuffer.get(), cch);
+
607 sWideCharStr.assign(szBuffer.get(), cbMultiByte != -1 ? wcsnlen(szBuffer.get(), cch) : (size_t)cch - 1);
+
608 SecureZeroMemory(szBuffer.get(), sizeof(WCHAR) * cch);
+
609 }
+
610
+
611 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
+
612
+
613 return cch;
+
614}
+
615
+
623template<class _Ax>
+
+
624static _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
+
625{
+
626 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
627
+
628 // Try to convert to stack buffer first.
+
629 int cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, szStackBuffer, _countof(szStackBuffer));
+
630 if (cch) {
+
631 // Copy from stack.
+
632 sWideCharStr.assign(szStackBuffer, szStackBuffer + cch);
+
633 }
+
634 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
635 // Query the required output size. Allocate buffer. Then convert again.
+
636 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
+
637 sWideCharStr.resize(cch);
+
638 cch = ::MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, sWideCharStr.data(), cch);
+
639 }
640
-
646template<class _Traits, class _Ax>
-
-
647static DWORD FormatMessage(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _Inout_ std::basic_string<char, _Traits, _Ax> &str, _In_opt_ va_list *Arguments)
-
648{
-
649 std::unique_ptr<CHAR[], winstd::LocalFree_delete<CHAR[]> > lpBuffer;
-
650 DWORD dwResult = FormatMessageA(dwFlags | FORMAT_MESSAGE_ALLOCATE_BUFFER, lpSource, dwMessageId, dwLanguageId, reinterpret_cast<LPSTR>((LPSTR*)get_ptr(lpBuffer)), 0, Arguments);
-
651 if (dwResult)
-
652 str.assign(lpBuffer.get(), dwResult);
-
653 return dwResult;
-
654}
+
641 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
+
642
+
643 return cch;
+
644}
-
655
-
661template<class _Traits, class _Ax>
-
-
662static DWORD FormatMessage(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &str, _In_opt_ va_list *Arguments)
-
663{
-
664 std::unique_ptr<WCHAR[], winstd::LocalFree_delete<WCHAR[]> > lpBuffer;
-
665 DWORD dwResult = FormatMessageW(dwFlags | FORMAT_MESSAGE_ALLOCATE_BUFFER, lpSource, dwMessageId, dwLanguageId, reinterpret_cast<LPWSTR>((LPWSTR*)get_ptr(lpBuffer)), 0, Arguments);
-
666 if (dwResult)
-
667 str.assign(lpBuffer.get(), dwResult);
-
668 return dwResult;
-
669}
-
-
670
+
645
+
653template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
+
+
654static _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
+
655{
+
656 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(WCHAR)];
+
657
+
658 // Try to convert to stack buffer first.
+
659 int cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szStackBuffer, _countof(szStackBuffer));
+
660 if (cch) {
+
661 // Copy from stack.
+
662 sWideCharStr.assign(szStackBuffer, cch);
+
663 }
+
664 else if (::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
665 // Query the required output size. Allocate buffer. Then convert again.
+
666 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), NULL, 0);
+
667 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
668 cch = ::MultiByteToWideChar(CodePage, dwFlags, sMultiByteStr.c_str(), (int)sMultiByteStr.length(), szBuffer.get(), cch);
+
669 sWideCharStr.assign(szBuffer.get(), cch);
+
670 SecureZeroMemory(szBuffer.get(), sizeof(WCHAR) * cch);
+
671 }
672
-
673#pragma warning(pop)
+
673 SecureZeroMemory(szStackBuffer, sizeof(szStackBuffer));
674
-
675namespace winstd
-
676{
-
679
-
683#ifdef _UNICODE
-
684 typedef std::wstring tstring;
-
685#else
-
686 typedef std::string tstring;
-
687#endif
-
688
-
692 template <class _Ty>
-
- -
694 {
- -
696
- -
701
-
705 template <class _Ty2> LocalFree_delete(const LocalFree_delete<_Ty2>&) {}
-
706
-
-
712 void operator()(_Ty *_Ptr) const
-
713 {
-
714 LocalFree(_Ptr);
-
715 }
+
675 return cch;
+
676}
-
716 };
+
677
+
683template<class _Traits, class _Ax>
+
+
684static DWORD FormatMessage(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _Inout_ std::basic_string<char, _Traits, _Ax> &str, _In_opt_ va_list *Arguments)
+
685{
+
686 std::unique_ptr<CHAR[], winstd::LocalFree_delete<CHAR[]> > lpBuffer;
+
687 DWORD dwResult = FormatMessageA(dwFlags | FORMAT_MESSAGE_ALLOCATE_BUFFER, lpSource, dwMessageId, dwLanguageId, reinterpret_cast<LPSTR>((LPSTR*)get_ptr(lpBuffer)), 0, Arguments);
+
688 if (dwResult)
+
689 str.assign(lpBuffer.get(), dwResult);
+
690 return dwResult;
+
691}
-
717
-
721 template <class _Ty>
-
-
722 struct LocalFree_delete<_Ty[]>
-
723 {
- +
692
+
698template<class _Traits, class _Ax>
+
+
699static DWORD FormatMessage(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &str, _In_opt_ va_list *Arguments)
+
700{
+
701 std::unique_ptr<WCHAR[], winstd::LocalFree_delete<WCHAR[]> > lpBuffer;
+
702 DWORD dwResult = FormatMessageW(dwFlags | FORMAT_MESSAGE_ALLOCATE_BUFFER, lpSource, dwMessageId, dwLanguageId, reinterpret_cast<LPWSTR>((LPWSTR*)get_ptr(lpBuffer)), 0, Arguments);
+
703 if (dwResult)
+
704 str.assign(lpBuffer.get(), dwResult);
+
705 return dwResult;
+
706}
+
+
707
+
709
+
710#pragma warning(pop)
+
711
+
712namespace winstd
+
713{
+
716
+
720#ifdef _UNICODE
+
721 typedef std::wstring tstring;
+
722#else
+
723 typedef std::string tstring;
+
724#endif
725
-
729 LocalFree_delete() noexcept {}
-
730
-
-
734 void operator()(_Frees_ptr_opt_ _Ty *_Ptr) const noexcept
-
735 {
-
736 LocalFree(_Ptr);
-
737 }
-
+
729 template <class _Ty>
+
+ +
731 {
+ +
733
+
738
-
744 template<class _Other>
-
-
745 void operator()(_Other *) const
-
746 {
-
747 LocalFree(_Ptr);
-
748 }
+
742 template <class _Ty2> LocalFree_delete(const LocalFree_delete<_Ty2>&) {}
+
743
+
+
749 void operator()(_Ty *_Ptr) const
+
750 {
+
751 LocalFree(_Ptr);
+
752 }
-
749 };
+
753 };
-
750
-
- -
755 {
- -
760
-
-
766 void operator()(HGLOBAL _Ptr) const
-
767 {
-
768 GlobalFree(_Ptr);
-
769 }
+
754
+
758 template <class _Ty>
+
+
759 struct LocalFree_delete<_Ty[]>
+
760 {
+ +
762
+
766 LocalFree_delete() noexcept {}
+
767
+
+
771 void operator()(_Frees_ptr_opt_ _Ty *_Ptr) const noexcept
+
772 {
+
773 LocalFree(_Ptr);
+
774 }
-
770 };
+
775
+
781 template<class _Other>
+
+
782 void operator()(_Other *) const
+
783 {
+
784 LocalFree(_Ptr);
+
785 }
-
771
-
775 template <class T>
-
- -
777 {
- - -
780
-
781 public:
-
-
787 globalmem_accessor(_In_ HGLOBAL hMem) : m_h(hMem)
-
788 {
-
789 m_data = reinterpret_cast<T*>(GlobalLock(hMem));
-
790 if (!m_data)
-
791 throw win_runtime_error("GlobalLock failed");
-
792 }
+
786 };
-
793
-
- -
800 {
-
801 GlobalUnlock(m_h);
-
802 }
+
787
+
+ +
792 {
+ +
797
+
+
803 void operator()(HGLOBAL _Ptr) const
+
804 {
+
805 GlobalFree(_Ptr);
+
806 }
-
803
-
-
807 T* data() const noexcept
-
808 {
-
809 return m_data;
-
810 }
+
807 };
-
811
-
812 protected:
-
813 HGLOBAL m_h;
- -
815 };
+
808
+
812 template <class T>
+
+ +
814 {
+ + +
817
+
818 public:
+
+
824 globalmem_accessor(_In_ HGLOBAL hMem) : m_h(hMem)
+
825 {
+
826 m_data = reinterpret_cast<T*>(GlobalLock(hMem));
+
827 if (!m_data)
+
828 throw win_runtime_error("GlobalLock failed");
+
829 }
-
816
-
820 template<class _Ty, class _Dx>
-
- -
822 {
-
823 public:
-
-
829 ref_unique_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) :
-
830 m_own(owner),
-
831 m_ptr(owner.release())
-
832 {}
+
830
+
+ +
837 {
+
838 GlobalUnlock(m_h);
+
839 }
-
833
-
- -
840 m_own(other.m_own),
-
841 m_ptr(other.m_ptr)
-
842 {
-
843 other.m_ptr = nullptr;
-
844 }
+
840
+
+
844 T* data() const noexcept
+
845 {
+
846 return m_data;
+
847 }
-
845
-
- -
850 {
-
851 if (m_ptr != nullptr)
-
852 m_own.reset(m_ptr);
-
853 }
+
848
+
849 protected:
+
850 HGLOBAL m_h;
+ +
852 };
-
854
-
-
860 operator typename _Ty**()
-
861 {
-
862 return &m_ptr;
-
863 }
+
853
+
857 template<class _Ty, class _Dx>
+
+ +
859 {
+
860 public:
+
+
866 ref_unique_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) :
+
867 m_own(owner),
+
868 m_ptr(owner.release())
+
869 {}
-
864
-
-
870 operator typename _Ty*&()
-
871 {
-
872 return m_ptr;
-
873 }
+
870
+
+ +
877 m_own(other.m_own),
+
878 m_ptr(other.m_ptr)
+
879 {
+
880 other.m_ptr = nullptr;
+
881 }
-
874
-
875 protected:
-
876 std::unique_ptr<_Ty, _Dx> &m_own;
-
877 _Ty *m_ptr;
-
878 };
+
882
+
+ +
887 {
+
888 if (m_ptr != nullptr)
+
889 m_own.reset(m_ptr);
+
890 }
-
879
-
887 template<class _Ty, class _Dx>
-
-
888 ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) noexcept
-
889 {
-
890 return ref_unique_ptr<_Ty, _Dx>(owner);
-
891 }
+
891
+
+
897 operator typename _Ty**()
+
898 {
+
899 return &m_ptr;
+
900 }
-
892
-
897 template<class _Ty, class _Dx>
-
-
898 class ref_unique_ptr<_Ty[], _Dx>
-
899 {
-
900 public:
-
-
906 ref_unique_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept :
-
907 m_own(owner),
-
908 m_ptr(owner.release())
-
909 {}
+
901
+
+
907 operator typename _Ty*&()
+
908 {
+
909 return m_ptr;
+
910 }
-
910
-
-
916 ref_unique_ptr(_Inout_ ref_unique_ptr<_Ty[], _Dx> &&other) :
-
917 m_own(other.m_own),
-
918 m_ptr(other.m_ptr)
-
919 {
-
920 other.m_ptr = nullptr;
-
921 }
+
911
+
912 protected:
+
913 std::unique_ptr<_Ty, _Dx> &m_own;
+
914 _Ty *m_ptr;
+
915 };
-
922
-
- -
927 {
-
928 if (m_ptr != nullptr)
-
929 m_own.reset(m_ptr);
-
930 }
+
916
+
924 template<class _Ty, class _Dx>
+
+
925 ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) noexcept
+
926 {
+
927 return ref_unique_ptr<_Ty, _Dx>(owner);
+
928 }
-
931
-
-
937 operator typename _Ty**() noexcept
-
938 {
-
939 return &m_ptr;
-
940 }
+
929
+
934 template<class _Ty, class _Dx>
+
+
935 class ref_unique_ptr<_Ty[], _Dx>
+
936 {
+
937 public:
+
+
943 ref_unique_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept :
+
944 m_own(owner),
+
945 m_ptr(owner.release())
+
946 {}
-
941
-
-
947 operator typename _Ty*&()
-
948 {
-
949 return m_ptr;
-
950 }
+
947
+
+
953 ref_unique_ptr(_Inout_ ref_unique_ptr<_Ty[], _Dx> &&other) :
+
954 m_own(other.m_own),
+
955 m_ptr(other.m_ptr)
+
956 {
+
957 other.m_ptr = nullptr;
+
958 }
-
951
-
952 protected:
-
953 std::unique_ptr<_Ty[], _Dx> &m_own;
-
954 _Ty *m_ptr;
-
955 };
+
959
+
+ +
964 {
+
965 if (m_ptr != nullptr)
+
966 m_own.reset(m_ptr);
+
967 }
-
956
-
965 template<class _Ty, class _Dx>
-
-
966 ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx>& owner) noexcept
-
967 {
-
968 return ref_unique_ptr<_Ty[], _Dx>(owner);
-
969 }
+
968
+
+
974 operator typename _Ty**() noexcept
+
975 {
+
976 return &m_ptr;
+
977 }
-
970
-
972
-
975
-
981 template <class T, const T INVAL>
-
-
982 class handle
-
983 {
-
984 public:
-
988 typedef T handle_type;
-
989
-
993 static const T invalid;
-
994
-
-
998 handle() noexcept : m_h(invalid)
-
999 {
-
1000 }
+
978
+
+
984 operator typename _Ty*&()
+
985 {
+
986 return m_ptr;
+
987 }
-
1001
-
-
1007 handle(_In_opt_ handle_type h) noexcept : m_h(h)
-
1008 {
-
1009 }
+
988
+
989 protected:
+
990 std::unique_ptr<_Ty[], _Dx> &m_own;
+
991 _Ty *m_ptr;
+
992 };
-
1010
-
- -
1017 {
-
1018 // Transfer handle.
-
1019 m_h = h.m_h;
-
1020 h.m_h = invalid;
-
1021 }
+
993
+
1002 template<class _Ty, class _Dx>
+
+
1003 ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx>& owner) noexcept
+
1004 {
+
1005 return ref_unique_ptr<_Ty[], _Dx>(owner);
+
1006 }
-
1022
-
1023 private:
-
1024 // This class is noncopyable.
-
1025 handle(_In_ const handle<handle_type, INVAL> &h) noexcept {};
-
1026 handle<handle_type, INVAL>& operator=(_In_ const handle<handle_type, INVAL> &h) noexcept {};
-
1027
-
1028 public:
-
- -
1035 {
-
1036 attach(h);
-
1037 return *this;
-
1038 }
+
1007
+
1009
+
1012
+
1018 template <class T, const T INVAL>
+
+ +
1020 {
+
1021 public:
+
1025 typedef T handle_type;
+
1026
+
1030 static const T invalid;
+
1031
+
+
1035 handle() noexcept : m_h(invalid)
+
1036 {
+
1037 }
-
1039
-
1045 #pragma warning(suppress: 26432) // Move constructor is also present, but not detected by code analysis somehow.
-
- -
1047 {
-
1048 if (this != std::addressof(h)) {
-
1049 // Transfer handle.
-
1050 if (m_h != invalid)
-
1051 free_internal();
-
1052 m_h = h.m_h;
-
1053 h.m_h = invalid;
-
1054 }
-
1055 return *this;
-
1056 }
+
1038
+
+
1044 handle(_In_opt_ handle_type h) noexcept : m_h(h)
+
1045 {
+
1046 }
-
1057
-
-
1063 operator handle_type() const
-
1064 {
-
1065 return m_h;
-
1066 }
+
1047
+
+ +
1054 {
+
1055 // Transfer handle.
+
1056 m_h = h.m_h;
+
1057 h.m_h = invalid;
+
1058 }
-
1067
-
- -
1074 {
-
1075 assert(m_h != invalid);
-
1076 return *m_h;
-
1077 }
+
1059
+
1060 private:
+
1061 // This class is noncopyable.
+
1062 handle(_In_ const handle<handle_type, INVAL> &h) noexcept {};
+
1063 handle<handle_type, INVAL>& operator=(_In_ const handle<handle_type, INVAL> &h) noexcept {};
+
1064
+
1065 public:
+
+ +
1072 {
+
1073 attach(h);
+
1074 return *this;
+
1075 }
-
1078
+
1076
+
1082 #pragma warning(suppress: 26432) // Move constructor is also present, but not detected by code analysis somehow.
- +
1084 {
-
1085 assert(m_h == invalid);
-
1086 return &m_h;
-
1087 }
+
1085 if (this != std::addressof(h)) {
+
1086 // Transfer handle.
+
1087 if (m_h != invalid)
+
1088 free_internal();
+
1089 m_h = h.m_h;
+
1090 h.m_h = invalid;
+
1091 }
+
1092 return *this;
+
1093 }
-
1088
-
- -
1095 {
-
1096 assert(m_h != invalid);
-
1097 return m_h;
-
1098 }
+
1094
+
+
1100 operator handle_type() const
+
1101 {
+
1102 return m_h;
+
1103 }
-
1099
+
1104
-
1110 bool operator!() const
+
1111 {
-
1112 return m_h == invalid;
-
1113 }
+
1112 assert(m_h != invalid);
+
1113 return *m_h;
+
1114 }
-
1114
-
-
1123 bool operator<(_In_opt_ handle_type h) const
-
1124 {
-
1125 return m_h < h;
-
1126 }
+
1115
+
+ +
1121 {
+
1122 assert(m_h == invalid);
+
1123 return &m_h;
+
1124 }
-
1127
-
-
1136 bool operator<=(_In_opt_ handle_type h) const
-
1137 {
-
1138 return !operator>(h);
-
1139 }
+
1125
+
+ +
1132 {
+
1133 assert(m_h != invalid);
+
1134 return m_h;
+
1135 }
-
1140
-
-
1149 bool operator>=(_In_opt_ handle_type h) const
-
1150 {
-
1151 return !operator<(h);
-
1152 }
+
1136
+
+
1147 bool operator!() const
+
1148 {
+
1149 return m_h == invalid;
+
1150 }
-
1153
-
-
1162 bool operator>(_In_opt_ handle_type h) const
-
1163 {
-
1164 return h < m_h;
-
1165 }
+
1151
+
+
1160 bool operator<(_In_opt_ handle_type h) const
+
1161 {
+
1162 return m_h < h;
+
1163 }
-
1166
-
-
1175 bool operator!=(_In_opt_ handle_type h) const
-
1176 {
-
1177 return !operator==(h);
-
1178 }
+
1164
+
+
1173 bool operator<=(_In_opt_ handle_type h) const
+
1174 {
+
1175 return !operator>(h);
+
1176 }
-
1179
-
-
1188 bool operator==(_In_opt_ handle_type h) const
-
1189 {
-
1190 return m_h == h;
-
1191 }
+
1177
+
+
1186 bool operator>=(_In_opt_ handle_type h) const
+
1187 {
+
1188 return !operator<(h);
+
1189 }
-
1192
-
-
1200 void attach(_In_opt_ handle_type h) noexcept
-
1201 {
-
1202 if (m_h != invalid)
-
1203 free_internal();
-
1204 m_h = h;
-
1205 }
+
1190
+
+
1199 bool operator>(_In_opt_ handle_type h) const
+
1200 {
+
1201 return h < m_h;
+
1202 }
-
1206
+
1203
- -
1213 {
-
1214 handle_type h = m_h;
-
1215 m_h = invalid;
-
1216 return h;
-
1217 }
+
1212 bool operator!=(_In_opt_ handle_type h) const
+
1213 {
+
1214 return !operator==(h);
+
1215 }
-
1218
-
-
1222 void free()
-
1223 {
-
1224 if (m_h != invalid) {
-
1225 free_internal();
-
1226 m_h = invalid;
-
1227 }
+
1216
+
+
1225 bool operator==(_In_opt_ handle_type h) const
+
1226 {
+
1227 return m_h == h;
1228 }
1229
-
1230 protected:
-
1234 virtual void free_internal() noexcept = 0;
-
1235
-
1236 protected:
- -
1238 };
+
+
1237 void attach(_In_opt_ handle_type h) noexcept
+
1238 {
+
1239 if (m_h != invalid)
+
1240 free_internal();
+
1241 m_h = h;
+
1242 }
-
1239
-
1240 template <class T, const T INVAL>
-
1241 const T handle<T, INVAL>::invalid = INVAL;
-
1242
-
1246 template <class T, T INVAL>
-
-
1247 class dplhandle : public handle<T, INVAL>
-
1248 {
-
1249 public:
-
-
1253 dplhandle() noexcept
-
1254 {
-
1255 }
+
1243
+
+ +
1250 {
+
1251 handle_type h = m_h;
+
1252 m_h = invalid;
+
1253 return h;
+
1254 }
-
1256
-
- -
1263 {
-
1264 }
+
1255
+
+
1259 void free()
+
1260 {
+
1261 if (m_h != invalid) {
+
1262 free_internal();
+
1263 m_h = invalid;
+
1264 }
+
1265 }
-
1265
-
1271 dplhandle<handle_type, INVAL>(_In_ const dplhandle<handle_type, INVAL> &h) : handle<handle_type, INVAL>(duplicate_internal(h.m_h))
-
1272 {
-
1273 }
-
1274
-
1280 dplhandle<handle_type, INVAL>(_Inout_ dplhandle<handle_type, INVAL> &&h) noexcept : handle<handle_type, INVAL>(std::move(h))
-
1281 {
-
1282 }
-
1283
-
- -
1290 {
- -
1292 return *this;
-
1293 }
+
1266
+
1267 protected:
+
1271 virtual void free_internal() noexcept = 0;
+
1272
+
1273 protected:
+ +
1275 };
-
1294
-
- -
1301 {
-
1302 if (this != std::addressof(h)) {
-
1303 if (h.m_h != invalid) {
-
1304 handle_type h_new = duplicate_internal(h.m_h);
-
1305
-
1306 if (m_h != invalid)
-
1307 free_internal();
-
1308
-
1309 m_h = h_new;
-
1310 } else {
-
1311 if (m_h != invalid)
-
1312 free_internal();
-
1313
-
1314 m_h = invalid;
-
1315 }
-
1316 }
-
1317 return *this;
-
1318 }
+
1276
+
1277 template <class T, const T INVAL>
+
1278 const T handle<T, INVAL>::invalid = INVAL;
+
1279
+
1283 template <class T, T INVAL>
+
+
1284 class dplhandle : public handle<T, INVAL>
+
1285 {
+
1286 public:
+
+
1290 dplhandle() noexcept
+
1291 {
+
1292 }
-
1319
-
1325 #pragma warning(disable: 26432) // Move constructor is also present, but not detected by code analysis somehow.
+
1293
+
+ +
1300 {
+
1301 }
+
+
1302
+
1308 dplhandle<handle_type, INVAL>(_In_ const dplhandle<handle_type, INVAL> &h) : handle<handle_type, INVAL>(duplicate_internal(h.m_h))
+
1309 {
+
1310 }
+
1311
+
1317 dplhandle<handle_type, INVAL>(_Inout_ dplhandle<handle_type, INVAL> &&h) noexcept : handle<handle_type, INVAL>(std::move(h))
+
1318 {
+
1319 }
+
1320
1331
- -
1338 {
-
1339 return m_h != invalid ? duplicate_internal(m_h) : invalid;
-
1340 }
+ +
1338 {
+
1339 if (this != std::addressof(h)) {
+
1340 if (h.m_h != invalid) {
+
1341 handle_type h_new = duplicate_internal(h.m_h);
+
1342
+
1343 if (m_h != invalid)
+
1344 free_internal();
+
1345
+
1346 m_h = h_new;
+
1347 } else {
+
1348 if (m_h != invalid)
+
1349 free_internal();
+
1350
+
1351 m_h = invalid;
+
1352 }
+
1353 }
+
1354 return *this;
+
1355 }
-
1341
-
- -
1348 {
-
1349 if (m_h != invalid)
-
1350 free_internal();
-
1351
-
1352 m_h = h != invalid ? duplicate_internal(h) : invalid;
-
1353 }
+
1356
+
1362 #pragma warning(disable: 26432) // Move constructor is also present, but not detected by code analysis somehow.
+
+ +
1364 {
+ +
1366 return *this;
+
1367 }
-
1354
-
1355 protected:
-
1364 virtual handle_type duplicate_internal(_In_ handle_type h) const = 0;
-
1365 };
-
-
1366
1368
-
1371
-
-
1381 inline std::string load_msg_from_res(_In_opt_ HMODULE hModule, _In_ UINT nId, _In_ WORD wLanguage)
-
1382 {
-
1383 std::string sResult;
-
1384 HRSRC hFoundRes = FindResourceExW(hModule, MAKEINTRESOURCEW(6), MAKEINTRESOURCEW(nId), wLanguage);
-
1385 if (hFoundRes) {
-
1386 DWORD dwSize = SizeofResource(hModule, hFoundRes);
-
1387 if (dwSize) {
-
1388 HGLOBAL hLoadedRes = LoadResource(hModule, hFoundRes);
-
1389 if (hLoadedRes) {
-
1390 LPCWSTR szMessage = reinterpret_cast<LPCWSTR>(LockResource(hLoadedRes));
-
1391 if (szMessage) {
-
1392 WideCharToMultiByte(CP_UTF8, 0, szMessage, dwSize / sizeof(*szMessage), sResult, NULL, NULL);
-
1393 return sResult;
-
1394 } else
-
1395 SetLastError(ERROR_LOCK_FAILED);
-
1396 }
-
1397 }
-
1398 }
-
1399 sprintf(sResult, "msg %u", nId);
-
1400 return sResult;
-
1401 }
+
+ +
1375 {
+
1376 return m_h != invalid ? duplicate_internal(m_h) : invalid;
+
1377 }
-
1402
-
-
1412 inline std::string fmt_msg_from_res(_In_opt_ HMODULE hModule, _In_ UINT nId, _In_ WORD wLanguage, ...)
-
1413 {
-
1414 std::string sResult;
-
1415 HRSRC hFoundRes = FindResourceExW(hModule, MAKEINTRESOURCEW(6), MAKEINTRESOURCEW(nId), wLanguage);
-
1416 if (hFoundRes) {
-
1417 DWORD dwSize = SizeofResource(hModule, hFoundRes);
-
1418 if (dwSize) {
-
1419 HGLOBAL hLoadedRes = LoadResource(hModule, hFoundRes);
-
1420 if (hLoadedRes) {
-
1421 LPCWSTR szFormat = reinterpret_cast<LPCWSTR>(LockResource(hLoadedRes));
-
1422 if (szFormat) {
-
1423 dwSize /= sizeof(*szFormat);
-
1424 assert(wcsnlen(szFormat, dwSize) < dwSize); // Resource strings must be zero-terminated to make strings directly usable with sprintf.
-
1425 va_list arg;
-
1426 va_start(arg, wLanguage);
-
1427 std::wstring sMessage;
-
1428 vsprintf(sMessage, szFormat, arg);
-
1429 va_end(arg);
-
1430 WideCharToMultiByte(CP_UTF8, 0, sMessage, sResult, NULL, NULL);
-
1431 return sResult;
-
1432 } else
-
1433 SetLastError(ERROR_LOCK_FAILED);
-
1434 }
-
1435 }
-
1436 }
-
1437 sprintf(sResult, "msg %u", nId);
-
1438 return sResult;
-
1439 }
+
1378
+
+ +
1385 {
+
1386 if (m_h != invalid)
+
1387 free_internal();
+
1388
+
1389 m_h = h != invalid ? duplicate_internal(h) : invalid;
+
1390 }
-
1440
-
1444 template <typename _Tn>
-
-
1445 class num_runtime_error : public std::runtime_error
-
1446 {
-
1447 public:
-
1448 typedef _Tn error_type;
-
1449
-
1450 public:
-
-
1457 num_runtime_error(_In_ error_type num, _In_ const std::string& msg) :
-
1458 m_num(num),
-
1459 runtime_error(msg)
-
1460 {
-
1461 }
+
1391
+
1392 protected:
+
1401 virtual handle_type duplicate_internal(_In_ handle_type h) const = 0;
+
1402 };
-
1462
-
-
1469 num_runtime_error(_In_ error_type num, _In_opt_z_ const char *msg = nullptr) :
-
1470 m_num(num),
-
1471 runtime_error(msg)
-
1472 {
+
1403
+
1405
+
1408
+
+
1418 inline std::string load_msg_from_res(_In_opt_ HMODULE hModule, _In_ UINT nId, _In_ WORD wLanguage)
+
1419 {
+
1420 std::string sResult;
+
1421 HRSRC hFoundRes = FindResourceExW(hModule, MAKEINTRESOURCEW(6), MAKEINTRESOURCEW(nId), wLanguage);
+
1422 if (hFoundRes) {
+
1423 DWORD dwSize = SizeofResource(hModule, hFoundRes);
+
1424 if (dwSize) {
+
1425 HGLOBAL hLoadedRes = LoadResource(hModule, hFoundRes);
+
1426 if (hLoadedRes) {
+
1427 LPCWSTR szMessage = reinterpret_cast<LPCWSTR>(LockResource(hLoadedRes));
+
1428 if (szMessage) {
+
1429 WideCharToMultiByte(CP_UTF8, 0, szMessage, dwSize / sizeof(*szMessage), sResult, NULL, NULL);
+
1430 return sResult;
+
1431 } else
+
1432 SetLastError(ERROR_LOCK_FAILED);
+
1433 }
+
1434 }
+
1435 }
+
1436 sprintf(sResult, "msg %u", nId);
+
1437 return sResult;
+
1438 }
+
+
1439
+
+
1449 inline std::string fmt_msg_from_res(_In_opt_ HMODULE hModule, _In_ UINT nId, _In_ WORD wLanguage, ...)
+
1450 {
+
1451 std::string sResult;
+
1452 HRSRC hFoundRes = FindResourceExW(hModule, MAKEINTRESOURCEW(6), MAKEINTRESOURCEW(nId), wLanguage);
+
1453 if (hFoundRes) {
+
1454 DWORD dwSize = SizeofResource(hModule, hFoundRes);
+
1455 if (dwSize) {
+
1456 HGLOBAL hLoadedRes = LoadResource(hModule, hFoundRes);
+
1457 if (hLoadedRes) {
+
1458 LPCWSTR szFormat = reinterpret_cast<LPCWSTR>(LockResource(hLoadedRes));
+
1459 if (szFormat) {
+
1460 dwSize /= sizeof(*szFormat);
+
1461 assert(wcsnlen(szFormat, dwSize) < dwSize); // Resource strings must be zero-terminated to make strings directly usable with sprintf.
+
1462 va_list arg;
+
1463 va_start(arg, wLanguage);
+
1464 std::wstring sMessage;
+
1465 vsprintf(sMessage, szFormat, arg);
+
1466 va_end(arg);
+
1467 WideCharToMultiByte(CP_UTF8, 0, sMessage, sResult, NULL, NULL);
+
1468 return sResult;
+
1469 } else
+
1470 SetLastError(ERROR_LOCK_FAILED);
+
1471 }
+
1472 }
1473 }
+
1474 sprintf(sResult, "msg %u", nId);
+
1475 return sResult;
+
1476 }
-
1474
-
- -
1479 {
-
1480 return m_num;
-
1481 }
-
-
1482
-
1483 protected:
- -
1485 };
-
+
1477
+
1481 template <typename _Tn>
+
+
1482 class num_runtime_error : public std::runtime_error
+
1483 {
+
1484 public:
+
1485 typedef _Tn error_type;
1486
-
- -
1491 {
-
1492 public:
-
-
1498 win_runtime_error(_In_ error_type num) : num_runtime_error<DWORD>(num, message(num))
-
1499 {}
+
1487 public:
+
+
1494 num_runtime_error(_In_ error_type num, _In_ const std::string& msg) :
+
1495 m_num(num),
+
1496 runtime_error(msg)
+
1497 {
+
1498 }
-
1500
-
-
1507 win_runtime_error(_In_ error_type num, _In_ const std::string& msg) : num_runtime_error<DWORD>(num, msg + ": " + message(num))
-
1508 {}
+
1499
+
+
1506 num_runtime_error(_In_ error_type num, _In_opt_z_ const char *msg = nullptr) :
+
1507 m_num(num),
+
1508 runtime_error(msg)
+
1509 {
+
1510 }
-
1509
-
-
1516 win_runtime_error(_In_ error_type num, _In_z_ const char *msg) : num_runtime_error<DWORD>(num, std::string(msg) + ": " + message(num))
-
1517 {}
+
1511
+
+ +
1516 {
+
1517 return m_num;
+
1518 }
-
1518
-
-
1522 win_runtime_error() : num_runtime_error<DWORD>(GetLastError(), message(GetLastError()))
-
1523 {}
+
1519
+
1520 protected:
+ +
1522 };
-
1524
-
-
1530 win_runtime_error(_In_ const std::string& msg) : num_runtime_error<DWORD>(GetLastError(), msg + ": " + message(GetLastError()))
-
1531 {}
+
1523
+
+ +
1528 {
+
1529 public:
+
+
1535 win_runtime_error(_In_ error_type num) : num_runtime_error<DWORD>(num, message(num))
+
1536 {}
-
1532
-
-
1538 win_runtime_error(_In_z_ const char *msg) : num_runtime_error<DWORD>(GetLastError(), std::string(msg) + ": " + message(GetLastError()))
-
1539 {}
+
1537
+
+
1544 win_runtime_error(_In_ error_type num, _In_ const std::string& msg) : num_runtime_error<DWORD>(num, msg + ": " + message(num))
+
1545 {}
-
1540
-
1541 protected:
-
-
1548 static std::string message(_In_ error_type num, _In_opt_ DWORD dwLanguageId = 0)
-
1549 {
-
1550 error_type runtime_num = GetLastError();
-
1551 std::wstring wstr;
-
1552 if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, num, dwLanguageId, wstr, NULL)) {
-
1553 // Stock Windows error messages contain CRLF. Well... Trim all the trailing white space.
-
1554 wstr.erase(wstr.find_last_not_of(L" \t\n\r\f\v") + 1);
-
1555 } else
-
1556 sprintf(wstr, num >= 0x10000 ? L"Error 0x%X" : L"Error %u", num);
-
1557 std::string str;
-
1558 WideCharToMultiByte(CP_UTF8, 0, wstr, str, NULL, NULL);
-
1559 SetLastError(runtime_num);
-
1560 return str;
-
1561 }
+
1546
+
+
1553 win_runtime_error(_In_ error_type num, _In_z_ const char *msg) : num_runtime_error<DWORD>(num, std::string(msg) + ": " + message(num))
+
1554 {}
-
1562 };
+
1555
+
+
1559 win_runtime_error() : num_runtime_error<DWORD>(GetLastError(), message(GetLastError()))
+
1560 {}
-
1563
-
1565
-
1568
-
1572 template<class _Elem, class _Traits, class _Ax>
-
-
1573 class basic_string_printf : public std::basic_string<_Elem, _Traits, _Ax>
-
1574 {
-
1575 public:
-
1578
-
-
1584 basic_string_printf(_In_z_ _Printf_format_string_ const _Elem *format, ...)
-
1585 {
-
1586 va_list arg;
-
1587 va_start(arg, format);
-
1588 vsprintf(*this, format, arg);
-
1589 va_end(arg);
-
1590 }
+
1561
+
+
1567 win_runtime_error(_In_ const std::string& msg) : num_runtime_error<DWORD>(GetLastError(), msg + ": " + message(GetLastError()))
+
1568 {}
-
1591
-
1593
-
1596
-
-
1603 basic_string_printf(_In_ HINSTANCE hInstance, _In_ UINT nFormatID, ...)
-
1604 {
-
1605 _Myt format;
-
1606 ATLENSURE(format.LoadString(hInstance, nFormatID));
-
1607
-
1608 va_list arg;
-
1609 va_start(arg, nFormatID);
-
1610 vsprintf(*this, format, arg);
-
1611 va_end(arg);
-
1612 }
+
1569
+
+
1575 win_runtime_error(_In_z_ const char *msg) : num_runtime_error<DWORD>(GetLastError(), std::string(msg) + ": " + message(GetLastError()))
+
1576 {}
-
1613
+
1577
+
1578 protected:
+
+
1585 static std::string message(_In_ error_type num, _In_opt_ DWORD dwLanguageId = 0)
+
1586 {
+
1587 error_type runtime_num = GetLastError();
+
1588 std::wstring wstr;
+
1589 if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, num, dwLanguageId, wstr, NULL)) {
+
1590 // Stock Windows error messages contain CRLF. Well... Trim all the trailing white space.
+
1591 wstr.erase(wstr.find_last_not_of(L" \t\n\r\f\v") + 1);
+
1592 } else
+
1593 sprintf(wstr, num >= 0x10000 ? L"Error 0x%X" : L"Error %u", num);
+
1594 std::string str;
+
1595 WideCharToMultiByte(CP_UTF8, 0, wstr, str, NULL, NULL);
+
1596 SetLastError(runtime_num);
+
1597 return str;
+
1598 }
+
+
1599 };
+
+
1600
+
1602
+
1605
+
1609 template<class _Elem, class _Traits, class _Ax>
+
+
1610 class basic_string_printf : public std::basic_string<_Elem, _Traits, _Ax>
+
1611 {
+
1612 public:
+
1615
-
1621 basic_string_printf(_In_ HINSTANCE hInstance, _In_ WORD wLanguageID, _In_ UINT nFormatID, ...)
+
1621 basic_string_printf(_In_z_ _Printf_format_string_ const _Elem *format, ...)
1622 {
-
1623 _Myt format;
-
1624 ATLENSURE(format.LoadString(hInstance, nFormatID, wLanguageID));
-
1625
-
1626 va_list arg;
-
1627 va_start(arg, nFormatID);
-
1628 vsprintf(*this, format, arg);
-
1629 va_end(arg);
-
1630 }
+
1623 va_list arg;
+
1624 va_start(arg, format);
+
1625 vsprintf(*this, format, arg);
+
1626 va_end(arg);
+
1627 }
-
1631
-
1633 };
-
-
1634
- -
1639
- +
1628
+
1630
+
1633
+
+
1640 basic_string_printf(_In_ HINSTANCE hInstance, _In_ UINT nFormatID, ...)
+
1641 {
+
1642 _Myt format;
+
1643 ATLENSURE(format.LoadString(hInstance, nFormatID));
1644
-
1648#ifdef _UNICODE
- -
1650#else
- -
1652#endif
-
1653
-
1657 template<class _Elem, class _Traits, class _Ax>
-
-
1658 class basic_string_msg : public std::basic_string<_Elem, _Traits, _Ax>
-
1659 {
-
1660 public:
-
1663
-
-
1669 basic_string_msg(_In_z_ _FormatMessage_format_string_ const _Elem *format, ...)
-
1670 {
-
1671 va_list arg;
-
1672 va_start(arg, format);
-
1673 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
-
1674 va_end(arg);
-
1675 }
+
1645 va_list arg;
+
1646 va_start(arg, nFormatID);
+
1647 vsprintf(*this, format, arg);
+
1648 va_end(arg);
+
1649 }
+
1650
+
+
1658 basic_string_printf(_In_ HINSTANCE hInstance, _In_ WORD wLanguageID, _In_ UINT nFormatID, ...)
+
1659 {
+
1660 _Myt format;
+
1661 ATLENSURE(format.LoadString(hInstance, nFormatID, wLanguageID));
+
1662
+
1663 va_list arg;
+
1664 va_start(arg, nFormatID);
+
1665 vsprintf(*this, format, arg);
+
1666 va_end(arg);
+
1667 }
+
+
1668
+
1670 };
+
+
1671
+
1676
-
1678
+
1681
-
-
1688 basic_string_msg(_In_ HINSTANCE hInstance, _In_ UINT nFormatID, ...)
-
1689 {
-
1690 _Myt format(GetManager());
-
1691 ATLENSURE(format.LoadString(hInstance, nFormatID));
-
1692
-
1693 va_list arg;
-
1694 va_start(arg, nFormatID);
-
1695 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
-
1696 va_end(arg);
-
1697 }
-
-
1698
+
1685#ifdef _UNICODE
+ +
1687#else
+ +
1689#endif
+
1690
+
1694 template<class _Elem, class _Traits, class _Ax>
+
+
1695 class basic_string_msg : public std::basic_string<_Elem, _Traits, _Ax>
+
1696 {
+
1697 public:
+
1700
-
1706 basic_string_msg(_In_ HINSTANCE hInstance, _In_ WORD wLanguageID, _In_ UINT nFormatID, ...)
+
1706 basic_string_msg(_In_z_ _FormatMessage_format_string_ const _Elem *format, ...)
1707 {
-
1708 _Myt format(GetManager());
-
1709 ATLENSURE(format.LoadString(hInstance, nFormatID, wLanguageID));
-
1710
-
1711 va_list arg;
-
1712 va_start(arg, nFormatID);
-
1713 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
-
1714 va_end(arg);
-
1715 }
+
1708 va_list arg;
+
1709 va_start(arg, format);
+
1710 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
+
1711 va_end(arg);
+
1712 }
-
1716
+
1713
+
1715
1718
-
-
1724 basic_string_msg(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _In_opt_ va_list *Arguments)
-
1725 {
-
1726 FormatMessage(dwFlags & ~FORMAT_MESSAGE_ARGUMENT_ARRAY, lpSource, dwMessageId, dwLanguageId, *this, Arguments);
-
1727 }
+
+
1725 basic_string_msg(_In_ HINSTANCE hInstance, _In_ UINT nFormatID, ...)
+
1726 {
+
1727 _Myt format(GetManager());
+
1728 ATLENSURE(format.LoadString(hInstance, nFormatID));
+
1729
+
1730 va_list arg;
+
1731 va_start(arg, nFormatID);
+
1732 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
+
1733 va_end(arg);
+
1734 }
-
1728
-
-
1734 basic_string_msg(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _In_opt_ DWORD_PTR *Arguments)
-
1735 {
-
1736 FormatMessage(dwFlags | FORMAT_MESSAGE_ARGUMENT_ARRAY, lpSource, dwMessageId, dwLanguageId, *this, (va_list*)Arguments);
-
1737 }
+
1735
+
+
1743 basic_string_msg(_In_ HINSTANCE hInstance, _In_ WORD wLanguageID, _In_ UINT nFormatID, ...)
+
1744 {
+
1745 _Myt format(GetManager());
+
1746 ATLENSURE(format.LoadString(hInstance, nFormatID, wLanguageID));
+
1747
+
1748 va_list arg;
+
1749 va_start(arg, nFormatID);
+
1750 FormatMessage(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, *this, &arg);
+
1751 va_end(arg);
+
1752 }
-
1738
-
-
1744 basic_string_msg(_In_ DWORD dwFlags, _In_z_ LPCTSTR pszFormat, _In_opt_ va_list *Arguments)
-
1745 {
-
1746 FormatMessage(dwFlags & ~FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING, pszFormat, 0, 0, *this, Arguments);
-
1747 }
+
1753
+
1755
+
+
1761 basic_string_msg(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _In_opt_ va_list *Arguments)
+
1762 {
+
1763 FormatMessage(dwFlags & ~FORMAT_MESSAGE_ARGUMENT_ARRAY, lpSource, dwMessageId, dwLanguageId, *this, Arguments);
+
1764 }
-
1748
-
-
1754 basic_string_msg(_In_ DWORD dwFlags, _In_z_ LPCTSTR pszFormat, _In_opt_ DWORD_PTR *Arguments)
-
1755 {
-
1756 FormatMessage(dwFlags | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING, pszFormat, 0, 0, *this, (va_list*)Arguments);
-
1757 }
+
1765
+
+
1771 basic_string_msg(_In_ DWORD dwFlags, _In_opt_ LPCVOID lpSource, _In_ DWORD dwMessageId, _In_ DWORD dwLanguageId, _In_opt_ DWORD_PTR *Arguments)
+
1772 {
+
1773 FormatMessage(dwFlags | FORMAT_MESSAGE_ARGUMENT_ARRAY, lpSource, dwMessageId, dwLanguageId, *this, (va_list*)Arguments);
+
1774 }
-
1758 };
+
1775
+
+
1781 basic_string_msg(_In_ DWORD dwFlags, _In_z_ LPCTSTR pszFormat, _In_opt_ va_list *Arguments)
+
1782 {
+
1783 FormatMessage(dwFlags & ~FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING, pszFormat, 0, 0, *this, Arguments);
+
1784 }
-
1759
- -
1764
- -
1769
-
1773#ifdef _UNICODE
-
1774 typedef wstring_msg tstring_msg;
-
1775#else
- -
1777#endif
-
1778
-
1782 template<class _Elem, class _Traits, class _Ax>
-
-
1783 class basic_string_guid : public std::basic_string<_Elem, _Traits, _Ax>
-
1784 {
-
1785 public:
-
1788
-
-
1795 basic_string_guid(_In_ const GUID &guid, _In_z_ _Printf_format_string_ const _Elem *format)
-
1796 {
-
1797 sprintf<_Elem, _Traits, _Ax>(*this, format,
-
1798 guid.Data1,
-
1799 guid.Data2,
-
1800 guid.Data3,
-
1801 guid.Data4[0], guid.Data4[1],
-
1802 guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
-
1803 }
+
1785
+
+
1791 basic_string_msg(_In_ DWORD dwFlags, _In_z_ LPCTSTR pszFormat, _In_opt_ DWORD_PTR *Arguments)
+
1792 {
+
1793 FormatMessage(dwFlags | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING, pszFormat, 0, 0, *this, (va_list*)Arguments);
+
1794 }
-
1804
-
1806 };
+
1795 };
-
1807
-
-
1811 class string_guid : public basic_string_guid<char, std::char_traits<char>, std::allocator<char> >
-
1812 {
-
1813 public:
-
1816
-
-
1822 string_guid(_In_ const GUID &guid) :
-
1823 basic_string_guid<char, std::char_traits<char>, std::allocator<char> >(guid, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}")
-
1824 {
-
1825 }
+
1796
+ +
1801
+ +
1806
+
1810#ifdef _UNICODE
+
1811 typedef wstring_msg tstring_msg;
+
1812#else
+ +
1814#endif
+
1815
+
1819 template<class _Elem, class _Traits, class _Ax>
+
+
1820 class basic_string_guid : public std::basic_string<_Elem, _Traits, _Ax>
+
1821 {
+
1822 public:
+
1825
+
+
1832 basic_string_guid(_In_ const GUID &guid, _In_z_ _Printf_format_string_ const _Elem *format)
+
1833 {
+
1834 sprintf<_Elem, _Traits, _Ax>(*this, format,
+
1835 guid.Data1,
+
1836 guid.Data2,
+
1837 guid.Data3,
+
1838 guid.Data4[0], guid.Data4[1],
+
1839 guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
+
1840 }
-
1826
-
1828 };
+
1841
+
1843 };
-
1829
-
-
1833 class wstring_guid : public basic_string_guid<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
-
1834 {
-
1835 public:
-
1838
-
-
1844 wstring_guid(_In_ const GUID &guid) :
-
1845 basic_string_guid<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(guid, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}")
-
1846 {
-
1847 }
+
1844
+
+
1848 class string_guid : public basic_string_guid<char, std::char_traits<char>, std::allocator<char> >
+
1849 {
+
1850 public:
+
1853
+
+
1859 string_guid(_In_ const GUID &guid) :
+
1860 basic_string_guid<char, std::char_traits<char>, std::allocator<char> >(guid, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}")
+
1861 {
+
1862 }
-
1848
-
1850 };
+
1863
+
1865 };
-
1851
-
1855#ifdef _UNICODE
-
1856 typedef wstring_guid tstring_guid;
-
1857#else
- -
1859#endif
-
1860
-
1862
-
1865
-
1866 // winstd::sanitizing_allocator::destroy() member generates _Ptr parameter not used warning for primitive datatypes _Ty.
-
1867 #pragma warning(push)
-
1868 #pragma warning(disable: 4100)
-
1869
-
1877 template<class _Ty>
-
-
1878 class sanitizing_allocator : public std::allocator<_Ty>
-
1879 {
-
1880 public:
-
1881 typedef std::allocator<_Ty> _Mybase;
-
1882
-
1886 template<class _Other>
-
-
1887 struct rebind
-
1888 {
- -
1890 };
+
1866
+
+
1870 class wstring_guid : public basic_string_guid<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
+
1871 {
+
1872 public:
+
1875
+
+
1881 wstring_guid(_In_ const GUID &guid) :
+
1882 basic_string_guid<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(guid, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}")
+
1883 {
+
1884 }
-
1891
-
- -
1896 {
-
1897 }
+
1885
+
1887 };
-
1898
-
- -
1903 {
-
1904 }
+
1888
+
1892#ifdef _UNICODE
+
1893 typedef wstring_guid tstring_guid;
+
1894#else
+ +
1896#endif
+
1897
+
1899
+
1902
+
1903 // winstd::sanitizing_allocator::destroy() member generates _Ptr parameter not used warning for primitive datatypes _Ty.
+
1904 #pragma warning(push)
+
1905 #pragma warning(disable: 4100)
+
1906
+
1914 template<class _Ty>
+
+
1915 class sanitizing_allocator : public std::allocator<_Ty>
+
1916 {
+
1917 public:
+
1918 typedef std::allocator<_Ty> _Mybase;
+
1919
+
1923 template<class _Other>
+
+
1924 struct rebind
+
1925 {
+ +
1927 };
-
1905
-
1909 template<class _Other>
-
-
1910 sanitizing_allocator(_In_ const sanitizing_allocator<_Other> &_Othr) noexcept : _Mybase(_Othr)
-
1911 {
-
1912 }
+
1928
+
+ +
1933 {
+
1934 }
-
1913
-
-
1917 void deallocate(_In_ pointer _Ptr, _In_ size_type _Size)
-
1918 {
-
1919 // Sanitize then free.
-
1920 SecureZeroMemory(_Ptr, _Size);
-
1921 _Mybase::deallocate(_Ptr, _Size);
-
1922 }
-
-
1923 };
-
-
1924
-
1925 #pragma warning(pop)
-
1926
-
1934 typedef std::basic_string<char, std::char_traits<char>, sanitizing_allocator<char> > sanitizing_string;
1935
-
1943 typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, sanitizing_allocator<wchar_t> > sanitizing_wstring;
-
1944
-
1948#ifdef _UNICODE
- -
1950#else
- -
1952#endif
-
1953
-
1957 template<size_t N>
-
- -
1959 {
-
1960 public:
-
- -
1965 {
-
1966 ZeroMemory(m_data, N);
-
1967 }
+
+ +
1940 {
+
1941 }
-
1968
-
- -
1973 {
-
1974 SecureZeroMemory(m_data, N);
-
1975 }
+
1942
+
1946 template<class _Other>
+
+
1947 sanitizing_allocator(_In_ const sanitizing_allocator<_Other> &_Othr) noexcept : _Mybase(_Othr)
+
1948 {
+
1949 }
-
1976
-
1977 public:
-
1978 unsigned char m_data[N];
-
1979 };
+
1950
+
+
1954 void deallocate(_In_ pointer _Ptr, _In_ size_type _Size)
+
1955 {
+
1956 // Sanitize then free.
+
1957 SecureZeroMemory(_Ptr, _Size);
+
1958 _Mybase::deallocate(_Ptr, _Size);
+
1959 }
-
1980
-
1982}
-
Base template class to support converting GUID to string.
Definition Common.h:1784
-
basic_string_guid(const GUID &guid, const _Elem *format)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1795
-
Base template class to support string formatting using FormatMessage() style templates.
Definition Common.h:1659
-
basic_string_msg(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, DWORD_PTR *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1734
-
basic_string_msg(DWORD dwFlags, LPCTSTR pszFormat, va_list *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1744
-
basic_string_msg(HINSTANCE hInstance, WORD wLanguageID, UINT nFormatID,...)
Initializes a new string and formats its contents using FormatMessage() style template in resources.
Definition Common.h:1706
-
basic_string_msg(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, va_list *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1724
-
basic_string_msg(const _Elem *format,...)
Initializes a new string and formats its contents using FormatMessage() style template.
Definition Common.h:1669
-
basic_string_msg(HINSTANCE hInstance, UINT nFormatID,...)
Initializes a new string and formats its contents using FormatMessage() style template in resources.
Definition Common.h:1688
-
basic_string_msg(DWORD dwFlags, LPCTSTR pszFormat, DWORD_PTR *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1754
-
Base template class to support string formatting using printf() style templates.
Definition Common.h:1574
-
basic_string_printf(const _Elem *format,...)
Initializes a new string and formats its contents using printf() style template.
Definition Common.h:1584
-
basic_string_printf(HINSTANCE hInstance, WORD wLanguageID, UINT nFormatID,...)
Initializes a new string and formats its contents using printf() style template in resources.
Definition Common.h:1621
-
basic_string_printf(HINSTANCE hInstance, UINT nFormatID,...)
Initializes a new string and formats its contents using printf() style template in resources.
Definition Common.h:1603
-
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1248
+
1960 };
+
+
1961
+
1962 #pragma warning(pop)
+
1963
+
1971 typedef std::basic_string<char, std::char_traits<char>, sanitizing_allocator<char> > sanitizing_string;
+
1972
+
1980 typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, sanitizing_allocator<wchar_t> > sanitizing_wstring;
+
1981
+
1985#ifdef _UNICODE
+ +
1987#else
+ +
1989#endif
+
1990
+
1994 template<size_t N>
+
+ +
1996 {
+
1997 public:
+
+ +
2002 {
+
2003 ZeroMemory(m_data, N);
+
2004 }
+
+
2005
+
+ +
2010 {
+
2011 SecureZeroMemory(m_data, N);
+
2012 }
+
+
2013
+
2014 public:
+
2015 unsigned char m_data[N];
+
2016 };
+
+
2017
+
2019}
+
Base template class to support converting GUID to string.
Definition Common.h:1821
+
basic_string_guid(const GUID &guid, const _Elem *format)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1832
+
Base template class to support string formatting using FormatMessage() style templates.
Definition Common.h:1696
+
basic_string_msg(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, DWORD_PTR *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1771
+
basic_string_msg(DWORD dwFlags, LPCTSTR pszFormat, va_list *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1781
+
basic_string_msg(HINSTANCE hInstance, WORD wLanguageID, UINT nFormatID,...)
Initializes a new string and formats its contents using FormatMessage() style template in resources.
Definition Common.h:1743
+
basic_string_msg(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, va_list *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1761
+
basic_string_msg(const _Elem *format,...)
Initializes a new string and formats its contents using FormatMessage() style template.
Definition Common.h:1706
+
basic_string_msg(HINSTANCE hInstance, UINT nFormatID,...)
Initializes a new string and formats its contents using FormatMessage() style template in resources.
Definition Common.h:1725
+
basic_string_msg(DWORD dwFlags, LPCTSTR pszFormat, DWORD_PTR *Arguments)
Initializes a new string and formats its contents using FormatMessage() style.
Definition Common.h:1791
+
Base template class to support string formatting using printf() style templates.
Definition Common.h:1611
+
basic_string_printf(const _Elem *format,...)
Initializes a new string and formats its contents using printf() style template.
Definition Common.h:1621
+
basic_string_printf(HINSTANCE hInstance, WORD wLanguageID, UINT nFormatID,...)
Initializes a new string and formats its contents using printf() style template in resources.
Definition Common.h:1658
+
basic_string_printf(HINSTANCE hInstance, UINT nFormatID,...)
Initializes a new string and formats its contents using printf() style template in resources.
Definition Common.h:1640
+
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1285
virtual handle_type duplicate_internal(handle_type h) const =0
Abstract member function that must be implemented by child classes to do the actual object handle dup...
-
dplhandle< handle_type, INVAL > & operator=(handle_type h) noexcept
Attaches already available object handle.
Definition Common.h:1289
-
handle_type duplicate() const
Duplicates and returns a new object handle.
Definition Common.h:1337
-
dplhandle< handle_type, INVAL > & operator=(dplhandle< handle_type, INVAL > &&h) noexcept
Moves the object.
Definition Common.h:1326
-
void attach_duplicated(handle_type h)
Duplicates an object handle and sets a new object handle.
Definition Common.h:1347
-
dplhandle(handle_type h) noexcept
Initializes a new class instance with an already available object handle.
Definition Common.h:1262
-
dplhandle< handle_type, INVAL > & operator=(const dplhandle< handle_type, INVAL > &h) noexcept
Duplicates the object.
Definition Common.h:1300
-
dplhandle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:1253
-
Context scope automatic GlobalAlloc (un)access.
Definition Common.h:777
-
HGLOBAL m_h
memory handle
Definition Common.h:813
-
virtual ~globalmem_accessor()
Decrements the lock count associated with a memory object.
Definition Common.h:799
-
T * m_data
memory pointer
Definition Common.h:814
-
T * data() const noexcept
Return data pointer.
Definition Common.h:807
-
globalmem_accessor(HGLOBAL hMem)
Locks a global memory object and returns a pointer to the first byte of the object's memory block.
Definition Common.h:787
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle_type *& operator*() const
Returns the object handle value when the object handle is a pointer to a value (class,...
Definition Common.h:1073
+
dplhandle< handle_type, INVAL > & operator=(handle_type h) noexcept
Attaches already available object handle.
Definition Common.h:1326
+
handle_type duplicate() const
Duplicates and returns a new object handle.
Definition Common.h:1374
+
dplhandle< handle_type, INVAL > & operator=(dplhandle< handle_type, INVAL > &&h) noexcept
Moves the object.
Definition Common.h:1363
+
void attach_duplicated(handle_type h)
Duplicates an object handle and sets a new object handle.
Definition Common.h:1384
+
dplhandle(handle_type h) noexcept
Initializes a new class instance with an already available object handle.
Definition Common.h:1299
+
dplhandle< handle_type, INVAL > & operator=(const dplhandle< handle_type, INVAL > &h) noexcept
Duplicates the object.
Definition Common.h:1337
+
dplhandle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:1290
+
Context scope automatic GlobalAlloc (un)access.
Definition Common.h:814
+
HGLOBAL m_h
memory handle
Definition Common.h:850
+
virtual ~globalmem_accessor()
Decrements the lock count associated with a memory object.
Definition Common.h:836
+
T * m_data
memory pointer
Definition Common.h:851
+
T * data() const noexcept
Return data pointer.
Definition Common.h:844
+
globalmem_accessor(HGLOBAL hMem)
Locks a global memory object and returns a pointer to the first byte of the object's memory block.
Definition Common.h:824
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle_type *& operator*() const
Returns the object handle value when the object handle is a pointer to a value (class,...
Definition Common.h:1110
virtual void free_internal() noexcept=0
Abstract member function that must be implemented by child classes to do the actual object destructio...
-
handle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:998
-
bool operator>=(handle_type h) const
Is handle greater than or equal to?
Definition Common.h:1149
-
handle_type operator->() const
Provides object handle member access when the object handle is a pointer to a class or struct.
Definition Common.h:1094
-
handle_type * operator&()
Returns the object handle reference.
Definition Common.h:1083
-
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle(handle_type h) noexcept
Initializes a new class instance with an already available object handle.
Definition Common.h:1007
-
bool operator<(handle_type h) const
Is handle less than?
Definition Common.h:1123
-
handle< handle_type, INVAL > & operator=(handle_type h) noexcept
Attaches already available object handle.
Definition Common.h:1034
-
bool operator!() const
Tests if the object handle is invalid.
Definition Common.h:1110
-
handle< handle_type, INVAL > & operator=(handle< handle_type, INVAL > &&h) noexcept
Move assignment.
Definition Common.h:1046
-
bool operator!=(handle_type h) const
Is handle not equal to?
Definition Common.h:1175
-
void free()
Destroys the object.
Definition Common.h:1222
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
-
bool operator==(handle_type h) const
Is handle equal to?
Definition Common.h:1188
-
handle(handle< handle_type, INVAL > &&h) noexcept
Move constructor.
Definition Common.h:1016
-
handle_type detach()
Dismisses the object handle from this class.
Definition Common.h:1212
-
bool operator>(handle_type h) const
Is handle greater than?
Definition Common.h:1162
-
bool operator<=(handle_type h) const
Is handle less than or equal to?
Definition Common.h:1136
-
Numerical runtime error.
Definition Common.h:1446
-
num_runtime_error(error_type num, const char *msg=nullptr)
Constructs an exception.
Definition Common.h:1469
-
num_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition Common.h:1457
-
error_type number() const
Returns the error number.
Definition Common.h:1478
-
_Tn error_type
Error number type.
Definition Common.h:1448
-
error_type m_num
Numeric error code.
Definition Common.h:1484
-
std::unique_ptr< _Ty[], _Dx > & m_own
Original owner of the pointer.
Definition Common.h:953
-
ref_unique_ptr(ref_unique_ptr< _Ty[], _Dx > &&other)
Moves object.
Definition Common.h:916
-
virtual ~ref_unique_ptr()
Returns ownership of the pointer.
Definition Common.h:926
-
ref_unique_ptr(std::unique_ptr< _Ty[], _Dx > &owner) noexcept
Takes ownership of the pointer.
Definition Common.h:906
-
_Ty * m_ptr
Pointer.
Definition Common.h:954
-
Helper class for returning pointers to std::unique_ptr.
Definition Common.h:822
-
std::unique_ptr< _Ty, _Dx > & m_own
Original owner of the pointer.
Definition Common.h:876
-
_Ty * m_ptr
Pointer.
Definition Common.h:877
-
ref_unique_ptr(ref_unique_ptr< _Ty, _Dx > &&other)
Moves object.
Definition Common.h:839
-
~ref_unique_ptr()
Returns ownership of the pointer.
Definition Common.h:849
-
ref_unique_ptr(std::unique_ptr< _Ty, _Dx > &owner)
Takes ownership of the pointer.
Definition Common.h:829
-
An allocator template that sanitizes each memory block before it is destroyed or reallocated.
Definition Common.h:1879
-
sanitizing_allocator(const sanitizing_allocator< _Ty > &_Othr)
Construct by copying.
Definition Common.h:1902
-
void deallocate(pointer _Ptr, size_type _Size)
Deallocate object at _Ptr sanitizing its content first.
Definition Common.h:1917
-
sanitizing_allocator(const sanitizing_allocator< _Other > &_Othr) noexcept
Construct from a related allocator.
Definition Common.h:1910
-
std::allocator< _Ty > _Mybase
Base type.
Definition Common.h:1881
-
sanitizing_allocator() noexcept
Construct default allocator.
Definition Common.h:1895
-
Sanitizing BLOB.
Definition Common.h:1959
-
sanitizing_blob()
Constructs uninitialized BLOB.
Definition Common.h:1964
-
~sanitizing_blob()
Sanitizes BLOB.
Definition Common.h:1972
-
Single-byte character implementation of a class to support converting GUID to string.
Definition Common.h:1812
-
string_guid(const GUID &guid)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1822
-
Windows runtime error.
Definition Common.h:1491
-
win_runtime_error(const char *msg)
Constructs an exception using GetLastError()
Definition Common.h:1538
-
win_runtime_error(error_type num, const char *msg)
Constructs an exception.
Definition Common.h:1516
-
win_runtime_error(error_type num)
Constructs an exception.
Definition Common.h:1498
-
win_runtime_error()
Constructs an exception using GetLastError()
Definition Common.h:1522
-
static std::string message(error_type num, DWORD dwLanguageId=0)
Returns a user-readable Windows error message. As std::exception messages may only be char*,...
Definition Common.h:1548
-
win_runtime_error(const std::string &msg)
Constructs an exception using GetLastError()
Definition Common.h:1530
-
win_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition Common.h:1507
-
Wide character implementation of a class to support converting GUID to string.
Definition Common.h:1834
-
wstring_guid(const GUID &guid)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1844
-
std::string load_msg_from_res(HMODULE hModule, UINT nId, WORD wLanguage)
Loads exception message string from resources and converts it to UTF-8.
Definition Common.h:1381
-
std::string fmt_msg_from_res(HMODULE hModule, UINT nId, WORD wLanguage,...)
Loads exception message sprintf template from resources, formats it and converts it to UTF-8.
Definition Common.h:1412
-
#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
-
std::string tstring
Multi-byte / Wide-character string (according to _UNICODE)
Definition Common.h:686
-
ref_unique_ptr< _Ty, _Dx > get_ptr(std::unique_ptr< _Ty, _Dx > &owner) noexcept
Helper function template for returning pointers to std::unique_ptr.
Definition Common.h:888
-
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:74
-
std::basic_string< wchar_t, std::char_traits< wchar_t >, sanitizing_allocator< wchar_t > > sanitizing_wstring
A sanitizing variant of std::wstring.
Definition Common.h:1943
-
sanitizing_string sanitizing_tstring
Multi-byte / Wide-character sanitizing string (according to _UNICODE)
Definition Common.h:1951
-
std::basic_string< char, std::char_traits< char >, sanitizing_allocator< char > > sanitizing_string
A sanitizing variant of std::string.
Definition Common.h:1934
-
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 Common.h:381
-
basic_string_printf< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > wstring_printf
Wide character implementation of a class to support string formatting using printf() style templates.
Definition Common.h:1643
-
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 Common.h:473
-
string_guid tstring_guid
Multi-byte / Wide-character string GUID (according to _UNICODE)
Definition Common.h:1858
-
basic_string_msg< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > wstring_msg
Wide character implementation of a class to support string formatting using FormatMessage() style tem...
Definition Common.h:1768
-
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:251
-
static DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< char, _Traits, _Ax > &str, va_list *Arguments)
Formats a message string.
Definition Common.h:647
-
basic_string_printf< char, std::char_traits< char >, std::allocator< char > > string_printf
Single-byte character implementation of a class to support string formatting using printf() style tem...
Definition Common.h:1638
-
static int vsnprintf(char *str, size_t capacity, const char *format, va_list arg)
Formats string using printf().
Definition Common.h:220
-
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 Common.h:555
-
string_printf tstring_printf
Multi-byte / Wide-character formatted string (according to _UNICODE)
Definition Common.h:1651
-
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 Common.h:299
-
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:284
-
basic_string_msg< char, std::char_traits< char >, std::allocator< char > > string_msg
Single-byte character implementation of a class to support string formatting using FormatMessage() st...
Definition Common.h:1763
-
string_msg tstring_msg
Multi-byte / Wide-character formatted string (according to _UNICODE)
Definition Common.h:1776
-
static const T invalid
Invalid handle value.
Definition Common.h:993
-
Deleter for unique_ptr using GlobalFree.
Definition Common.h:755
-
GlobalFree_delete()
Default construct.
Definition Common.h:759
-
void operator()(HGLOBAL _Ptr) const
Delete a pointer.
Definition Common.h:766
-
LocalFree_delete() noexcept
Default construct.
Definition Common.h:729
-
LocalFree_delete< _Ty > _Myt
This type.
Definition Common.h:724
-
void operator()(_Other *) const
Delete a pointer of another type.
Definition Common.h:745
-
void operator()(_Ty *_Ptr) const noexcept
Delete a pointer.
Definition Common.h:734
-
Deleter for unique_ptr using LocalFree.
Definition Common.h:694
-
LocalFree_delete< _Ty > _Myt
This type.
Definition Common.h:695
-
LocalFree_delete(const LocalFree_delete< _Ty2 > &)
Construct from another LocalFree_delete.
Definition Common.h:705
-
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Common.h:712
-
LocalFree_delete()
Default construct.
Definition Common.h:700
-
Convert this type to sanitizing_allocator<_Other>
Definition Common.h:1888
-
sanitizing_allocator< _Other > other
Other type.
Definition Common.h:1889
+
handle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:1035
+
bool operator>=(handle_type h) const
Is handle greater than or equal to?
Definition Common.h:1186
+
handle_type operator->() const
Provides object handle member access when the object handle is a pointer to a class or struct.
Definition Common.h:1131
+
handle_type * operator&()
Returns the object handle reference.
Definition Common.h:1120
+
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle(handle_type h) noexcept
Initializes a new class instance with an already available object handle.
Definition Common.h:1044
+
bool operator<(handle_type h) const
Is handle less than?
Definition Common.h:1160
+
handle< handle_type, INVAL > & operator=(handle_type h) noexcept
Attaches already available object handle.
Definition Common.h:1071
+
bool operator!() const
Tests if the object handle is invalid.
Definition Common.h:1147
+
handle< handle_type, INVAL > & operator=(handle< handle_type, INVAL > &&h) noexcept
Move assignment.
Definition Common.h:1083
+
bool operator!=(handle_type h) const
Is handle not equal to?
Definition Common.h:1212
+
void free()
Destroys the object.
Definition Common.h:1259
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
+
bool operator==(handle_type h) const
Is handle equal to?
Definition Common.h:1225
+
handle(handle< handle_type, INVAL > &&h) noexcept
Move constructor.
Definition Common.h:1053
+
handle_type detach()
Dismisses the object handle from this class.
Definition Common.h:1249
+
bool operator>(handle_type h) const
Is handle greater than?
Definition Common.h:1199
+
bool operator<=(handle_type h) const
Is handle less than or equal to?
Definition Common.h:1173
+
Numerical runtime error.
Definition Common.h:1483
+
num_runtime_error(error_type num, const char *msg=nullptr)
Constructs an exception.
Definition Common.h:1506
+
num_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition Common.h:1494
+
error_type number() const
Returns the error number.
Definition Common.h:1515
+
_Tn error_type
Error number type.
Definition Common.h:1485
+
error_type m_num
Numeric error code.
Definition Common.h:1521
+
std::unique_ptr< _Ty[], _Dx > & m_own
Original owner of the pointer.
Definition Common.h:990
+
ref_unique_ptr(ref_unique_ptr< _Ty[], _Dx > &&other)
Moves object.
Definition Common.h:953
+
virtual ~ref_unique_ptr()
Returns ownership of the pointer.
Definition Common.h:963
+
ref_unique_ptr(std::unique_ptr< _Ty[], _Dx > &owner) noexcept
Takes ownership of the pointer.
Definition Common.h:943
+
_Ty * m_ptr
Pointer.
Definition Common.h:991
+
Helper class for returning pointers to std::unique_ptr.
Definition Common.h:859
+
std::unique_ptr< _Ty, _Dx > & m_own
Original owner of the pointer.
Definition Common.h:913
+
_Ty * m_ptr
Pointer.
Definition Common.h:914
+
ref_unique_ptr(ref_unique_ptr< _Ty, _Dx > &&other)
Moves object.
Definition Common.h:876
+
~ref_unique_ptr()
Returns ownership of the pointer.
Definition Common.h:886
+
ref_unique_ptr(std::unique_ptr< _Ty, _Dx > &owner)
Takes ownership of the pointer.
Definition Common.h:866
+
An allocator template that sanitizes each memory block before it is destroyed or reallocated.
Definition Common.h:1916
+
sanitizing_allocator(const sanitizing_allocator< _Ty > &_Othr)
Construct by copying.
Definition Common.h:1939
+
void deallocate(pointer _Ptr, size_type _Size)
Deallocate object at _Ptr sanitizing its content first.
Definition Common.h:1954
+
sanitizing_allocator(const sanitizing_allocator< _Other > &_Othr) noexcept
Construct from a related allocator.
Definition Common.h:1947
+
std::allocator< _Ty > _Mybase
Base type.
Definition Common.h:1918
+
sanitizing_allocator() noexcept
Construct default allocator.
Definition Common.h:1932
+
Sanitizing BLOB.
Definition Common.h:1996
+
sanitizing_blob()
Constructs uninitialized BLOB.
Definition Common.h:2001
+
~sanitizing_blob()
Sanitizes BLOB.
Definition Common.h:2009
+
Single-byte character implementation of a class to support converting GUID to string.
Definition Common.h:1849
+
string_guid(const GUID &guid)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1859
+
Windows runtime error.
Definition Common.h:1528
+
win_runtime_error(const char *msg)
Constructs an exception using GetLastError()
Definition Common.h:1575
+
win_runtime_error(error_type num, const char *msg)
Constructs an exception.
Definition Common.h:1553
+
win_runtime_error(error_type num)
Constructs an exception.
Definition Common.h:1535
+
win_runtime_error()
Constructs an exception using GetLastError()
Definition Common.h:1559
+
static std::string message(error_type num, DWORD dwLanguageId=0)
Returns a user-readable Windows error message. As std::exception messages may only be char*,...
Definition Common.h:1585
+
win_runtime_error(const std::string &msg)
Constructs an exception using GetLastError()
Definition Common.h:1567
+
win_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition Common.h:1544
+
Wide character implementation of a class to support converting GUID to string.
Definition Common.h:1871
+
wstring_guid(const GUID &guid)
Initializes a new string and formats its contents to string representation of given GUID.
Definition Common.h:1881
+
std::string load_msg_from_res(HMODULE hModule, UINT nId, WORD wLanguage)
Loads exception message string from resources and converts it to UTF-8.
Definition Common.h:1418
+
std::string fmt_msg_from_res(HMODULE hModule, UINT nId, WORD wLanguage,...)
Loads exception message sprintf template from resources, formats it and converts it to UTF-8.
Definition Common.h:1449
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
+
std::string tstring
Multi-byte / Wide-character string (according to _UNICODE)
Definition Common.h:723
+
ref_unique_ptr< _Ty, _Dx > get_ptr(std::unique_ptr< _Ty, _Dx > &owner) noexcept
Helper function template for returning pointers to std::unique_ptr.
Definition Common.h:925
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
+
std::basic_string< wchar_t, std::char_traits< wchar_t >, sanitizing_allocator< wchar_t > > sanitizing_wstring
A sanitizing variant of std::wstring.
Definition Common.h:1980
+
sanitizing_string sanitizing_tstring
Multi-byte / Wide-character sanitizing string (according to _UNICODE)
Definition Common.h:1988
+
std::basic_string< char, std::char_traits< char >, sanitizing_allocator< char > > sanitizing_string
A sanitizing variant of std::string.
Definition Common.h:1971
+
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 Common.h:418
+
basic_string_printf< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > wstring_printf
Wide character implementation of a class to support string formatting using printf() style templates.
Definition Common.h:1680
+
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 Common.h:510
+
string_guid tstring_guid
Multi-byte / Wide-character string GUID (according to _UNICODE)
Definition Common.h:1895
+
basic_string_msg< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > wstring_msg
Wide character implementation of a class to support string formatting using FormatMessage() style tem...
Definition Common.h:1805
+
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:288
+
static DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< char, _Traits, _Ax > &str, va_list *Arguments)
Formats a message string.
Definition Common.h:684
+
basic_string_printf< char, std::char_traits< char >, std::allocator< char > > string_printf
Single-byte character implementation of a class to support string formatting using printf() style tem...
Definition Common.h:1675
+
static int vsnprintf(char *str, size_t capacity, const char *format, va_list arg)
Formats string using printf().
Definition Common.h:257
+
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 Common.h:592
+
string_printf tstring_printf
Multi-byte / Wide-character formatted string (according to _UNICODE)
Definition Common.h:1688
+
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 Common.h:336
+
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:321
+
basic_string_msg< char, std::char_traits< char >, std::allocator< char > > string_msg
Single-byte character implementation of a class to support string formatting using FormatMessage() st...
Definition Common.h:1800
+
string_msg tstring_msg
Multi-byte / Wide-character formatted string (according to _UNICODE)
Definition Common.h:1813
+
static const T invalid
Invalid handle value.
Definition Common.h:1030
+
Deleter for unique_ptr using GlobalFree.
Definition Common.h:792
+
GlobalFree_delete()
Default construct.
Definition Common.h:796
+
void operator()(HGLOBAL _Ptr) const
Delete a pointer.
Definition Common.h:803
+
LocalFree_delete() noexcept
Default construct.
Definition Common.h:766
+
LocalFree_delete< _Ty > _Myt
This type.
Definition Common.h:761
+
void operator()(_Other *) const
Delete a pointer of another type.
Definition Common.h:782
+
void operator()(_Ty *_Ptr) const noexcept
Delete a pointer.
Definition Common.h:771
+
Deleter for unique_ptr using LocalFree.
Definition Common.h:731
+
LocalFree_delete< _Ty > _Myt
This type.
Definition Common.h:732
+
LocalFree_delete(const LocalFree_delete< _Ty2 > &)
Construct from another LocalFree_delete.
Definition Common.h:742
+
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Common.h:749
+
LocalFree_delete()
Default construct.
Definition Common.h:737
+
Convert this type to sanitizing_allocator<_Other>
Definition Common.h:1925
+
sanitizing_allocator< _Other > other
Other type.
Definition Common.h:1926
diff --git a/_cred_8h_source.html b/_cred_8h_source.html index fbde9fc9..13a89615 100644 --- a/_cred_8h_source.html +++ b/_cred_8h_source.html @@ -282,7 +282,7 @@ $(document).ready(function() { init_codefold(0); });
static BOOL CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, std::unique_ptr< PCREDENTIALW[], winstd::CredFree_delete< PCREDENTIALW[]> > &cCredentials) noexcept
Enumerates the credentials from the user's credential set. The credential set used is the one associa...
Definition Cred.h:217
static BOOL CredProtectW(BOOL fAsSelf, LPCWSTR pszCredentials, DWORD cchCredentials, std::basic_string< wchar_t, _Traits, _Ax > &sProtectedCredentials, CRED_PROTECTION_TYPE *ProtectionType)
Encrypts the specified credentials so that only the current security context can decrypt them.
Definition Cred.h:48
static BOOL CredUnprotectW(BOOL fAsSelf, LPCWSTR pszProtectedCredentials, DWORD cchCredentials, std::basic_string< wchar_t, _Traits, _Ax > &sCredentials)
Decrypts credentials that were previously encrypted by using the CredProtect function.
Definition Cred.h:100
-
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:93
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
CredFree_delete< _Ty > _Myt
This type.
Definition Cred.h:162
CredFree_delete()
Default construct.
Definition Cred.h:167
void operator()(_Other *) const
Delete a pointer of another type.
Definition Cred.h:185
@@ -295,7 +295,7 @@ $(document).ready(function() { init_codefold(0); });
diff --git a/_crypt_8h_source.html b/_crypt_8h_source.html index fcc343ea..fe52b48b 100644 --- a/_crypt_8h_source.html +++ b/_crypt_8h_source.html @@ -233,640 +233,648 @@ $(document).ready(function() { init_codefold(0); });
177static _Success_(return != 0) BOOL CryptEncrypt(_In_ HCRYPTKEY hKey, _In_opt_ HCRYPTHASH hHash, _In_ BOOL Final, _In_ DWORD dwFlags, _Inout_ std::vector<_Ty, _Ax> &aData)
178{
-
179 DWORD
-
180 dwDataLen = (DWORD)(aData.size() * sizeof(_Ty)),
-
181 dwBufLen = (DWORD)(aData.capacity() * sizeof(_Ty)),
-
182 dwEncLen = dwDataLen,
-
183 dwResult;
-
184
-
185 if (dwBufLen) {
-
186 aData.resize(dwBufLen);
-
187 if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
-
188 // Encryption succeeded.
-
189 assert(dwEncLen <= dwBufLen);
-
190 if (dwEncLen < dwBufLen)
-
191 aData.resize((dwEncLen + sizeof(_Ty) - 1) / sizeof(_Ty));
-
192 return TRUE;
-
193 } else
-
194 dwResult = GetLastError();
-
195 } else if (CryptEncrypt(hKey, NULL, Final, dwFlags, NULL, &dwEncLen, 0)) {
-
196 // CryptEncrypt() always succeeds for output data size queries.
-
197 // dwEncLen contains required output data size. Continue as if the buffer was to small. Actually, the output buffer _was_ too small!
-
198 dwResult = ERROR_MORE_DATA;
-
199 } else
-
200 dwResult = GetLastError();
-
201
-
202 if (dwResult == ERROR_MORE_DATA) {
-
203 // Encrypted data will be longer. Reserve more space and retry.
-
204 aData.resize(((dwBufLen = dwEncLen) + sizeof(_Ty) - 1) / sizeof(_Ty));
-
205 dwEncLen = dwDataLen;
-
206 if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
-
207 // Encryption succeeded.
-
208 assert(dwEncLen <= dwBufLen);
-
209 if (dwEncLen < dwBufLen)
-
210 aData.resize((dwEncLen + sizeof(_Ty) - 1) / sizeof(_Ty));
-
211 return TRUE;
-
212 }
-
213 } else {
-
214 // Resize back to data length.
-
215 aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
-
216 }
-
217
-
218 return FALSE;
-
219}
+
179 SIZE_T
+
180 sDataLen = SIZETMult(aData.size(), sizeof(_Ty)),
+
181 sBufLen = SIZETMult(aData.capacity(), sizeof(_Ty));
+
182 if (sDataLen > DWORD_MAX || sBufLen > DWORD_MAX)
+
183 throw std::invalid_argument("Data too big");
+
184 DWORD
+
185 dwDataLen = static_cast<DWORD>(sDataLen),
+
186 dwBufLen = static_cast<DWORD>(sBufLen),
+
187 dwEncLen = dwDataLen,
+
188 dwResult;
+
189
+
190 if (dwBufLen) {
+
191 aData.resize(dwBufLen);
+
192 if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
+
193 // Encryption succeeded.
+
194 assert(dwEncLen <= dwBufLen);
+
195 if (dwEncLen < dwBufLen)
+
196 aData.resize((dwEncLen + sizeof(_Ty) - 1) / sizeof(_Ty));
+
197 return TRUE;
+
198 } else
+
199 dwResult = GetLastError();
+
200 } else if (CryptEncrypt(hKey, NULL, Final, dwFlags, NULL, &dwEncLen, 0)) {
+
201 // CryptEncrypt() always succeeds for output data size queries.
+
202 // dwEncLen contains required output data size. Continue as if the buffer was to small. Actually, the output buffer _was_ too small!
+
203 dwResult = ERROR_MORE_DATA;
+
204 } else
+
205 dwResult = GetLastError();
+
206
+
207 if (dwResult == ERROR_MORE_DATA) {
+
208 // Encrypted data will be longer. Reserve more space and retry.
+
209 aData.resize(((dwBufLen = dwEncLen) + sizeof(_Ty) - 1) / sizeof(_Ty));
+
210 dwEncLen = dwDataLen;
+
211 if (CryptEncrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwEncLen, dwBufLen)) {
+
212 // Encryption succeeded.
+
213 assert(dwEncLen <= dwBufLen);
+
214 if (dwEncLen < dwBufLen)
+
215 aData.resize((dwEncLen + sizeof(_Ty) - 1) / sizeof(_Ty));
+
216 return TRUE;
+
217 }
+
218 } else {
+
219 // Resize back to data length.
+
220 aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
+
221 }
+
222
+
223 return FALSE;
+
224}
-
220
-
226template<class _Ty, class _Ax>
-
-
227static _Success_(return != 0) BOOL CryptDecrypt(_In_ HCRYPTKEY hKey, _In_opt_ HCRYPTHASH hHash, _In_ BOOL Final, _In_ DWORD dwFlags, _Inout_ std::vector<_Ty, _Ax> &aData)
-
228{
-
229 DWORD dwDataLen = (DWORD)(aData.size() * sizeof(_Ty));
-
230
-
231 if (CryptDecrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwDataLen)) {
-
232 // Decryption succeeded.
-
233 aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
-
234 return TRUE;
-
235 }
-
236
-
237 return FALSE;
-
238}
+
225
+
231template<class _Ty, class _Ax>
+
+
232static _Success_(return != 0) BOOL CryptDecrypt(_In_ HCRYPTKEY hKey, _In_opt_ HCRYPTHASH hHash, _In_ BOOL Final, _In_ DWORD dwFlags, _Inout_ std::vector<_Ty, _Ax> &aData)
+
233{
+
234 SIZE_T sDataLen = SIZETMult(aData.size(), sizeof(_Ty));
+
235 if (sDataLen > DWORD_MAX)
+
236 throw std::invalid_argument("Data too big");
+
237 DWORD dwDataLen = static_cast<DWORD>(sDataLen);
+
238
+
239 if (CryptDecrypt(hKey, hHash, Final, dwFlags, reinterpret_cast<BYTE*>(aData.data()), &dwDataLen)) {
+
240 // Decryption succeeded.
+
241 aData.resize((dwDataLen + sizeof(_Ty) - 1) / sizeof(_Ty));
+
242 return TRUE;
+
243 }
+
244
+
245 return FALSE;
+
246}
-
239
-
241
-
242namespace winstd
-
243{
-
246
-
-
252 class cert_context : public dplhandle<PCCERT_CONTEXT, NULL>
-
253 {
- -
255
-
256 public:
-
- -
263 {
-
264 if (m_h != invalid)
- -
266 }
+
247
+
249
+
250namespace winstd
+
251{
+
254
+
+
260 class cert_context : public dplhandle<PCCERT_CONTEXT, NULL>
+
261 {
+ +
263
+
264 public:
+
+ +
271 {
+
272 if (m_h != invalid)
+ +
274 }
-
267
-
-
276 bool operator==(_In_ const handle_type &other) const noexcept
-
277 {
-
278 // TODO: [Crypto] Make constant time.
-
279 return
-
280 m_h == other ||
-
281 m_h->cbCertEncoded == other->cbCertEncoded && memcmp(m_h->pbCertEncoded, other->pbCertEncoded, m_h->cbCertEncoded) == 0;
-
282 }
+
275
+
+
284 bool operator==(_In_ const handle_type &other) const noexcept
+
285 {
+
286 // TODO: [Crypto] Make constant time.
+
287 return
+
288 m_h == other ||
+
289 m_h->cbCertEncoded == other->cbCertEncoded && memcmp(m_h->pbCertEncoded, other->pbCertEncoded, m_h->cbCertEncoded) == 0;
+
290 }
-
283
-
-
292 bool operator!=(_In_ const handle_type &other) const noexcept
-
293 {
-
294 return !operator==(other);
-
295 }
+
291
+
+
300 bool operator!=(_In_ const handle_type &other) const noexcept
+
301 {
+
302 return !operator==(other);
+
303 }
-
296
-
-
305 bool operator<(_In_ const handle_type &other) const noexcept
-
306 {
-
307 // TODO: [Crypto] Make constant time.
-
308 const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
-
309 return r < 0 || r == 0 && m_h->cbCertEncoded < other->cbCertEncoded;
-
310 }
+
304
+
+
313 bool operator<(_In_ const handle_type &other) const noexcept
+
314 {
+
315 // TODO: [Crypto] Make constant time.
+
316 const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
+
317 return r < 0 || r == 0 && m_h->cbCertEncoded < other->cbCertEncoded;
+
318 }
-
311
-
-
320 bool operator>(_In_ const handle_type &other) const noexcept
-
321 {
-
322 // TODO: [Crypto] Make constant time.
-
323 const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
-
324 return r > 0 || r == 0 && m_h->cbCertEncoded > other->cbCertEncoded;
-
325 }
+
319
+
+
328 bool operator>(_In_ const handle_type &other) const noexcept
+
329 {
+
330 // TODO: [Crypto] Make constant time.
+
331 const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
+
332 return r > 0 || r == 0 && m_h->cbCertEncoded > other->cbCertEncoded;
+
333 }
-
326
-
-
335 bool operator<=(_In_ const handle_type &other) const noexcept
-
336 {
-
337 return !operator>(other);
-
338 }
+
334
+
+
343 bool operator<=(_In_ const handle_type &other) const noexcept
+
344 {
+
345 return !operator>(other);
+
346 }
-
339
-
-
348 bool operator>=(_In_ const handle_type &other) const noexcept
-
349 {
-
350 return !operator<(other);
-
351 }
+
347
+
+
356 bool operator>=(_In_ const handle_type &other) const noexcept
+
357 {
+
358 return !operator<(other);
+
359 }
-
352
-
353 protected:
-
-
359 void free_internal() noexcept override
-
360 {
-
361 CertFreeCertificateContext(m_h);
-
362 }
+
360
+
361 protected:
+
+
367 void free_internal() noexcept override
+
368 {
+
369 CertFreeCertificateContext(m_h);
+
370 }
-
363
-
- -
374 {
-
375 // As per doc, this only increases refcounter. Should never fail.
-
376 return CertDuplicateCertificateContext(h);
-
377 }
+
371
+
+ +
382 {
+
383 // As per doc, this only increases refcounter. Should never fail.
+
384 return CertDuplicateCertificateContext(h);
+
385 }
-
378 };
+
386 };
-
379
-
-
385 class cert_chain_context : public dplhandle<PCCERT_CHAIN_CONTEXT, NULL>
-
386 {
- -
388
-
389 public:
-
- -
396 {
-
397 if (m_h != invalid)
- -
399 }
+
387
+
+
393 class cert_chain_context : public dplhandle<PCCERT_CHAIN_CONTEXT, NULL>
+
394 {
+ +
396
+
397 public:
+
+ +
404 {
+
405 if (m_h != invalid)
+ +
407 }
-
400
-
401 protected:
-
-
407 void free_internal() noexcept override
-
408 {
-
409 CertFreeCertificateChain(m_h);
-
410 }
+
408
+
409 protected:
+
+
415 void free_internal() noexcept override
+
416 {
+
417 CertFreeCertificateChain(m_h);
+
418 }
-
411
-
- -
422 {
-
423 // As per doc, this only increases refcounter. Should never fail.
-
424 return CertDuplicateCertificateChain(h);
-
425 }
+
419
+
+ +
430 {
+
431 // As per doc, this only increases refcounter. Should never fail.
+
432 return CertDuplicateCertificateChain(h);
+
433 }
-
426 };
+
434 };
-
427
-
-
434 class cert_store : public handle<HCERTSTORE, NULL>
-
435 {
- -
437
-
438 public:
-
-
444 virtual ~cert_store()
-
445 {
-
446 if (m_h != invalid)
- -
448 }
+
435
+
+
442 class cert_store : public handle<HCERTSTORE, NULL>
+
443 {
+ +
445
+
446 public:
+
+
452 virtual ~cert_store()
+
453 {
+
454 if (m_h != invalid)
+ +
456 }
-
449
-
450 protected:
-
-
456 void free_internal() noexcept override
-
457 {
-
458 CertCloseStore(m_h, 0);
-
459 }
+
457
+
458 protected:
+
+
464 void free_internal() noexcept override
+
465 {
+
466 CertCloseStore(m_h, 0);
+
467 }
-
460 };
+
468 };
-
461
-
-
467 class crypt_prov : public handle<HCRYPTPROV, NULL>
-
468 {
- -
470
-
471 public:
-
-
477 virtual ~crypt_prov()
-
478 {
-
479 if (m_h != invalid)
- -
481 }
+
469
+
+
475 class crypt_prov : public handle<HCRYPTPROV, NULL>
+
476 {
+ +
478
+
479 public:
+
+
485 virtual ~crypt_prov()
+
486 {
+
487 if (m_h != invalid)
+ +
489 }
-
482
-
483 protected:
-
-
489 void free_internal() noexcept override
-
490 {
-
491 CryptReleaseContext(m_h, 0);
-
492 }
+
490
+
491 protected:
+
+
497 void free_internal() noexcept override
+
498 {
+
499 CryptReleaseContext(m_h, 0);
+
500 }
-
493 };
+
501 };
-
494
-
-
500 class crypt_hash : public dplhandle<HCRYPTHASH, NULL>
-
501 {
- -
503
-
504 public:
-
-
510 virtual ~crypt_hash()
-
511 {
-
512 if (m_h != invalid)
- -
514 }
+
502
+
+
508 class crypt_hash : public dplhandle<HCRYPTHASH, NULL>
+
509 {
+ +
511
+
512 public:
+
+
518 virtual ~crypt_hash()
+
519 {
+
520 if (m_h != invalid)
+ +
522 }
-
515
-
516 protected:
-
-
522 void free_internal() noexcept override
-
523 {
-
524 CryptDestroyHash(m_h);
-
525 }
+
523
+
524 protected:
+
+
530 void free_internal() noexcept override
+
531 {
+
532 CryptDestroyHash(m_h);
+
533 }
-
526
-
- -
537 {
-
538 handle_type hNew;
-
539 if (CryptDuplicateHash(h, NULL, 0, &hNew))
-
540 return hNew;
-
541 throw win_runtime_error("CryptDuplicateHash failed");
-
542 }
+
534
+
+ +
545 {
+
546 handle_type hNew;
+
547 if (CryptDuplicateHash(h, NULL, 0, &hNew))
+
548 return hNew;
+
549 throw win_runtime_error("CryptDuplicateHash failed");
+
550 }
-
543 };
+
551 };
-
544
-
-
553 class crypt_key : public dplhandle<HCRYPTKEY, NULL>
-
554 {
- -
556
-
557 public:
-
-
563 virtual ~crypt_key()
-
564 {
-
565 if (m_h != invalid)
- -
567 }
+
552
+
+
561 class crypt_key : public dplhandle<HCRYPTKEY, NULL>
+
562 {
+ +
564
+
565 public:
+
+
571 virtual ~crypt_key()
+
572 {
+
573 if (m_h != invalid)
+ +
575 }
-
568
-
-
577 bool create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
-
578 {
-
579 if (dwKeySpec != AT_KEYEXCHANGE && dwKeySpec != AT_SIGNATURE) {
-
580 SetLastError(ERROR_INVALID_PARAMETER);
-
581 return false;
-
582 }
-
583
-
584 // Generate the private key.
-
585 handle_type h;
-
586 if (CryptGenKey(hProv, dwKeySpec, CRYPT_EXPORTABLE, &h)) {
-
587 // Export the private key, we'll convert it to a private exponent of one key.
-
588 std::vector<BYTE, sanitizing_allocator<BYTE>> key_blob;
-
589 if (CryptExportKey(h, 0, PRIVATEKEYBLOB, 0, key_blob)) {
-
590 CryptDestroyKey(h);
+
576
+
+
585 bool create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
+
586 {
+
587 if (dwKeySpec != AT_KEYEXCHANGE && dwKeySpec != AT_SIGNATURE) {
+
588 SetLastError(ERROR_INVALID_PARAMETER);
+
589 return false;
+
590 }
591
-
592 // Get the byte length of the key.
-
593 size_t
-
594 size_key = *reinterpret_cast<DWORD*>(&key_blob[12])/8,
-
595 size_prime = size_key/2;
-
596
-
597 // Modify the Exponent in Key BLOB format
-
598 // Key BLOB format is documented in SDK
+
592 // Generate the private key.
+
593 handle_type h;
+
594 if (CryptGenKey(hProv, dwKeySpec, CRYPT_EXPORTABLE, &h)) {
+
595 // Export the private key, we'll convert it to a private exponent of one key.
+
596 std::vector<BYTE, sanitizing_allocator<BYTE>> key_blob;
+
597 if (CryptExportKey(h, 0, PRIVATEKEYBLOB, 0, key_blob)) {
+
598 CryptDestroyKey(h);
599
-
600 // Convert pubexp in rsapubkey to 1
-
601 LPBYTE ptr = &key_blob[16];
-
602 *reinterpret_cast<DWORD*>(ptr) = 1;
-
603 ptr += sizeof(DWORD);
+
600 // Get the byte length of the key.
+
601 size_t
+
602 size_key = *reinterpret_cast<DWORD*>(&key_blob[12])/8,
+
603 size_prime = size_key/2;
604
-
605 // Skip modulus, prime1, prime2
-
606 ptr += size_key;
-
607 ptr += size_prime;
-
608 ptr += size_prime;
-
609
-
610 // Convert exponent1 to 1
-
611 ptr[0] = 1;
-
612 memset(ptr + 1, 0, size_prime - 1);
-
613 ptr += size_prime;
-
614
-
615 // Convert exponent2 to 1
-
616 ptr[0] = 1;
-
617 memset(ptr + 1, 0, size_prime - 1);
-
618 ptr += size_prime;
-
619
-
620 // Skip coefficient
+
605 // Modify the Exponent in Key BLOB format
+
606 // Key BLOB format is documented in SDK
+
607
+
608 // Convert pubexp in rsapubkey to 1
+
609 LPBYTE ptr = &key_blob[16];
+
610 *reinterpret_cast<DWORD*>(ptr) = 1;
+
611 ptr += sizeof(DWORD);
+
612
+
613 // Skip modulus, prime1, prime2
+
614 ptr += size_key;
+
615 ptr += size_prime;
+
616 ptr += size_prime;
+
617
+
618 // Convert exponent1 to 1
+
619 ptr[0] = 1;
+
620 memset(ptr + 1, 0, size_prime - 1);
621 ptr += size_prime;
622
-
623 // Convert privateExponent to 1
+
623 // Convert exponent2 to 1
624 ptr[0] = 1;
-
625 memset(ptr + 1, 0, size_key - 1);
-
626
-
627 // Import the exponent-of-one private key.
-
628 if (CryptImportKey(hProv, key_blob.data(), static_cast<DWORD>(key_blob.size()), 0, 0, &h)) {
-
629 attach(h);
-
630 return true;
-
631 }
-
632 } else
-
633 CryptDestroyKey(h);
-
634 }
-
635
-
636 return false;
-
637 }
+
625 memset(ptr + 1, 0, size_prime - 1);
+
626 ptr += size_prime;
+
627
+
628 // Skip coefficient
+
629 ptr += size_prime;
+
630
+
631 // Convert privateExponent to 1
+
632 ptr[0] = 1;
+
633 memset(ptr + 1, 0, size_key - 1);
+
634
+
635 // Import the exponent-of-one private key.
+
636 if (CryptImportKey(hProv, key_blob.data(), static_cast<DWORD>(key_blob.size()), 0, 0, &h)) {
+
637 attach(h);
+
638 return true;
+
639 }
+
640 } else
+
641 CryptDestroyKey(h);
+
642 }
+
643
+
644 return false;
+
645 }
-
638
-
639 protected:
-
-
645 void free_internal() noexcept override
-
646 {
-
647 CryptDestroyKey(m_h);
-
648 }
+
646
+
647 protected:
+
+
653 void free_internal() noexcept override
+
654 {
+
655 CryptDestroyKey(m_h);
+
656 }
-
649
-
- -
660 {
-
661 handle_type hNew;
-
662 if (CryptDuplicateKey(h, NULL, 0, &hNew))
-
663 return hNew;
-
664 throw win_runtime_error("CryptDuplicateKey failed");
-
665 }
+
657
+
+ +
668 {
+
669 handle_type hNew;
+
670 if (CryptDuplicateKey(h, NULL, 0, &hNew))
+
671 return hNew;
+
672 throw win_runtime_error("CryptDuplicateKey failed");
+
673 }
-
666 };
+
674 };
-
667
-
671 #pragma warning(push)
-
672 #pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
-
-
673 class data_blob : public DATA_BLOB
-
674 {
-
675 public:
-
-
679 data_blob() noexcept
-
680 {
-
681 cbData = 0;
-
682 pbData = NULL;
-
683 }
+
675
+
679 #pragma warning(push)
+
680 #pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
+
+
681 class data_blob : public DATA_BLOB
+
682 {
+
683 public:
+
+
687 data_blob() noexcept
+
688 {
+
689 cbData = 0;
+
690 pbData = NULL;
+
691 }
-
684
-
-
688 data_blob(_In_count_(size) BYTE *data, _In_ DWORD size) noexcept
-
689 {
-
690 cbData = size;
-
691 pbData = data;
-
692 }
+
692
+
+
696 data_blob(_In_count_(size) BYTE *data, _In_ DWORD size) noexcept
+
697 {
+
698 cbData = size;
+
699 pbData = data;
+
700 }
-
693
-
-
697 data_blob(_In_ const DATA_BLOB &other)
-
698 {
-
699 cbData = other.cbData;
-
700 if (cbData) {
-
701 pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
-
702 if (!pbData) throw win_runtime_error("LocalAlloc failed");
-
703 memcpy(pbData, other.pbData, other.cbData);
-
704 } else
-
705 pbData = NULL;
-
706 }
+
701
+
+
705 data_blob(_In_ const DATA_BLOB &other)
+
706 {
+
707 cbData = other.cbData;
+
708 if (cbData) {
+
709 pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
+
710 if (!pbData) throw win_runtime_error("LocalAlloc failed");
+
711 memcpy(pbData, other.pbData, other.cbData);
+
712 } else
+
713 pbData = NULL;
+
714 }
-
707
-
-
711 data_blob(_Inout_ data_blob &&other) noexcept
-
712 {
-
713 cbData = other.cbData;
-
714 pbData = other.pbData;
-
715 other.cbData = 0;
-
716 other.pbData = NULL;
-
717 }
+
715
+
+
719 data_blob(_Inout_ data_blob &&other) noexcept
+
720 {
+
721 cbData = other.cbData;
+
722 pbData = other.pbData;
+
723 other.cbData = 0;
+
724 other.pbData = NULL;
+
725 }
-
718
-
-
722 virtual ~data_blob()
-
723 {
-
724 if (pbData != NULL)
-
725 LocalFree(pbData);
-
726 }
+
726
+
+
730 virtual ~data_blob()
+
731 {
+
732 if (pbData != NULL)
+
733 LocalFree(pbData);
+
734 }
-
727
-
-
731 data_blob& operator=(_In_ const DATA_BLOB &other)
-
732 {
-
733 if (this != &other) {
-
734 cbData = other.cbData;
-
735 if (pbData)
-
736 LocalFree(pbData);
-
737 if (cbData) {
-
738 pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
-
739 if (!pbData) throw win_runtime_error("LocalAlloc failed");
-
740 memcpy(pbData, other.pbData, other.cbData);
-
741 } else
-
742 pbData = NULL;
-
743 }
-
744
-
745 return *this;
-
746 }
+
735
+
+
739 data_blob& operator=(_In_ const DATA_BLOB &other)
+
740 {
+
741 if (this != &other) {
+
742 cbData = other.cbData;
+
743 if (pbData)
+
744 LocalFree(pbData);
+
745 if (cbData) {
+
746 pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
+
747 if (!pbData) throw win_runtime_error("LocalAlloc failed");
+
748 memcpy(pbData, other.pbData, other.cbData);
+
749 } else
+
750 pbData = NULL;
+
751 }
+
752
+
753 return *this;
+
754 }
-
747
-
-
751 data_blob& operator=(_Inout_ data_blob &&other) noexcept
-
752 {
-
753 if (this != &other) {
-
754 cbData = other.cbData;
-
755 if (pbData)
-
756 LocalFree(pbData);
-
757 pbData = other.pbData;
-
758 other.cbData = 0;
-
759 other.pbData = NULL;
-
760 }
-
761
-
762 return *this;
-
763 }
-
-
764
-
-
768 DWORD size() const noexcept
-
769 {
-
770 return cbData;
+
755
+
+
759 data_blob& operator=(_Inout_ data_blob &&other) noexcept
+
760 {
+
761 if (this != &other) {
+
762 cbData = other.cbData;
+
763 if (pbData)
+
764 LocalFree(pbData);
+
765 pbData = other.pbData;
+
766 other.cbData = 0;
+
767 other.pbData = NULL;
+
768 }
+
769
+
770 return *this;
771 }
772
-
776 const BYTE* data() const noexcept
+
776 DWORD size() const noexcept
777 {
-
778 return pbData;
+
778 return cbData;
779 }
780
-
784 BYTE* data() noexcept
+
784 const BYTE* data() const noexcept
785 {
786 return pbData;
787 }
-
788 };
+
788
+
+
792 BYTE* data() noexcept
+
793 {
+
794 return pbData;
+
795 }
-
789 #pragma warning(pop)
-
790
-
792}
-
793
-
796
-
797#pragma warning(push)
-
798#pragma warning(disable: 4505) // Don't warn on unused code
-
799
-
-
805static BOOL CertGetCertificateChain(_In_opt_ HCERTCHAINENGINE hChainEngine, _In_ PCCERT_CONTEXT pCertContext, _In_opt_ LPFILETIME pTime, _In_opt_ HCERTSTORE hAdditionalStore, _In_ PCERT_CHAIN_PARA pChainPara, _In_ DWORD dwFlags, _Reserved_ LPVOID pvReserved, _Inout_ winstd::cert_chain_context &ctx)
-
806{
-
807 PCCERT_CHAIN_CONTEXT pChainContext;
-
808 BOOL bResult = CertGetCertificateChain(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, &pChainContext);
-
809 if (bResult)
-
810 ctx.attach(pChainContext);
-
811 return bResult;
-
812}
+
796 };
-
813
-
-
815static BOOL CryptAcquireContextA(_Inout_ winstd::crypt_prov &prov, _In_opt_ LPCSTR szContainer, _In_opt_ LPCSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags)
-
816{
-
817 HCRYPTPROV h;
-
818 BOOL bResult = CryptAcquireContextA(&h, szContainer, szProvider, dwProvType, dwFlags);
-
819 if (bResult)
-
820 prov.attach(h);
-
821 return bResult;
-
822}
+
797 #pragma warning(pop)
+
798
+
800}
+
801
+
804
+
805#pragma warning(push)
+
806#pragma warning(disable: 4505) // Don't warn on unused code
+
807
+
+
813static BOOL CertGetCertificateChain(_In_opt_ HCERTCHAINENGINE hChainEngine, _In_ PCCERT_CONTEXT pCertContext, _In_opt_ LPFILETIME pTime, _In_opt_ HCERTSTORE hAdditionalStore, _In_ PCERT_CHAIN_PARA pChainPara, _In_ DWORD dwFlags, _Reserved_ LPVOID pvReserved, _Inout_ winstd::cert_chain_context &ctx)
+
814{
+
815 PCCERT_CHAIN_CONTEXT pChainContext;
+
816 BOOL bResult = CertGetCertificateChain(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, &pChainContext);
+
817 if (bResult)
+
818 ctx.attach(pChainContext);
+
819 return bResult;
+
820}
-
823
-
-
829static BOOL CryptAcquireContextW(_Inout_ winstd::crypt_prov &prov, _In_opt_ LPCWSTR szContainer, _In_opt_ LPCWSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags)
-
830{
-
831 HCRYPTPROV h;
-
832 BOOL bResult = CryptAcquireContextW(&h, szContainer, szProvider, dwProvType, dwFlags);
-
833 if (bResult)
-
834 prov.attach(h);
-
835 return bResult;
-
836}
+
821
+
+
823static BOOL CryptAcquireContextA(_Inout_ winstd::crypt_prov &prov, _In_opt_ LPCSTR szContainer, _In_opt_ LPCSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags)
+
824{
+
825 HCRYPTPROV h;
+
826 BOOL bResult = CryptAcquireContextA(&h, szContainer, szProvider, dwProvType, dwFlags);
+
827 if (bResult)
+
828 prov.attach(h);
+
829 return bResult;
+
830}
-
837
-
-
843static BOOL CryptCreateHash(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTKEY hKey, _In_ DWORD dwFlags, _Inout_ winstd::crypt_hash &hash)
-
844{
-
845 HCRYPTHASH h;
-
846 BOOL bResult = CryptCreateHash(hProv, Algid, hKey, dwFlags, &h);
-
847 if (bResult)
-
848 hash.attach(h);
-
849 return bResult;
-
850}
+
831
+
+
837static BOOL CryptAcquireContextW(_Inout_ winstd::crypt_prov &prov, _In_opt_ LPCWSTR szContainer, _In_opt_ LPCWSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags)
+
838{
+
839 HCRYPTPROV h;
+
840 BOOL bResult = CryptAcquireContextW(&h, szContainer, szProvider, dwProvType, dwFlags);
+
841 if (bResult)
+
842 prov.attach(h);
+
843 return bResult;
+
844}
-
851
-
-
857static BOOL CryptGenKey(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
-
858{
-
859 HCRYPTKEY h;
-
860 BOOL bResult = CryptGenKey(hProv, Algid, dwFlags, &h);
-
861 if (bResult)
-
862 key.attach(h);
-
863 return bResult;
-
864}
+
845
+
+
851static BOOL CryptCreateHash(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTKEY hKey, _In_ DWORD dwFlags, _Inout_ winstd::crypt_hash &hash)
+
852{
+
853 HCRYPTHASH h;
+
854 BOOL bResult = CryptCreateHash(hProv, Algid, hKey, dwFlags, &h);
+
855 if (bResult)
+
856 hash.attach(h);
+
857 return bResult;
+
858}
-
865
-
-
871static bool CryptImportKey(_In_ HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
-
872{
-
873 HCRYPTKEY h;
-
874 BOOL bResult = CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h);
-
875 if (bResult)
-
876 key.attach(h);
-
877 return bResult;
-
878}
+
859
+
+
865static BOOL CryptGenKey(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
+
866{
+
867 HCRYPTKEY h;
+
868 BOOL bResult = CryptGenKey(hProv, Algid, dwFlags, &h);
+
869 if (bResult)
+
870 key.attach(h);
+
871 return bResult;
+
872}
-
879
-
-
885static bool CryptImportPublicKeyInfo(_In_ HCRYPTPROV hCryptProv, _In_ DWORD dwCertEncodingType, _In_ PCERT_PUBLIC_KEY_INFO pInfo, _Inout_ winstd::crypt_key &key)
-
886{
-
887 HCRYPTKEY h;
-
888 BOOL bResult = CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h);
-
889 if (bResult)
-
890 key.attach(h);
-
891 return bResult;
-
892}
+
873
+
+
879static bool CryptImportKey(_In_ HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
+
880{
+
881 HCRYPTKEY h;
+
882 BOOL bResult = CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h);
+
883 if (bResult)
+
884 key.attach(h);
+
885 return bResult;
+
886}
-
893
-
-
899static bool CryptDeriveKey(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTHASH hBaseData, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
-
900{
-
901 HCRYPTKEY h;
-
902 BOOL bResult = CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, &h);
-
903 if (bResult)
-
904 key.attach(h);
-
905 return bResult;
-
906}
+
887
+
+
893static bool CryptImportPublicKeyInfo(_In_ HCRYPTPROV hCryptProv, _In_ DWORD dwCertEncodingType, _In_ PCERT_PUBLIC_KEY_INFO pInfo, _Inout_ winstd::crypt_key &key)
+
894{
+
895 HCRYPTKEY h;
+
896 BOOL bResult = CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h);
+
897 if (bResult)
+
898 key.attach(h);
+
899 return bResult;
+
900}
-
907
-
908#pragma warning(pop)
-
909
-
PCCERT_CHAIN_CONTEXT wrapper class.
Definition Crypt.h:386
-
virtual ~cert_chain_context()
Destroys the certificate chain context.
Definition Crypt.h:395
-
void free_internal() noexcept override
Destroys the certificate chain context.
Definition Crypt.h:407
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the certificate chain context.
Definition Crypt.h:421
-
PCCERT_CONTEXT wrapper class.
Definition Crypt.h:253
-
bool operator<=(const handle_type &other) const noexcept
Is certificate less than or equal?
Definition Crypt.h:335
-
void free_internal() noexcept override
Destroys the certificate context.
Definition Crypt.h:359
-
bool operator==(const handle_type &other) const noexcept
Is certificate equal to?
Definition Crypt.h:276
-
bool operator>=(const handle_type &other) const noexcept
Is certificate greater than or equal?
Definition Crypt.h:348
-
bool operator>(const handle_type &other) const noexcept
Is certificate greater than?
Definition Crypt.h:320
-
bool operator<(const handle_type &other) const noexcept
Is certificate less than?
Definition Crypt.h:305
-
bool operator!=(const handle_type &other) const noexcept
Is certificate not equal to?
Definition Crypt.h:292
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the certificate context.
Definition Crypt.h:373
-
virtual ~cert_context()
Destroys the certificate context.
Definition Crypt.h:262
-
HCERTSTORE wrapper class.
Definition Crypt.h:435
-
virtual ~cert_store()
Closes the certificate store.
Definition Crypt.h:444
-
void free_internal() noexcept override
Closes the certificate store.
Definition Crypt.h:456
-
HCRYPTHASH wrapper class.
Definition Crypt.h:501
-
void free_internal() noexcept override
Destroys the hash context.
Definition Crypt.h:522
-
virtual ~crypt_hash()
Destroys the hash context.
Definition Crypt.h:510
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the hash context.
Definition Crypt.h:536
-
HCRYPTKEY wrapper class.
Definition Crypt.h:554
-
handle_type duplicate_internal(handle_type h) const override
Duplicates the key.
Definition Crypt.h:659
-
virtual ~crypt_key()
Destroys the key.
Definition Crypt.h:563
-
bool create_exp1(HCRYPTPROV hProv, DWORD dwKeySpec)
Creates Exponent-of-one key.
Definition Crypt.h:577
-
void free_internal() noexcept override
Destroys the key.
Definition Crypt.h:645
-
HCRYPTPROV wrapper class.
Definition Crypt.h:468
-
virtual ~crypt_prov()
Releases the cryptographic context.
Definition Crypt.h:477
-
void free_internal() noexcept override
Releases the cryptographic context.
Definition Crypt.h:489
-
DATA_BLOB wrapper class.
Definition Crypt.h:674
-
data_blob(const DATA_BLOB &other)
Duplicate an existing BLOB.
Definition Crypt.h:697
-
virtual ~data_blob()
Destroys the BLOB.
Definition Crypt.h:722
-
BYTE * data() noexcept
Get BLOB buffer.
Definition Crypt.h:784
-
const BYTE * data() const noexcept
Get BLOB buffer.
Definition Crypt.h:776
-
data_blob() noexcept
Initializes an empty BLOB.
Definition Crypt.h:679
-
data_blob(data_blob &&other) noexcept
Move an existing BLOB.
Definition Crypt.h:711
-
data_blob & operator=(data_blob &&other) noexcept
Move an existing BLOB.
Definition Crypt.h:751
-
data_blob(BYTE *data, DWORD size) noexcept
Initializes a BLOB from existing data.
Definition Crypt.h:688
-
DWORD size() const noexcept
Get BLOB size.
Definition Crypt.h:768
-
data_blob & operator=(const DATA_BLOB &other)
Copy an existing BLOB.
Definition Crypt.h:731
-
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1248
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
-
Windows runtime error.
Definition Common.h:1491
-
static bool CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, winstd::crypt_key &key)
Imports the public key.
Definition Crypt.h:885
+
901
+
+
907static bool CryptDeriveKey(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTHASH hBaseData, _In_ DWORD dwFlags, _Inout_ winstd::crypt_key &key)
+
908{
+
909 HCRYPTKEY h;
+
910 BOOL bResult = CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, &h);
+
911 if (bResult)
+
912 key.attach(h);
+
913 return bResult;
+
914}
+
+
915
+
916#pragma warning(pop)
+
917
+
PCCERT_CHAIN_CONTEXT wrapper class.
Definition Crypt.h:394
+
virtual ~cert_chain_context()
Destroys the certificate chain context.
Definition Crypt.h:403
+
void free_internal() noexcept override
Destroys the certificate chain context.
Definition Crypt.h:415
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the certificate chain context.
Definition Crypt.h:429
+
PCCERT_CONTEXT wrapper class.
Definition Crypt.h:261
+
bool operator<=(const handle_type &other) const noexcept
Is certificate less than or equal?
Definition Crypt.h:343
+
void free_internal() noexcept override
Destroys the certificate context.
Definition Crypt.h:367
+
bool operator==(const handle_type &other) const noexcept
Is certificate equal to?
Definition Crypt.h:284
+
bool operator>=(const handle_type &other) const noexcept
Is certificate greater than or equal?
Definition Crypt.h:356
+
bool operator>(const handle_type &other) const noexcept
Is certificate greater than?
Definition Crypt.h:328
+
bool operator<(const handle_type &other) const noexcept
Is certificate less than?
Definition Crypt.h:313
+
bool operator!=(const handle_type &other) const noexcept
Is certificate not equal to?
Definition Crypt.h:300
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the certificate context.
Definition Crypt.h:381
+
virtual ~cert_context()
Destroys the certificate context.
Definition Crypt.h:270
+
HCERTSTORE wrapper class.
Definition Crypt.h:443
+
virtual ~cert_store()
Closes the certificate store.
Definition Crypt.h:452
+
void free_internal() noexcept override
Closes the certificate store.
Definition Crypt.h:464
+
HCRYPTHASH wrapper class.
Definition Crypt.h:509
+
void free_internal() noexcept override
Destroys the hash context.
Definition Crypt.h:530
+
virtual ~crypt_hash()
Destroys the hash context.
Definition Crypt.h:518
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the hash context.
Definition Crypt.h:544
+
HCRYPTKEY wrapper class.
Definition Crypt.h:562
+
handle_type duplicate_internal(handle_type h) const override
Duplicates the key.
Definition Crypt.h:667
+
virtual ~crypt_key()
Destroys the key.
Definition Crypt.h:571
+
bool create_exp1(HCRYPTPROV hProv, DWORD dwKeySpec)
Creates Exponent-of-one key.
Definition Crypt.h:585
+
void free_internal() noexcept override
Destroys the key.
Definition Crypt.h:653
+
HCRYPTPROV wrapper class.
Definition Crypt.h:476
+
virtual ~crypt_prov()
Releases the cryptographic context.
Definition Crypt.h:485
+
void free_internal() noexcept override
Releases the cryptographic context.
Definition Crypt.h:497
+
DATA_BLOB wrapper class.
Definition Crypt.h:682
+
data_blob(const DATA_BLOB &other)
Duplicate an existing BLOB.
Definition Crypt.h:705
+
virtual ~data_blob()
Destroys the BLOB.
Definition Crypt.h:730
+
BYTE * data() noexcept
Get BLOB buffer.
Definition Crypt.h:792
+
const BYTE * data() const noexcept
Get BLOB buffer.
Definition Crypt.h:784
+
data_blob() noexcept
Initializes an empty BLOB.
Definition Crypt.h:687
+
data_blob(data_blob &&other) noexcept
Move an existing BLOB.
Definition Crypt.h:719
+
data_blob & operator=(data_blob &&other) noexcept
Move an existing BLOB.
Definition Crypt.h:759
+
data_blob(BYTE *data, DWORD size) noexcept
Initializes a BLOB from existing data.
Definition Crypt.h:696
+
DWORD size() const noexcept
Get BLOB size.
Definition Crypt.h:776
+
data_blob & operator=(const DATA_BLOB &other)
Copy an existing BLOB.
Definition Crypt.h:739
+
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1285
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
+
Windows runtime error.
Definition Common.h:1528
+
static bool CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, winstd::crypt_key &key)
Imports the public key.
Definition Crypt.h:893
static BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, std::vector< _Ty, _Ax > &aData)
Retrieves the information contained in an extended property of a certificate context.
Definition Crypt.h:59
-
static BOOL CertGetCertificateChain(HCERTCHAINENGINE hChainEngine, PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore, PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved, winstd::cert_chain_context &ctx)
The CertGetCertificateChain function builds a certificate chain context starting from an end certific...
Definition Crypt.h:805
+
static BOOL CertGetCertificateChain(HCERTCHAINENGINE hChainEngine, PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore, PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved, winstd::cert_chain_context &ctx)
The CertGetCertificateChain function builds a certificate chain context starting from an end certific...
Definition Crypt.h:813
static BOOL CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, std::vector< _Ty, _Ax > &aData, DWORD dwFlags)
Retrieves data that governs the operations of a hash object. The actual hash value can be retrieved b...
Definition Crypt.h:84
static DWORD CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, std::basic_string< wchar_t, _Traits, _Ax > &sNameString)
Obtains the subject or issuer name from a certificate CERT_CONTEXT structure and stores it in a std::...
Definition Crypt.h:41
-
static BOOL CryptAcquireContextA(winstd::crypt_prov &prov, LPCSTR szContainer, LPCSTR szProvider, DWORD dwProvType, DWORD dwFlags)
Acquires the cryptographic context.
Definition Crypt.h:815
+
static BOOL CryptAcquireContextA(winstd::crypt_prov &prov, LPCSTR szContainer, LPCSTR szProvider, DWORD dwProvType, DWORD dwFlags)
Acquires the cryptographic context.
Definition Crypt.h:823
static DWORD CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, std::basic_string< char, _Traits, _Ax > &sNameString)
Obtains the subject or issuer name from a certificate CERT_CONTEXT structure and stores it in a std::...
Definition Crypt.h:23
-
static BOOL CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, winstd::crypt_key &key)
Generates the key.
Definition Crypt.h:857
+
static BOOL CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, winstd::crypt_key &key)
Generates the key.
Definition Crypt.h:865
static BOOL CryptExportKey(HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
Exports a cryptographic key or a key pair from a cryptographic service provider (CSP) in a secure man...
Definition Crypt.h:158
static BOOL CryptGetKeyParam(HCRYPTKEY hKey, DWORD dwParam, std::vector< _Ty, _Ax > &aData, DWORD dwFlags)
Retrieves data that governs the operations of a key.
Definition Crypt.h:121
-
static BOOL CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, winstd::crypt_hash &hash)
Creates the hash context.
Definition Crypt.h:843
-
static BOOL CryptAcquireContextW(winstd::crypt_prov &prov, LPCWSTR szContainer, LPCWSTR szProvider, DWORD dwProvType, DWORD dwFlags)
Acquires the cryptographic context.
Definition Crypt.h:829
+
static BOOL CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, winstd::crypt_hash &hash)
Creates the hash context.
Definition Crypt.h:851
+
static BOOL CryptAcquireContextW(winstd::crypt_prov &prov, LPCWSTR szContainer, LPCWSTR szProvider, DWORD dwProvType, DWORD dwFlags)
Acquires the cryptographic context.
Definition Crypt.h:837
static BOOL CryptEncrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
Encrypts data.
Definition Crypt.h:177
-
static bool CryptDeriveKey(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, winstd::crypt_key &key)
Generates cryptographic session keys derived from a base data value.
Definition Crypt.h:899
-
static BOOL CryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
Decrypts data previously encrypted by using the CryptEncrypt function.
Definition Crypt.h:227
-
static bool CryptImportKey(HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, winstd::crypt_key &key)
Imports the key.
Definition Crypt.h:871
-
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:93
-
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:175
-
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:163
-
static const T invalid
Invalid handle value.
Definition Common.h:993
+
static bool CryptDeriveKey(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, winstd::crypt_key &key)
Generates cryptographic session keys derived from a base data value.
Definition Crypt.h:907
+
static BOOL CryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
Decrypts data previously encrypted by using the CryptEncrypt function.
Definition Crypt.h:232
+
static bool CryptImportKey(HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, winstd::crypt_key &key)
Imports the key.
Definition Crypt.h:879
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
+
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:176
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const T invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_e_a_p_8h_source.html b/_e_a_p_8h_source.html index bac0bcca..e586cf08 100644 --- a/_e_a_p_8h_source.html +++ b/_e_a_p_8h_source.html @@ -627,7 +627,7 @@ $(document).ready(function() { init_codefold(0); });
683}
684
685#pragma warning(pop)
-
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1248
+
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition Common.h:1285
EAP_ATTRIBUTE wrapper class.
Definition EAP.h:213
eap_attr() noexcept
Initializes a new EAP attribute set to eatReserved.
Definition EAP.h:218
eap_attr(eap_attr &&a) noexcept
Moves an existing EAP attribute.
Definition EAP.h:242
@@ -668,10 +668,10 @@ $(document).ready(function() { init_codefold(0); });
std::wstring m_root_cause_desc
A localized and readable string that describes the root cause of the error.
Definition EAP.h:674
const GUID & help_link_id() const noexcept
Returns help_link ID.
Definition EAP.h:663
DWORD m_reason
The reason code for the error.
Definition EAP.h:671
-
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
-
Windows runtime error.
Definition Common.h:1491
+
T handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
+
Windows runtime error.
Definition Common.h:1528
std::unique_ptr< EAP_ERROR, EapHostPeerFreeEapError_delete > eap_error_runtime
EAP_ERROR wrapper class.
Definition EAP.h:205
std::unique_ptr< BYTE[], EapHostPeerFreeMemory_delete > eap_blob
EapHost BLOB wrapper class.
Definition EAP.h:128
static bool operator==(const EAP_METHOD_TYPE &a, const EAP_METHOD_TYPE &b) noexcept
Are EAP method types equal?
Definition EAP.h:39
@@ -699,9 +699,9 @@ $(document).ready(function() { init_codefold(0); });
@ start
Start of EAP methods.
@ mschapv2
EAP-MSCHAPv2.
@ identity
Identity.
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
-
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:175
-
static const T invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:176
+
static const T invalid
Invalid handle value.
Definition Common.h:1030
Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeEapError.
Definition EAP.h:185
EapHostPeerFreeEapError_delete() noexcept
Default constructor.
Definition EAP.h:189
void operator()(EAP_ERROR *_Ptr) const noexcept
Delete a pointer.
Definition EAP.h:196
@@ -717,7 +717,7 @@ $(document).ready(function() { init_codefold(0); });
diff --git a/_e_t_w_8h_source.html b/_e_t_w_8h_source.html index edc9d858..882d9bb0 100644 --- a/_e_t_w_8h_source.html +++ b/_e_t_w_8h_source.html @@ -1134,24 +1134,24 @@ $(document).ready(function() { init_codefold(0); });
ETW trace.
Definition ETW.h:906
virtual ~event_trace()
Closes the trace.
Definition ETW.h:915
void free_internal() noexcept override
Closes the trace.
Definition ETW.h:927
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:998
-
REGHANDLE handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle() noexcept
Initializes a new class instance with the object handle set to INVAL.
Definition Common.h:1035
+
REGHANDLE handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
static ULONG TdhGetEventInformation(PEVENT_RECORD pEvent, ULONG TdhContextCount, PTDH_CONTEXT pTdhContext, std::unique_ptr< TRACE_EVENT_INFO > &info)
Retrieves metadata about an event.
Definition ETW.h:58
static ULONG TdhGetProperty(PEVENT_RECORD pEvent, ULONG TdhContextCount, PTDH_CONTEXT pTdhContext, ULONG PropertyDataCount, PPROPERTY_DATA_DESCRIPTOR pPropertyData, std::vector< _Ty, _Ax > &aData)
Retrieves a property value from the event data.
Definition ETW.h:33
static ULONG TdhGetEventMapInformation(PEVENT_RECORD pEvent, LPWSTR pMapName, std::unique_ptr< EVENT_MAP_INFO > &info)
Retrieves information about the event map contained in the event.
Definition ETW.h:84
static const event_data blank_event_data
Blank event data used as terminator.
Definition ETW.h:291
-
#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
-
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:251
-
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:163
-
static const REGHANDLE invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
+
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:288
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const REGHANDLE invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_g_d_i_8h_source.html b/_g_d_i_8h_source.html index b7f2aa22..fa3d1a94 100644 --- a/_g_d_i_8h_source.html +++ b/_g_d_i_8h_source.html @@ -274,9 +274,9 @@ $(document).ready(function() { init_codefold(0); });
Windows HGDIOBJ wrapper class.
Definition GDI.h:22
void free_internal() noexcept override
Closes an open object handle.
Definition GDI.h:43
virtual ~gdi_handle()
Closes an open object handle.
Definition GDI.h:31
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
HDC handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
HDC handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
Windows HICON wrapper class.
Definition GDI.h:53
void free_internal() noexcept override
Closes an open object handle.
Definition GDI.h:74
virtual ~icon()
Closes an open object handle.
Definition GDI.h:62
@@ -288,14 +288,14 @@ $(document).ready(function() { init_codefold(0); });
window_dc() noexcept
Initializes an empty device context.
Definition GDI.h:120
window_dc & operator=(window_dc &&h) noexcept
Copy an existing device context.
Definition GDI.h:143
window_dc(window_dc &&h) noexcept
Move an existing device context.
Definition GDI.h:135
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
-
#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 T invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const T invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_m_s_i_8h_source.html b/_m_s_i_8h_source.html index 4d8aafa7..aa6fedf0 100644 --- a/_m_s_i_8h_source.html +++ b/_m_s_i_8h_source.html @@ -396,7 +396,7 @@ $(document).ready(function() { init_codefold(0); });
329}
330
-
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:93
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
static UINT MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Formats record field data and properties using a format string and stores it in a std::wstring string...
Definition MSI.h:169
static UINT MsiGetPropertyW(MSIHANDLE hInstall, LPCWSTR szName, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Gets the value for an installer property and stores it in a std::wstring string.
Definition MSI.h:53
static UINT MsiGetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, std::basic_string< char, _Traits, _Ax > &sValue)
Returns the full target path for a folder in the Directory table and stores it in a std::wstring stri...
Definition MSI.h:219
@@ -411,7 +411,7 @@ $(document).ready(function() { init_codefold(0); });
diff --git a/_s_d_d_l_8h_source.html b/_s_d_d_l_8h_source.html index 70f74e2c..af468f7a 100644 --- a/_s_d_d_l_8h_source.html +++ b/_s_d_d_l_8h_source.html @@ -187,13 +187,13 @@ $(document).ready(function() { init_codefold(0); });
~security_attributes()
Destroys the SECURITY_ATTRIBUTES.
Definition SDDL.h:47
security_attributes & operator=(security_attributes &&a) noexcept
Moves an existing SECURITY_ATTRIBUTES.
Definition SDDL.h:56
security_attributes() noexcept
Initializes a new SECURITY_ATTRIBUTES.
Definition SDDL.h:26
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
static BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, winstd::security_attributes &sa, PULONG SecurityDescriptorSize)
Converts a string-format security descriptor into a valid, functional security descriptor.
Definition SDDL.h:80
static BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(LPCWSTR StringSecurityDescriptor, DWORD StringSDRevision, winstd::security_attributes &sa, PULONG SecurityDescriptorSize)
Converts a string-format security descriptor into a valid, functional security descriptor.
Definition SDDL.h:97
diff --git a/_sec_8h_source.html b/_sec_8h_source.html index dd785267..a0772202 100644 --- a/_sec_8h_source.html +++ b/_sec_8h_source.html @@ -379,12 +379,12 @@ $(document).ready(function() { init_codefold(0); });
383
385}
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
PCredHandle handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
-
Numerical runtime error.
Definition Common.h:1446
-
SECURITY_STATUS error_type
Error number type.
Definition Common.h:1448
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
PCredHandle handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
+
Numerical runtime error.
Definition Common.h:1483
+
SECURITY_STATUS error_type
Error number type.
Definition Common.h:1485
SecBufferDesc wrapper class.
Definition Sec.h:318
virtual ~sec_buffer_desc()
Frees the security buffer descriptor.
Definition Sec.h:335
sec_buffer_desc(PSecBuffer buf, ULONG count, ULONG version=SECBUFFER_VERSION)
Initializes security buffer descriptor.
Definition Sec.h:323
@@ -411,13 +411,13 @@ $(document).ready(function() { init_codefold(0); });
sec_runtime_error(error_type num, const char *msg=nullptr)
Constructs an exception.
Definition Sec.h:372
sec_runtime_error(const sec_runtime_error &other)
Copies an exception.
Definition Sec.h:380
sec_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition Sec.h:363
-
#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
-
static const PCredHandle invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
+
static const PCredHandle invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_setup_a_p_i_8h_source.html b/_setup_a_p_i_8h_source.html index 1253e489..aa95b09f 100644 --- a/_setup_a_p_i_8h_source.html +++ b/_setup_a_p_i_8h_source.html @@ -165,8 +165,8 @@ $(document).ready(function() { init_codefold(0); });
107
109}
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle_type m_h
Object handle.
Definition Common.h:1237
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle_type m_h
Object handle.
Definition Common.h:1274
HDEVINFO wrapper class.
Definition SetupAPI.h:26
virtual ~setup_device_info_list()
Frees the device information set.
Definition SetupAPI.h:35
void free_internal() noexcept override
Frees the device information set.
Definition SetupAPI.h:47
@@ -174,14 +174,14 @@ $(document).ready(function() { init_codefold(0); });
setup_driver_info_list_builder(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD DriverType) noexcept
Construct the builder and builds a list of drivers that is associated with a specific device or with ...
Definition SetupAPI.h:67
virtual ~setup_driver_info_list_builder()
Deletes a driver list and destructs the builder.
Definition SetupAPI.h:83
BOOL status() const noexcept
Return result of SetupDiBuildDriverInfoList() call.
Definition SetupAPI.h:94
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
-
#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 HDEVINFO invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const HDEVINFO invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_shell_8h_source.html b/_shell_8h_source.html index 2febb809..456d1f01 100644 --- a/_shell_8h_source.html +++ b/_shell_8h_source.html @@ -169,7 +169,7 @@ $(document).ready(function() { init_codefold(0); });
diff --git a/_w_l_a_n_8h_source.html b/_w_l_a_n_8h_source.html index 154442e0..8834f046 100644 --- a/_w_l_a_n_8h_source.html +++ b/_w_l_a_n_8h_source.html @@ -104,144 +104,146 @@ $(document).ready(function() { init_codefold(0); });
34static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue, __reserved PVOID pReserved)
35{
-
36 DWORD dwSize = 0;
+
36 SIZE_T sSize = 0;
37
38 if (!::pfnWlanReasonCodeToString)
39 return ERROR_CALL_NOT_IMPLEMENTED;
40
41 for (;;) {
42 // Increment size and allocate buffer.
-
43 dwSize += 1024;
-
44 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[dwSize]);
-
45
-
46 // Try!
-
47 DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved);
-
48 if (dwResult == ERROR_SUCCESS) {
-
49 DWORD dwLength = (DWORD)wcsnlen(szBuffer.get(), dwSize);
-
50 if (dwLength < dwSize - 1) {
-
51 // Buffer was long enough.
-
52 sValue.assign(szBuffer.get(), dwLength);
-
53 return ERROR_SUCCESS;
-
54 }
-
55 } else {
-
56 // Return error code.
-
57 return dwResult;
-
58 }
-
59 }
-
60}
+
43 sSize = SIZETAdd(sSize, 1024);
+
44 if (sSize > DWORD_MAX)
+
45 throw std::runtime_exception("Data too big");
+
46 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[sSize]);
+
47
+
48 // Try!
+
49 DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, static_cast<DWORD>(sSize), szBuffer.get(), pReserved);
+
50 if (dwResult == ERROR_SUCCESS) {
+
51 SIZE_T sLength = wcsnlen(szBuffer.get(), sSize);
+
52 if (sLength < sSize - 1) {
+
53 // Buffer was long enough.
+
54 sValue.assign(szBuffer.get(), sLength);
+
55 return ERROR_SUCCESS;
+
56 }
+
57 } else {
+
58 // Return error code.
+
59 return dwResult;
+
60 }
+
61 }
+
62}
-
61
63
-
64namespace winstd
-
65{
-
68
-
-
72 template <class _Ty> struct WlanFreeMemory_delete
-
73 {
- -
75
- -
80
-
84 template <class _Ty2> WlanFreeMemory_delete(const WlanFreeMemory_delete<_Ty2>&) {}
-
85
-
-
89 void operator()(_Ty *_Ptr) const
-
90 {
-
91 WlanFreeMemory(_Ptr);
-
92 }
+
65
+
66namespace winstd
+
67{
+
70
+
+
74 template <class _Ty> struct WlanFreeMemory_delete
+
75 {
+ +
77
+ +
82
+
86 template <class _Ty2> WlanFreeMemory_delete(const WlanFreeMemory_delete<_Ty2>&) {}
+
87
+
+
91 void operator()(_Ty *_Ptr) const
+
92 {
+
93 WlanFreeMemory(_Ptr);
+
94 }
-
93 };
+
95 };
-
94
-
-
98 template <class _Ty> struct WlanFreeMemory_delete<_Ty[]>
-
99 {
- -
101
- -
106
-
-
110 void operator()(_Ty *_Ptr) const
-
111 {
-
112 WlanFreeMemory(_Ptr);
-
113 }
+
96
+
+
100 template <class _Ty> struct WlanFreeMemory_delete<_Ty[]>
+
101 {
+ +
103
+ +
108
+
+
112 void operator()(_Ty *_Ptr) const
+
113 {
+
114 WlanFreeMemory(_Ptr);
+
115 }
-
114
-
118 template<class _Other>
-
-
119 void operator()(_Other *) const
-
120 {
-
121 WlanFreeMemory(_Ptr);
-
122 }
+
116
+
120 template<class _Other>
+
+
121 void operator()(_Other *) const
+
122 {
+
123 WlanFreeMemory(_Ptr);
+
124 }
-
123 };
+
125 };
-
124
-
-
130 class wlan_handle : public handle<HANDLE, NULL>
-
131 {
- -
133
-
134 public:
-
-
140 virtual ~wlan_handle()
-
141 {
-
142 if (m_h != invalid)
- -
144 }
+
126
+
+
132 class wlan_handle : public handle<HANDLE, NULL>
+
133 {
+ +
135
+
136 public:
+
+
142 virtual ~wlan_handle()
+
143 {
+
144 if (m_h != invalid)
+ +
146 }
-
145
-
146 protected:
-
-
152 void free_internal() noexcept override
-
153 {
-
154 WlanCloseHandle(m_h, NULL);
-
155 }
+
147
+
148 protected:
+
+
154 void free_internal() noexcept override
+
155 {
+
156 WlanCloseHandle(m_h, NULL);
+
157 }
-
156 };
+
158 };
-
157
-
159}
-
160
-
163
-
169#pragma warning(suppress: 4505) // Don't warn on unused code
-
-
170static DWORD WlanOpenHandle(
-
171 _In_ DWORD dwClientVersion,
-
172 _Reserved_ PVOID pReserved,
-
173 _Out_ PDWORD pdwNegotiatedVersion,
-
174 _Inout_ winstd::wlan_handle &handle)
-
175{
-
176 HANDLE h;
-
177 DWORD dwResult = WlanOpenHandle(dwClientVersion, pReserved, pdwNegotiatedVersion, &h);
-
178 if (dwResult == ERROR_SUCCESS)
-
179 handle.attach(h);
-
180 return dwResult;
-
181}
+
159
+
161}
+
162
+
165
+
171#pragma warning(suppress: 4505) // Don't warn on unused code
+
+
172static DWORD WlanOpenHandle(
+
173 _In_ DWORD dwClientVersion,
+
174 _Reserved_ PVOID pReserved,
+
175 _Out_ PDWORD pdwNegotiatedVersion,
+
176 _Inout_ winstd::wlan_handle &handle)
+
177{
+
178 HANDLE h;
+
179 DWORD dwResult = WlanOpenHandle(dwClientVersion, pReserved, pdwNegotiatedVersion, &h);
+
180 if (dwResult == ERROR_SUCCESS)
+
181 handle.attach(h);
+
182 return dwResult;
+
183}
-
182
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
WLAN handle wrapper.
Definition WLAN.h:131
-
virtual ~wlan_handle()
Closes a connection to the server.
Definition WLAN.h:140
-
void free_internal() noexcept override
Closes a connection to the server.
Definition WLAN.h:152
-
#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:993
-
static DWORD WlanOpenHandle(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, winstd::wlan_handle &handle)
Opens a connection to the server.
Definition WLAN.h:170
+
184
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
WLAN handle wrapper.
Definition WLAN.h:133
+
virtual ~wlan_handle()
Closes a connection to the server.
Definition WLAN.h:142
+
void free_internal() noexcept override
Closes a connection to the server.
Definition WLAN.h:154
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const HANDLE invalid
Invalid handle value.
Definition Common.h:1030
+
static DWORD WlanOpenHandle(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, winstd::wlan_handle &handle)
Opens a connection to the server.
Definition WLAN.h:172
static DWORD WlanReasonCodeToString(DWORD dwReasonCode, std::basic_string< wchar_t, _Traits, _Ax > &sValue, __reserved PVOID pReserved)
Retrieves a string that describes a specified reason code and stores it in a std::wstring string.
Definition WLAN.h:34
-
WlanFreeMemory_delete()
Default construct.
Definition WLAN.h:105
-
void operator()(_Other *) const
Delete a pointer of another type.
Definition WLAN.h:119
-
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition WLAN.h:100
-
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition WLAN.h:110
-
Deleter for unique_ptr using WlanFreeMemory.
Definition WLAN.h:73
-
WlanFreeMemory_delete()
Default construct.
Definition WLAN.h:79
-
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition WLAN.h:89
-
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition WLAN.h:74
-
WlanFreeMemory_delete(const WlanFreeMemory_delete< _Ty2 > &)
Construct from another WlanFreeMemory_delete.
Definition WLAN.h:84
+
WlanFreeMemory_delete()
Default construct.
Definition WLAN.h:107
+
void operator()(_Other *) const
Delete a pointer of another type.
Definition WLAN.h:121
+
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition WLAN.h:102
+
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition WLAN.h:112
+
Deleter for unique_ptr using WlanFreeMemory.
Definition WLAN.h:75
+
WlanFreeMemory_delete()
Default construct.
Definition WLAN.h:81
+
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition WLAN.h:91
+
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition WLAN.h:76
+
WlanFreeMemory_delete(const WlanFreeMemory_delete< _Ty2 > &)
Construct from another WlanFreeMemory_delete.
Definition WLAN.h:86
diff --git a/_win_8h_source.html b/_win_8h_source.html index e991c80c..a4f4d517 100644 --- a/_win_8h_source.html +++ b/_win_8h_source.html @@ -252,1829 +252,1833 @@ $(document).ready(function() { init_codefold(0); });
177
179template<class _Traits, class _Ax>
-
180static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<char, _Traits, _Ax> &sValue) noexcept
+
180static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<char, _Traits, _Ax> &sValue)
181{
182 assert(0); // TODO: Test this code.
183
-
184 for (DWORD dwSizeOut = (DWORD)strlen(lpSrc) + 0x100;;) {
-
185 DWORD dwSizeIn = dwSizeOut;
-
186 std::unique_ptr<char[]> szBuffer(new char[(size_t)dwSizeIn + 2]); // Note: ANSI version requires one extra char.
-
187 dwSizeOut = ::ExpandEnvironmentStringsA(lpSrc, szBuffer.get(), dwSizeIn);
-
188 if (dwSizeOut == 0) {
-
189 // Error or zero-length input.
-
190 break;
-
191 } else if (dwSizeOut <= dwSizeIn) {
-
192 // The buffer was sufficient.
-
193 sValue.assign(szBuffer.get(), dwSizeOut - 1);
-
194 return dwSizeOut;
-
195 }
-
196 }
-
197
-
198 sValue.clear();
-
199 return 0;
-
200}
-
-
201
-
207template<class _Traits, class _Ax>
-
-
208static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue) noexcept
-
209{
-
210 for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) {
-
211 DWORD dwSizeIn = dwSizeOut;
-
212 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[(size_t)dwSizeIn + 1]);
-
213 dwSizeOut = ::ExpandEnvironmentStringsW(lpSrc, szBuffer.get(), dwSizeIn);
-
214 if (dwSizeOut == 0) {
-
215 // Error or zero-length input.
-
216 break;
-
217 } else if (dwSizeOut <= dwSizeIn) {
-
218 // The buffer was sufficient.
-
219 sValue.assign(szBuffer.get(), dwSizeOut - 1);
-
220 return dwSizeOut;
-
221 }
-
222 }
-
223
-
224 sValue.clear();
-
225 return 0;
-
226}
+
184 for (SIZE_T sSizeOut = SIZETAdd(strlen(lpSrc), 0x100);;) {
+
185 if (sSizeOut > DWORD_MAX)
+
186 throw std::invalid_argument("String too big");
+
187 DWORD dwSizeIn = static_cast<DWORD>(sSizeOut);
+
188 std::unique_ptr<char[]> szBuffer(new char[(size_t)dwSizeIn + 2]); // Note: ANSI version requires one extra char.
+
189 sSizeOut = ::ExpandEnvironmentStringsA(lpSrc, szBuffer.get(), dwSizeIn);
+
190 if (sSizeOut == 0) {
+
191 // Error or zero-length input.
+
192 break;
+
193 } else if (sSizeOut <= dwSizeIn) {
+
194 // The buffer was sufficient.
+
195 sValue.assign(szBuffer.get(), sSizeOut - 1);
+
196 return static_cast<DWORD>(sSizeOut);
+
197 }
+
198 }
+
199
+
200 sValue.clear();
+
201 return 0;
+
202}
+
203
+
209template<class _Traits, class _Ax>
+
+
210static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
+
211{
+
212 for (SIZE_T sSizeOut = SIZETAdd(wcslen(lpSrc), 0x100);;) {
+
213 if (sSizeOut > DWORD_MAX)
+
214 throw std::invalid_argument("String too big");
+
215 DWORD dwSizeIn = static_cast<DWORD>(sSizeOut);
+
216 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[(size_t)dwSizeIn + 1]);
+
217 sSizeOut = ::ExpandEnvironmentStringsW(lpSrc, szBuffer.get(), dwSizeIn);
+
218 if (sSizeOut == 0) {
+
219 // Error or zero-length input.
+
220 break;
+
221 } else if (sSizeOut <= dwSizeIn) {
+
222 // The buffer was sufficient.
+
223 sValue.assign(szBuffer.get(), sSizeOut - 1);
+
224 return static_cast<DWORD>(sSizeOut);
+
225 }
+
226 }
227
-
229template<class _Traits, class _Ax>
-
-
230static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<char, _Traits, _Ax> &str) noexcept
-
231{
-
232 assert(0); // TODO: Test this code.
-
233
-
234 sprintf(str, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
-
235 lpGuid->Data1,
-
236 lpGuid->Data2,
-
237 lpGuid->Data3,
-
238 lpGuid->Data4[0], lpGuid->Data4[1],
-
239 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
-
240}
+
228 sValue.clear();
+
229 return 0;
+
230}
-
241
-
248template<class _Traits, class _Ax>
-
-
249static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &str) noexcept
-
250{
-
251 assert(0); // TODO: Test this code.
-
252
-
253 sprintf(str, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
-
254 lpGuid->Data1,
-
255 lpGuid->Data2,
-
256 lpGuid->Data3,
-
257 lpGuid->Data4[0], lpGuid->Data4[1],
-
258 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
-
259}
+
231
+
233template<class _Traits, class _Ax>
+
+
234static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<char, _Traits, _Ax> &str) noexcept
+
235{
+
236 assert(0); // TODO: Test this code.
+
237
+
238 sprintf(str, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+
239 lpGuid->Data1,
+
240 lpGuid->Data2,
+
241 lpGuid->Data3,
+
242 lpGuid->Data4[0], lpGuid->Data4[1],
+
243 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
+
244}
-
260
-
262#ifdef _UNICODE
-
263#define GuidToString GuidToStringW
-
264#else
-
265#define GuidToString GuidToStringA
-
266#endif
-
267
-
-
269static _Success_(return) BOOL StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd = NULL) noexcept
-
270{
-
271 GUID g;
-
272 LPSTR lpszEnd;
-
273 unsigned long ulTmp;
-
274 unsigned long long ullTmp;
-
275
-
276 if (!lpszGuid || !lpGuid || *lpszGuid != '{') return FALSE;
-
277 lpszGuid++;
-
278
-
279 g.Data1 = strtoul(lpszGuid, &lpszEnd, 16);
-
280 if (errno == ERANGE) return FALSE;
-
281 lpszGuid = lpszEnd;
+
245
+
252template<class _Traits, class _Ax>
+
+
253static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &str) noexcept
+
254{
+
255 assert(0); // TODO: Test this code.
+
256
+
257 sprintf(str, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+
258 lpGuid->Data1,
+
259 lpGuid->Data2,
+
260 lpGuid->Data3,
+
261 lpGuid->Data4[0], lpGuid->Data4[1],
+
262 lpGuid->Data4[2], lpGuid->Data4[3], lpGuid->Data4[4], lpGuid->Data4[5], lpGuid->Data4[6], lpGuid->Data4[7]);
+
263}
+
+
264
+
266#ifdef _UNICODE
+
267#define GuidToString GuidToStringW
+
268#else
+
269#define GuidToString GuidToStringA
+
270#endif
+
271
+
+
273static _Success_(return) BOOL StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd = NULL) noexcept
+
274{
+
275 GUID g;
+
276 LPSTR lpszEnd;
+
277 unsigned long ulTmp;
+
278 unsigned long long ullTmp;
+
279
+
280 if (!lpszGuid || !lpGuid || *lpszGuid != '{') return FALSE;
+
281 lpszGuid++;
282
-
283 if (*lpszGuid != '-') return FALSE;
-
284 lpszGuid++;
-
285
-
286 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
-
287 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
288 g.Data2 = static_cast<unsigned short>(ulTmp);
-
289 lpszGuid = lpszEnd;
-
290
-
291 if (*lpszGuid != '-') return FALSE;
-
292 lpszGuid++;
-
293
-
294 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
-
295 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
296 g.Data3 = static_cast<unsigned short>(ulTmp);
-
297 lpszGuid = lpszEnd;
-
298
-
299 if (*lpszGuid != '-') return FALSE;
-
300 lpszGuid++;
-
301
-
302 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
-
303 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
304 g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
-
305 g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
-
306 lpszGuid = lpszEnd;
-
307
-
308 if (*lpszGuid != '-') return FALSE;
-
309 lpszGuid++;
-
310
-
311 ullTmp = _strtoui64(lpszGuid, &lpszEnd, 16);
-
312 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
-
313 g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
-
314 g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
-
315 g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
-
316 g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
-
317 g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
-
318 g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
-
319 lpszGuid = lpszEnd;
-
320
-
321 if (*lpszGuid != '}') return FALSE;
-
322 lpszGuid++;
-
323
-
324 if (lpszGuidEnd)
-
325 *lpszGuidEnd = lpszGuid;
-
326
-
327 *lpGuid = g;
-
328 return TRUE;
-
329}
-
+
283 g.Data1 = strtoul(lpszGuid, &lpszEnd, 16);
+
284 if (errno == ERANGE) return FALSE;
+
285 lpszGuid = lpszEnd;
+
286
+
287 if (*lpszGuid != '-') return FALSE;
+
288 lpszGuid++;
+
289
+
290 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
+
291 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
292 g.Data2 = static_cast<unsigned short>(ulTmp);
+
293 lpszGuid = lpszEnd;
+
294
+
295 if (*lpszGuid != '-') return FALSE;
+
296 lpszGuid++;
+
297
+
298 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
+
299 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
300 g.Data3 = static_cast<unsigned short>(ulTmp);
+
301 lpszGuid = lpszEnd;
+
302
+
303 if (*lpszGuid != '-') return FALSE;
+
304 lpszGuid++;
+
305
+
306 ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
+
307 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
308 g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
+
309 g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
+
310 lpszGuid = lpszEnd;
+
311
+
312 if (*lpszGuid != '-') return FALSE;
+
313 lpszGuid++;
+
314
+
315 ullTmp = _strtoui64(lpszGuid, &lpszEnd, 16);
+
316 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
+
317 g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
+
318 g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
+
319 g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
+
320 g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
+
321 g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
+
322 g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
+
323 lpszGuid = lpszEnd;
+
324
+
325 if (*lpszGuid != '}') return FALSE;
+
326 lpszGuid++;
+
327
+
328 if (lpszGuidEnd)
+
329 *lpszGuidEnd = lpszGuid;
330
-
-
342static _Success_(return) BOOL StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd = NULL) noexcept
-
343{
-
344 GUID g;
-
345 LPWSTR lpszEnd;
-
346 unsigned long ulTmp;
-
347 unsigned long long ullTmp;
-
348
-
349 if (!lpszGuid || !lpGuid || *lpszGuid != '{') return FALSE;
-
350 lpszGuid++;
-
351
-
352 g.Data1 = wcstoul(lpszGuid, &lpszEnd, 16);
-
353 if (errno == ERANGE) return FALSE;
-
354 lpszGuid = lpszEnd;
+
331 *lpGuid = g;
+
332 return TRUE;
+
333}
+
+
334
+
+
346static _Success_(return) BOOL StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd = NULL) noexcept
+
347{
+
348 GUID g;
+
349 LPWSTR lpszEnd;
+
350 unsigned long ulTmp;
+
351 unsigned long long ullTmp;
+
352
+
353 if (!lpszGuid || !lpGuid || *lpszGuid != '{') return FALSE;
+
354 lpszGuid++;
355
-
356 if (*lpszGuid != '-') return FALSE;
-
357 lpszGuid++;
-
358
-
359 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
-
360 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
361 g.Data2 = static_cast<unsigned short>(ulTmp);
-
362 lpszGuid = lpszEnd;
-
363
-
364 if (*lpszGuid != '-') return FALSE;
-
365 lpszGuid++;
-
366
-
367 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
-
368 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
369 g.Data3 = static_cast<unsigned short>(ulTmp);
-
370 lpszGuid = lpszEnd;
-
371
-
372 if (*lpszGuid != '-') return FALSE;
-
373 lpszGuid++;
-
374
-
375 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
-
376 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
-
377 g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
-
378 g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
-
379 lpszGuid = lpszEnd;
-
380
-
381 if (*lpszGuid != '-') return FALSE;
-
382 lpszGuid++;
-
383
-
384 ullTmp = _wcstoui64(lpszGuid, &lpszEnd, 16);
-
385 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
-
386 g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
-
387 g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
-
388 g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
-
389 g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
-
390 g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
-
391 g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
-
392 lpszGuid = lpszEnd;
-
393
-
394 if (*lpszGuid != '}') return FALSE;
-
395 lpszGuid++;
-
396
-
397 if (lpszGuidEnd)
-
398 *lpszGuidEnd = lpszGuid;
-
399
-
400 *lpGuid = g;
-
401 return TRUE;
-
402}
-
+
356 g.Data1 = wcstoul(lpszGuid, &lpszEnd, 16);
+
357 if (errno == ERANGE) return FALSE;
+
358 lpszGuid = lpszEnd;
+
359
+
360 if (*lpszGuid != '-') return FALSE;
+
361 lpszGuid++;
+
362
+
363 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
+
364 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
365 g.Data2 = static_cast<unsigned short>(ulTmp);
+
366 lpszGuid = lpszEnd;
+
367
+
368 if (*lpszGuid != '-') return FALSE;
+
369 lpszGuid++;
+
370
+
371 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
+
372 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
373 g.Data3 = static_cast<unsigned short>(ulTmp);
+
374 lpszGuid = lpszEnd;
+
375
+
376 if (*lpszGuid != '-') return FALSE;
+
377 lpszGuid++;
+
378
+
379 ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
+
380 if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
+
381 g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
+
382 g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
+
383 lpszGuid = lpszEnd;
+
384
+
385 if (*lpszGuid != '-') return FALSE;
+
386 lpszGuid++;
+
387
+
388 ullTmp = _wcstoui64(lpszGuid, &lpszEnd, 16);
+
389 if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
+
390 g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
+
391 g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
+
392 g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
+
393 g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
+
394 g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
+
395 g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
+
396 lpszGuid = lpszEnd;
+
397
+
398 if (*lpszGuid != '}') return FALSE;
+
399 lpszGuid++;
+
400
+
401 if (lpszGuidEnd)
+
402 *lpszGuidEnd = lpszGuid;
403
-
405#ifdef _UNICODE
-
406#define StringToGuid StringToGuidW
-
407#else
-
408#define StringToGuid StringToGuidA
-
409#endif
-
410
-
429template<class _Traits, class _Ax>
-
-
430static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<char, _Traits, _Ax> &sValue) noexcept
-
431{
-
432 LSTATUS lResult;
-
433 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
434 DWORD dwSize = sizeof(aStackBuffer), dwType;
-
435
-
436 // Try with stack buffer first.
-
437 lResult = ::RegQueryValueExA(hReg, pszName, NULL, &dwType, aStackBuffer, &dwSize);
-
438 if (lResult == ERROR_SUCCESS) {
-
439 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
-
440 // The value is REG_SZ or REG_MULTI_SZ.
-
441 dwSize /= sizeof(CHAR);
-
442 sValue.assign(reinterpret_cast<LPCSTR>(aStackBuffer), dwSize && reinterpret_cast<LPCSTR>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
-
443 } else if (dwType == REG_EXPAND_SZ) {
-
444 // The value is REG_EXPAND_SZ. Expand it from stack buffer.
-
445 if (::ExpandEnvironmentStringsA(reinterpret_cast<LPCSTR>(aStackBuffer), sValue) == 0)
-
446 lResult = ::GetLastError();
-
447 } else {
-
448 // The value is not a string type.
-
449 lResult = ERROR_INVALID_DATA;
-
450 }
-
451 } else if (lResult == ERROR_MORE_DATA) {
-
452 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
-
453 // The value is REG_SZ or REG_MULTI_SZ. Read it now.
-
454 std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
-
455 if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
-
456 dwSize /= sizeof(CHAR);
-
457 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
-
458 }
-
459 } else if (dwType == REG_EXPAND_SZ) {
-
460 // The value is REG_EXPAND_SZ. Read it and expand environment variables.
-
461 std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
-
462 if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
-
463 if (::ExpandEnvironmentStringsA(szBuffer.get(), sValue) == 0)
-
464 lResult = ::GetLastError();
-
465 }
-
466 } else {
-
467 // The value is not a string type.
-
468 lResult = ERROR_INVALID_DATA;
-
469 }
-
470 }
-
471
-
472 return lResult;
-
473}
+
404 *lpGuid = g;
+
405 return TRUE;
+
406}
-
474
-
493template<class _Traits, class _Ax>
-
-
494static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue) noexcept
-
495{
-
496 LSTATUS lResult;
-
497 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
498 DWORD dwSize = sizeof(aStackBuffer), dwType;
-
499
-
500 // Try with stack buffer first.
-
501 lResult = ::RegQueryValueExW(hReg, pszName, NULL, &dwType, aStackBuffer, &dwSize);
-
502 if (lResult == ERROR_SUCCESS) {
-
503 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
-
504 // The value is REG_SZ or REG_MULTI_SZ.
-
505 dwSize /= sizeof(WCHAR);
-
506 sValue.assign(reinterpret_cast<LPCWSTR>(aStackBuffer), dwSize && reinterpret_cast<LPCWSTR>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
-
507 } else if (dwType == REG_EXPAND_SZ) {
-
508 // The value is REG_EXPAND_SZ. Expand it from stack buffer.
-
509 if (::ExpandEnvironmentStringsW(reinterpret_cast<LPCWSTR>(aStackBuffer), sValue) == 0)
-
510 lResult = ::GetLastError();
-
511 } else {
-
512 // The value is not a string type.
-
513 lResult = ERROR_INVALID_DATA;
-
514 }
-
515 } else if (lResult == ERROR_MORE_DATA) {
-
516 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
-
517 // The value is REG_SZ or REG_MULTI_SZ. Read it now.
-
518 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
-
519 if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
-
520 dwSize /= sizeof(WCHAR);
-
521 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
-
522 }
-
523 } else if (dwType == REG_EXPAND_SZ) {
-
524 // The value is REG_EXPAND_SZ. Read it and expand environment variables.
-
525 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
-
526 if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
-
527 if (::ExpandEnvironmentStringsW(szBuffer.get(), sValue) == 0)
-
528 lResult = ::GetLastError();
-
529 }
-
530 } else {
-
531 // The value is not a string type.
-
532 lResult = ERROR_INVALID_DATA;
-
533 }
-
534 }
-
535
-
536 return lResult;
-
537}
+
407
+
409#ifdef _UNICODE
+
410#define StringToGuid StringToGuidW
+
411#else
+
412#define StringToGuid StringToGuidA
+
413#endif
+
414
+
433template<class _Traits, class _Ax>
+
+
434static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<char, _Traits, _Ax> &sValue) noexcept
+
435{
+
436 LSTATUS lResult;
+
437 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
438 DWORD dwSize = sizeof(aStackBuffer), dwType;
+
439
+
440 // Try with stack buffer first.
+
441 lResult = ::RegQueryValueExA(hReg, pszName, NULL, &dwType, aStackBuffer, &dwSize);
+
442 if (lResult == ERROR_SUCCESS) {
+
443 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
+
444 // The value is REG_SZ or REG_MULTI_SZ.
+
445 dwSize /= sizeof(CHAR);
+
446 sValue.assign(reinterpret_cast<LPCSTR>(aStackBuffer), dwSize && reinterpret_cast<LPCSTR>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
+
447 } else if (dwType == REG_EXPAND_SZ) {
+
448 // The value is REG_EXPAND_SZ. Expand it from stack buffer.
+
449 if (::ExpandEnvironmentStringsA(reinterpret_cast<LPCSTR>(aStackBuffer), sValue) == 0)
+
450 lResult = ::GetLastError();
+
451 } else {
+
452 // The value is not a string type.
+
453 lResult = ERROR_INVALID_DATA;
+
454 }
+
455 } else if (lResult == ERROR_MORE_DATA) {
+
456 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
+
457 // The value is REG_SZ or REG_MULTI_SZ. Read it now.
+
458 std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
+
459 if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
+
460 dwSize /= sizeof(CHAR);
+
461 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
+
462 }
+
463 } else if (dwType == REG_EXPAND_SZ) {
+
464 // The value is REG_EXPAND_SZ. Read it and expand environment variables.
+
465 std::unique_ptr<CHAR[]> szBuffer(new CHAR[dwSize / sizeof(CHAR)]);
+
466 if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
+
467 if (::ExpandEnvironmentStringsA(szBuffer.get(), sValue) == 0)
+
468 lResult = ::GetLastError();
+
469 }
+
470 } else {
+
471 // The value is not a string type.
+
472 lResult = ERROR_INVALID_DATA;
+
473 }
+
474 }
+
475
+
476 return lResult;
+
477}
-
538
-
540template<class _Ty, class _Ax>
-
-
541static LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
-
542{
-
543 LSTATUS lResult;
-
544 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
545 DWORD dwSize = sizeof(aStackBuffer);
-
546
-
547 // Try with stack buffer first.
-
548 lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
-
549 if (lResult == ERROR_SUCCESS) {
-
550 // Copy from stack buffer.
-
551 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
-
552 memcpy(aData.data(), aStackBuffer, dwSize);
-
553 } else if (lResult == ERROR_MORE_DATA) {
-
554 // Allocate buffer on heap and retry.
+
478
+
497template<class _Traits, class _Ax>
+
+
498static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue) noexcept
+
499{
+
500 LSTATUS lResult;
+
501 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
502 DWORD dwSize = sizeof(aStackBuffer), dwType;
+
503
+
504 // Try with stack buffer first.
+
505 lResult = ::RegQueryValueExW(hReg, pszName, NULL, &dwType, aStackBuffer, &dwSize);
+
506 if (lResult == ERROR_SUCCESS) {
+
507 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
+
508 // The value is REG_SZ or REG_MULTI_SZ.
+
509 dwSize /= sizeof(WCHAR);
+
510 sValue.assign(reinterpret_cast<LPCWSTR>(aStackBuffer), dwSize && reinterpret_cast<LPCWSTR>(aStackBuffer)[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
+
511 } else if (dwType == REG_EXPAND_SZ) {
+
512 // The value is REG_EXPAND_SZ. Expand it from stack buffer.
+
513 if (::ExpandEnvironmentStringsW(reinterpret_cast<LPCWSTR>(aStackBuffer), sValue) == 0)
+
514 lResult = ::GetLastError();
+
515 } else {
+
516 // The value is not a string type.
+
517 lResult = ERROR_INVALID_DATA;
+
518 }
+
519 } else if (lResult == ERROR_MORE_DATA) {
+
520 if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
+
521 // The value is REG_SZ or REG_MULTI_SZ. Read it now.
+
522 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
+
523 if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
+
524 dwSize /= sizeof(WCHAR);
+
525 sValue.assign(szBuffer.get(), dwSize && szBuffer[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
+
526 }
+
527 } else if (dwType == REG_EXPAND_SZ) {
+
528 // The value is REG_EXPAND_SZ. Read it and expand environment variables.
+
529 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[dwSize / sizeof(WCHAR)]);
+
530 if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(szBuffer.get()), &dwSize)) == ERROR_SUCCESS) {
+
531 if (::ExpandEnvironmentStringsW(szBuffer.get(), sValue) == 0)
+
532 lResult = ::GetLastError();
+
533 }
+
534 } else {
+
535 // The value is not a string type.
+
536 lResult = ERROR_INVALID_DATA;
+
537 }
+
538 }
+
539
+
540 return lResult;
+
541}
+
+
542
+
544template<class _Ty, class _Ax>
+
+
545static LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
+
546{
+
547 LSTATUS lResult;
+
548 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
549 DWORD dwSize = sizeof(aStackBuffer);
+
550
+
551 // Try with stack buffer first.
+
552 lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
+
553 if (lResult == ERROR_SUCCESS) {
+
554 // Copy from stack buffer.
555 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
-
556 lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
-
557 }
-
558
-
559 return lResult;
-
560}
+
556 memcpy(aData.data(), aStackBuffer, dwSize);
+
557 } else if (lResult == ERROR_MORE_DATA) {
+
558 // Allocate buffer on heap and retry.
+
559 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
+
560 lResult = RegQueryValueExA(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
+
561 }
+
562
+
563 return lResult;
+
564}
-
561
-
567template<class _Ty, class _Ax>
-
-
568static LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
-
569{
-
570 LSTATUS lResult;
-
571 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
572 DWORD dwSize = sizeof(aStackBuffer);
-
573
-
574 // Try with stack buffer first.
-
575 lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
-
576 if (lResult == ERROR_SUCCESS) {
-
577 // Copy from stack buffer.
-
578 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
-
579 memcpy(aData.data(), aStackBuffer, dwSize);
-
580 } else if (lResult == ERROR_MORE_DATA) {
-
581 // Allocate buffer on heap and retry.
+
565
+
571template<class _Ty, class _Ax>
+
+
572static LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
+
573{
+
574 LSTATUS lResult;
+
575 BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
576 DWORD dwSize = sizeof(aStackBuffer);
+
577
+
578 // Try with stack buffer first.
+
579 lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, aStackBuffer, &dwSize);
+
580 if (lResult == ERROR_SUCCESS) {
+
581 // Copy from stack buffer.
582 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
-
583 lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
-
584 }
-
585
-
586 return lResult;
-
587}
+
583 memcpy(aData.data(), aStackBuffer, dwSize);
+
584 } else if (lResult == ERROR_MORE_DATA) {
+
585 // Allocate buffer on heap and retry.
+
586 aData.resize((dwSize + sizeof(_Ty) - 1) / sizeof(_Ty));
+
587 lResult = RegQueryValueExW(hKey, lpValueName, lpReserved, NULL, reinterpret_cast<LPBYTE>(aData.data()), &dwSize);
+
588 }
+
589
+
590 return lResult;
+
591}
-
588
-
589#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
-
590
-
592template<class _Traits, class _Ax>
-
-
593static 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
-
594{
-
595 // According to "Remarks" section in MSDN documentation of RegLoadMUIString(),
-
596 // this function is defined but not implemented as ANSI variation.
-
597 assert(0);
-
598 return ERROR_CALL_NOT_IMPLEMENTED;
-
599}
+
592
+
593#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+
594
+
596template<class _Traits, class _Ax>
+
+
597static 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
+
598{
+
599 // According to "Remarks" section in MSDN documentation of RegLoadMUIString(),
+
600 // this function is defined but not implemented as ANSI variation.
+
601 assert(0);
+
602 return ERROR_CALL_NOT_IMPLEMENTED;
+
603}
-
600
-
606template<class _Traits, class _Ax>
-
-
607static 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
-
608{
-
609 LSTATUS lResult;
-
610 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)];
-
611 DWORD dwSize;
-
612
-
613 Flags &= ~REG_MUI_STRING_TRUNCATE;
-
614
-
615 // Try with stack buffer first.
-
616 lResult = RegLoadMUIStringW(hKey, pszValue, szStackBuffer, sizeof(szStackBuffer), &dwSize, Flags, pszDirectory);
-
617 if (lResult == ERROR_SUCCESS) {
-
618 // Copy from stack buffer.
-
619 sOut.assign(szStackBuffer, wcsnlen(szStackBuffer, dwSize/sizeof(wchar_t)));
-
620 } else if (lResult == ERROR_MORE_DATA) {
-
621 // Allocate buffer on heap and retry.
-
622 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[(dwSize + sizeof(wchar_t) - 1)/sizeof(wchar_t)]);
-
623 sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? wcsnlen(szBuffer.get(), dwSize/sizeof(wchar_t)) : 0);
-
624 }
-
625
-
626 return lResult;
-
627}
+
604
+
610template<class _Traits, class _Ax>
+
+
611static 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{
+
613 LSTATUS lResult;
+
614 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)];
+
615 DWORD dwSize;
+
616
+
617 Flags &= ~REG_MUI_STRING_TRUNCATE;
+
618
+
619 // Try with stack buffer first.
+
620 lResult = RegLoadMUIStringW(hKey, pszValue, szStackBuffer, sizeof(szStackBuffer), &dwSize, Flags, pszDirectory);
+
621 if (lResult == ERROR_SUCCESS) {
+
622 // Copy from stack buffer.
+
623 sOut.assign(szStackBuffer, wcsnlen(szStackBuffer, dwSize/sizeof(wchar_t)));
+
624 } else if (lResult == ERROR_MORE_DATA) {
+
625 // Allocate buffer on heap and retry.
+
626 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[(dwSize + sizeof(wchar_t) - 1)/sizeof(wchar_t)]);
+
627 sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? wcsnlen(szBuffer.get(), dwSize/sizeof(wchar_t)) : 0);
+
628 }
+
629
+
630 return lResult;
+
631}
-
628
-
629#endif
-
630
-
636template<class _Traits, class _Ax>
-
-
637static _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
-
638{
-
639 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
-
640
-
641 // Try to convert to stack buffer first.
-
642 int cch = ::NormalizeString(NormForm, lpSrcString, cwSrcLength, szStackBuffer, _countof(szStackBuffer));
-
643 if (cch > 0) {
-
644 // Copy from stack.
-
645 sDstString.assign(szStackBuffer, cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
646 } else {
-
647 switch (::GetLastError()) {
-
648 case ERROR_INSUFFICIENT_BUFFER:
-
649 for (int i = 10; i--;) {
-
650 // Allocate buffer. Then convert again.
-
651 cch = -cch;
-
652 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
653 cch = ::NormalizeString(NormForm, lpSrcString, cwSrcLength, szBuffer.get(), cch);
-
654 if (cch > 0) {
-
655 sDstString.assign(szBuffer.get(), cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
-
656 break;
-
657 }
-
658 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
-
659 sDstString.clear();
+
632
+
633#endif
+
634
+
640template<class _Traits, class _Ax>
+
+
641static _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
+
642{
+
643 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
+
644
+
645 // Try to convert to stack buffer first.
+
646 int cch = ::NormalizeString(NormForm, lpSrcString, cwSrcLength, szStackBuffer, _countof(szStackBuffer));
+
647 if (cch > 0) {
+
648 // Copy from stack.
+
649 sDstString.assign(szStackBuffer, cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
+
650 } else {
+
651 switch (::GetLastError()) {
+
652 case ERROR_INSUFFICIENT_BUFFER:
+
653 for (int i = 10; i--;) {
+
654 // Allocate buffer. Then convert again.
+
655 cch = -cch;
+
656 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
657 cch = ::NormalizeString(NormForm, lpSrcString, cwSrcLength, szBuffer.get(), cch);
+
658 if (cch > 0) {
+
659 sDstString.assign(szBuffer.get(), cwSrcLength != -1 ? wcsnlen(szStackBuffer, cch) : (size_t)cch - 1);
660 break;
661 }
-
662 }
-
663 break;
-
664
-
665 case ERROR_SUCCESS:
-
666 sDstString.clear();
+
662 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+
663 sDstString.clear();
+
664 break;
+
665 }
+
666 }
667 break;
-
668 }
-
669 }
-
670
-
671 return cch;
-
672}
+
668
+
669 case ERROR_SUCCESS:
+
670 sDstString.clear();
+
671 break;
+
672 }
+
673 }
+
674
+
675 return cch;
+
676}
-
673
-
679template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
-
-
680static _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
-
681{
-
682 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
-
683
-
684 // Try to convert to stack buffer first.
-
685 int cch = ::NormalizeString(NormForm, sSrcString.c_str(), (int)sSrcString.length(), szStackBuffer, _countof(szStackBuffer));
-
686 if (cch > 0) {
-
687 // Copy from stack.
-
688 sDstString.assign(szStackBuffer, cch);
-
689 } else {
-
690 switch (::GetLastError()) {
-
691 case ERROR_INSUFFICIENT_BUFFER:
-
692 for (int i = 10; i--;) {
-
693 // Allocate buffer. Then convert again.
-
694 cch = -cch;
-
695 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
-
696 cch = ::NormalizeString(NormForm, sSrcString.c_str(), (int)sSrcString.length(), szBuffer.get(), cch);
-
697 if (cch > 0) {
-
698 sDstString.assign(szBuffer.get(), cch);
-
699 break;
-
700 }
-
701 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
-
702 sDstString.clear();
+
677
+
683template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
+
+
684static _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
+
685{
+
686 WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
+
687
+
688 // Try to convert to stack buffer first.
+
689 int cch = ::NormalizeString(NormForm, sSrcString.c_str(), (int)sSrcString.length(), szStackBuffer, _countof(szStackBuffer));
+
690 if (cch > 0) {
+
691 // Copy from stack.
+
692 sDstString.assign(szStackBuffer, cch);
+
693 } else {
+
694 switch (::GetLastError()) {
+
695 case ERROR_INSUFFICIENT_BUFFER:
+
696 for (int i = 10; i--;) {
+
697 // Allocate buffer. Then convert again.
+
698 cch = -cch;
+
699 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[cch]);
+
700 cch = ::NormalizeString(NormForm, sSrcString.c_str(), (int)sSrcString.length(), szBuffer.get(), cch);
+
701 if (cch > 0) {
+
702 sDstString.assign(szBuffer.get(), cch);
703 break;
704 }
-
705 }
-
706 break;
-
707
-
708 case ERROR_SUCCESS:
-
709 sDstString.clear();
+
705 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+
706 sDstString.clear();
+
707 break;
+
708 }
+
709 }
710 break;
-
711 }
-
712 }
-
713
-
714 return cch;
-
715}
+
711
+
712 case ERROR_SUCCESS:
+
713 sDstString.clear();
+
714 break;
+
715 }
+
716 }
+
717
+
718 return cch;
+
719}
-
716
-
718template<class _Traits, class _Ax>
-
-
719static _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept
-
720{
-
721 // Get read-only pointer to string resource.
-
722 LPCSTR pszStr;
-
723 int i = LoadStringA(hInstance, uID, reinterpret_cast<LPSTR>(&pszStr), 0);
-
724 if (i) {
-
725 sBuffer.assign(pszStr, i);
-
726 return i;
-
727 } else
-
728 return 0;
-
729}
+
720
+
722template<class _Traits, class _Ax>
+
+
723static _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept
+
724{
+
725 // Get read-only pointer to string resource.
+
726 LPCSTR pszStr;
+
727 int i = LoadStringA(hInstance, uID, reinterpret_cast<LPSTR>(&pszStr), 0);
+
728 if (i) {
+
729 sBuffer.assign(pszStr, i);
+
730 return i;
+
731 } else
+
732 return 0;
+
733}
-
730
-
736template<class _Traits, class _Ax>
-
-
737static _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer) noexcept
-
738{
-
739 // Get read-only pointer to string resource.
-
740 LPCWSTR pszStr;
-
741 int i = LoadStringW(hInstance, uID, reinterpret_cast<LPWSTR>(&pszStr), 0);
-
742 if (i) {
-
743 sBuffer.assign(pszStr, i);
-
744 return i;
-
745 } else
-
746 return 0;
-
747}
+
734
+
740template<class _Traits, class _Ax>
+
+
741static _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer) noexcept
+
742{
+
743 // Get read-only pointer to string resource.
+
744 LPCWSTR pszStr;
+
745 int i = LoadStringW(hInstance, uID, reinterpret_cast<LPWSTR>(&pszStr), 0);
+
746 if (i) {
+
747 sBuffer.assign(pszStr, i);
+
748 return i;
+
749 } else
+
750 return 0;
+
751}
-
748
-
-
754static VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noexcept
-
755{
-
756 std::string str;
-
757 try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
-
758 OutputDebugStringA(str.c_str());
-
759}
+
752
+
+
758static VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noexcept
+
759{
+
760 std::string str;
+
761 try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
+
762 OutputDebugStringA(str.c_str());
+
763}
-
760
-
-
766static VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) noexcept
-
767{
-
768 std::wstring str;
-
769 try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
-
770 OutputDebugStringW(str.c_str());
-
771}
+
764
+
+
770static VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) noexcept
+
771{
+
772 std::wstring str;
+
773 try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
+
774 OutputDebugStringW(str.c_str());
+
775}
-
772
-
-
778static VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) noexcept
-
779{
-
780 va_list arg;
-
781 va_start(arg, lpOutputString);
-
782 OutputDebugStrV(lpOutputString, arg);
-
783 va_end(arg);
-
784}
+
776
+
+
782static VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) noexcept
+
783{
+
784 va_list arg;
+
785 va_start(arg, lpOutputString);
+
786 OutputDebugStrV(lpOutputString, arg);
+
787 va_end(arg);
+
788}
-
785
-
-
791static VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept
-
792{
-
793 va_list arg;
-
794 va_start(arg, lpOutputString);
-
795 OutputDebugStrV(lpOutputString, arg);
-
796 va_end(arg);
-
797}
+
789
+
+
795static VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept
+
796{
+
797 va_list arg;
+
798 va_start(arg, lpOutputString);
+
799 OutputDebugStrV(lpOutputString, arg);
+
800 va_end(arg);
+
801}
-
798
-
800template<class _Traits, class _Ax>
-
-
801static _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
-
802{
-
803 int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
-
804 if (iResult) {
-
805 // Allocate buffer on heap and retry.
-
806 std::unique_ptr<char[]> szBuffer(new char[iResult]);
-
807 iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
-
808 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
-
809 return iResult;
-
810 }
-
811
-
812 return iResult;
-
813}
+
802
+
804template<class _Traits, class _Ax>
+
+
805static _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
+
806{
+
807 int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
+
808 if (iResult) {
+
809 // Allocate buffer on heap and retry.
+
810 std::unique_ptr<char[]> szBuffer(new char[iResult]);
+
811 iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
+
812 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
+
813 return iResult;
+
814 }
+
815
+
816 return iResult;
+
817}
-
814
-
820template<class _Traits, class _Ax>
-
-
821static _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
-
822{
-
823 int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
-
824 if (iResult) {
-
825 // Allocate buffer on heap and retry.
-
826 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[iResult]);
-
827 iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
-
828 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
-
829 return iResult;
-
830 }
-
831
-
832 return iResult;
-
833}
+
818
+
824template<class _Traits, class _Ax>
+
+
825static _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
+
826{
+
827 int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
+
828 if (iResult) {
+
829 // Allocate buffer on heap and retry.
+
830 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[iResult]);
+
831 iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult);
+
832 sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0);
+
833 return iResult;
+
834 }
+
835
+
836 return iResult;
+
837}
-
834
-
836template<class _Traits, class _Ax>
-
-
837static _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
-
838{
-
839 assert(0); // TODO: Test this code.
-
840
-
841 DWORD dwNameLen = 0, dwRefDomainLen = 0;
-
842
-
843 if (LookupAccountSidA(lpSystemName, lpSid,
-
844 NULL, &dwNameLen ,
-
845 NULL, &dwRefDomainLen,
-
846 peUse))
-
847 {
-
848 // Name and domain is blank.
-
849 if (sName ) sName ->clear();
-
850 if (sReferencedDomainName) sReferencedDomainName->clear();
-
851 return TRUE;
-
852 } else if (GetLastError() == ERROR_MORE_DATA) {
-
853 // Allocate on heap and retry.
-
854 std::unique_ptr<char[]> bufName (new char[dwNameLen ]);
-
855 std::unique_ptr<char[]> bufRefDomain(new char[dwRefDomainLen]);
-
856 if (LookupAccountSidA(lpSystemName, lpSid,
-
857 bufName .get(), &dwNameLen ,
-
858 bufRefDomain.get(), &dwRefDomainLen,
-
859 peUse))
-
860 {
-
861 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
-
862 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
-
863 return TRUE;
-
864 }
-
865 }
-
866
-
867 return FALSE;
-
868}
+
838
+
840template<class _Traits, class _Ax>
+
+
841static _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
+
842{
+
843 assert(0); // TODO: Test this code.
+
844
+
845 DWORD dwNameLen = 0, dwRefDomainLen = 0;
+
846
+
847 if (LookupAccountSidA(lpSystemName, lpSid,
+
848 NULL, &dwNameLen ,
+
849 NULL, &dwRefDomainLen,
+
850 peUse))
+
851 {
+
852 // Name and domain is blank.
+
853 if (sName ) sName ->clear();
+
854 if (sReferencedDomainName) sReferencedDomainName->clear();
+
855 return TRUE;
+
856 } else if (GetLastError() == ERROR_MORE_DATA) {
+
857 // Allocate on heap and retry.
+
858 std::unique_ptr<char[]> bufName (new char[dwNameLen ]);
+
859 std::unique_ptr<char[]> bufRefDomain(new char[dwRefDomainLen]);
+
860 if (LookupAccountSidA(lpSystemName, lpSid,
+
861 bufName .get(), &dwNameLen ,
+
862 bufRefDomain.get(), &dwRefDomainLen,
+
863 peUse))
+
864 {
+
865 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
+
866 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
+
867 return TRUE;
+
868 }
+
869 }
+
870
+
871 return FALSE;
+
872}
-
869
-
875template<class _Traits, class _Ax>
-
-
876static _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
-
877{
-
878 assert(0); // TODO: Test this code.
-
879
-
880 DWORD dwNameLen = 0, dwRefDomainLen = 0;
-
881
-
882 if (LookupAccountSidW(lpSystemName, lpSid,
-
883 NULL, &dwNameLen ,
-
884 NULL, &dwRefDomainLen,
-
885 peUse))
-
886 {
-
887 // Name and domain is blank.
-
888 if (sName ) sName ->clear();
-
889 if (sReferencedDomainName) sReferencedDomainName->clear();
-
890 return TRUE;
-
891 } else if (GetLastError() == ERROR_MORE_DATA) {
-
892 // Allocate on heap and retry.
-
893 std::unique_ptr<wchar_t[]> bufName (new wchar_t[dwNameLen ]);
-
894 std::unique_ptr<wchar_t[]> bufRefDomain(new wchar_t[dwRefDomainLen]);
-
895 if (LookupAccountSidW(lpSystemName, lpSid,
-
896 bufName .get(), &dwNameLen ,
-
897 bufRefDomain.get(), &dwRefDomainLen,
-
898 peUse))
-
899 {
-
900 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
-
901 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
-
902 return TRUE;
-
903 }
-
904 }
-
905
-
906 return FALSE;
-
907}
+
873
+
879template<class _Traits, class _Ax>
+
+
880static _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
+
881{
+
882 assert(0); // TODO: Test this code.
+
883
+
884 DWORD dwNameLen = 0, dwRefDomainLen = 0;
+
885
+
886 if (LookupAccountSidW(lpSystemName, lpSid,
+
887 NULL, &dwNameLen ,
+
888 NULL, &dwRefDomainLen,
+
889 peUse))
+
890 {
+
891 // Name and domain is blank.
+
892 if (sName ) sName ->clear();
+
893 if (sReferencedDomainName) sReferencedDomainName->clear();
+
894 return TRUE;
+
895 } else if (GetLastError() == ERROR_MORE_DATA) {
+
896 // Allocate on heap and retry.
+
897 std::unique_ptr<wchar_t[]> bufName (new wchar_t[dwNameLen ]);
+
898 std::unique_ptr<wchar_t[]> bufRefDomain(new wchar_t[dwRefDomainLen]);
+
899 if (LookupAccountSidW(lpSystemName, lpSid,
+
900 bufName .get(), &dwNameLen ,
+
901 bufRefDomain.get(), &dwRefDomainLen,
+
902 peUse))
+
903 {
+
904 if (sName ) sName ->assign(bufName .get(), dwNameLen - 1);
+
905 if (sReferencedDomainName) sReferencedDomainName->assign(bufRefDomain.get(), dwRefDomainLen - 1);
+
906 return TRUE;
+
907 }
+
908 }
+
909
+
910 return FALSE;
+
911}
-
908
-
-
914static _Success_(return != FALSE) BOOL CreateWellKnownSid(_In_ WELL_KNOWN_SID_TYPE WellKnownSidType, _In_opt_ PSID DomainSid, _Inout_ std::unique_ptr<SID> &Sid)
-
915{
-
916 BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
917 DWORD dwSize = sizeof(szStackBuffer);
-
918
-
919 if (CreateWellKnownSid(WellKnownSidType, DomainSid, szStackBuffer, &dwSize)) {
-
920 // The stack buffer was big enough to retrieve complete data. Alloc and copy.
-
921 Sid.reset((SID*)new BYTE[dwSize]);
-
922 memcpy(Sid.get(), szStackBuffer, dwSize);
-
923 return TRUE;
-
924 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
925 // The stack buffer was too small to retrieve complete data. Alloc and retry.
-
926 Sid.reset((SID*)new BYTE[dwSize]);
-
927 return CreateWellKnownSid(WellKnownSidType, DomainSid, Sid.get(), &dwSize);
-
928 } else
-
929 return FALSE;
-
930}
+
912
+
+
918static _Success_(return != FALSE) BOOL CreateWellKnownSid(_In_ WELL_KNOWN_SID_TYPE WellKnownSidType, _In_opt_ PSID DomainSid, _Inout_ std::unique_ptr<SID> &Sid)
+
919{
+
920 BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
921 DWORD dwSize = sizeof(szStackBuffer);
+
922
+
923 if (CreateWellKnownSid(WellKnownSidType, DomainSid, szStackBuffer, &dwSize)) {
+
924 // The stack buffer was big enough to retrieve complete data. Alloc and copy.
+
925 Sid.reset((SID*)new BYTE[dwSize]);
+
926 memcpy(Sid.get(), szStackBuffer, dwSize);
+
927 return TRUE;
+
928 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
929 // The stack buffer was too small to retrieve complete data. Alloc and retry.
+
930 Sid.reset((SID*)new BYTE[dwSize]);
+
931 return CreateWellKnownSid(WellKnownSidType, DomainSid, Sid.get(), &dwSize);
+
932 } else
+
933 return FALSE;
+
934}
-
931
-
937template<class _Ty>
-
-
938static _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) noexcept
-
939{
-
940 BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES];
-
941 DWORD dwSize;
-
942
-
943 if (GetTokenInformation(TokenHandle, TokenInformationClass, szStackBuffer, sizeof(szStackBuffer), &dwSize)) {
-
944 // The stack buffer was big enough to retrieve complete data. Alloc and copy.
-
945 TokenInformation.reset((_Ty*)(new BYTE[dwSize]));
-
946 memcpy(TokenInformation.get(), szStackBuffer, dwSize);
-
947 return TRUE;
-
948 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
949 // The stack buffer was too small to retrieve complete data. Alloc and retry.
-
950 TokenInformation.reset((_Ty*)(new BYTE[dwSize]));
-
951 return GetTokenInformation(TokenHandle, TokenInformationClass, TokenInformation.get(), dwSize, &dwSize);
-
952 } else
-
953 return FALSE;
-
954}
+
935
+
941template<class _Ty>
+
+
942static _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) noexcept
+
943{
+
944 BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES];
+
945 DWORD dwSize;
+
946
+
947 if (GetTokenInformation(TokenHandle, TokenInformationClass, szStackBuffer, sizeof(szStackBuffer), &dwSize)) {
+
948 // The stack buffer was big enough to retrieve complete data. Alloc and copy.
+
949 TokenInformation.reset((_Ty*)(new BYTE[dwSize]));
+
950 memcpy(TokenInformation.get(), szStackBuffer, dwSize);
+
951 return TRUE;
+
952 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
953 // The stack buffer was too small to retrieve complete data. Alloc and retry.
+
954 TokenInformation.reset((_Ty*)(new BYTE[dwSize]));
+
955 return GetTokenInformation(TokenHandle, TokenInformationClass, TokenInformation.get(), dwSize, &dwSize);
+
956 } else
+
957 return FALSE;
+
958}
-
955
-
961template<class _Traits, class _Ax>
-
-
962static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<char, _Traits, _Ax>& sExeName)
-
963{
-
964 char szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(char)];
-
965 DWORD dwSize = _countof(szStackBuffer);
-
966
-
967 // Try with stack buffer first.
-
968 if (::QueryFullProcessImageNameA(hProcess, dwFlags, szStackBuffer, &dwSize)) {
-
969 // Copy from stack.
-
970 sExeName.assign(szStackBuffer, dwSize);
-
971 return TRUE;
-
972 }
-
973 for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(char); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
-
974 // Allocate on heap and retry.
-
975 std::unique_ptr<char[]> szBuffer(new char[dwCapacity]);
-
976 dwSize = dwCapacity;
-
977 if (::QueryFullProcessImageNameA(hProcess, dwFlags, szBuffer.get(), &dwSize)) {
-
978 sExeName.assign(szBuffer.get(), dwSize);
-
979 return TRUE;
-
980 }
-
981 }
-
982 return FALSE;
-
983}
+
959
+
965template<class _Traits, class _Ax>
+
+
966static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<char, _Traits, _Ax>& sExeName)
+
967{
+
968 char szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(char)];
+
969 DWORD dwSize = _countof(szStackBuffer);
+
970
+
971 // Try with stack buffer first.
+
972 if (::QueryFullProcessImageNameA(hProcess, dwFlags, szStackBuffer, &dwSize)) {
+
973 // Copy from stack.
+
974 sExeName.assign(szStackBuffer, dwSize);
+
975 return TRUE;
+
976 }
+
977 for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(char); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
+
978 // Allocate on heap and retry.
+
979 std::unique_ptr<char[]> szBuffer(new char[dwCapacity]);
+
980 dwSize = dwCapacity;
+
981 if (::QueryFullProcessImageNameA(hProcess, dwFlags, szBuffer.get(), &dwSize)) {
+
982 sExeName.assign(szBuffer.get(), dwSize);
+
983 return TRUE;
+
984 }
+
985 }
+
986 return FALSE;
+
987}
-
984
-
990template<class _Traits, class _Ax>
-
-
991static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<wchar_t, _Traits, _Ax>& sExeName)
-
992{
-
993 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t)];
-
994 DWORD dwSize = _countof(szStackBuffer);
-
995
-
996 // Try with stack buffer first.
-
997 if (::QueryFullProcessImageNameW(hProcess, dwFlags, szStackBuffer, &dwSize)) {
-
998 // Copy from stack.
-
999 sExeName.assign(szStackBuffer, dwSize);
-
1000 return TRUE;
-
1001 }
-
1002 for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
-
1003 // Allocate on heap and retry.
-
1004 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[dwCapacity]);
-
1005 dwSize = dwCapacity;
-
1006 if (::QueryFullProcessImageNameW(hProcess, dwFlags, szBuffer.get(), &dwSize)) {
-
1007 sExeName.assign(szBuffer.get(), dwSize);
-
1008 return TRUE;
-
1009 }
-
1010 }
-
1011 return FALSE;
-
1012}
+
988
+
994template<class _Traits, class _Ax>
+
+
995static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<wchar_t, _Traits, _Ax>& sExeName)
+
996{
+
997 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t)];
+
998 DWORD dwSize = _countof(szStackBuffer);
+
999
+
1000 // Try with stack buffer first.
+
1001 if (::QueryFullProcessImageNameW(hProcess, dwFlags, szStackBuffer, &dwSize)) {
+
1002 // Copy from stack.
+
1003 sExeName.assign(szStackBuffer, dwSize);
+
1004 return TRUE;
+
1005 }
+
1006 for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) {
+
1007 // Allocate on heap and retry.
+
1008 std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[dwCapacity]);
+
1009 dwSize = dwCapacity;
+
1010 if (::QueryFullProcessImageNameW(hProcess, dwFlags, szBuffer.get(), &dwSize)) {
+
1011 sExeName.assign(szBuffer.get(), dwSize);
+
1012 return TRUE;
+
1013 }
+
1014 }
+
1015 return FALSE;
+
1016}
-
1013
-
1015
-
1016#pragma warning(pop)
1017
-
1018namespace winstd
-
1019{
-
1022
-
1026 template<HANDLE INVALID>
-
-
1027 class win_handle : public handle<HANDLE, INVALID>
-
1028 {
- -
1030
-
1031 public:
-
-
1037 virtual ~win_handle()
-
1038 {
-
1039 if (m_h != invalid)
-
1040 free_internal();
-
1041 }
+
1019
+
1020#pragma warning(pop)
+
1021
+
1022namespace winstd
+
1023{
+
1026
+
1030 template<HANDLE INVALID>
+
+
1031 class win_handle : public handle<HANDLE, INVALID>
+
1032 {
+ +
1034
+
1035 public:
+
+
1041 virtual ~win_handle()
+
1042 {
+
1043 if (m_h != invalid)
+
1044 free_internal();
+
1045 }
-
1042
-
1043 protected:
-
-
1049 void free_internal() noexcept override
-
1050 {
-
1051 CloseHandle(m_h);
-
1052 }
+
1046
+
1047 protected:
+
+
1053 void free_internal() noexcept override
+
1054 {
+
1055 CloseHandle(m_h);
+
1056 }
-
1053 };
+
1057 };
-
1054
-
-
1060 class library : public handle<HMODULE, NULL>
-
1061 {
- -
1063
-
1064 public:
-
-
1070 virtual ~library()
-
1071 {
-
1072 if (m_h != invalid)
-
1073 free_internal();
-
1074 }
+
1058
+
+
1064 class library : public handle<HMODULE, NULL>
+
1065 {
+ +
1067
+
1068 public:
+
+
1074 virtual ~library()
+
1075 {
+
1076 if (m_h != invalid)
+
1077 free_internal();
+
1078 }
-
1075
-
1076 protected:
-
-
1082 void free_internal() noexcept override
-
1083 {
-
1084 FreeLibrary(m_h);
-
1085 }
+
1079
+
1080 protected:
+
+
1086 void free_internal() noexcept override
+
1087 {
+
1088 FreeLibrary(m_h);
+
1089 }
-
1086 };
+
1090 };
-
1087
- -
1094
- -
1101
- -
1108
- -
1115
- -
1123
- -
1130
-
-
1134 template <class _Ty> struct UnmapViewOfFile_delete
-
1135 {
- -
1137
- -
1142
- -
1147
-
-
1151 void operator()(_Ty* _Ptr) const
-
1152 {
-
1153 if (!UnmapViewOfFile(_Ptr))
-
1154 throw win_runtime_error("UnmapViewOfFile failed");
-
1155 }
+
1091
+ +
1098
+ +
1105
+ +
1112
+ +
1119
+ +
1127
+ +
1134
+
+
1138 template <class _Ty> struct UnmapViewOfFile_delete
+
1139 {
+ +
1141
+ +
1146
+ +
1151
+
+
1155 void operator()(_Ty* _Ptr) const
+
1156 {
+
1157 if (!UnmapViewOfFile(_Ptr))
+
1158 throw win_runtime_error("UnmapViewOfFile failed");
+
1159 }
-
1156 };
+
1160 };
-
1157
-
-
1161 template <class _Ty> struct UnmapViewOfFile_delete<_Ty[]>
-
1162 {
- -
1164
- -
1169
-
-
1173 void operator()(_Ty* _Ptr) const
-
1174 {
-
1175 if (!UnmapViewOfFile(_Ptr))
-
1176 throw win_runtime_error("UnmapViewOfFile failed");
-
1177 }
+
1161
+
+
1165 template <class _Ty> struct UnmapViewOfFile_delete<_Ty[]>
+
1166 {
+ +
1168
+ +
1173
+
+
1177 void operator()(_Ty* _Ptr) const
+
1178 {
+
1179 if (!UnmapViewOfFile(_Ptr))
+
1180 throw win_runtime_error("UnmapViewOfFile failed");
+
1181 }
-
1178
-
1182 template<class _Other>
-
-
1183 void operator()(_Other*) const
-
1184 {
-
1185 if (!UnmapViewOfFile(_Ptr))
-
1186 throw win_runtime_error("UnmapViewOfFile failed");
-
1187 }
+
1182
+
1186 template<class _Other>
+
+
1187 void operator()(_Other*) const
+
1188 {
+
1189 if (!UnmapViewOfFile(_Ptr))
+
1190 throw win_runtime_error("UnmapViewOfFile failed");
+
1191 }
-
1188 };
+
1192 };
-
1189
- -
1197
-
- -
1202 {
- - -
1205
-
1206 public:
-
- -
1213 {
-
1214 InitializeCriticalSection(&m_data);
-
1215 }
+
1193
+ +
1201
+
+ +
1206 {
+ + +
1209
+
1210 public:
+
+ +
1217 {
+
1218 InitializeCriticalSection(&m_data);
+
1219 }
-
1216
-
- -
1223 {
-
1224 DeleteCriticalSection(&m_data);
-
1225 }
+
1220
+
+ +
1227 {
+
1228 DeleteCriticalSection(&m_data);
+
1229 }
-
1226
-
-
1232 operator LPCRITICAL_SECTION() noexcept
-
1233 {
-
1234 return &m_data;
-
1235 }
-
-
1236
-
1237 protected:
-
1238 CRITICAL_SECTION m_data;
-
1239 };
+
1230
+
+
1236 operator LPCRITICAL_SECTION() noexcept
+
1237 {
+
1238 return &m_data;
+
1239 }
1240
-
-
1246 class find_file : public handle<HANDLE, INVALID_HANDLE_VALUE>
-
1247 {
-
1248 WINSTD_HANDLE_IMPL(find_file, INVALID_HANDLE_VALUE)
-
1249
-
1250 public:
-
-
1256 virtual ~find_file()
-
1257 {
-
1258 if (m_h != invalid)
-
1259 free_internal();
-
1260 }
+
1241 protected:
+
1242 CRITICAL_SECTION m_data;
+
1243 };
-
1261
-
1262 protected:
-
-
1268 void free_internal() noexcept override
-
1269 {
-
1270 FindClose(m_h);
-
1271 }
+
1244
+
+
1250 class find_file : public handle<HANDLE, INVALID_HANDLE_VALUE>
+
1251 {
+
1252 WINSTD_HANDLE_IMPL(find_file, INVALID_HANDLE_VALUE)
+
1253
+
1254 public:
+
+
1260 virtual ~find_file()
+
1261 {
+
1262 if (m_h != invalid)
+
1263 free_internal();
+
1264 }
-
1272 };
+
1265
+
1266 protected:
+
+
1272 void free_internal() noexcept override
+
1273 {
+
1274 FindClose(m_h);
+
1275 }
-
1273
-
-
1279 class heap : public handle<HANDLE, NULL>
-
1280 {
- -
1282
-
1283 public:
-
-
1289 virtual ~heap()
-
1290 {
-
1291 if (m_h != invalid)
-
1292 free_internal();
-
1293 }
+
1276 };
-
1294
-
-
1302 bool enumerate() noexcept
-
1303 {
-
1304 assert(m_h != invalid);
-
1305
-
1306 bool found = false;
-
1307
-
1308 // Lock the heap for exclusive access.
-
1309 HeapLock(m_h);
-
1310
-
1311 PROCESS_HEAP_ENTRY e;
-
1312 e.lpData = NULL;
-
1313 while (HeapWalk(m_h, &e) != FALSE) {
-
1314 if ((e.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) {
- -
1316 _T("Allocated block%s%s\n")
-
1317 _T(" Data portion begins at: %#p\n Size: %d bytes\n")
-
1318 _T(" Overhead: %d bytes\n Region index: %d\n"),
-
1319 (e.wFlags & PROCESS_HEAP_ENTRY_MOVEABLE) != 0 ? tstring_printf(_T(", movable with HANDLE %#p"), e.Block.hMem).c_str() : _T(""),
-
1320 (e.wFlags & PROCESS_HEAP_ENTRY_DDESHARE) != 0 ? _T(", DDESHARE") : _T(""),
-
1321 e.lpData,
-
1322 e.cbData,
-
1323 e.cbOverhead,
-
1324 e.iRegionIndex);
-
1325
-
1326 found = true;
-
1327 }
-
1328 }
+
1277
+
+
1283 class heap : public handle<HANDLE, NULL>
+
1284 {
+ +
1286
+
1287 public:
+
+
1293 virtual ~heap()
+
1294 {
+
1295 if (m_h != invalid)
+
1296 free_internal();
+
1297 }
+
+
1298
+
+
1306 bool enumerate() noexcept
+
1307 {
+
1308 assert(m_h != invalid);
+
1309
+
1310 bool found = false;
+
1311
+
1312 // Lock the heap for exclusive access.
+
1313 HeapLock(m_h);
+
1314
+
1315 PROCESS_HEAP_ENTRY e;
+
1316 e.lpData = NULL;
+
1317 while (HeapWalk(m_h, &e) != FALSE) {
+
1318 if ((e.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) {
+ +
1320 _T("Allocated block%s%s\n")
+
1321 _T(" Data portion begins at: %#p\n Size: %d bytes\n")
+
1322 _T(" Overhead: %d bytes\n Region index: %d\n"),
+
1323 (e.wFlags & PROCESS_HEAP_ENTRY_MOVEABLE) != 0 ? tstring_printf(_T(", movable with HANDLE %#p"), e.Block.hMem).c_str() : _T(""),
+
1324 (e.wFlags & PROCESS_HEAP_ENTRY_DDESHARE) != 0 ? _T(", DDESHARE") : _T(""),
+
1325 e.lpData,
+
1326 e.cbData,
+
1327 e.cbOverhead,
+
1328 e.iRegionIndex);
1329
-
1330 const DWORD dwResult = GetLastError();
-
1331 if (dwResult != ERROR_NO_MORE_ITEMS)
-
1332 OutputDebugStr(_T("HeapWalk failed (error %u).\n"), dwResult);
+
1330 found = true;
+
1331 }
+
1332 }
1333
-
1334 // Unlock the heap.
-
1335 HeapUnlock(m_h);
-
1336
-
1337 return found;
-
1338 }
+
1334 const DWORD dwResult = GetLastError();
+
1335 if (dwResult != ERROR_NO_MORE_ITEMS)
+
1336 OutputDebugStr(_T("HeapWalk failed (error %u).\n"), dwResult);
+
1337
+
1338 // Unlock the heap.
+
1339 HeapUnlock(m_h);
+
1340
+
1341 return found;
+
1342 }
-
1339
-
1340 protected:
-
-
1346 void free_internal() noexcept override
-
1347 {
-
1348 enumerate();
-
1349 HeapDestroy(m_h);
-
1350 }
+
1343
+
1344 protected:
+
+
1350 void free_internal() noexcept override
+
1351 {
+
1352 enumerate();
+
1353 HeapDestroy(m_h);
+
1354 }
-
1351 };
+
1355 };
-
1352
-
1356 template <class _Ty>
-
- -
1358 {
-
1359 public:
-
1360 typedef typename _Ty value_type;
-
1361
-
1362 typedef _Ty *pointer;
-
1363 typedef _Ty& reference;
-
1364 typedef const _Ty *const_pointer;
-
1365 typedef const _Ty& const_reference;
-
1366
-
1367 typedef SIZE_T size_type;
-
1368 typedef ptrdiff_t difference_type;
-
1369
-
1373 template <class _Other>
-
-
1374 struct rebind
-
1375 {
- -
1377 };
+
1356
+
1360 template <class _Ty>
+
+ +
1362 {
+
1363 public:
+
1364 typedef typename _Ty value_type;
+
1365
+
1366 typedef _Ty *pointer;
+
1367 typedef _Ty& reference;
+
1368 typedef const _Ty *const_pointer;
+
1369 typedef const _Ty& const_reference;
+
1370
+
1371 typedef SIZE_T size_type;
+
1372 typedef ptrdiff_t difference_type;
+
1373
+
1377 template <class _Other>
+
+
1378 struct rebind
+
1379 {
+ +
1381 };
-
1378
-
1379 public:
-
- -
1386 {
-
1387 }
+
1382
+
1383 public:
+
+ +
1390 {
+
1391 }
-
1388
-
1394 template <class _Other>
-
- -
1396 {
-
1397 }
+
1392
+
1398 template <class _Other>
+
+ +
1400 {
+
1401 }
-
1398
-
- -
1407 {
-
1408 assert(m_heap);
-
1409 return (pointer)HeapAlloc(m_heap, 0, count * sizeof(_Ty));
-
1410 }
+
1402
+
+ +
1411 {
+
1412 assert(m_heap);
+
1413 return (pointer)HeapAlloc(m_heap, 0, count * sizeof(_Ty));
+
1414 }
-
1411
-
-
1418 void deallocate(_In_ pointer ptr, _In_ size_type size)
-
1419 {
-
1420 UNREFERENCED_PARAMETER(size);
-
1421 assert(m_heap);
-
1422 HeapFree(m_heap, 0, ptr);
-
1423 }
+
1415
+
+
1422 void deallocate(_In_ pointer ptr, _In_ size_type size)
+
1423 {
+
1424 UNREFERENCED_PARAMETER(size);
+
1425 assert(m_heap);
+
1426 HeapFree(m_heap, 0, ptr);
+
1427 }
-
1424
-
-
1431 void construct(_Inout_ pointer ptr, _In_ const _Ty& val)
-
1432 {
-
1433 ::new ((void*)ptr) _Ty(val);
-
1434 }
+
1428
+
+
1435 void construct(_Inout_ pointer ptr, _In_ const _Ty& val)
+
1436 {
+
1437 ::new ((void*)ptr) _Ty(val);
+
1438 }
-
1435
-
-
1442 void construct(_Inout_ pointer ptr, _Inout_ _Ty&& val)
-
1443 {
-
1444 ::new ((void*)ptr) _Ty(std::forward<_Ty>(val));
-
1445 }
+
1439
+
+
1446 void construct(_Inout_ pointer ptr, _Inout_ _Ty&& val)
+
1447 {
+
1448 ::new ((void*)ptr) _Ty(std::forward<_Ty>(val));
+
1449 }
-
1446
-
-
1452 void destroy(_Inout_ pointer ptr)
-
1453 {
-
1454 ptr->_Ty::~_Ty();
-
1455 }
+
1450
+
+
1456 void destroy(_Inout_ pointer ptr)
+
1457 {
+
1458 ptr->_Ty::~_Ty();
+
1459 }
-
1456
-
- -
1461 {
-
1462 return (SIZE_T)-1;
-
1463 }
-
-
1464
-
1465 public:
-
1466 HANDLE m_heap;
-
1467 };
+
1460
+
+ +
1465 {
+
1466 return (SIZE_T)-1;
+
1467 }
1468
-
- -
1473 {
- - -
1476
-
1477 public:
-
-
1485 actctx_activator(_In_ HANDLE hActCtx) noexcept
-
1486 {
-
1487 if (!ActivateActCtx(hActCtx, &m_cookie))
-
1488 m_cookie = 0;
-
1489 }
+
1469 public:
+
1470 HANDLE m_heap;
+
1471 };
-
1490
-
- -
1497 {
-
1498 if (m_cookie)
-
1499 DeactivateActCtx(0, m_cookie);
-
1500 }
+
1472
+
+ +
1477 {
+ + +
1480
+
1481 public:
+
+
1489 actctx_activator(_In_ HANDLE hActCtx) noexcept
+
1490 {
+
1491 if (!ActivateActCtx(hActCtx, &m_cookie))
+
1492 m_cookie = 0;
+
1493 }
-
1501
-
1502 protected:
-
1503 ULONG_PTR m_cookie;
-
1504 };
+
1494
+
+ +
1501 {
+
1502 if (m_cookie)
+
1503 DeactivateActCtx(0, m_cookie);
+
1504 }
1505
-
- -
1510 {
-
1511 public:
-
1515 impersonator() noexcept : m_cookie(FALSE) {}
-
1516
-
- -
1523 {
-
1524 if (m_cookie)
-
1525 RevertToSelf();
-
1526 }
+
1506 protected:
+
1507 ULONG_PTR m_cookie;
+
1508 };
-
1527
-
1531 operator bool () const { return m_cookie; }
-
1532
-
1533 protected:
- -
1535 };
+
1509
+
+ +
1514 {
+
1515 public:
+
1519 impersonator() noexcept : m_cookie(FALSE) {}
+
1520
+
+ +
1527 {
+
1528 if (m_cookie)
+
1529 RevertToSelf();
+
1530 }
+
1531
+
1535 operator bool () const { return m_cookie; }
1536
-
- -
1541 {
- - -
1544
-
1545 public:
-
-
1553 user_impersonator(_In_opt_ HANDLE hToken) noexcept
-
1554 {
-
1555 m_cookie = hToken && ImpersonateLoggedOnUser(hToken);
-
1556 }
+
1537 protected:
+ +
1539 };
-
1557 };
+
1540
+
+ +
1545 {
+ + +
1548
+
1549 public:
+
+
1557 user_impersonator(_In_opt_ HANDLE hToken) noexcept
+
1558 {
+
1559 m_cookie = hToken && ImpersonateLoggedOnUser(hToken);
+
1560 }
-
1558
-
- -
1563 {
- - -
1566
-
1567 public:
-
- -
1572 {
-
1573 TOKEN_PRIVILEGES privileges = { 1, {{{ 0, 0 }, SE_PRIVILEGE_ENABLED }} };
-
1574 if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &privileges.Privileges[0].Luid) ||
-
1575 !ImpersonateSelf(SecurityImpersonation))
-
1576 return;
-
1577
-
1578 {
-
1579 HANDLE h;
-
1580 if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES, FALSE, &h))
-
1581 goto revert;
-
1582 win_handle<INVALID_HANDLE_VALUE> thread_token(h);
-
1583 if (!AdjustTokenPrivileges(thread_token, FALSE, &privileges, sizeof(privileges), NULL, NULL))
-
1584 goto revert;
-
1585 process_snapshot process_snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-
1586 if (!process_snapshot)
-
1587 goto revert;
-
1588 PROCESSENTRY32 entry = { sizeof(PROCESSENTRY32) };
-
1589 if (!Process32First(process_snapshot, &entry))
-
1590 goto revert;
-
1591 while (_tcsicmp(entry.szExeFile, TEXT("winlogon.exe")) != 0)
-
1592 if (!Process32Next(process_snapshot, &entry))
-
1593 goto revert;
-
1594 process winlogon_process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, entry.th32ProcessID);
-
1595 if (!winlogon_process)
-
1596 goto revert;
-
1597 if (!OpenProcessToken(winlogon_process, TOKEN_IMPERSONATE | TOKEN_DUPLICATE, &h))
-
1598 goto revert;
-
1599 win_handle<INVALID_HANDLE_VALUE> winlogon_token(h);
-
1600 if (!DuplicateToken(winlogon_token, SecurityImpersonation, &h))
-
1601 goto revert;
-
1602 win_handle<INVALID_HANDLE_VALUE> duplicated_token(h);
-
1603 if (!SetThreadToken(NULL, duplicated_token))
-
1604 goto revert;
-
1605 }
-
1606
-
1607 m_cookie = TRUE;
-
1608 return;
-
1609
-
1610 revert:
-
1611 DWORD dwResult = GetLastError();
-
1612 RevertToSelf();
-
1613 SetLastError(dwResult);
-
1614 }
+
1561 };
-
1615 };
+
1562
+
+ +
1567 {
+ + +
1570
+
1571 public:
+
+ +
1576 {
+
1577 TOKEN_PRIVILEGES privileges = { 1, {{{ 0, 0 }, SE_PRIVILEGE_ENABLED }} };
+
1578 if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &privileges.Privileges[0].Luid) ||
+
1579 !ImpersonateSelf(SecurityImpersonation))
+
1580 return;
+
1581
+
1582 {
+
1583 HANDLE h;
+
1584 if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES, FALSE, &h))
+
1585 goto revert;
+
1586 win_handle<INVALID_HANDLE_VALUE> thread_token(h);
+
1587 if (!AdjustTokenPrivileges(thread_token, FALSE, &privileges, sizeof(privileges), NULL, NULL))
+
1588 goto revert;
+
1589 process_snapshot process_snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+
1590 if (!process_snapshot)
+
1591 goto revert;
+
1592 PROCESSENTRY32 entry = { sizeof(PROCESSENTRY32) };
+
1593 if (!Process32First(process_snapshot, &entry))
+
1594 goto revert;
+
1595 while (_tcsicmp(entry.szExeFile, TEXT("winlogon.exe")) != 0)
+
1596 if (!Process32Next(process_snapshot, &entry))
+
1597 goto revert;
+
1598 process winlogon_process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, entry.th32ProcessID);
+
1599 if (!winlogon_process)
+
1600 goto revert;
+
1601 if (!OpenProcessToken(winlogon_process, TOKEN_IMPERSONATE | TOKEN_DUPLICATE, &h))
+
1602 goto revert;
+
1603 win_handle<INVALID_HANDLE_VALUE> winlogon_token(h);
+
1604 if (!DuplicateToken(winlogon_token, SecurityImpersonation, &h))
+
1605 goto revert;
+
1606 win_handle<INVALID_HANDLE_VALUE> duplicated_token(h);
+
1607 if (!SetThreadToken(NULL, duplicated_token))
+
1608 goto revert;
+
1609 }
+
1610
+
1611 m_cookie = TRUE;
+
1612 return;
+
1613
+
1614 revert:
+
1615 DWORD dwResult = GetLastError();
+
1616 RevertToSelf();
+
1617 SetLastError(dwResult);
+
1618 }
-
1616
-
- -
1621 {
-
1622 public:
-
-
1628 clipboard_opener(_In_opt_ HWND hWndNewOwner = NULL)
-
1629 {
-
1630 if (!OpenClipboard(hWndNewOwner))
-
1631 throw win_runtime_error("OpenClipboard failed");
-
1632 }
+
1619 };
-
1633
-
- -
1640 {
-
1641 CloseClipboard();
-
1642 }
+
1620
+
+ +
1625 {
+
1626 public:
+
+
1632 clipboard_opener(_In_opt_ HWND hWndNewOwner = NULL)
+
1633 {
+
1634 if (!OpenClipboard(hWndNewOwner))
+
1635 throw win_runtime_error("OpenClipboard failed");
+
1636 }
-
1643 };
+
1637
+
+ +
1644 {
+
1645 CloseClipboard();
+
1646 }
-
1644
-
- -
1649 {
- - -
1652
-
1653 public:
-
-
1661 console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) noexcept : m_handler(HandlerRoutine)
-
1662 {
-
1663 m_cookie = SetConsoleCtrlHandler(m_handler, TRUE);
-
1664 }
+
1647 };
-
1665
-
- -
1672 {
-
1673 if (m_cookie)
-
1674 SetConsoleCtrlHandler(m_handler, FALSE);
-
1675 }
+
1648
+
+ +
1653 {
+ + +
1656
+
1657 public:
+
+
1665 console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) noexcept : m_handler(HandlerRoutine)
+
1666 {
+
1667 m_cookie = SetConsoleCtrlHandler(m_handler, TRUE);
+
1668 }
-
1676
-
1677 protected:
- -
1679 PHANDLER_ROUTINE m_handler;
-
1680 };
+
1669
+
+ +
1676 {
+
1677 if (m_cookie)
+
1678 SetConsoleCtrlHandler(m_handler, FALSE);
+
1679 }
-
1681
-
-
1685 class vmemory : public handle<LPVOID, NULL>
-
1686 {
- -
1688
-
1689 public:
-
-
1693 vmemory() noexcept : m_proc(NULL)
-
1694 {
-
1695 }
+
1680
+
1681 protected:
+ +
1683 PHANDLER_ROUTINE m_handler;
+
1684 };
-
1696
-
-
1703 vmemory(_In_ handle_type h, _In_ HANDLE proc) noexcept :
-
1704 m_proc(proc),
- -
1706 {
-
1707 }
+
1685
+
+
1689 class vmemory : public handle<LPVOID, NULL>
+
1690 {
+ +
1692
+
1693 public:
+
+
1697 vmemory() noexcept : m_proc(NULL)
+
1698 {
+
1699 }
-
1708
-
-
1714 vmemory(_Inout_ vmemory &&h) noexcept :
-
1715 m_proc(std::move(h.m_proc)),
-
1716 handle<LPVOID, NULL>(std::move(h))
-
1717 {
-
1718 }
+
1700
+
+
1707 vmemory(_In_ handle_type h, _In_ HANDLE proc) noexcept :
+
1708 m_proc(proc),
+ +
1710 {
+
1711 }
-
1719
-
-
1725 virtual ~vmemory()
-
1726 {
-
1727 if (m_h != invalid)
-
1728 VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
-
1729 }
+
1712
+
+
1718 vmemory(_Inout_ vmemory &&h) noexcept :
+
1719 m_proc(std::move(h.m_proc)),
+
1720 handle<LPVOID, NULL>(std::move(h))
+
1721 {
+
1722 }
-
1730
-
-
1736 vmemory& operator=(_Inout_ vmemory &&other) noexcept
-
1737 {
-
1738 if (this != std::addressof(other)) {
-
1739 (handle<handle_type, NULL>&&)*this = std::move(other);
-
1740 m_proc = std::move(other.m_proc);
-
1741 }
-
1742 return *this;
-
1743 }
+
1723
+
+
1729 virtual ~vmemory()
+
1730 {
+
1731 if (m_h != invalid)
+
1732 VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
+
1733 }
-
1744
-
-
1753 void attach(_In_ HANDLE proc, _In_opt_ handle_type h) noexcept
-
1754 {
-
1755 m_proc = proc;
-
1756 if (m_h != invalid)
-
1757 free_internal();
-
1758 m_h = h;
-
1759 }
+
1734
+
+
1740 vmemory& operator=(_Inout_ vmemory &&other) noexcept
+
1741 {
+
1742 if (this != std::addressof(other)) {
+
1743 (handle<handle_type, NULL>&&)*this = std::move(other);
+
1744 m_proc = std::move(other.m_proc);
+
1745 }
+
1746 return *this;
+
1747 }
-
1760
-
-
1770 bool alloc(
-
1771 _In_ HANDLE hProcess,
-
1772 _In_opt_ LPVOID lpAddress,
-
1773 _In_ SIZE_T dwSize,
-
1774 _In_ DWORD flAllocationType,
-
1775 _In_ DWORD flProtect) noexcept
-
1776 {
-
1777 handle_type h = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect);
-
1778 if (h != invalid) {
-
1779 attach(hProcess, h);
-
1780 return true;
-
1781 } else
-
1782 return false;
-
1783 }
+
1748
+
+
1757 void attach(_In_ HANDLE proc, _In_opt_ handle_type h) noexcept
+
1758 {
+
1759 m_proc = proc;
+
1760 if (m_h != invalid)
+
1761 free_internal();
+
1762 m_h = h;
+
1763 }
-
1784
-
1785 protected:
-
-
1791 void free_internal() noexcept override
-
1792 {
-
1793 VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
-
1794 }
+
1764
+
+
1774 bool alloc(
+
1775 _In_ HANDLE hProcess,
+
1776 _In_opt_ LPVOID lpAddress,
+
1777 _In_ SIZE_T dwSize,
+
1778 _In_ DWORD flAllocationType,
+
1779 _In_ DWORD flProtect) noexcept
+
1780 {
+
1781 handle_type h = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect);
+
1782 if (h != invalid) {
+
1783 attach(hProcess, h);
+
1784 return true;
+
1785 } else
+
1786 return false;
+
1787 }
-
1795
-
1796 protected:
-
1797 HANDLE m_proc;
-
1798 };
+
1788
+
1789 protected:
+
+
1795 void free_internal() noexcept override
+
1796 {
+
1797 VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
+
1798 }
1799
-
-
1806 class reg_key : public handle<HKEY, NULL>
-
1807 {
- -
1809
-
1810 public:
-
-
1816 virtual ~reg_key()
-
1817 {
-
1818 if (m_h != invalid)
-
1819 free_internal();
-
1820 }
+
1800 protected:
+
1801 HANDLE m_proc;
+
1802 };
-
1821
-
-
1831 bool delete_subkey(_In_z_ LPCTSTR szSubkey)
-
1832 {
-
1833 LSTATUS s;
-
1834
-
1835 s = RegDeleteKey(m_h, szSubkey);
-
1836 if (s == ERROR_SUCCESS || s == ERROR_FILE_NOT_FOUND)
-
1837 return true;
+
1803
+
+
1810 class reg_key : public handle<HKEY, NULL>
+
1811 {
+ +
1813
+
1814 public:
+
+
1820 virtual ~reg_key()
+
1821 {
+
1822 if (m_h != invalid)
+
1823 free_internal();
+
1824 }
+
+
1825
+
+
1835 bool delete_subkey(_In_z_ LPCTSTR szSubkey)
+
1836 {
+
1837 LSTATUS s;
1838
-
1839 {
-
1840 reg_key k;
-
1841 handle_type h;
-
1842 s = RegOpenKeyEx(m_h, szSubkey, 0, KEY_ENUMERATE_SUB_KEYS, &h);
-
1843 if (s == ERROR_SUCCESS)
-
1844 k.attach(h);
-
1845 else {
-
1846 SetLastError(s);
-
1847 return false;
-
1848 }
-
1849 for (;;) {
-
1850 TCHAR szName[MAX_PATH];
-
1851 DWORD dwSize = _countof(szName);
-
1852 s = RegEnumKeyEx(k, 0, szName, &dwSize, NULL, NULL, NULL, NULL);
-
1853 if (s == ERROR_SUCCESS)
-
1854 k.delete_subkey(szName);
-
1855 else if (s == ERROR_NO_MORE_ITEMS)
-
1856 break;
-
1857 else {
-
1858 SetLastError(s);
-
1859 return false;
-
1860 }
-
1861 }
-
1862 }
-
1863
-
1864 s = RegDeleteKey(m_h, szSubkey);
-
1865 if (s == ERROR_SUCCESS)
-
1866 return true;
-
1867 else {
-
1868 SetLastError(s);
-
1869 return false;
-
1870 }
-
1871 }
+
1839 s = RegDeleteKey(m_h, szSubkey);
+
1840 if (s == ERROR_SUCCESS || s == ERROR_FILE_NOT_FOUND)
+
1841 return true;
+
1842
+
1843 {
+
1844 reg_key k;
+
1845 handle_type h;
+
1846 s = RegOpenKeyEx(m_h, szSubkey, 0, KEY_ENUMERATE_SUB_KEYS, &h);
+
1847 if (s == ERROR_SUCCESS)
+
1848 k.attach(h);
+
1849 else {
+
1850 SetLastError(s);
+
1851 return false;
+
1852 }
+
1853 for (;;) {
+
1854 TCHAR szName[MAX_PATH];
+
1855 DWORD dwSize = _countof(szName);
+
1856 s = RegEnumKeyEx(k, 0, szName, &dwSize, NULL, NULL, NULL, NULL);
+
1857 if (s == ERROR_SUCCESS)
+
1858 k.delete_subkey(szName);
+
1859 else if (s == ERROR_NO_MORE_ITEMS)
+
1860 break;
+
1861 else {
+
1862 SetLastError(s);
+
1863 return false;
+
1864 }
+
1865 }
+
1866 }
+
1867
+
1868 s = RegDeleteKey(m_h, szSubkey);
+
1869 if (s == ERROR_SUCCESS)
+
1870 return true;
+
1871 else {
+
1872 SetLastError(s);
+
1873 return false;
+
1874 }
+
1875 }
-
1872
-
1873 protected:
-
-
1879 void free_internal() noexcept override
-
1880 {
-
1881 RegCloseKey(m_h);
-
1882 }
+
1876
+
1877 protected:
+
+
1883 void free_internal() noexcept override
+
1884 {
+
1885 RegCloseKey(m_h);
+
1886 }
-
1883 };
+
1887 };
-
1884
-
-
1888 class security_id : public handle<PSID, NULL>
-
1889 {
- -
1891
-
1892 public:
-
- -
1899 {
-
1900 if (m_h != invalid)
-
1901 free_internal();
-
1902 }
+
1888
+
+
1892 class security_id : public handle<PSID, NULL>
+
1893 {
+ +
1895
+
1896 public:
+
+ +
1903 {
+
1904 if (m_h != invalid)
+
1905 free_internal();
+
1906 }
-
1903
-
1904 protected:
-
-
1910 void free_internal() noexcept override
-
1911 {
-
1912 FreeSid(m_h);
-
1913 }
+
1907
+
1908 protected:
+
+
1914 void free_internal() noexcept override
+
1915 {
+
1916 FreeSid(m_h);
+
1917 }
-
1914 };
+
1918 };
-
1915
-
-
1919 class process_information : public PROCESS_INFORMATION
-
1920 {
- - -
1923
-
1924 public:
-
- -
1929 {
-
1930 hProcess = INVALID_HANDLE_VALUE;
-
1931 hThread = INVALID_HANDLE_VALUE;
-
1932 dwProcessId = 0;
-
1933 dwThreadId = 0;
-
1934 }
-
-
1935
-
- -
1940 {
-
1941 #pragma warning(push)
-
1942 #pragma warning(disable: 6001) // Using uninitialized memory '*this'. << ???
-
1943
-
1944 if (hProcess != INVALID_HANDLE_VALUE)
-
1945 CloseHandle(hProcess);
-
1946
-
1947 if (hThread != INVALID_HANDLE_VALUE)
-
1948 CloseHandle(hThread);
-
1949
-
1950 #pragma warning(pop)
-
1951 }
-
-
1952 };
+
1919
+
+
1923 class process_information : public PROCESS_INFORMATION
+
1924 {
+ + +
1927
+
1928 public:
+
+ +
1933 {
+
1934 hProcess = INVALID_HANDLE_VALUE;
+
1935 hThread = INVALID_HANDLE_VALUE;
+
1936 dwProcessId = 0;
+
1937 dwThreadId = 0;
+
1938 }
+
1939
+
+ +
1944 {
+
1945 #pragma warning(push)
+
1946 #pragma warning(disable: 6001) // Using uninitialized memory '*this'. << ???
+
1947
+
1948 if (hProcess != INVALID_HANDLE_VALUE)
+
1949 CloseHandle(hProcess);
+
1950
+
1951 if (hThread != INVALID_HANDLE_VALUE)
+
1952 CloseHandle(hThread);
1953
-
-
1959 class event_log : public handle<HANDLE, NULL>
-
1960 {
- -
1962
-
1963 public:
-
-
1969 virtual ~event_log()
-
1970 {
-
1971 if (m_h != invalid)
-
1972 free_internal();
-
1973 }
+
1954 #pragma warning(pop)
+
1955 }
-
1974
-
1975 protected:
-
-
1981 void free_internal() noexcept override
-
1982 {
-
1983 DeregisterEventSource(m_h);
-
1984 }
+
1956 };
-
1985 };
+
1957
+
+
1963 class event_log : public handle<HANDLE, NULL>
+
1964 {
+ +
1966
+
1967 public:
+
+
1973 virtual ~event_log()
+
1974 {
+
1975 if (m_h != invalid)
+
1976 free_internal();
+
1977 }
-
1986
-
-
1990 class sc_handle : public handle<SC_HANDLE, NULL>
-
1991 {
- -
1993
-
1994 public:
-
-
2000 virtual ~sc_handle()
-
2001 {
-
2002 if (m_h != invalid)
-
2003 free_internal();
-
2004 }
+
1978
+
1979 protected:
+
+
1985 void free_internal() noexcept override
+
1986 {
+
1987 DeregisterEventSource(m_h);
+
1988 }
-
2005
-
2006 protected:
-
-
2012 void free_internal() noexcept override
-
2013 {
-
2014 CloseServiceHandle(m_h);
-
2015 }
+
1989 };
-
2016 };
+
1990
+
+
1994 class sc_handle : public handle<SC_HANDLE, NULL>
+
1995 {
+ +
1997
+
1998 public:
+
+
2004 virtual ~sc_handle()
+
2005 {
+
2006 if (m_h != invalid)
+
2007 free_internal();
+
2008 }
-
2017
-
2019}
-
2020
-
2023
-
2024#pragma warning(push)
-
2025#pragma warning(disable: 4505) // Don't warn on unused code
-
2026
-
-
2028static LSTATUS RegCreateKeyExA(
-
2029 _In_ HKEY hKey,
-
2030 _In_ LPCSTR lpSubKey,
-
2031 _Reserved_ DWORD Reserved,
-
2032 _In_opt_ LPSTR lpClass,
-
2033 _In_ DWORD dwOptions,
-
2034 _In_ REGSAM samDesired,
-
2035 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-
2036 _Inout_ winstd::reg_key &result,
-
2037 _Out_opt_ LPDWORD lpdwDisposition)
-
2038{
-
2039 HKEY h;
-
2040 LSTATUS s = RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
-
2041 if (s == ERROR_SUCCESS)
-
2042 result.attach(h);
-
2043 return s;
-
2044}
+
2009
+
2010 protected:
+
+
2016 void free_internal() noexcept override
+
2017 {
+
2018 CloseServiceHandle(m_h);
+
2019 }
-
2045
-
-
2051static LSTATUS RegCreateKeyExW(
-
2052 _In_ HKEY hKey,
-
2053 _In_ LPCWSTR lpSubKey,
-
2054 _Reserved_ DWORD Reserved,
-
2055 _In_opt_ LPWSTR lpClass,
-
2056 _In_ DWORD dwOptions,
-
2057 _In_ REGSAM samDesired,
-
2058 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-
2059 _Inout_ winstd::reg_key &result,
-
2060 _Out_opt_ LPDWORD lpdwDisposition)
-
2061{
-
2062 HKEY h;
-
2063 LSTATUS s = RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
-
2064 if (s == ERROR_SUCCESS)
-
2065 result.attach(h);
-
2066 return s;
-
2067}
+
2020 };
-
2068
-
-
2070static LSTATUS RegOpenKeyExA(
-
2071 _In_ HKEY hKey,
-
2072 _In_opt_ LPCSTR lpSubKey,
-
2073 _In_opt_ DWORD ulOptions,
-
2074 _In_ REGSAM samDesired,
-
2075 _Inout_ winstd::reg_key &result)
-
2076{
-
2077 HKEY h;
-
2078 LSTATUS s = RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, &h);
-
2079 if (s == ERROR_SUCCESS)
-
2080 result.attach(h);
-
2081 return s;
-
2082}
+
2021
+
2023}
+
2024
+
2027
+
2028#pragma warning(push)
+
2029#pragma warning(disable: 4505) // Don't warn on unused code
+
2030
+
+
2032static LSTATUS RegCreateKeyExA(
+
2033 _In_ HKEY hKey,
+
2034 _In_ LPCSTR lpSubKey,
+
2035 _Reserved_ DWORD Reserved,
+
2036 _In_opt_ LPSTR lpClass,
+
2037 _In_ DWORD dwOptions,
+
2038 _In_ REGSAM samDesired,
+
2039 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+
2040 _Inout_ winstd::reg_key &result,
+
2041 _Out_opt_ LPDWORD lpdwDisposition)
+
2042{
+
2043 HKEY h;
+
2044 LSTATUS s = RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
+
2045 if (s == ERROR_SUCCESS)
+
2046 result.attach(h);
+
2047 return s;
+
2048}
-
2083
-
-
2089static LSTATUS RegOpenKeyExW(
-
2090 _In_ HKEY hKey,
-
2091 _In_opt_ LPCWSTR lpSubKey,
-
2092 _In_opt_ DWORD ulOptions,
-
2093 _In_ REGSAM samDesired,
-
2094 _Inout_ winstd::reg_key &result)
-
2095{
-
2096 HKEY h;
-
2097 LSTATUS s = RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, &h);
-
2098 if (s == ERROR_SUCCESS)
-
2099 result.attach(h);
-
2100 return s;
-
2101}
+
2049
+
+
2055static LSTATUS RegCreateKeyExW(
+
2056 _In_ HKEY hKey,
+
2057 _In_ LPCWSTR lpSubKey,
+
2058 _Reserved_ DWORD Reserved,
+
2059 _In_opt_ LPWSTR lpClass,
+
2060 _In_ DWORD dwOptions,
+
2061 _In_ REGSAM samDesired,
+
2062 _In_opt_ CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+
2063 _Inout_ winstd::reg_key &result,
+
2064 _Out_opt_ LPDWORD lpdwDisposition)
+
2065{
+
2066 HKEY h;
+
2067 LSTATUS s = RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
+
2068 if (s == ERROR_SUCCESS)
+
2069 result.attach(h);
+
2070 return s;
+
2071}
-
2102
-
-
2108static BOOL OpenProcessToken(_In_ HANDLE ProcessHandle, _In_ DWORD DesiredAccess, _Inout_ winstd::win_handle<NULL> &TokenHandle)
-
2109{
-
2110 HANDLE h;
-
2111 if (OpenProcessToken(ProcessHandle, DesiredAccess, &h)) {
-
2112 TokenHandle.attach(h);
-
2113 return TRUE;
-
2114 }
-
2115 return FALSE;
-
2116}
+
2072
+
+
2074static LSTATUS RegOpenKeyExA(
+
2075 _In_ HKEY hKey,
+
2076 _In_opt_ LPCSTR lpSubKey,
+
2077 _In_opt_ DWORD ulOptions,
+
2078 _In_ REGSAM samDesired,
+
2079 _Inout_ winstd::reg_key &result)
+
2080{
+
2081 HKEY h;
+
2082 LSTATUS s = RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, &h);
+
2083 if (s == ERROR_SUCCESS)
+
2084 result.attach(h);
+
2085 return s;
+
2086}
-
2117
-
-
2123static 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)
-
2124{
-
2125 HANDLE h;
-
2126 if (DuplicateTokenEx(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, &h)) {
-
2127 NewToken.attach(h);
-
2128 return TRUE;
-
2129 }
-
2130 return FALSE;
-
2131}
+
2087
+
+
2093static LSTATUS RegOpenKeyExW(
+
2094 _In_ HKEY hKey,
+
2095 _In_opt_ LPCWSTR lpSubKey,
+
2096 _In_opt_ DWORD ulOptions,
+
2097 _In_ REGSAM samDesired,
+
2098 _Inout_ winstd::reg_key &result)
+
2099{
+
2100 HKEY h;
+
2101 LSTATUS s = RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, &h);
+
2102 if (s == ERROR_SUCCESS)
+
2103 result.attach(h);
+
2104 return s;
+
2105}
-
2132
-
-
2138static 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)
-
2139{
-
2140 PSID h;
-
2141 if (AllocateAndInitializeSid(pIdentifierAuthority, nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, &h)) {
-
2142 Sid.attach(h);
-
2143 return TRUE;
-
2144 }
-
2145 return FALSE;
-
2146}
+
2106
+
+
2112static BOOL OpenProcessToken(_In_ HANDLE ProcessHandle, _In_ DWORD DesiredAccess, _Inout_ winstd::win_handle<NULL> &TokenHandle)
+
2113{
+
2114 HANDLE h;
+
2115 if (OpenProcessToken(ProcessHandle, DesiredAccess, &h)) {
+
2116 TokenHandle.attach(h);
+
2117 return TRUE;
+
2118 }
+
2119 return FALSE;
+
2120}
-
2147
-
-
2149static DWORD SetEntriesInAclA(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_A pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
-
2150{
-
2151 PACL h;
-
2152 DWORD dwResult = SetEntriesInAclA(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
-
2153 if (dwResult == ERROR_SUCCESS)
-
2154 Acl.reset(h);
-
2155 return ERROR_SUCCESS;
-
2156}
+
2121
+
+
2127static 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)
+
2128{
+
2129 HANDLE h;
+
2130 if (DuplicateTokenEx(hExistingToken, dwDesiredAccess, lpTokenAttributes, ImpersonationLevel, TokenType, &h)) {
+
2131 NewToken.attach(h);
+
2132 return TRUE;
+
2133 }
+
2134 return FALSE;
+
2135}
-
2157
-
-
2163static DWORD SetEntriesInAclW(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_W pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
-
2164{
-
2165 PACL h;
-
2166 DWORD dwResult = SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
-
2167 if (dwResult == ERROR_SUCCESS)
-
2168 Acl.reset(h);
-
2169 return ERROR_SUCCESS;
-
2170}
+
2136
+
+
2142static 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)
+
2143{
+
2144 PSID h;
+
2145 if (AllocateAndInitializeSid(pIdentifierAuthority, nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, &h)) {
+
2146 Sid.attach(h);
+
2147 return TRUE;
+
2148 }
+
2149 return FALSE;
+
2150}
-
2171
-
2177template<class _Traits, class _Ax>
-
-
2178_Success_(return != 0) BOOL GetThreadPreferredUILanguages(_In_ DWORD dwFlags, _Out_ PULONG pulNumLanguages, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
-
2179{
-
2180 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)];
-
2181 ULONG ulSize = _countof(szStackBuffer);
-
2182
-
2183 // Try with stack buffer first.
-
2184 if (GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, szStackBuffer, &ulSize)) {
-
2185 // Copy from stack.
-
2186 sValue.assign(szStackBuffer, ulSize - 1);
-
2187 return TRUE;
-
2188 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-
2189 // Query required size.
-
2190 ulSize = 0;
-
2191 GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, NULL, &ulSize);
-
2192 // Allocate on heap and retry.
-
2193 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[ulSize]);
-
2194 if (GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, szBuffer.get(), &ulSize)) {
-
2195 sValue.assign(szBuffer.get(), ulSize - 1);
-
2196 return TRUE;
-
2197 }
-
2198 }
-
2199 return FALSE;
-
2200}
+
2151
+
+
2153static DWORD SetEntriesInAclA(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_A pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
+
2154{
+
2155 PACL h;
+
2156 DWORD dwResult = SetEntriesInAclA(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
+
2157 if (dwResult == ERROR_SUCCESS)
+
2158 Acl.reset(h);
+
2159 return ERROR_SUCCESS;
+
2160}
-
2201
-
2202#pragma warning(pop)
-
2203
-
Activates given activation context in constructor and deactivates it in destructor.
Definition Win.h:1473
-
actctx_activator(HANDLE hActCtx) noexcept
Construct the activator and activates the given activation context.
Definition Win.h:1485
-
virtual ~actctx_activator()
Deactivates activation context and destructs the activator.
Definition Win.h:1496
-
ULONG_PTR m_cookie
Cookie for context deactivation.
Definition Win.h:1503
-
Base template class to support string formatting using printf() style templates.
Definition Common.h:1574
-
Clipboard management.
Definition Win.h:1621
-
virtual ~clipboard_opener()
Closes the clipboard.
Definition Win.h:1639
-
clipboard_opener(HWND hWndNewOwner=NULL)
Opens the clipboard for examination and prevents other applications from modifying the clipboard cont...
Definition Win.h:1628
-
Console control handler stack management.
Definition Win.h:1649
-
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:1661
-
virtual ~console_ctrl_handler()
Pops console control handler from the console control handler stack.
Definition Win.h:1671
-
PHANDLER_ROUTINE m_handler
Pointer to console control handler.
Definition Win.h:1679
-
BOOL m_cookie
Did pushing the console control handler succeed?
Definition Win.h:1678
-
Critical section wrapper.
Definition Win.h:1202
-
critical_section() noexcept
Construct the object and initializes a critical section object.
Definition Win.h:1212
-
CRITICAL_SECTION m_data
Critical section struct.
Definition Win.h:1238
-
virtual ~critical_section()
Releases all resources used by an unowned critical section object.
Definition Win.h:1222
-
Event log handle wrapper.
Definition Win.h:1960
-
void free_internal() noexcept override
Closes an event log handle.
Definition Win.h:1981
-
virtual ~event_log()
Closes an event log handle.
Definition Win.h:1969
-
Find-file handle wrapper.
Definition Win.h:1247
-
virtual ~find_file()
Closes a file search handle.
Definition Win.h:1256
-
void free_internal() noexcept override
Closes a file search handle.
Definition Win.h:1268
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
LPVOID handle_type
Datatype of the object handle this template class handles.
Definition Common.h:988
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1200
-
HeapAlloc allocator.
Definition Win.h:1358
-
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:1367
-
_Ty value_type
A type that is managed by the allocator.
Definition Win.h:1360
-
heap_allocator(const heap_allocator< _Other > &other)
Constructs allocator from another type.
Definition Win.h:1395
-
HANDLE m_heap
Heap handle.
Definition Win.h:1466
-
pointer allocate(size_type count)
Allocates a new memory block.
Definition Win.h:1406
-
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:1368
-
heap_allocator(HANDLE heap)
Constructs allocator.
Definition Win.h:1385
-
_Ty & reference
A type that provides a reference to the type of object managed by the allocator.
Definition Win.h:1363
-
void construct(pointer ptr, _Ty &&val)
Calls moving constructor for the element.
Definition Win.h:1442
-
void deallocate(pointer ptr, size_type size)
Frees memory block.
Definition Win.h:1418
-
size_type max_size() const
Returns maximum memory block size.
Definition Win.h:1460
-
void construct(pointer ptr, const _Ty &val)
Calls copying constructor for the element.
Definition Win.h:1431
-
const _Ty & const_reference
A type that provides a constant reference to type of object managed by the allocator.
Definition Win.h:1365
-
const _Ty * const_pointer
A type that provides a constant pointer to the type of object managed by the allocator.
Definition Win.h:1364
-
_Ty * pointer
A type that provides a pointer to the type of object managed by the allocator.
Definition Win.h:1362
-
void destroy(pointer ptr)
Calls destructor for the element.
Definition Win.h:1452
-
Heap handle wrapper.
Definition Win.h:1280
-
bool enumerate() noexcept
Enumerates allocated heap blocks using OutputDebugString()
Definition Win.h:1302
-
void free_internal() noexcept override
Destroys the heap.
Definition Win.h:1346
-
virtual ~heap()
Destroys the heap.
Definition Win.h:1289
-
Base class for thread impersonation of another security context.
Definition Win.h:1510
-
virtual ~impersonator()
Reverts to current user and destructs the impersonator.
Definition Win.h:1522
-
impersonator() noexcept
Construct the impersonator.
Definition Win.h:1515
-
BOOL m_cookie
Did impersonation succeed?
Definition Win.h:1534
-
Module handle wrapper.
Definition Win.h:1061
-
void free_internal() noexcept override
Frees the module.
Definition Win.h:1082
-
virtual ~library()
Frees the module.
Definition Win.h:1070
-
PROCESS_INFORMATION struct wrapper.
Definition Win.h:1920
-
~process_information()
Closes process and thread handles.
Definition Win.h:1939
-
process_information() noexcept
Constructs blank PROCESS_INFORMATION.
Definition Win.h:1928
-
Registry key wrapper class.
Definition Win.h:1807
-
void free_internal() noexcept override
Closes a handle to the registry key.
Definition Win.h:1879
-
bool delete_subkey(LPCTSTR szSubkey)
Deletes the specified registry subkey.
Definition Win.h:1831
-
virtual ~reg_key()
Closes a handle to the registry key.
Definition Win.h:1816
-
SC_HANDLE wrapper class.
Definition Win.h:1991
-
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:2012
-
virtual ~sc_handle()
Closes an open object handle.
Definition Win.h:2000
-
SID wrapper class.
Definition Win.h:1889
-
void free_internal() noexcept override
Closes a handle to the SID.
Definition Win.h:1910
-
virtual ~security_id()
Closes a handle to the SID.
Definition Win.h:1898
-
Lets the calling thread impersonate the security context of the SYSTEM user.
Definition Win.h:1563
-
system_impersonator() noexcept
Construct the impersonator and impersonates the SYSTEM user.
Definition Win.h:1571
-
Lets the calling thread impersonate the security context of a logged-on user.
Definition Win.h:1541
-
user_impersonator(HANDLE hToken) noexcept
Construct the impersonator and impersonates the given user.
Definition Win.h:1553
-
Memory in virtual address space of a process handle wrapper.
Definition Win.h:1686
-
vmemory & operator=(vmemory &&other) noexcept
Move assignment.
Definition Win.h:1736
-
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:1770
-
void free_internal() noexcept override
Frees the memory.
Definition Win.h:1791
-
void attach(HANDLE proc, handle_type h) noexcept
Sets a new memory handle for the class.
Definition Win.h:1753
-
virtual ~vmemory()
Frees the memory.
Definition Win.h:1725
-
vmemory(handle_type h, HANDLE proc) noexcept
Initializes a new class instance with an already available object handle.
Definition Win.h:1703
-
vmemory() noexcept
Initializes a new class instance with the memory handle set to INVAL.
Definition Win.h:1693
-
vmemory(vmemory &&h) noexcept
Move constructor.
Definition Win.h:1714
-
HANDLE m_proc
Handle of memory's process.
Definition Win.h:1797
-
Windows HANDLE wrapper class.
Definition Win.h:1028
-
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:1049
-
virtual ~win_handle()
Closes an open object handle.
Definition Win.h:1037
-
Windows runtime error.
Definition Common.h:1491
-
#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
-
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:251
-
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:284
-
#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:993
-
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:637
-
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:180
-
static BOOL StringToGuidA(LPCSTR lpszGuid, LPGUID lpGuid, LPCSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:269
+
2161
+
+
2167static DWORD SetEntriesInAclW(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_W pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
+
2168{
+
2169 PACL h;
+
2170 DWORD dwResult = SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
+
2171 if (dwResult == ERROR_SUCCESS)
+
2172 Acl.reset(h);
+
2173 return ERROR_SUCCESS;
+
2174}
+
+
2175
+
2181template<class _Traits, class _Ax>
+
+
2182_Success_(return != 0) BOOL GetThreadPreferredUILanguages(_In_ DWORD dwFlags, _Out_ PULONG pulNumLanguages, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
+
2183{
+
2184 wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)];
+
2185 ULONG ulSize = _countof(szStackBuffer);
+
2186
+
2187 // Try with stack buffer first.
+
2188 if (GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, szStackBuffer, &ulSize)) {
+
2189 // Copy from stack.
+
2190 sValue.assign(szStackBuffer, ulSize - 1);
+
2191 return TRUE;
+
2192 } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+
2193 // Query required size.
+
2194 ulSize = 0;
+
2195 GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, NULL, &ulSize);
+
2196 // Allocate on heap and retry.
+
2197 std::unique_ptr<WCHAR[]> szBuffer(new WCHAR[ulSize]);
+
2198 if (GetThreadPreferredUILanguages(dwFlags, pulNumLanguages, szBuffer.get(), &ulSize)) {
+
2199 sValue.assign(szBuffer.get(), ulSize - 1);
+
2200 return TRUE;
+
2201 }
+
2202 }
+
2203 return FALSE;
+
2204}
+
+
2205
+
2206#pragma warning(pop)
+
2207
+
Activates given activation context in constructor and deactivates it in destructor.
Definition Win.h:1477
+
actctx_activator(HANDLE hActCtx) noexcept
Construct the activator and activates the given activation context.
Definition Win.h:1489
+
virtual ~actctx_activator()
Deactivates activation context and destructs the activator.
Definition Win.h:1500
+
ULONG_PTR m_cookie
Cookie for context deactivation.
Definition Win.h:1507
+
Base template class to support string formatting using printf() style templates.
Definition Common.h:1611
+
Clipboard management.
Definition Win.h:1625
+
virtual ~clipboard_opener()
Closes the clipboard.
Definition Win.h:1643
+
clipboard_opener(HWND hWndNewOwner=NULL)
Opens the clipboard for examination and prevents other applications from modifying the clipboard cont...
Definition Win.h:1632
+
Console control handler stack management.
Definition Win.h:1653
+
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:1665
+
virtual ~console_ctrl_handler()
Pops console control handler from the console control handler stack.
Definition Win.h:1675
+
PHANDLER_ROUTINE m_handler
Pointer to console control handler.
Definition Win.h:1683
+
BOOL m_cookie
Did pushing the console control handler succeed?
Definition Win.h:1682
+
Critical section wrapper.
Definition Win.h:1206
+
critical_section() noexcept
Construct the object and initializes a critical section object.
Definition Win.h:1216
+
CRITICAL_SECTION m_data
Critical section struct.
Definition Win.h:1242
+
virtual ~critical_section()
Releases all resources used by an unowned critical section object.
Definition Win.h:1226
+
Event log handle wrapper.
Definition Win.h:1964
+
void free_internal() noexcept override
Closes an event log handle.
Definition Win.h:1985
+
virtual ~event_log()
Closes an event log handle.
Definition Win.h:1973
+
Find-file handle wrapper.
Definition Win.h:1251
+
virtual ~find_file()
Closes a file search handle.
Definition Win.h:1260
+
void free_internal() noexcept override
Closes a file search handle.
Definition Win.h:1272
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
LPVOID handle_type
Datatype of the object handle this template class handles.
Definition Common.h:1025
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition Common.h:1237
+
HeapAlloc allocator.
Definition Win.h:1362
+
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:1371
+
_Ty value_type
A type that is managed by the allocator.
Definition Win.h:1364
+
heap_allocator(const heap_allocator< _Other > &other)
Constructs allocator from another type.
Definition Win.h:1399
+
HANDLE m_heap
Heap handle.
Definition Win.h:1470
+
pointer allocate(size_type count)
Allocates a new memory block.
Definition Win.h:1410
+
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:1372
+
heap_allocator(HANDLE heap)
Constructs allocator.
Definition Win.h:1389
+
_Ty & reference
A type that provides a reference to the type of object managed by the allocator.
Definition Win.h:1367
+
void construct(pointer ptr, _Ty &&val)
Calls moving constructor for the element.
Definition Win.h:1446
+
void deallocate(pointer ptr, size_type size)
Frees memory block.
Definition Win.h:1422
+
size_type max_size() const
Returns maximum memory block size.
Definition Win.h:1464
+
void construct(pointer ptr, const _Ty &val)
Calls copying constructor for the element.
Definition Win.h:1435
+
const _Ty & const_reference
A type that provides a constant reference to type of object managed by the allocator.
Definition Win.h:1369
+
const _Ty * const_pointer
A type that provides a constant pointer to the type of object managed by the allocator.
Definition Win.h:1368
+
_Ty * pointer
A type that provides a pointer to the type of object managed by the allocator.
Definition Win.h:1366
+
void destroy(pointer ptr)
Calls destructor for the element.
Definition Win.h:1456
+
Heap handle wrapper.
Definition Win.h:1284
+
bool enumerate() noexcept
Enumerates allocated heap blocks using OutputDebugString()
Definition Win.h:1306
+
void free_internal() noexcept override
Destroys the heap.
Definition Win.h:1350
+
virtual ~heap()
Destroys the heap.
Definition Win.h:1293
+
Base class for thread impersonation of another security context.
Definition Win.h:1514
+
virtual ~impersonator()
Reverts to current user and destructs the impersonator.
Definition Win.h:1526
+
impersonator() noexcept
Construct the impersonator.
Definition Win.h:1519
+
BOOL m_cookie
Did impersonation succeed?
Definition Win.h:1538
+
Module handle wrapper.
Definition Win.h:1065
+
void free_internal() noexcept override
Frees the module.
Definition Win.h:1086
+
virtual ~library()
Frees the module.
Definition Win.h:1074
+
PROCESS_INFORMATION struct wrapper.
Definition Win.h:1924
+
~process_information()
Closes process and thread handles.
Definition Win.h:1943
+
process_information() noexcept
Constructs blank PROCESS_INFORMATION.
Definition Win.h:1932
+
Registry key wrapper class.
Definition Win.h:1811
+
void free_internal() noexcept override
Closes a handle to the registry key.
Definition Win.h:1883
+
bool delete_subkey(LPCTSTR szSubkey)
Deletes the specified registry subkey.
Definition Win.h:1835
+
virtual ~reg_key()
Closes a handle to the registry key.
Definition Win.h:1820
+
SC_HANDLE wrapper class.
Definition Win.h:1995
+
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:2016
+
virtual ~sc_handle()
Closes an open object handle.
Definition Win.h:2004
+
SID wrapper class.
Definition Win.h:1893
+
void free_internal() noexcept override
Closes a handle to the SID.
Definition Win.h:1914
+
virtual ~security_id()
Closes a handle to the SID.
Definition Win.h:1902
+
Lets the calling thread impersonate the security context of the SYSTEM user.
Definition Win.h:1567
+
system_impersonator() noexcept
Construct the impersonator and impersonates the SYSTEM user.
Definition Win.h:1575
+
Lets the calling thread impersonate the security context of a logged-on user.
Definition Win.h:1545
+
user_impersonator(HANDLE hToken) noexcept
Construct the impersonator and impersonates the given user.
Definition Win.h:1557
+
Memory in virtual address space of a process handle wrapper.
Definition Win.h:1690
+
vmemory & operator=(vmemory &&other) noexcept
Move assignment.
Definition Win.h:1740
+
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:1774
+
void free_internal() noexcept override
Frees the memory.
Definition Win.h:1795
+
void attach(HANDLE proc, handle_type h) noexcept
Sets a new memory handle for the class.
Definition Win.h:1757
+
virtual ~vmemory()
Frees the memory.
Definition Win.h:1729
+
vmemory(handle_type h, HANDLE proc) noexcept
Initializes a new class instance with an already available object handle.
Definition Win.h:1707
+
vmemory() noexcept
Initializes a new class instance with the memory handle set to INVAL.
Definition Win.h:1697
+
vmemory(vmemory &&h) noexcept
Move constructor.
Definition Win.h:1718
+
HANDLE m_proc
Handle of memory's process.
Definition Win.h:1801
+
Windows HANDLE wrapper class.
Definition Win.h:1032
+
void free_internal() noexcept override
Closes an open object handle.
Definition Win.h:1053
+
virtual ~win_handle()
Closes an open object handle.
Definition Win.h:1041
+
Windows runtime error.
Definition Common.h:1528
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
+
static int vsprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
Formats string using printf().
Definition Common.h:288
+
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:321
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const HANDLE invalid
Invalid handle value.
Definition Common.h:1030
+
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:641
+
static DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Expands environment-variable strings, replaces them with the values defined for the current user,...
Definition Win.h:210
+
static BOOL StringToGuidA(LPCSTR lpszGuid, LPGUID lpGuid, LPCSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:273
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:82
-
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:2051
-
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:719
-
win_handle< INVALID_HANDLE_VALUE > file
File handle wrapper.
Definition Win.h:1122
+
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:2055
+
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:723
+
win_handle< INVALID_HANDLE_VALUE > file
File handle wrapper.
Definition Win.h:1126
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:144
-
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:2028
-
static LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2070
-
static LSTATUS RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2089
-
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:230
-
static BOOL StringToGuidW(LPCWSTR lpszGuid, LPGUID lpGuid, LPCWSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:342
-
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:607
-
static BOOL OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, winstd::win_handle< NULL > &TokenHandle)
Opens the access token associated with a process.
Definition Win.h:2108
-
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:2163
-
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:837
+
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:2032
+
static LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2074
+
static LSTATUS RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
Opens the specified registry key.
Definition Win.h:2093
+
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:234
+
static BOOL StringToGuidW(LPCWSTR lpszGuid, LPGUID lpGuid, LPCWSTR *lpszGuidEnd=NULL) noexcept
Parses string with GUID and stores it to GUID.
Definition Win.h:346
+
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:611
+
static BOOL OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, winstd::win_handle< NULL > &TokenHandle)
Opens the access token associated with a process.
Definition Win.h:2112
+
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:2167
+
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:841
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:57
-
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:876
-
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:2138
-
win_handle< INVALID_HANDLE_VALUE > process_snapshot
Process snapshot handle wrapper.
Definition Win.h:1107
+
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:880
+
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:2142
+
win_handle< INVALID_HANDLE_VALUE > process_snapshot
Process snapshot handle wrapper.
Definition Win.h:1111
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:26
-
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:821
-
static BOOL CreateWellKnownSid(WELL_KNOWN_SID_TYPE WellKnownSidType, PSID DomainSid, std::unique_ptr< SID > &Sid)
Creates a SID for predefined aliases.
Definition Win.h:914
-
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:737
-
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:938
-
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:2123
-
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:2149
-
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:568
+
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:825
+
static BOOL CreateWellKnownSid(WELL_KNOWN_SID_TYPE WellKnownSidType, PSID DomainSid, std::unique_ptr< SID > &Sid)
Creates a SID for predefined aliases.
Definition Win.h:918
+
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:741
+
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:942
+
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:2127
+
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:2153
+
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:572
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:164
-
win_handle< NULL > event
Event handle wrapper.
Definition Win.h:1196
-
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:593
-
static VOID OutputDebugStr(LPCSTR lpOutputString,...) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:778
-
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:962
-
win_handle< NULL > mutex
Mutex handle wrapper.
Definition Win.h:1114
-
win_handle< NULL > file_mapping
File mapping.
Definition Win.h:1129
-
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:991
-
win_handle< NULL > process
Process handle wrapper.
Definition Win.h:1093
-
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:541
-
BOOL GetThreadPreferredUILanguages(DWORD dwFlags, PULONG pulNumLanguages, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Retrieves the thread preferred UI languages for the current thread.
Definition Win.h:2178
-
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:430
+
win_handle< NULL > event
Event handle wrapper.
Definition Win.h:1200
+
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:597
+
static VOID OutputDebugStr(LPCSTR lpOutputString,...) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:782
+
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:966
+
win_handle< NULL > mutex
Mutex handle wrapper.
Definition Win.h:1118
+
static DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, std::basic_string< char, _Traits, _Ax > &sValue)
Expands environment-variable strings, replaces them with the values defined for the current user,...
Definition Win.h:180
+
win_handle< NULL > file_mapping
File mapping.
Definition Win.h:1133
+
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:995
+
win_handle< NULL > process
Process handle wrapper.
Definition Win.h:1097
+
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:545
+
BOOL GetThreadPreferredUILanguages(DWORD dwFlags, PULONG pulNumLanguages, std::basic_string< wchar_t, _Traits, _Ax > &sValue)
Retrieves the thread preferred UI languages for the current thread.
Definition Win.h:2182
+
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:434
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:115
-
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:801
-
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:208
-
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:249
-
static VOID OutputDebugStrV(LPCSTR lpOutputString, va_list arg) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:754
-
win_handle< NULL > thread
Thread handle wrapper.
Definition Win.h:1100
-
Deleter for unique_ptr using LocalFree.
Definition Common.h:694
-
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1168
-
void operator()(_Other *) const
Delete a pointer of another type.
Definition Win.h:1183
-
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1173
-
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1163
-
Deleter for unique_ptr using UnmapViewOfFile.
Definition Win.h:1135
-
UnmapViewOfFile_delete(const UnmapViewOfFile_delete< _Ty2 > &)
Construct from another UnmapViewOfFile_delete.
Definition Win.h:1146
-
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1151
-
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1136
-
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1141
-
A structure that enables an allocator for objects of one type to allocate storage for objects of anot...
Definition Win.h:1375
-
heap_allocator< _Other > other
Other allocator type.
Definition Win.h:1376
+
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:805
+
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:253
+
static VOID OutputDebugStrV(LPCSTR lpOutputString, va_list arg) noexcept
Formats and sends a string to the debugger for display.
Definition Win.h:758
+
win_handle< NULL > thread
Thread handle wrapper.
Definition Win.h:1104
+
Deleter for unique_ptr using LocalFree.
Definition Common.h:731
+
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1172
+
void operator()(_Other *) const
Delete a pointer of another type.
Definition Win.h:1187
+
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1177
+
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1167
+
Deleter for unique_ptr using UnmapViewOfFile.
Definition Win.h:1139
+
UnmapViewOfFile_delete(const UnmapViewOfFile_delete< _Ty2 > &)
Construct from another UnmapViewOfFile_delete.
Definition Win.h:1150
+
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Win.h:1155
+
UnmapViewOfFile_delete< _Ty > _Myt
This type.
Definition Win.h:1140
+
UnmapViewOfFile_delete()
Default construct.
Definition Win.h:1145
+
A structure that enables an allocator for objects of one type to allocate storage for objects of anot...
Definition Win.h:1379
+
heap_allocator< _Other > other
Other allocator type.
Definition Win.h:1380
diff --git a/_win_h_t_t_p_8h_source.html b/_win_h_t_t_p_8h_source.html index abf38c79..b692288e 100644 --- a/_win_h_t_t_p_8h_source.html +++ b/_win_h_t_t_p_8h_source.html @@ -122,17 +122,17 @@ $(document).ready(function() { init_codefold(0); });
51
53}
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle_type m_h
Object handle.
Definition Common.h:1237
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle_type m_h
Object handle.
Definition Common.h:1274
HTTP handle wrapper class.
Definition WinHTTP.h:25
virtual ~http()
Closes a handle to the HTTP.
Definition WinHTTP.h:34
void free_internal() noexcept override
Closes a handle to the HTTP.
Definition WinHTTP.h:46
-
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:163
-
static const HINTERNET invalid
Invalid handle value.
Definition Common.h:993
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const HINTERNET invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_win_sock2_8h_source.html b/_win_sock2_8h_source.html index edbc1905..8e992dde 100644 --- a/_win_sock2_8h_source.html +++ b/_win_sock2_8h_source.html @@ -253,10 +253,10 @@ $(document).ready(function() { init_codefold(0); });
ADDRINFOA wrapper class.
Definition WinSock2.h:109
void free_internal() noexcept override
Frees address information.
Definition WinSock2.h:130
virtual ~addrinfo()
Frees address information.
Definition WinSock2.h:118
-
Base abstract template class to support generic object handle keeping.
Definition Common.h:983
-
handle_type m_h
Object handle.
Definition Common.h:1237
-
Numerical runtime error.
Definition Common.h:1446
-
int error_type
Error number type.
Definition Common.h:1448
+
Base abstract template class to support generic object handle keeping.
Definition Common.h:1020
+
handle_type m_h
Object handle.
Definition Common.h:1274
+
Numerical runtime error.
Definition Common.h:1483
+
int error_type
Error number type.
Definition Common.h:1485
ADDRINFOW wrapper class.
Definition WinSock2.h:142
virtual ~waddrinfo()
Frees address information.
Definition WinSock2.h:151
void free_internal() noexcept override
Frees address information.
Definition WinSock2.h:163
@@ -271,14 +271,14 @@ $(document).ready(function() { init_codefold(0); });
addrinfo taddrinfo
Multi-byte / Wide-character ADDRINFO wrapper class (according to _UNICODE)
Definition WinSock2.h:175
static INT GetAddrInfoW(PCWSTR pNodeName, PCWSTR pServiceName, const ADDRINFOW *pHints, winstd::waddrinfo &result)
Provides protocol-independent translation from a host name to an address.
Definition WinSock2.h:208
static INT GetAddrInfoA(PCSTR pNodeName, PCSTR pServiceName, const ADDRINFOA *pHints, winstd::addrinfo &result)
Provides protocol-independent translation from a host name to an address.
Definition WinSock2.h:190
-
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 Common.h:299
-
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:284
-
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:163
-
static const PADDRINFOA invalid
Invalid handle value.
Definition Common.h:993
+
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 Common.h:336
+
static int sprintf(std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
Formats string using printf().
Definition Common.h:321
+
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
+
static const PADDRINFOA invalid
Invalid handle value.
Definition Common.h:1030
diff --git a/_win_trust_8h_source.html b/_win_trust_8h_source.html index 5df63e6e..e341c41c 100644 --- a/_win_trust_8h_source.html +++ b/_win_trust_8h_source.html @@ -132,16 +132,16 @@ $(document).ready(function() { init_codefold(0); });
57
59}
-
Windows runtime error.
Definition Common.h:1491
+
Windows runtime error.
Definition Common.h:1528
WinTrust engine wrapper class.
Definition WinTrust.h:23
wintrust(HWND hwnd, const GUID &action, WINTRUST_DATA &wtd)
Initializes a new class instance.
Definition WinTrust.h:31
virtual ~wintrust()
Destroys the WinTrust context.
Definition WinTrust.h:44
-
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:66
-
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:74
+
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
+
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition Common.h:75
diff --git a/annotated.html b/annotated.html index 8dc0e612..c71c7a3e 100644 --- a/annotated.html +++ b/annotated.html @@ -174,7 +174,7 @@ $(function() {
diff --git a/classes.html b/classes.html index b450a028..e4e5aba0 100644 --- a/classes.html +++ b/classes.html @@ -130,7 +130,7 @@ $(function() {
diff --git a/classwinstd_1_1actctx__activator-members.html b/classwinstd_1_1actctx__activator-members.html index 3fb92ed8..6ce4b9cf 100644 --- a/classwinstd_1_1actctx__activator-members.html +++ b/classwinstd_1_1actctx__activator-members.html @@ -86,7 +86,7 @@ $(function() {
diff --git a/classwinstd_1_1actctx__activator.html b/classwinstd_1_1actctx__activator.html index f071cf32..f6a3b76f 100644 --- a/classwinstd_1_1actctx__activator.html +++ b/classwinstd_1_1actctx__activator.html @@ -175,7 +175,7 @@ ULONG_PTR m_cookie diff --git a/classwinstd_1_1addrinfo-members.html b/classwinstd_1_1addrinfo-members.html index a0570fdb..f6cd4294 100644 --- a/classwinstd_1_1addrinfo-members.html +++ b/classwinstd_1_1addrinfo-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1addrinfo.html b/classwinstd_1_1addrinfo.html index ce024f2c..433d7dff 100644 --- a/classwinstd_1_1addrinfo.html +++ b/classwinstd_1_1addrinfo.html @@ -255,7 +255,7 @@ static const PADDRINFOA in
diff --git a/classwinstd_1_1basic__string__guid-members.html b/classwinstd_1_1basic__string__guid-members.html index b4bfaf1b..53b68018 100644 --- a/classwinstd_1_1basic__string__guid-members.html +++ b/classwinstd_1_1basic__string__guid-members.html @@ -84,7 +84,7 @@ $(function() {
diff --git a/classwinstd_1_1basic__string__guid.html b/classwinstd_1_1basic__string__guid.html index a1ea584a..776bb1b0 100644 --- a/classwinstd_1_1basic__string__guid.html +++ b/classwinstd_1_1basic__string__guid.html @@ -155,7 +155,7 @@ template<class _Elem , class _Traits , class _Ax >
diff --git a/classwinstd_1_1basic__string__msg-members.html b/classwinstd_1_1basic__string__msg-members.html index 403af0c8..aa97c94e 100644 --- a/classwinstd_1_1basic__string__msg-members.html +++ b/classwinstd_1_1basic__string__msg-members.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/classwinstd_1_1basic__string__msg.html b/classwinstd_1_1basic__string__msg.html index fe63fee2..00fbaf67 100644 --- a/classwinstd_1_1basic__string__msg.html +++ b/classwinstd_1_1basic__string__msg.html @@ -499,7 +499,7 @@ template<class _Elem , class _Traits , class _Ax >
diff --git a/classwinstd_1_1basic__string__printf-members.html b/classwinstd_1_1basic__string__printf-members.html index 5aaac95d..9997636c 100644 --- a/classwinstd_1_1basic__string__printf-members.html +++ b/classwinstd_1_1basic__string__printf-members.html @@ -86,7 +86,7 @@ $(function() {
diff --git a/classwinstd_1_1basic__string__printf.html b/classwinstd_1_1basic__string__printf.html index f1ef2ca4..c6f5f179 100644 --- a/classwinstd_1_1basic__string__printf.html +++ b/classwinstd_1_1basic__string__printf.html @@ -274,7 +274,7 @@ template<class _Elem , class _Traits , class _Ax >
diff --git a/classwinstd_1_1bstr-members.html b/classwinstd_1_1bstr-members.html index e96585d1..d45ff3d1 100644 --- a/classwinstd_1_1bstr-members.html +++ b/classwinstd_1_1bstr-members.html @@ -120,7 +120,7 @@ $(function() {
diff --git a/classwinstd_1_1bstr.html b/classwinstd_1_1bstr.html index ae0031c8..047ad47c 100644 --- a/classwinstd_1_1bstr.html +++ b/classwinstd_1_1bstr.html @@ -369,7 +369,7 @@ static const T invalid
diff --git a/classwinstd_1_1cert__chain__context-members.html b/classwinstd_1_1cert__chain__context-members.html index 3a4db4a6..0956de3a 100644 --- a/classwinstd_1_1cert__chain__context-members.html +++ b/classwinstd_1_1cert__chain__context-members.html @@ -116,7 +116,7 @@ $(function() {
diff --git a/classwinstd_1_1cert__chain__context.html b/classwinstd_1_1cert__chain__context.html index cf07796d..633e544f 100644 --- a/classwinstd_1_1cert__chain__context.html +++ b/classwinstd_1_1cert__chain__context.html @@ -326,7 +326,7 @@ static const T invalid
diff --git a/classwinstd_1_1cert__context-members.html b/classwinstd_1_1cert__context-members.html index 2d133535..a86ef975 100644 --- a/classwinstd_1_1cert__context-members.html +++ b/classwinstd_1_1cert__context-members.html @@ -122,7 +122,7 @@ $(function() {
diff --git a/classwinstd_1_1cert__context.html b/classwinstd_1_1cert__context.html index 98df8927..2963750c 100644 --- a/classwinstd_1_1cert__context.html +++ b/classwinstd_1_1cert__context.html @@ -578,7 +578,7 @@ static const T invalid
diff --git a/classwinstd_1_1cert__store-members.html b/classwinstd_1_1cert__store-members.html index 9c11e44d..e78116ae 100644 --- a/classwinstd_1_1cert__store-members.html +++ b/classwinstd_1_1cert__store-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1cert__store.html b/classwinstd_1_1cert__store.html index aa21215d..7bf89e34 100644 --- a/classwinstd_1_1cert__store.html +++ b/classwinstd_1_1cert__store.html @@ -257,7 +257,7 @@ static const HCERTSTORE in
diff --git a/classwinstd_1_1clipboard__opener-members.html b/classwinstd_1_1clipboard__opener-members.html index 4fe98d9c..47f12934 100644 --- a/classwinstd_1_1clipboard__opener-members.html +++ b/classwinstd_1_1clipboard__opener-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1clipboard__opener.html b/classwinstd_1_1clipboard__opener.html index f41fb394..a405f87a 100644 --- a/classwinstd_1_1clipboard__opener.html +++ b/classwinstd_1_1clipboard__opener.html @@ -161,7 +161,7 @@ Public Member Functions
diff --git a/classwinstd_1_1com__initializer-members.html b/classwinstd_1_1com__initializer-members.html index 7dac7c88..dc758685 100644 --- a/classwinstd_1_1com__initializer-members.html +++ b/classwinstd_1_1com__initializer-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1com__initializer.html b/classwinstd_1_1com__initializer.html index e80baeb0..3b7c201b 100644 --- a/classwinstd_1_1com__initializer.html +++ b/classwinstd_1_1com__initializer.html @@ -243,7 +243,7 @@ HRESULT m_result<
diff --git a/classwinstd_1_1com__obj-members.html b/classwinstd_1_1com__obj-members.html index 02f40c2b..c1c5c037 100644 --- a/classwinstd_1_1com__obj-members.html +++ b/classwinstd_1_1com__obj-members.html @@ -121,7 +121,7 @@ $(function() {
diff --git a/classwinstd_1_1com__obj.html b/classwinstd_1_1com__obj.html index e9d7f623..850b529e 100644 --- a/classwinstd_1_1com__obj.html +++ b/classwinstd_1_1com__obj.html @@ -502,7 +502,7 @@ template<class _Other >
diff --git a/classwinstd_1_1com__runtime__error-members.html b/classwinstd_1_1com__runtime__error-members.html index bd250a6d..6973eed1 100644 --- a/classwinstd_1_1com__runtime__error-members.html +++ b/classwinstd_1_1com__runtime__error-members.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/classwinstd_1_1com__runtime__error.html b/classwinstd_1_1com__runtime__error.html index 7f048f25..4d9b1a71 100644 --- a/classwinstd_1_1com__runtime__error.html +++ b/classwinstd_1_1com__runtime__error.html @@ -228,7 +228,7 @@ typedef HRESULT error_type
diff --git a/classwinstd_1_1console__ctrl__handler-members.html b/classwinstd_1_1console__ctrl__handler-members.html index 612b984c..4e736960 100644 --- a/classwinstd_1_1console__ctrl__handler-members.html +++ b/classwinstd_1_1console__ctrl__handler-members.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/classwinstd_1_1console__ctrl__handler.html b/classwinstd_1_1console__ctrl__handler.html index a1252361..6ff4566d 100644 --- a/classwinstd_1_1console__ctrl__handler.html +++ b/classwinstd_1_1console__ctrl__handler.html @@ -179,7 +179,7 @@ PHANDLER_ROUTINE m_handler
diff --git a/classwinstd_1_1critical__section-members.html b/classwinstd_1_1critical__section-members.html index 0d4135af..56825c29 100644 --- a/classwinstd_1_1critical__section-members.html +++ b/classwinstd_1_1critical__section-members.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/classwinstd_1_1critical__section.html b/classwinstd_1_1critical__section.html index a35ea0b3..3a54e119 100644 --- a/classwinstd_1_1critical__section.html +++ b/classwinstd_1_1critical__section.html @@ -200,7 +200,7 @@ CRITICAL_SECTION m_data diff --git a/classwinstd_1_1crypt__hash-members.html b/classwinstd_1_1crypt__hash-members.html index a7567220..eb0f88e9 100644 --- a/classwinstd_1_1crypt__hash-members.html +++ b/classwinstd_1_1crypt__hash-members.html @@ -116,7 +116,7 @@ $(function() {
diff --git a/classwinstd_1_1crypt__hash.html b/classwinstd_1_1crypt__hash.html index 24c86b96..5621b93a 100644 --- a/classwinstd_1_1crypt__hash.html +++ b/classwinstd_1_1crypt__hash.html @@ -326,7 +326,7 @@ static const T invalid
diff --git a/classwinstd_1_1crypt__key-members.html b/classwinstd_1_1crypt__key-members.html index 3e9e7c60..c4980156 100644 --- a/classwinstd_1_1crypt__key-members.html +++ b/classwinstd_1_1crypt__key-members.html @@ -117,7 +117,7 @@ $(function() {
diff --git a/classwinstd_1_1crypt__key.html b/classwinstd_1_1crypt__key.html index bebcd7c4..8b921c48 100644 --- a/classwinstd_1_1crypt__key.html +++ b/classwinstd_1_1crypt__key.html @@ -381,7 +381,7 @@ static const T invalid
diff --git a/classwinstd_1_1crypt__prov-members.html b/classwinstd_1_1crypt__prov-members.html index 97ab58bf..d6755de8 100644 --- a/classwinstd_1_1crypt__prov-members.html +++ b/classwinstd_1_1crypt__prov-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1crypt__prov.html b/classwinstd_1_1crypt__prov.html index 7d42a571..4afa8ea8 100644 --- a/classwinstd_1_1crypt__prov.html +++ b/classwinstd_1_1crypt__prov.html @@ -255,7 +255,7 @@ static const HCRYPTPROV in
diff --git a/classwinstd_1_1data__blob-members.html b/classwinstd_1_1data__blob-members.html index db03667c..c4fa26ea 100644 --- a/classwinstd_1_1data__blob-members.html +++ b/classwinstd_1_1data__blob-members.html @@ -93,7 +93,7 @@ $(function() {
diff --git a/classwinstd_1_1data__blob.html b/classwinstd_1_1data__blob.html index 81c2af59..b0d4ac24 100644 --- a/classwinstd_1_1data__blob.html +++ b/classwinstd_1_1data__blob.html @@ -143,7 +143,7 @@ BYTE * data () noexcep
diff --git a/classwinstd_1_1dc-members.html b/classwinstd_1_1dc-members.html index f36a31c0..7bb4f074 100644 --- a/classwinstd_1_1dc-members.html +++ b/classwinstd_1_1dc-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1dc.html b/classwinstd_1_1dc.html index fc51726a..91fd3535 100644 --- a/classwinstd_1_1dc.html +++ b/classwinstd_1_1dc.html @@ -254,7 +254,7 @@ static const HDC invalid diff --git a/classwinstd_1_1dc__selector-members.html b/classwinstd_1_1dc__selector-members.html index 1262c414..8111f53e 100644 --- a/classwinstd_1_1dc__selector-members.html +++ b/classwinstd_1_1dc__selector-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1dc__selector.html b/classwinstd_1_1dc__selector.html index 9b120180..414c2d09 100644 --- a/classwinstd_1_1dc__selector.html +++ b/classwinstd_1_1dc__selector.html @@ -215,7 +215,7 @@ HGDIOBJ m_orig diff --git a/classwinstd_1_1dplhandle-members.html b/classwinstd_1_1dplhandle-members.html index dfb13962..00e32b93 100644 --- a/classwinstd_1_1dplhandle-members.html +++ b/classwinstd_1_1dplhandle-members.html @@ -115,7 +115,7 @@ $(function() {
diff --git a/classwinstd_1_1dplhandle.html b/classwinstd_1_1dplhandle.html index 70a15c39..cbd9bbb3 100644 --- a/classwinstd_1_1dplhandle.html +++ b/classwinstd_1_1dplhandle.html @@ -547,7 +547,7 @@ template<class T , T INVAL>
diff --git a/classwinstd_1_1eap__attr-members.html b/classwinstd_1_1eap__attr-members.html index 47b6d947..898e0987 100644 --- a/classwinstd_1_1eap__attr-members.html +++ b/classwinstd_1_1eap__attr-members.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/classwinstd_1_1eap__attr.html b/classwinstd_1_1eap__attr.html index a66b2003..1719c3b5 100644 --- a/classwinstd_1_1eap__attr.html +++ b/classwinstd_1_1eap__attr.html @@ -180,7 +180,7 @@ Public Member Functions
diff --git a/classwinstd_1_1eap__method__info__array-members.html b/classwinstd_1_1eap__method__info__array-members.html index 6cc7510c..f25d816e 100644 --- a/classwinstd_1_1eap__method__info__array-members.html +++ b/classwinstd_1_1eap__method__info__array-members.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/classwinstd_1_1eap__method__info__array.html b/classwinstd_1_1eap__method__info__array.html index a76e9c1f..e961bf6a 100644 --- a/classwinstd_1_1eap__method__info__array.html +++ b/classwinstd_1_1eap__method__info__array.html @@ -187,7 +187,7 @@ Public Member Functions
diff --git a/classwinstd_1_1eap__method__prop-members.html b/classwinstd_1_1eap__method__prop-members.html index 465b2ad9..251b9488 100644 --- a/classwinstd_1_1eap__method__prop-members.html +++ b/classwinstd_1_1eap__method__prop-members.html @@ -86,7 +86,7 @@ $(function() {
diff --git a/classwinstd_1_1eap__method__prop.html b/classwinstd_1_1eap__method__prop.html index beca9f50..638e5005 100644 --- a/classwinstd_1_1eap__method__prop.html +++ b/classwinstd_1_1eap__method__prop.html @@ -248,7 +248,7 @@ Public Member Functions
diff --git a/classwinstd_1_1eap__packet-members.html b/classwinstd_1_1eap__packet-members.html index 2c89f31b..bbb35427 100644 --- a/classwinstd_1_1eap__packet-members.html +++ b/classwinstd_1_1eap__packet-members.html @@ -118,7 +118,7 @@ $(function() {
diff --git a/classwinstd_1_1eap__packet.html b/classwinstd_1_1eap__packet.html index a678de36..35e11859 100644 --- a/classwinstd_1_1eap__packet.html +++ b/classwinstd_1_1eap__packet.html @@ -353,7 +353,7 @@ static const T invalid
diff --git a/classwinstd_1_1eap__runtime__error-members.html b/classwinstd_1_1eap__runtime__error-members.html index 99c22ea3..4c508d68 100644 --- a/classwinstd_1_1eap__runtime__error-members.html +++ b/classwinstd_1_1eap__runtime__error-members.html @@ -111,7 +111,7 @@ $(function() {
diff --git a/classwinstd_1_1eap__runtime__error.html b/classwinstd_1_1eap__runtime__error.html index 0241af54..97cf4248 100644 --- a/classwinstd_1_1eap__runtime__error.html +++ b/classwinstd_1_1eap__runtime__error.html @@ -313,7 +313,7 @@ typedef DWORD error_type diff --git a/classwinstd_1_1event__data-members.html b/classwinstd_1_1event__data-members.html index 2ccaaa25..32223866 100644 --- a/classwinstd_1_1event__data-members.html +++ b/classwinstd_1_1event__data-members.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/classwinstd_1_1event__data.html b/classwinstd_1_1event__data.html index a8584ac6..f960e1dd 100644 --- a/classwinstd_1_1event__data.html +++ b/classwinstd_1_1event__data.html @@ -540,7 +540,7 @@ template<class _Elem , class _Traits , class _Ax >
diff --git a/classwinstd_1_1event__fn__auto-members.html b/classwinstd_1_1event__fn__auto-members.html index b4706377..80e9b777 100644 --- a/classwinstd_1_1event__fn__auto-members.html +++ b/classwinstd_1_1event__fn__auto-members.html @@ -92,7 +92,7 @@ $(function() {
diff --git a/classwinstd_1_1event__fn__auto.html b/classwinstd_1_1event__fn__auto.html index 02b9f2f1..74326dd5 100644 --- a/classwinstd_1_1event__fn__auto.html +++ b/classwinstd_1_1event__fn__auto.html @@ -138,7 +138,7 @@ EVENT_DATA_DESCRIPTOR m_fn
diff --git a/classwinstd_1_1event__fn__auto__ret-members.html b/classwinstd_1_1event__fn__auto__ret-members.html index 63b82634..6c550405 100644 --- a/classwinstd_1_1event__fn__auto__ret-members.html +++ b/classwinstd_1_1event__fn__auto__ret-members.html @@ -93,7 +93,7 @@ $(function() {
diff --git a/classwinstd_1_1event__fn__auto__ret.html b/classwinstd_1_1event__fn__auto__ret.html index 0f498d7d..2e6f78bb 100644 --- a/classwinstd_1_1event__fn__auto__ret.html +++ b/classwinstd_1_1event__fn__auto__ret.html @@ -143,7 +143,7 @@ class winstd::event_fn_auto_ret< T >

Helper template to write an e

diff --git a/classwinstd_1_1event__log-members.html b/classwinstd_1_1event__log-members.html index bc14fc1e..6490726e 100644 --- a/classwinstd_1_1event__log-members.html +++ b/classwinstd_1_1event__log-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1event__log.html b/classwinstd_1_1event__log.html index 8c07c613..47d8eeef 100644 --- a/classwinstd_1_1event__log.html +++ b/classwinstd_1_1event__log.html @@ -255,7 +255,7 @@ static const HANDLE invali
diff --git a/classwinstd_1_1event__provider-members.html b/classwinstd_1_1event__provider-members.html index 1b96a893..242763fb 100644 --- a/classwinstd_1_1event__provider-members.html +++ b/classwinstd_1_1event__provider-members.html @@ -115,7 +115,7 @@ $(function() {
diff --git a/classwinstd_1_1event__provider.html b/classwinstd_1_1event__provider.html index 2d8fa8c7..7453b400 100644 --- a/classwinstd_1_1event__provider.html +++ b/classwinstd_1_1event__provider.html @@ -684,7 +684,7 @@ static const REGHANDLE inv
diff --git a/classwinstd_1_1event__rec-members.html b/classwinstd_1_1event__rec-members.html index 4e127c4f..f3faa15a 100644 --- a/classwinstd_1_1event__rec-members.html +++ b/classwinstd_1_1event__rec-members.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/classwinstd_1_1event__rec.html b/classwinstd_1_1event__rec.html index f4a66d48..af7dae03 100644 --- a/classwinstd_1_1event__rec.html +++ b/classwinstd_1_1event__rec.html @@ -531,7 +531,7 @@ Protected Member Functions
diff --git a/classwinstd_1_1event__session-members.html b/classwinstd_1_1event__session-members.html index a316bc1d..cf57934b 100644 --- a/classwinstd_1_1event__session-members.html +++ b/classwinstd_1_1event__session-members.html @@ -118,7 +118,7 @@ $(function() {
diff --git a/classwinstd_1_1event__session.html b/classwinstd_1_1event__session.html index 3e763c3a..0a2f77c6 100644 --- a/classwinstd_1_1event__session.html +++ b/classwinstd_1_1event__session.html @@ -688,7 +688,7 @@ static const TRACEHANDLE i
diff --git a/classwinstd_1_1event__trace-members.html b/classwinstd_1_1event__trace-members.html index da3ab37c..1023adcc 100644 --- a/classwinstd_1_1event__trace-members.html +++ b/classwinstd_1_1event__trace-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1event__trace.html b/classwinstd_1_1event__trace.html index 9e782710..e9ab8248 100644 --- a/classwinstd_1_1event__trace.html +++ b/classwinstd_1_1event__trace.html @@ -255,7 +255,7 @@ static const TRACEHANDLE i
diff --git a/classwinstd_1_1event__trace__enabler-members.html b/classwinstd_1_1event__trace__enabler-members.html index fc4cadb6..6f30dc35 100644 --- a/classwinstd_1_1event__trace__enabler-members.html +++ b/classwinstd_1_1event__trace__enabler-members.html @@ -96,7 +96,7 @@ $(function() {
diff --git a/classwinstd_1_1event__trace__enabler.html b/classwinstd_1_1event__trace__enabler.html index c3d3ea37..fefa65fb 100644 --- a/classwinstd_1_1event__trace__enabler.html +++ b/classwinstd_1_1event__trace__enabler.html @@ -351,7 +351,7 @@ PEVENT_FILTER_DESCRIPTOR m
diff --git a/classwinstd_1_1find__file-members.html b/classwinstd_1_1find__file-members.html index 62575a9d..07c49bfe 100644 --- a/classwinstd_1_1find__file-members.html +++ b/classwinstd_1_1find__file-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1find__file.html b/classwinstd_1_1find__file.html index 6f7c715b..0f108df2 100644 --- a/classwinstd_1_1find__file.html +++ b/classwinstd_1_1find__file.html @@ -255,7 +255,7 @@ static const HANDLE invali
diff --git a/classwinstd_1_1gdi__handle-members.html b/classwinstd_1_1gdi__handle-members.html index fb0ff522..195620ea 100644 --- a/classwinstd_1_1gdi__handle-members.html +++ b/classwinstd_1_1gdi__handle-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1gdi__handle.html b/classwinstd_1_1gdi__handle.html index 9f02a36a..d2c7b303 100644 --- a/classwinstd_1_1gdi__handle.html +++ b/classwinstd_1_1gdi__handle.html @@ -259,7 +259,7 @@ template<class T >
diff --git a/classwinstd_1_1globalmem__accessor-members.html b/classwinstd_1_1globalmem__accessor-members.html index d3eb5ba2..9720ade7 100644 --- a/classwinstd_1_1globalmem__accessor-members.html +++ b/classwinstd_1_1globalmem__accessor-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1globalmem__accessor.html b/classwinstd_1_1globalmem__accessor.html index 285a73fd..8479ed32 100644 --- a/classwinstd_1_1globalmem__accessor.html +++ b/classwinstd_1_1globalmem__accessor.html @@ -182,7 +182,7 @@ template<class T >
diff --git a/classwinstd_1_1handle-members.html b/classwinstd_1_1handle-members.html index 5bc4c67f..81d0ceaa 100644 --- a/classwinstd_1_1handle-members.html +++ b/classwinstd_1_1handle-members.html @@ -106,7 +106,7 @@ $(function() {
diff --git a/classwinstd_1_1handle.html b/classwinstd_1_1handle.html index 855df42c..a268ec91 100644 --- a/classwinstd_1_1handle.html +++ b/classwinstd_1_1handle.html @@ -851,7 +851,7 @@ template<class T , const T INVAL>
diff --git a/classwinstd_1_1heap-members.html b/classwinstd_1_1heap-members.html index 4cef5b88..036bd094 100644 --- a/classwinstd_1_1heap-members.html +++ b/classwinstd_1_1heap-members.html @@ -108,7 +108,7 @@ $(function() {
diff --git a/classwinstd_1_1heap.html b/classwinstd_1_1heap.html index 54ca0397..f985e3b8 100644 --- a/classwinstd_1_1heap.html +++ b/classwinstd_1_1heap.html @@ -290,7 +290,7 @@ static const HANDLE invali
diff --git a/classwinstd_1_1heap__allocator-members.html b/classwinstd_1_1heap__allocator-members.html index 28db1156..8f12b3a8 100644 --- a/classwinstd_1_1heap__allocator-members.html +++ b/classwinstd_1_1heap__allocator-members.html @@ -99,7 +99,7 @@ $(function() {
diff --git a/classwinstd_1_1heap__allocator.html b/classwinstd_1_1heap__allocator.html index 2ecf0d53..02d035de 100644 --- a/classwinstd_1_1heap__allocator.html +++ b/classwinstd_1_1heap__allocator.html @@ -461,7 +461,7 @@ template<class _Ty >
diff --git a/classwinstd_1_1http-members.html b/classwinstd_1_1http-members.html index 23b42fd5..9c961052 100644 --- a/classwinstd_1_1http-members.html +++ b/classwinstd_1_1http-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1http.html b/classwinstd_1_1http.html index be9381ca..1aab9b49 100644 --- a/classwinstd_1_1http.html +++ b/classwinstd_1_1http.html @@ -255,7 +255,7 @@ static const HINTERNET inv
diff --git a/classwinstd_1_1icon-members.html b/classwinstd_1_1icon-members.html index f6228616..0e332252 100644 --- a/classwinstd_1_1icon-members.html +++ b/classwinstd_1_1icon-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1icon.html b/classwinstd_1_1icon.html index 05156333..00269973 100644 --- a/classwinstd_1_1icon.html +++ b/classwinstd_1_1icon.html @@ -254,7 +254,7 @@ static const HICON invalid
diff --git a/classwinstd_1_1impersonator-members.html b/classwinstd_1_1impersonator-members.html index 6be4985c..828e25e1 100644 --- a/classwinstd_1_1impersonator-members.html +++ b/classwinstd_1_1impersonator-members.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/classwinstd_1_1impersonator.html b/classwinstd_1_1impersonator.html index 16f86569..7f53c408 100644 --- a/classwinstd_1_1impersonator.html +++ b/classwinstd_1_1impersonator.html @@ -155,7 +155,7 @@ BOOL m_cookie diff --git a/classwinstd_1_1library-members.html b/classwinstd_1_1library-members.html index cd6cbbf6..2608509a 100644 --- a/classwinstd_1_1library-members.html +++ b/classwinstd_1_1library-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1library.html b/classwinstd_1_1library.html index 06de757c..dd9590a7 100644 --- a/classwinstd_1_1library.html +++ b/classwinstd_1_1library.html @@ -255,7 +255,7 @@ static const HMODULE inval
diff --git a/classwinstd_1_1num__runtime__error-members.html b/classwinstd_1_1num__runtime__error-members.html index bb33fdad..fd3d288b 100644 --- a/classwinstd_1_1num__runtime__error-members.html +++ b/classwinstd_1_1num__runtime__error-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1num__runtime__error.html b/classwinstd_1_1num__runtime__error.html index 9b21cce8..37c5d008 100644 --- a/classwinstd_1_1num__runtime__error.html +++ b/classwinstd_1_1num__runtime__error.html @@ -225,7 +225,7 @@ template<typename _Tn >
diff --git a/classwinstd_1_1process__information-members.html b/classwinstd_1_1process__information-members.html index 65d35f22..dbec35fc 100644 --- a/classwinstd_1_1process__information-members.html +++ b/classwinstd_1_1process__information-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1process__information.html b/classwinstd_1_1process__information.html index 06d76398..389b2ece 100644 --- a/classwinstd_1_1process__information.html +++ b/classwinstd_1_1process__information.html @@ -111,7 +111,7 @@ Public Member Functions
diff --git a/classwinstd_1_1ref__unique__ptr-members.html b/classwinstd_1_1ref__unique__ptr-members.html index 57f0b77b..fa0337e2 100644 --- a/classwinstd_1_1ref__unique__ptr-members.html +++ b/classwinstd_1_1ref__unique__ptr-members.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/classwinstd_1_1ref__unique__ptr.html b/classwinstd_1_1ref__unique__ptr.html index 0bbb0316..86f11974 100644 --- a/classwinstd_1_1ref__unique__ptr.html +++ b/classwinstd_1_1ref__unique__ptr.html @@ -260,7 +260,7 @@ template<class _Ty , class _Dx >
diff --git a/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4-members.html b/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4-members.html index 04dd3007..b588fe7d 100644 --- a/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4-members.html +++ b/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4-members.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4.html b/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4.html index 05902a30..c2a0a1ad 100644 --- a/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4.html +++ b/classwinstd_1_1ref__unique__ptr_3_01___ty_0f_0e_00_01___dx_01_4.html @@ -260,7 +260,7 @@ template<class _Ty , class _Dx >
diff --git a/classwinstd_1_1reg__key-members.html b/classwinstd_1_1reg__key-members.html index 75c9eeab..7858dc12 100644 --- a/classwinstd_1_1reg__key-members.html +++ b/classwinstd_1_1reg__key-members.html @@ -108,7 +108,7 @@ $(function() {
diff --git a/classwinstd_1_1reg__key.html b/classwinstd_1_1reg__key.html index 19841d67..ceb8de26 100644 --- a/classwinstd_1_1reg__key.html +++ b/classwinstd_1_1reg__key.html @@ -299,7 +299,7 @@ static const HKEY invalid<
diff --git a/classwinstd_1_1safearray-members.html b/classwinstd_1_1safearray-members.html index ab68daf4..01fe6ed5 100644 --- a/classwinstd_1_1safearray-members.html +++ b/classwinstd_1_1safearray-members.html @@ -116,7 +116,7 @@ $(function() {
diff --git a/classwinstd_1_1safearray.html b/classwinstd_1_1safearray.html index 44ff4840..e9d35cad 100644 --- a/classwinstd_1_1safearray.html +++ b/classwinstd_1_1safearray.html @@ -325,7 +325,7 @@ static const T invalid
diff --git a/classwinstd_1_1safearray__accessor-members.html b/classwinstd_1_1safearray__accessor-members.html index cec78a67..50f9c250 100644 --- a/classwinstd_1_1safearray__accessor-members.html +++ b/classwinstd_1_1safearray__accessor-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1safearray__accessor.html b/classwinstd_1_1safearray__accessor.html index 8a45a118..e951b98f 100644 --- a/classwinstd_1_1safearray__accessor.html +++ b/classwinstd_1_1safearray__accessor.html @@ -182,7 +182,7 @@ template<class T >
diff --git a/classwinstd_1_1sanitizing__allocator-members.html b/classwinstd_1_1sanitizing__allocator-members.html index e649b39c..57073af3 100644 --- a/classwinstd_1_1sanitizing__allocator-members.html +++ b/classwinstd_1_1sanitizing__allocator-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1sanitizing__allocator.html b/classwinstd_1_1sanitizing__allocator.html index f0ac18c2..b86314ce 100644 --- a/classwinstd_1_1sanitizing__allocator.html +++ b/classwinstd_1_1sanitizing__allocator.html @@ -137,7 +137,7 @@ class winstd::sanitizing_allocator< _Ty >

An allocator template th

diff --git a/classwinstd_1_1sanitizing__blob-members.html b/classwinstd_1_1sanitizing__blob-members.html index 3c7f943b..67007f92 100644 --- a/classwinstd_1_1sanitizing__blob-members.html +++ b/classwinstd_1_1sanitizing__blob-members.html @@ -86,7 +86,7 @@ $(function() {
diff --git a/classwinstd_1_1sanitizing__blob.html b/classwinstd_1_1sanitizing__blob.html index 0036e482..05a02005 100644 --- a/classwinstd_1_1sanitizing__blob.html +++ b/classwinstd_1_1sanitizing__blob.html @@ -114,7 +114,7 @@ class winstd::sanitizing_blob< N >

Sanitizing BLOB.

diff --git a/classwinstd_1_1sc__handle-members.html b/classwinstd_1_1sc__handle-members.html index 74423250..a7928234 100644 --- a/classwinstd_1_1sc__handle-members.html +++ b/classwinstd_1_1sc__handle-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1sc__handle.html b/classwinstd_1_1sc__handle.html index 3ca506b6..9ffd7bc7 100644 --- a/classwinstd_1_1sc__handle.html +++ b/classwinstd_1_1sc__handle.html @@ -254,7 +254,7 @@ static const SC_HANDLE inv
diff --git a/classwinstd_1_1sec__buffer__desc-members.html b/classwinstd_1_1sec__buffer__desc-members.html index 93cfaee1..bcba506d 100644 --- a/classwinstd_1_1sec__buffer__desc-members.html +++ b/classwinstd_1_1sec__buffer__desc-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1sec__buffer__desc.html b/classwinstd_1_1sec__buffer__desc.html index de98ea04..db9a6d86 100644 --- a/classwinstd_1_1sec__buffer__desc.html +++ b/classwinstd_1_1sec__buffer__desc.html @@ -139,7 +139,7 @@ Public Member Functions
diff --git a/classwinstd_1_1sec__context-members.html b/classwinstd_1_1sec__context-members.html index 52ab9576..1c7e0b88 100644 --- a/classwinstd_1_1sec__context-members.html +++ b/classwinstd_1_1sec__context-members.html @@ -114,7 +114,7 @@ $(function() {
diff --git a/classwinstd_1_1sec__context.html b/classwinstd_1_1sec__context.html index beee281e..0e8809fd 100644 --- a/classwinstd_1_1sec__context.html +++ b/classwinstd_1_1sec__context.html @@ -486,7 +486,7 @@ static const PCtxtHandle i
diff --git a/classwinstd_1_1sec__credentials-members.html b/classwinstd_1_1sec__credentials-members.html index e1ef4e8f..7b5d09a9 100644 --- a/classwinstd_1_1sec__credentials-members.html +++ b/classwinstd_1_1sec__credentials-members.html @@ -113,7 +113,7 @@ $(function() {
diff --git a/classwinstd_1_1sec__credentials.html b/classwinstd_1_1sec__credentials.html index b936ded6..9b68f5e5 100644 --- a/classwinstd_1_1sec__credentials.html +++ b/classwinstd_1_1sec__credentials.html @@ -465,7 +465,7 @@ static const PCredHandle i
diff --git a/classwinstd_1_1sec__runtime__error-members.html b/classwinstd_1_1sec__runtime__error-members.html index 03e4739a..334ce194 100644 --- a/classwinstd_1_1sec__runtime__error-members.html +++ b/classwinstd_1_1sec__runtime__error-members.html @@ -91,7 +91,7 @@ $(function() {
diff --git a/classwinstd_1_1sec__runtime__error.html b/classwinstd_1_1sec__runtime__error.html index 211c2f5d..6fd000f2 100644 --- a/classwinstd_1_1sec__runtime__error.html +++ b/classwinstd_1_1sec__runtime__error.html @@ -265,7 +265,7 @@ typedef SECURITY_STATUS er
diff --git a/classwinstd_1_1security__attributes-members.html b/classwinstd_1_1security__attributes-members.html index ddf5005e..9fc7a019 100644 --- a/classwinstd_1_1security__attributes-members.html +++ b/classwinstd_1_1security__attributes-members.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/classwinstd_1_1security__attributes.html b/classwinstd_1_1security__attributes.html index f2c0f228..7f3dfd58 100644 --- a/classwinstd_1_1security__attributes.html +++ b/classwinstd_1_1security__attributes.html @@ -112,7 +112,7 @@ Public Member Functions
diff --git a/classwinstd_1_1security__id-members.html b/classwinstd_1_1security__id-members.html index 7b114884..fc73ce04 100644 --- a/classwinstd_1_1security__id-members.html +++ b/classwinstd_1_1security__id-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1security__id.html b/classwinstd_1_1security__id.html index b0ea02f7..89b1a2ae 100644 --- a/classwinstd_1_1security__id.html +++ b/classwinstd_1_1security__id.html @@ -254,7 +254,7 @@ static const PSID invalid<
diff --git a/classwinstd_1_1setup__device__info__list-members.html b/classwinstd_1_1setup__device__info__list-members.html index bc43498c..e193f20d 100644 --- a/classwinstd_1_1setup__device__info__list-members.html +++ b/classwinstd_1_1setup__device__info__list-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1setup__device__info__list.html b/classwinstd_1_1setup__device__info__list.html index 81b26f34..7b95e75b 100644 --- a/classwinstd_1_1setup__device__info__list.html +++ b/classwinstd_1_1setup__device__info__list.html @@ -257,7 +257,7 @@ static const HDEVINFO inva
diff --git a/classwinstd_1_1setup__driver__info__list__builder-members.html b/classwinstd_1_1setup__driver__info__list__builder-members.html index 3dbd6ae6..5e4b51a0 100644 --- a/classwinstd_1_1setup__driver__info__list__builder-members.html +++ b/classwinstd_1_1setup__driver__info__list__builder-members.html @@ -86,7 +86,7 @@ $(function() {
diff --git a/classwinstd_1_1setup__driver__info__list__builder.html b/classwinstd_1_1setup__driver__info__list__builder.html index c83253e7..4be8776d 100644 --- a/classwinstd_1_1setup__driver__info__list__builder.html +++ b/classwinstd_1_1setup__driver__info__list__builder.html @@ -209,7 +209,7 @@ Public Member Functions
diff --git a/classwinstd_1_1string__guid-members.html b/classwinstd_1_1string__guid-members.html index 6c443d02..6722de15 100644 --- a/classwinstd_1_1string__guid-members.html +++ b/classwinstd_1_1string__guid-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1string__guid.html b/classwinstd_1_1string__guid.html index 4c321587..98e6048d 100644 --- a/classwinstd_1_1string__guid.html +++ b/classwinstd_1_1string__guid.html @@ -148,7 +148,7 @@ Public Member Functions
diff --git a/classwinstd_1_1system__impersonator-members.html b/classwinstd_1_1system__impersonator-members.html index 80d38c8f..c916ff0e 100644 --- a/classwinstd_1_1system__impersonator-members.html +++ b/classwinstd_1_1system__impersonator-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1system__impersonator.html b/classwinstd_1_1system__impersonator.html index c0cc6d5a..7e413d3a 100644 --- a/classwinstd_1_1system__impersonator.html +++ b/classwinstd_1_1system__impersonator.html @@ -130,7 +130,7 @@ BOOL m_cookie diff --git a/classwinstd_1_1user__impersonator-members.html b/classwinstd_1_1user__impersonator-members.html index afbf19e5..9f8ed545 100644 --- a/classwinstd_1_1user__impersonator-members.html +++ b/classwinstd_1_1user__impersonator-members.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/classwinstd_1_1user__impersonator.html b/classwinstd_1_1user__impersonator.html index c7a79e9d..7843ab00 100644 --- a/classwinstd_1_1user__impersonator.html +++ b/classwinstd_1_1user__impersonator.html @@ -165,7 +165,7 @@ BOOL m_cookie diff --git a/classwinstd_1_1variant-members.html b/classwinstd_1_1variant-members.html index a0fbfb47..207135c0 100644 --- a/classwinstd_1_1variant-members.html +++ b/classwinstd_1_1variant-members.html @@ -144,7 +144,7 @@ $(function() {
diff --git a/classwinstd_1_1variant.html b/classwinstd_1_1variant.html index ab17ff26..1394093e 100644 --- a/classwinstd_1_1variant.html +++ b/classwinstd_1_1variant.html @@ -614,7 +614,7 @@ virtual ~variant () diff --git a/classwinstd_1_1vmemory-members.html b/classwinstd_1_1vmemory-members.html index d8a66aaa..3114a9b8 100644 --- a/classwinstd_1_1vmemory-members.html +++ b/classwinstd_1_1vmemory-members.html @@ -114,7 +114,7 @@ $(function() {
diff --git a/classwinstd_1_1vmemory.html b/classwinstd_1_1vmemory.html index f20c2296..1487c78c 100644 --- a/classwinstd_1_1vmemory.html +++ b/classwinstd_1_1vmemory.html @@ -502,7 +502,7 @@ static const LPVOID invali
diff --git a/classwinstd_1_1waddrinfo-members.html b/classwinstd_1_1waddrinfo-members.html index 9d7806e4..b43c560c 100644 --- a/classwinstd_1_1waddrinfo-members.html +++ b/classwinstd_1_1waddrinfo-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1waddrinfo.html b/classwinstd_1_1waddrinfo.html index dda350dc..39a1c98a 100644 --- a/classwinstd_1_1waddrinfo.html +++ b/classwinstd_1_1waddrinfo.html @@ -255,7 +255,7 @@ static const PADDRINFOW in
diff --git a/classwinstd_1_1win__handle-members.html b/classwinstd_1_1win__handle-members.html index 4daab5b3..36ffe46d 100644 --- a/classwinstd_1_1win__handle-members.html +++ b/classwinstd_1_1win__handle-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1win__handle.html b/classwinstd_1_1win__handle.html index 7a706deb..e300a9b6 100644 --- a/classwinstd_1_1win__handle.html +++ b/classwinstd_1_1win__handle.html @@ -259,7 +259,7 @@ template<HANDLE INVALID>
diff --git a/classwinstd_1_1win__runtime__error-members.html b/classwinstd_1_1win__runtime__error-members.html index 03db6cfe..d41553db 100644 --- a/classwinstd_1_1win__runtime__error-members.html +++ b/classwinstd_1_1win__runtime__error-members.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/classwinstd_1_1win__runtime__error.html b/classwinstd_1_1win__runtime__error.html index 7ceee1cc..46ec7cd8 100644 --- a/classwinstd_1_1win__runtime__error.html +++ b/classwinstd_1_1win__runtime__error.html @@ -390,7 +390,7 @@ typedef DWORD error_type diff --git a/classwinstd_1_1window__dc-members.html b/classwinstd_1_1window__dc-members.html index 07e9a93d..3dfc0a0b 100644 --- a/classwinstd_1_1window__dc-members.html +++ b/classwinstd_1_1window__dc-members.html @@ -112,7 +112,7 @@ $(function() {
diff --git a/classwinstd_1_1window__dc.html b/classwinstd_1_1window__dc.html index a9e98d98..7de2597c 100644 --- a/classwinstd_1_1window__dc.html +++ b/classwinstd_1_1window__dc.html @@ -278,7 +278,7 @@ static const HDC invalid diff --git a/classwinstd_1_1wintrust-members.html b/classwinstd_1_1wintrust-members.html index 98b6f71b..c98ae69b 100644 --- a/classwinstd_1_1wintrust-members.html +++ b/classwinstd_1_1wintrust-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1wintrust.html b/classwinstd_1_1wintrust.html index 902f9c0f..f450a48a 100644 --- a/classwinstd_1_1wintrust.html +++ b/classwinstd_1_1wintrust.html @@ -105,7 +105,7 @@ virtual ~wintrust () diff --git a/classwinstd_1_1wlan__handle-members.html b/classwinstd_1_1wlan__handle-members.html index c9ba317b..ba9db8b0 100644 --- a/classwinstd_1_1wlan__handle-members.html +++ b/classwinstd_1_1wlan__handle-members.html @@ -107,7 +107,7 @@ $(function() {
diff --git a/classwinstd_1_1wlan__handle.html b/classwinstd_1_1wlan__handle.html index 559b7236..90dce577 100644 --- a/classwinstd_1_1wlan__handle.html +++ b/classwinstd_1_1wlan__handle.html @@ -255,7 +255,7 @@ static const HANDLE invali
diff --git a/classwinstd_1_1ws2__runtime__error-members.html b/classwinstd_1_1ws2__runtime__error-members.html index 6806a928..18f7108a 100644 --- a/classwinstd_1_1ws2__runtime__error-members.html +++ b/classwinstd_1_1ws2__runtime__error-members.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/classwinstd_1_1ws2__runtime__error.html b/classwinstd_1_1ws2__runtime__error.html index 683d1c75..9f49d4a5 100644 --- a/classwinstd_1_1ws2__runtime__error.html +++ b/classwinstd_1_1ws2__runtime__error.html @@ -389,7 +389,7 @@ typedef int error_type
diff --git a/classwinstd_1_1wstring__guid-members.html b/classwinstd_1_1wstring__guid-members.html index 912a4da7..29245549 100644 --- a/classwinstd_1_1wstring__guid-members.html +++ b/classwinstd_1_1wstring__guid-members.html @@ -85,7 +85,7 @@ $(function() {
diff --git a/classwinstd_1_1wstring__guid.html b/classwinstd_1_1wstring__guid.html index bbe24827..e3237950 100644 --- a/classwinstd_1_1wstring__guid.html +++ b/classwinstd_1_1wstring__guid.html @@ -148,7 +148,7 @@ Public Member Functions
diff --git a/dir_4be4f7b278e009bf0f1906cf31fb73bd.html b/dir_4be4f7b278e009bf0f1906cf31fb73bd.html index ca3ebf3c..6f325b9e 100644 --- a/dir_4be4f7b278e009bf0f1906cf31fb73bd.html +++ b/dir_4be4f7b278e009bf0f1906cf31fb73bd.html @@ -86,7 +86,7 @@ Files
diff --git a/dir_6f50bb204833d887b928571856c82fbe.html b/dir_6f50bb204833d887b928571856c82fbe.html index eb1dae25..aa07ecdb 100644 --- a/dir_6f50bb204833d887b928571856c82fbe.html +++ b/dir_6f50bb204833d887b928571856c82fbe.html @@ -118,7 +118,7 @@ Files
diff --git a/dir_d44c64559bbebec7f509842c48db8b23.html b/dir_d44c64559bbebec7f509842c48db8b23.html index d13c2789..8671c50b 100644 --- a/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/dir_d44c64559bbebec7f509842c48db8b23.html @@ -86,7 +86,7 @@ Directories
diff --git a/files.html b/files.html index 00469c76..f9eeac21 100644 --- a/files.html +++ b/files.html @@ -101,7 +101,7 @@ $(function() {
diff --git a/functions.html b/functions.html index 71c2f3be..1fcc094b 100644 --- a/functions.html +++ b/functions.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_a.html b/functions_a.html index e5ca594f..e2b5a657 100644 --- a/functions_a.html +++ b/functions_a.html @@ -83,7 +83,7 @@ $(function() {
diff --git a/functions_b.html b/functions_b.html index bda55fc0..e2498e27 100644 --- a/functions_b.html +++ b/functions_b.html @@ -81,7 +81,7 @@ $(function() {
diff --git a/functions_c.html b/functions_c.html index b65c9cc9..b4b394c4 100644 --- a/functions_c.html +++ b/functions_c.html @@ -92,7 +92,7 @@ $(function() {
diff --git a/functions_d.html b/functions_d.html index e7355fa5..32996ef5 100644 --- a/functions_d.html +++ b/functions_d.html @@ -89,7 +89,7 @@ $(function() {
diff --git a/functions_e.html b/functions_e.html index 6b0b8041..f6fefe02 100644 --- a/functions_e.html +++ b/functions_e.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/functions_f.html b/functions_f.html index 60333b39..c6f8c378 100644 --- a/functions_f.html +++ b/functions_f.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func.html b/functions_func.html index cb73c619..9220505f 100644 --- a/functions_func.html +++ b/functions_func.html @@ -83,7 +83,7 @@ $(function() {
diff --git a/functions_func_b.html b/functions_func_b.html index e7790b64..2a32325d 100644 --- a/functions_func_b.html +++ b/functions_func_b.html @@ -81,7 +81,7 @@ $(function() {
diff --git a/functions_func_c.html b/functions_func_c.html index 6231459b..f635873c 100644 --- a/functions_func_c.html +++ b/functions_func_c.html @@ -90,7 +90,7 @@ $(function() {
diff --git a/functions_func_d.html b/functions_func_d.html index c090cd3d..7787280a 100644 --- a/functions_func_d.html +++ b/functions_func_d.html @@ -88,7 +88,7 @@ $(function() {
diff --git a/functions_func_e.html b/functions_func_e.html index 0a93384f..4bf0cd60 100644 --- a/functions_func_e.html +++ b/functions_func_e.html @@ -94,7 +94,7 @@ $(function() {
diff --git a/functions_func_f.html b/functions_func_f.html index f81c618a..7b734527 100644 --- a/functions_func_f.html +++ b/functions_func_f.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_g.html b/functions_func_g.html index 55c9e7a9..521ff357 100644 --- a/functions_func_g.html +++ b/functions_func_g.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_h.html b/functions_func_h.html index 97995854..c2e37b1b 100644 --- a/functions_func_h.html +++ b/functions_func_h.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_func_i.html b/functions_func_i.html index d82b5c64..f241fd78 100644 --- a/functions_func_i.html +++ b/functions_func_i.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_l.html b/functions_func_l.html index 9f589f34..7486d1b6 100644 --- a/functions_func_l.html +++ b/functions_func_l.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_m.html b/functions_func_m.html index ce04de2e..6084aac5 100644 --- a/functions_func_m.html +++ b/functions_func_m.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_n.html b/functions_func_n.html index 2568497d..09745dd3 100644 --- a/functions_func_n.html +++ b/functions_func_n.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_func_o.html b/functions_func_o.html index 56a998f0..be129db9 100644 --- a/functions_func_o.html +++ b/functions_func_o.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/functions_func_p.html b/functions_func_p.html index 867f42f0..61128c19 100644 --- a/functions_func_p.html +++ b/functions_func_p.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_q.html b/functions_func_q.html index 8ad24d3a..f49862a7 100644 --- a/functions_func_q.html +++ b/functions_func_q.html @@ -78,7 +78,7 @@ $(function() {
diff --git a/functions_func_r.html b/functions_func_r.html index b95e8e41..283e428d 100644 --- a/functions_func_r.html +++ b/functions_func_r.html @@ -83,7 +83,7 @@ $(function() {
diff --git a/functions_func_s.html b/functions_func_s.html index 024d97b7..d477f4f9 100644 --- a/functions_func_s.html +++ b/functions_func_s.html @@ -94,7 +94,7 @@ $(function() {
diff --git a/functions_func_t.html b/functions_func_t.html index 43acddd2..473bb503 100644 --- a/functions_func_t.html +++ b/functions_func_t.html @@ -78,7 +78,7 @@ $(function() {
diff --git a/functions_func_u.html b/functions_func_u.html index fbac4460..28b2ba6e 100644 --- a/functions_func_u.html +++ b/functions_func_u.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_v.html b/functions_func_v.html index 7f495787..4e79e0a4 100644 --- a/functions_func_v.html +++ b/functions_func_v.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_func_w.html b/functions_func_w.html index 0138fee0..52e560d0 100644 --- a/functions_func_w.html +++ b/functions_func_w.html @@ -84,7 +84,7 @@ $(function() {
diff --git a/functions_func_~.html b/functions_func_~.html index c2439ae1..fcb1f1fd 100644 --- a/functions_func_~.html +++ b/functions_func_~.html @@ -134,7 +134,7 @@ $(function() {
diff --git a/functions_g.html b/functions_g.html index 3ccbdb62..66733114 100644 --- a/functions_g.html +++ b/functions_g.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_h.html b/functions_h.html index f7effae5..e6b35ef8 100644 --- a/functions_h.html +++ b/functions_h.html @@ -81,7 +81,7 @@ $(function() {
diff --git a/functions_i.html b/functions_i.html index 27f4bfb6..16a61123 100644 --- a/functions_i.html +++ b/functions_i.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_l.html b/functions_l.html index dd8188ee..59b00cb1 100644 --- a/functions_l.html +++ b/functions_l.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_m.html b/functions_m.html index 80b06fdf..a295c5b3 100644 --- a/functions_m.html +++ b/functions_m.html @@ -116,7 +116,7 @@ $(function() {
diff --git a/functions_n.html b/functions_n.html index 41f43d3f..bcb07705 100644 --- a/functions_n.html +++ b/functions_n.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_o.html b/functions_o.html index 60667936..9efcf509 100644 --- a/functions_o.html +++ b/functions_o.html @@ -96,7 +96,7 @@ $(function() {
diff --git a/functions_p.html b/functions_p.html index b392dd12..9df93485 100644 --- a/functions_p.html +++ b/functions_p.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_q.html b/functions_q.html index 9712167e..276055aa 100644 --- a/functions_q.html +++ b/functions_q.html @@ -78,7 +78,7 @@ $(function() {
diff --git a/functions_r.html b/functions_r.html index a1e7508d..421dcaf3 100644 --- a/functions_r.html +++ b/functions_r.html @@ -84,7 +84,7 @@ $(function() {
diff --git a/functions_s.html b/functions_s.html index 8566ee99..3ff1e4d5 100644 --- a/functions_s.html +++ b/functions_s.html @@ -95,7 +95,7 @@ $(function() {
diff --git a/functions_t.html b/functions_t.html index b46ac1f7..9eb9026e 100644 --- a/functions_t.html +++ b/functions_t.html @@ -78,7 +78,7 @@ $(function() {
diff --git a/functions_type.html b/functions_type.html index 81c0a026..baf8b908 100644 --- a/functions_type.html +++ b/functions_type.html @@ -87,7 +87,7 @@ $(function() {
diff --git a/functions_u.html b/functions_u.html index a5b4569e..79495beb 100644 --- a/functions_u.html +++ b/functions_u.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/functions_v.html b/functions_v.html index d35f1edf..1b7ae18b 100644 --- a/functions_v.html +++ b/functions_v.html @@ -80,7 +80,7 @@ $(function() {
diff --git a/functions_vars.html b/functions_vars.html index d16a7b7d..3ad656b7 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -119,7 +119,7 @@ $(function() {
diff --git a/functions_w.html b/functions_w.html index 7597924b..e6a4dbd9 100644 --- a/functions_w.html +++ b/functions_w.html @@ -84,7 +84,7 @@ $(function() {
diff --git a/functions_~.html b/functions_~.html index 9a2177d5..30167de6 100644 --- a/functions_~.html +++ b/functions_~.html @@ -134,7 +134,7 @@ $(function() {
diff --git a/group___setup_a_p_i.html b/group___setup_a_p_i.html index 801a1a08..fa6f3179 100644 --- a/group___setup_a_p_i.html +++ b/group___setup_a_p_i.html @@ -89,7 +89,7 @@ Classes
diff --git a/group___win_sock2_a_p_i.html b/group___win_sock2_a_p_i.html index d61f2dbe..0ed6a404 100644 --- a/group___win_sock2_a_p_i.html +++ b/group___win_sock2_a_p_i.html @@ -213,7 +213,7 @@ Functions
diff --git a/group___win_std_c_o_m.html b/group___win_std_c_o_m.html index 14dad691..747193b2 100644 --- a/group___win_std_c_o_m.html +++ b/group___win_std_c_o_m.html @@ -223,7 +223,7 @@ template<class T >
diff --git a/group___win_std_cred_a_p_i.html b/group___win_std_cred_a_p_i.html index 9b5472c2..02194957 100644 --- a/group___win_std_cred_a_p_i.html +++ b/group___win_std_cred_a_p_i.html @@ -442,7 +442,7 @@ template<class _Traits , class _Ax > diff --git a/group___win_std_crypto_a_p_i.html b/group___win_std_crypto_a_p_i.html index d7448d2f..f5c63a29 100644 --- a/group___win_std_crypto_a_p_i.html +++ b/group___win_std_crypto_a_p_i.html @@ -1195,7 +1195,7 @@ template<class T > diff --git a/group___win_std_e_a_p_a_p_i.html b/group___win_std_e_a_p_a_p_i.html index f0f40bff..6cc38ecb 100644 --- a/group___win_std_e_a_p_a_p_i.html +++ b/group___win_std_e_a_p_a_p_i.html @@ -344,7 +344,7 @@ static const EAP_ATTRIBUTE  diff --git a/group___win_std_e_t_w_a_p_i.html b/group___win_std_e_t_w_a_p_i.html index e6f8dba4..aaf805da 100644 --- a/group___win_std_e_t_w_a_p_i.html +++ b/group___win_std_e_t_w_a_p_i.html @@ -291,7 +291,7 @@ template<class _Ty , class _Ax > diff --git a/group___win_std_exceptions.html b/group___win_std_exceptions.html index f2098ff4..2aaafe6a 100644 --- a/group___win_std_exceptions.html +++ b/group___win_std_exceptions.html @@ -221,7 +221,7 @@ Functions diff --git a/group___win_std_gdi_a_p_i.html b/group___win_std_gdi_a_p_i.html index cb1ba0f3..0ff6af4d 100644 --- a/group___win_std_gdi_a_p_i.html +++ b/group___win_std_gdi_a_p_i.html @@ -98,7 +98,7 @@ Classes diff --git a/group___win_std_general.html b/group___win_std_general.html index 6512cf99..fac3e24d 100644 --- a/group___win_std_general.html +++ b/group___win_std_general.html @@ -290,7 +290,7 @@ template<class _Ty , class _Dx > diff --git a/group___win_std_m_s_i_a_p_i.html b/group___win_std_m_s_i_a_p_i.html index 1383ff5d..ba9cb82f 100644 --- a/group___win_std_m_s_i_a_p_i.html +++ b/group___win_std_m_s_i_a_p_i.html @@ -645,7 +645,7 @@ template<class _Ty , class _Ax > diff --git a/group___win_std_mem_sanitize.html b/group___win_std_mem_sanitize.html index 4214c4d1..0c9a666f 100644 --- a/group___win_std_mem_sanitize.html +++ b/group___win_std_mem_sanitize.html @@ -138,7 +138,7 @@ typedef diff --git a/group___win_std_s_d_d_l.html b/group___win_std_s_d_d_l.html index edff2a86..e143da87 100644 --- a/group___win_std_s_d_d_l.html +++ b/group___win_std_s_d_d_l.html @@ -198,7 +198,7 @@ Functions diff --git a/group___win_std_security_a_p_i.html b/group___win_std_security_a_p_i.html index afa1e9cf..9a66eb69 100644 --- a/group___win_std_security_a_p_i.html +++ b/group___win_std_security_a_p_i.html @@ -92,7 +92,7 @@ Classes diff --git a/group___win_std_shell_w_a_p_i.html b/group___win_std_shell_w_a_p_i.html index 33917fb2..d65c86d7 100644 --- a/group___win_std_shell_w_a_p_i.html +++ b/group___win_std_shell_w_a_p_i.html @@ -244,7 +244,7 @@ template<class _Traits , class _Ax > diff --git a/group___win_std_str_format.html b/group___win_std_str_format.html index 2fa005fa..81e45ba4 100644 --- a/group___win_std_str_format.html +++ b/group___win_std_str_format.html @@ -231,7 +231,7 @@ Functions
Example
// Please note the PCSTR typecasting invokes an operator to return
// pointer to formatted buffer rather than class reference itself.
cout << (PCSTR)(winstd::string_printf("%i is less than %i.\n", 1, 5));
-
Base template class to support string formatting using printf() style templates.
Definition Common.h:1574
+
Base template class to support string formatting using printf() style templates.
Definition Common.h:1611

Macro Definition Documentation

@@ -1376,7 +1376,7 @@ template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 > diff --git a/group___win_std_sys_handles.html b/group___win_std_sys_handles.html index be7930d4..64e998e8 100644 --- a/group___win_std_sys_handles.html +++ b/group___win_std_sys_handles.html @@ -184,7 +184,7 @@ static const T winstd::han diff --git a/group___win_std_w_l_a_n_a_p_i.html b/group___win_std_w_l_a_n_a_p_i.html index f3ba4a03..1724e75b 100644 --- a/group___win_std_w_l_a_n_a_p_i.html +++ b/group___win_std_w_l_a_n_a_p_i.html @@ -203,7 +203,7 @@ template<class _Traits , class _Ax > diff --git a/group___win_std_win_a_p_i.html b/group___win_std_win_a_p_i.html index 4069e7da..d4c7c638 100644 --- a/group___win_std_win_a_p_i.html +++ b/group___win_std_win_a_p_i.html @@ -201,14 +201,14 @@ Functions 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.
  -template<class _Traits , class _Ax > -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, and stores it in a std::wstring string.
-  -template<class _Traits , class _Ax > -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, and stores it in a std::wstring string.
-  +template<class _Traits , class _Ax > +static DWORD ExpandEnvironmentStringsA (LPCSTR lpSrc, std::basic_string< char, _Traits, _Ax > &sValue) + Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string.
+  +template<class _Traits , class _Ax > +static DWORD ExpandEnvironmentStringsW (LPCWSTR lpSrc, std::basic_string< wchar_t, _Traits, _Ax > &sValue) + Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string.
+  template<class _Traits , class _Ax > static VOID GuidToStringA (LPCGUID lpGuid, std::basic_string< char, _Traits, _Ax > &str) noexcept  Formats GUID and stores it in a std::wstring string.
@@ -718,8 +718,8 @@ Functions - -

◆ ExpandEnvironmentStringsA()

+ +

◆ ExpandEnvironmentStringsA()

@@ -749,7 +749,7 @@ template<class _Traits , class _Ax >
-staticnoexcept +static
@@ -759,8 +759,8 @@ template<class _Traits , class _Ax >
- -

◆ ExpandEnvironmentStringsW()

+ +

◆ ExpandEnvironmentStringsW()

@@ -790,7 +790,7 @@ template<class _Traits , class _Ax >
-staticnoexcept +static
@@ -2824,7 +2824,7 @@ template<class _Ty , class _Ax >
diff --git a/group___win_std_win_h_t_t_p.html b/group___win_std_win_h_t_t_p.html index ef99bbed..416e6090 100644 --- a/group___win_std_win_h_t_t_p.html +++ b/group___win_std_win_h_t_t_p.html @@ -86,7 +86,7 @@ Classes diff --git a/group___win_trust_a_p_i.html b/group___win_trust_a_p_i.html index 08724271..504da029 100644 --- a/group___win_trust_a_p_i.html +++ b/group___win_trust_a_p_i.html @@ -86,7 +86,7 @@ Classes diff --git a/hierarchy.html b/hierarchy.html index d4685102..57d479ef 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -230,7 +230,7 @@ $(function() { diff --git a/index.html b/index.html index 9709e5f9..9817aa56 100644 --- a/index.html +++ b/index.html @@ -90,8 +90,8 @@ Example
if (!lib_shell32)
throw winstd::win_runtime_error("LoadLibraryEx failed");
m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(48)));
-
Module handle wrapper.
Definition Win.h:1061
-
Windows runtime error.
Definition Common.h:1491
+
Module handle wrapper.
Definition Win.h:1065
+
Windows runtime error.
Definition Common.h:1528

Functions and Templates

Different Win32 API functions have different ways of returning variable-sized data. Getting tired of carefully studying MSDN for each particular Win32 API function how to preallocate the output memory correctly? We too...

@@ -103,7 +103,7 @@ Example
std::string response;
WideCharToMultiByte(CP_OEMCP, 0, L"Copyright \u00A9 2017", -1, response, NULL, NULL);
std::cout << response.c_str() << std::endl;
-
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 Common.h:299
+
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 Common.h:336

String Formatters

For those situations where one must quckly compose a temporary string using sprintf() or FormatMessage(). Or, convert a GUID to a string on the fly.

@@ -116,7 +116,7 @@ Example
"Maximum packet size too small (minimum: %zu, available: %u)",
sizeof(EapPacket) + 1,
dwMaxSendPacketSize));
-
Base template class to support string formatting using printf() style templates.
Definition Common.h:1574
+
Base template class to support string formatting using printf() style templates.
Definition Common.h:1611

What WinStd Is Not

WinStd is not trying to be a full-fledged object-oriented framework on top of Win32 API. We have Microsoft to publish those once every few years - and obsolete it when they loose interest. WinStd aims at augmenting Win32 API with a little bit of help from C++.

@@ -148,7 +148,7 @@ Usage diff --git a/md__s_e_c_u_r_i_t_y.html b/md__s_e_c_u_r_i_t_y.html index fb3f96f6..d1efa376 100644 --- a/md__s_e_c_u_r_i_t_y.html +++ b/md__s_e_c_u_r_i_t_y.html @@ -90,7 +90,7 @@ Reporting a Vulnerability diff --git a/pages.html b/pages.html index 63ea0af6..76cf95be 100644 --- a/pages.html +++ b/pages.html @@ -81,7 +81,7 @@ $(function() { diff --git a/pch_8h_source.html b/pch_8h_source.html index e7feca36..f6e8e91b 100644 --- a/pch_8h_source.html +++ b/pch_8h_source.html @@ -112,7 +112,7 @@ $(document).ready(function() { init_codefold(0); }); diff --git a/search/all_5.js b/search/all_5.js index 34710ff0..c1aaa261 100644 --- a/search/all_5.js +++ b/search/all_5.js @@ -32,7 +32,7 @@ var searchData= ['event_5ftrace_5fenabler_29',['event_trace_enabler',['../classwinstd_1_1event__trace__enabler.html#a8666ba08639a65fa01eb64c4855d68a3',1,'winstd::event_trace_enabler::event_trace_enabler(const event_session &session, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)'],['../classwinstd_1_1event__trace__enabler.html#a50ce2e4286dbfc133c7f4a4762b65a05',1,'winstd::event_trace_enabler::event_trace_enabler(LPCGUID SourceId, TRACEHANDLE TraceHandle, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)'],['../classwinstd_1_1event__trace__enabler.html',1,'winstd::event_trace_enabler']]], ['example_30',['example',['../index.html#autotoc_md4',1,'Example'],['../index.html#autotoc_md6',1,'Example'],['../index.html#autotoc_md8',1,'Example']]], ['exceptions_31',['Exceptions',['../group___win_std_exceptions.html',1,'']]], - ['expandenvironmentstringsa_32',['ExpandEnvironmentStringsA',['../group___win_std_win_a_p_i.html#ga07fbe3c3b5aceaf3442a26fc3b6ce4b0',1,'Win.h']]], - ['expandenvironmentstringsw_33',['ExpandEnvironmentStringsW',['../group___win_std_win_a_p_i.html#gad2e379fa7f86f101bff21d2c10b7d430',1,'Win.h']]], + ['expandenvironmentstringsa_32',['ExpandEnvironmentStringsA',['../group___win_std_win_a_p_i.html#gaa221c59f3872964ad57fb6626d36e394',1,'Win.h']]], + ['expandenvironmentstringsw_33',['ExpandEnvironmentStringsW',['../group___win_std_win_a_p_i.html#ga088118fb47c75907356463e00e8fc2ec',1,'Win.h']]], ['extensible_20authentication_20protocol_20api_34',['Extensible Authentication Protocol API',['../group___win_std_e_a_p_a_p_i.html',1,'']]] ]; diff --git a/search/functions_4.js b/search/functions_4.js index 555ce0e4..fee20f81 100644 --- a/search/functions_4.js +++ b/search/functions_4.js @@ -17,6 +17,6 @@ var searchData= ['event_5frec_14',['event_rec',['../classwinstd_1_1event__rec.html#af2f781ca85c2d92b001bb32bf4839f11',1,'winstd::event_rec::event_rec()'],['../classwinstd_1_1event__rec.html#afd6e48f124743c9f5b0c576db2165787',1,'winstd::event_rec::event_rec(const event_rec &other)'],['../classwinstd_1_1event__rec.html#a73f9f035b70ce7c030e2c616d3f42e37',1,'winstd::event_rec::event_rec(const EVENT_RECORD &other)'],['../classwinstd_1_1event__rec.html#ac3a21e4c1a4469e7b85fc235f65006ca',1,'winstd::event_rec::event_rec(event_rec &&other) noexcept']]], ['event_5fsession_15',['event_session',['../classwinstd_1_1event__session.html#a24a43016accd86270c6a2ca6cf4934de',1,'winstd::event_session::event_session()'],['../classwinstd_1_1event__session.html#a21775ae7a7620d92be3b63d36bba757d',1,'winstd::event_session::event_session(handle_type h, const EVENT_TRACE_PROPERTIES *prop)'],['../classwinstd_1_1event__session.html#a14581a7203ad6d89bf69903093cfe83c',1,'winstd::event_session::event_session(event_session &&other) noexcept']]], ['event_5ftrace_5fenabler_16',['event_trace_enabler',['../classwinstd_1_1event__trace__enabler.html#a50ce2e4286dbfc133c7f4a4762b65a05',1,'winstd::event_trace_enabler::event_trace_enabler(LPCGUID SourceId, TRACEHANDLE TraceHandle, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)'],['../classwinstd_1_1event__trace__enabler.html#a8666ba08639a65fa01eb64c4855d68a3',1,'winstd::event_trace_enabler::event_trace_enabler(const event_session &session, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)']]], - ['expandenvironmentstringsa_17',['ExpandEnvironmentStringsA',['../group___win_std_win_a_p_i.html#ga07fbe3c3b5aceaf3442a26fc3b6ce4b0',1,'Win.h']]], - ['expandenvironmentstringsw_18',['ExpandEnvironmentStringsW',['../group___win_std_win_a_p_i.html#gad2e379fa7f86f101bff21d2c10b7d430',1,'Win.h']]] + ['expandenvironmentstringsa_17',['ExpandEnvironmentStringsA',['../group___win_std_win_a_p_i.html#gaa221c59f3872964ad57fb6626d36e394',1,'Win.h']]], + ['expandenvironmentstringsw_18',['ExpandEnvironmentStringsW',['../group___win_std_win_a_p_i.html#ga088118fb47c75907356463e00e8fc2ec',1,'Win.h']]] ]; diff --git a/structwinstd_1_1_co_task_mem_free__delete-members.html b/structwinstd_1_1_co_task_mem_free__delete-members.html index 91728f39..01188504 100644 --- a/structwinstd_1_1_co_task_mem_free__delete-members.html +++ b/structwinstd_1_1_co_task_mem_free__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_co_task_mem_free__delete.html b/structwinstd_1_1_co_task_mem_free__delete.html index 5f4e315f..e0d79e73 100644 --- a/structwinstd_1_1_co_task_mem_free__delete.html +++ b/structwinstd_1_1_co_task_mem_free__delete.html @@ -137,7 +137,7 @@ template<class _T > diff --git a/structwinstd_1_1_cred_free__delete-members.html b/structwinstd_1_1_cred_free__delete-members.html index 067cab67..faf4d0d3 100644 --- a/structwinstd_1_1_cred_free__delete-members.html +++ b/structwinstd_1_1_cred_free__delete-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_cred_free__delete.html b/structwinstd_1_1_cred_free__delete.html index 3b858fd3..5da94d7a 100644 --- a/structwinstd_1_1_cred_free__delete.html +++ b/structwinstd_1_1_cred_free__delete.html @@ -150,7 +150,7 @@ template<class _Ty > diff --git a/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4-members.html b/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4-members.html index f83d4ceb..464ffa58 100644 --- a/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4-members.html +++ b/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4.html b/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4.html index 3b2dfbd9..aa071571 100644 --- a/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4.html +++ b/structwinstd_1_1_cred_free__delete_3_01___ty_0f_0e_4.html @@ -182,7 +182,7 @@ template<class _Ty > diff --git a/structwinstd_1_1_eap_host_peer_free_eap_error__delete-members.html b/structwinstd_1_1_eap_host_peer_free_eap_error__delete-members.html index 462431b1..a5d79311 100644 --- a/structwinstd_1_1_eap_host_peer_free_eap_error__delete-members.html +++ b/structwinstd_1_1_eap_host_peer_free_eap_error__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_eap_host_peer_free_eap_error__delete.html b/structwinstd_1_1_eap_host_peer_free_eap_error__delete.html index 483a452c..d675a9d2 100644 --- a/structwinstd_1_1_eap_host_peer_free_eap_error__delete.html +++ b/structwinstd_1_1_eap_host_peer_free_eap_error__delete.html @@ -134,7 +134,7 @@ Public Member Functions diff --git a/structwinstd_1_1_eap_host_peer_free_error_memory__delete-members.html b/structwinstd_1_1_eap_host_peer_free_error_memory__delete-members.html index 5ba7b871..668fe8ba 100644 --- a/structwinstd_1_1_eap_host_peer_free_error_memory__delete-members.html +++ b/structwinstd_1_1_eap_host_peer_free_error_memory__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_eap_host_peer_free_error_memory__delete.html b/structwinstd_1_1_eap_host_peer_free_error_memory__delete.html index f33612e4..d6cbe106 100644 --- a/structwinstd_1_1_eap_host_peer_free_error_memory__delete.html +++ b/structwinstd_1_1_eap_host_peer_free_error_memory__delete.html @@ -134,7 +134,7 @@ Public Member Functions diff --git a/structwinstd_1_1_eap_host_peer_free_memory__delete-members.html b/structwinstd_1_1_eap_host_peer_free_memory__delete-members.html index 5822efa3..ba4c6f45 100644 --- a/structwinstd_1_1_eap_host_peer_free_memory__delete-members.html +++ b/structwinstd_1_1_eap_host_peer_free_memory__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_eap_host_peer_free_memory__delete.html b/structwinstd_1_1_eap_host_peer_free_memory__delete.html index 3ac1299a..b8004ce8 100644 --- a/structwinstd_1_1_eap_host_peer_free_memory__delete.html +++ b/structwinstd_1_1_eap_host_peer_free_memory__delete.html @@ -137,7 +137,7 @@ template<class _T > diff --git a/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete-members.html b/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete-members.html index f8b5e229..68f20c5c 100644 --- a/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete-members.html +++ b/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete.html b/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete.html index 319ce57b..8ef074da 100644 --- a/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete.html +++ b/structwinstd_1_1_eap_host_peer_free_runtime_memory__delete.html @@ -106,7 +106,7 @@ template<class _T > diff --git a/structwinstd_1_1_global_free__delete-members.html b/structwinstd_1_1_global_free__delete-members.html index 16c4006c..b50d6721 100644 --- a/structwinstd_1_1_global_free__delete-members.html +++ b/structwinstd_1_1_global_free__delete-members.html @@ -85,7 +85,7 @@ $(function() { diff --git a/structwinstd_1_1_global_free__delete.html b/structwinstd_1_1_global_free__delete.html index 6b1e35b0..1f93c59d 100644 --- a/structwinstd_1_1_global_free__delete.html +++ b/structwinstd_1_1_global_free__delete.html @@ -134,7 +134,7 @@ Public Member Functions diff --git a/structwinstd_1_1_local_free__delete-members.html b/structwinstd_1_1_local_free__delete-members.html index 5e210746..24b13bd0 100644 --- a/structwinstd_1_1_local_free__delete-members.html +++ b/structwinstd_1_1_local_free__delete-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_local_free__delete.html b/structwinstd_1_1_local_free__delete.html index 46b01595..083e4860 100644 --- a/structwinstd_1_1_local_free__delete.html +++ b/structwinstd_1_1_local_free__delete.html @@ -150,7 +150,7 @@ template<class _Ty > diff --git a/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4-members.html b/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4-members.html index 088762b8..e43a6cc3 100644 --- a/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4-members.html +++ b/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4.html b/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4.html index 3da452d1..bbe6983f 100644 --- a/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4.html +++ b/structwinstd_1_1_local_free__delete_3_01___ty_0f_0e_4.html @@ -152,7 +152,7 @@ template<class _Other > diff --git a/structwinstd_1_1_unmap_view_of_file__delete-members.html b/structwinstd_1_1_unmap_view_of_file__delete-members.html index f3a6ef9a..377204ee 100644 --- a/structwinstd_1_1_unmap_view_of_file__delete-members.html +++ b/structwinstd_1_1_unmap_view_of_file__delete-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_unmap_view_of_file__delete.html b/structwinstd_1_1_unmap_view_of_file__delete.html index bb4fd05d..a0e003e3 100644 --- a/structwinstd_1_1_unmap_view_of_file__delete.html +++ b/structwinstd_1_1_unmap_view_of_file__delete.html @@ -119,7 +119,7 @@ struct winstd::UnmapViewOfFile_delete< _Ty >

Deleter for unique_pt

diff --git a/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4-members.html b/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4-members.html index 23bf2d2a..cd7d91e7 100644 --- a/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4-members.html +++ b/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4.html b/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4.html index 54111a84..a7ab5023 100644 --- a/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4.html +++ b/structwinstd_1_1_unmap_view_of_file__delete_3_01___ty_0f_0e_4.html @@ -119,7 +119,7 @@ struct winstd::UnmapViewOfFile_delete< _Ty[]>

Deleter for unique_p

diff --git a/structwinstd_1_1_wlan_free_memory__delete-members.html b/structwinstd_1_1_wlan_free_memory__delete-members.html index 883109e2..9e5d56e9 100644 --- a/structwinstd_1_1_wlan_free_memory__delete-members.html +++ b/structwinstd_1_1_wlan_free_memory__delete-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_wlan_free_memory__delete.html b/structwinstd_1_1_wlan_free_memory__delete.html index e026055a..3f2f684d 100644 --- a/structwinstd_1_1_wlan_free_memory__delete.html +++ b/structwinstd_1_1_wlan_free_memory__delete.html @@ -119,7 +119,7 @@ struct winstd::WlanFreeMemory_delete< _Ty >

Deleter for unique_ptr

diff --git a/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4-members.html b/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4-members.html index d3e7d41c..05ed90bf 100644 --- a/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4-members.html +++ b/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4-members.html @@ -87,7 +87,7 @@ $(function() { diff --git a/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4.html b/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4.html index 75a518d2..c6edf5ba 100644 --- a/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4.html +++ b/structwinstd_1_1_wlan_free_memory__delete_3_01___ty_0f_0e_4.html @@ -119,7 +119,7 @@ struct winstd::WlanFreeMemory_delete< _Ty[]>

Deleter for unique_pt

diff --git a/structwinstd_1_1heap__allocator_1_1rebind-members.html b/structwinstd_1_1heap__allocator_1_1rebind-members.html index b09ca1c8..a866a29c 100644 --- a/structwinstd_1_1heap__allocator_1_1rebind-members.html +++ b/structwinstd_1_1heap__allocator_1_1rebind-members.html @@ -84,7 +84,7 @@ $(function() { diff --git a/structwinstd_1_1heap__allocator_1_1rebind.html b/structwinstd_1_1heap__allocator_1_1rebind.html index 570a459b..ceb6049e 100644 --- a/structwinstd_1_1heap__allocator_1_1rebind.html +++ b/structwinstd_1_1heap__allocator_1_1rebind.html @@ -103,7 +103,7 @@ struct winstd::heap_allocator< _Ty >::rebind< _Other >

A str

diff --git a/structwinstd_1_1sanitizing__allocator_1_1rebind-members.html b/structwinstd_1_1sanitizing__allocator_1_1rebind-members.html index e78844e9..86448e6d 100644 --- a/structwinstd_1_1sanitizing__allocator_1_1rebind-members.html +++ b/structwinstd_1_1sanitizing__allocator_1_1rebind-members.html @@ -84,7 +84,7 @@ $(function() { diff --git a/structwinstd_1_1sanitizing__allocator_1_1rebind.html b/structwinstd_1_1sanitizing__allocator_1_1rebind.html index b80cc005..5c0a5631 100644 --- a/structwinstd_1_1sanitizing__allocator_1_1rebind.html +++ b/structwinstd_1_1sanitizing__allocator_1_1rebind.html @@ -103,7 +103,7 @@ struct winstd::sanitizing_allocator< _Ty >::rebind< _Other >

diff --git a/topics.html b/topics.html index be85d2bb..f8913b9f 100644 --- a/topics.html +++ b/topics.html @@ -101,7 +101,7 @@ $(function() {