From 0ab15294870fbf14b101e9c7b37bcf0701d672c2 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 11 Oct 2021 17:59:40 +0200 Subject: [PATCH] Improve til::gen_random documentation (#11465) --- NOTICE.md | 30 +++++++++++++++++++++++++++--- src/inc/til/rand.h | 12 ++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/NOTICE.md b/NOTICE.md index 8fc966f8a..5c153f6ab 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -117,7 +117,6 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ``` ## dynamic_bitset @@ -148,7 +147,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ``` ## \{fmt\} @@ -215,7 +213,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ``` @@ -249,7 +246,34 @@ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` +## PCG Random Number Generation + +**Source**: [https://github.com/imneme/pcg-cpp](https://github.com/imneme/pcg-cpp) + +### License + +``` +Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ``` ## ConEmu diff --git a/src/inc/til/rand.h b/src/inc/til/rand.h index d0b8f4902..da403a96e 100644 --- a/src/inc/til/rand.h +++ b/src/inc/til/rand.h @@ -12,8 +12,16 @@ namespace til struct RtlGenRandomLoader { RtlGenRandomLoader() noexcept : - // The documentation states to use advapi32.dll, but technically - // SystemFunction036 lives in cryptbase.dll since Windows 7. + // The documentation states: + // This function has no associated import library. This function is available + // as a resource named SystemFunction036 in Advapi32.dll. You must use the + // LoadLibrary and GetProcAddress functions to dynamically link to Advapi32.dll. + // + // There's two downsides to using advapi32.dll however: + // * The actual implementation resides in cryptbase.dll and... + // * In older versions of Windows (7 and older) advapi32.dll didn't use forwarding to + // cryptbase, instead it was using LoadLibrary()/GetProcAddress() on every call. + // * advapi32.dll doesn't exist on MinWin, cryptbase.dll however does. module{ LoadLibraryExW(L"cryptbase.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32) }, proc{ reinterpret_cast(GetProcAddress(module.get(), "SystemFunction036")) } {