From 44902cb49cd51e2bb2f1cef05cb3c0e799b83434 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 3 Aug 2024 16:11:57 +0100 Subject: Rework OS abstractions - As much as possible avoid dragging system headers into translation units. This should avoid namespace pollution and, hopefully, speed up builds a little bit. - Avoid leaning on the UCRT so much on Windows - prefer native win32 calls and native file handles except where doing so is inconvenient (in particular, for stat(), which we might try and replace later). - Also, switch from SystemFunction036 to ProcessPrng on Windows. This requires us to generate a stub for bcryptprimitives.dll because Microsoft haven't bothered to provide a link library, but the function is better-documented and seems to be a more direct under-the-hood call as well. Apparently it's what's used by the major web browsers these days, which seems like a good indication it's stable and trusted. - Lastly, remove a bunch of functions and macros and stuff that weren't actually being used. It seems good to try and keep the scope of OS-dependent stuff relatively contained and only add to it when actually required. --- src/stubs/BCryptPrimitives.c | 6 ++++++ src/stubs/bcryptprimitives.def | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 src/stubs/BCryptPrimitives.c create mode 100644 src/stubs/bcryptprimitives.def (limited to 'src/stubs') diff --git a/src/stubs/BCryptPrimitives.c b/src/stubs/BCryptPrimitives.c new file mode 100644 index 0000000..afcaa7e --- /dev/null +++ b/src/stubs/BCryptPrimitives.c @@ -0,0 +1,6 @@ +/* This file is dedicated to the public domain. */ + +// We have to define a real function with the right number of arguments to get +// the mangled symbol _ProcessPrng@8, which the .def file apparently turns +// into an "undecorate" .lib entry through some undocumented magic (of course!). +int __stdcall ProcessPrng(void *x, unsigned int y) { return 0; } diff --git a/src/stubs/bcryptprimitives.def b/src/stubs/bcryptprimitives.def new file mode 100644 index 0000000..9021d7c --- /dev/null +++ b/src/stubs/bcryptprimitives.def @@ -0,0 +1,7 @@ +; This file is dedicated to the public domain. + +LIBRARY bcryptprimitives +EXPORTS + ProcessPrng + +; vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3