HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
seed_win32_impl.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8
9#include "seed_intf.hpp"
10#include "../utility/utility.hpp"
11#include "../macros.hpp"
12#include <format>
13
14hi_export_module(hikogui.random.seed : impl);
15
16hi_export namespace hi::inline v1 {
17
18inline void generate_seed(void *ptr, size_t size)
19{
20 auto status = BCryptGenRandom(NULL, static_cast<PUCHAR>(ptr), narrow_cast<ULONG>(size), BCRYPT_USE_SYSTEM_PREFERRED_RNG);
21 if (not SUCCEEDED(status)) {
22 throw os_error(std::format("BCryptGenRandom(): {}", get_last_error_message(status)));
23 }
24}
25
26}
Rules for working with win32 headers.
hi_export std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
Definition exception_win32_impl.hpp:30
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
void generate_seed(void *ptr, size_t size)
Load a random seed.
Definition seed_win32_impl.hpp:18