`ProcessRng` is the only publicly documented function exported by `bcryptprimitives`. This stub simply forwards it to `RtlGenRandom` in `advapi32`.
Documentation: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
-- v2: bcryptprimitives: ProcessRng stub
From: Chris Denton chris@chrisdenton.dev
ProcessPrng is the only publicly documented function exported by bcryptprimitives. This stub simply forwards it to RtlGenRandom in advapi32.
Note that there is no documented header file or import lib.
Documentation: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng --- configure | 2 + configure.ac | 1 + dlls/bcryptprimitives/Makefile.in | 8 ++++ dlls/bcryptprimitives/bcryptprimitives.spec | 1 + dlls/bcryptprimitives/bcryptprimitives_main.c | 44 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 dlls/bcryptprimitives/Makefile.in create mode 100644 dlls/bcryptprimitives/bcryptprimitives.spec create mode 100644 dlls/bcryptprimitives/bcryptprimitives_main.c
diff --git a/configure b/configure index 7d568162159..afec0af39af 100755 --- a/configure +++ b/configure @@ -986,6 +986,7 @@ enable_avicap32 enable_avifil32 enable_avrt enable_bcrypt +enable_bcryptprimitives enable_bluetoothapis enable_browseui enable_bthprops_cpl @@ -21218,6 +21219,7 @@ wine_fn_config_makefile dlls/avifile.dll16 enable_win16 wine_fn_config_makefile dlls/avrt enable_avrt wine_fn_config_makefile dlls/bcrypt enable_bcrypt wine_fn_config_makefile dlls/bcrypt/tests enable_tests +wine_fn_config_makefile dlls/bcryptprimitives enable_bcryptprimitives wine_fn_config_makefile dlls/bluetoothapis enable_bluetoothapis wine_fn_config_makefile dlls/browseui enable_browseui wine_fn_config_makefile dlls/browseui/tests enable_tests diff --git a/configure.ac b/configure.ac index 3ab6d787d61..4cac45e6e42 100644 --- a/configure.ac +++ b/configure.ac @@ -2392,6 +2392,7 @@ WINE_CONFIG_MAKEFILE(dlls/avifile.dll16,enable_win16) WINE_CONFIG_MAKEFILE(dlls/avrt) WINE_CONFIG_MAKEFILE(dlls/bcrypt) WINE_CONFIG_MAKEFILE(dlls/bcrypt/tests) +WINE_CONFIG_MAKEFILE(dlls/bcryptprimitives) WINE_CONFIG_MAKEFILE(dlls/bluetoothapis) WINE_CONFIG_MAKEFILE(dlls/browseui) WINE_CONFIG_MAKEFILE(dlls/browseui/tests) diff --git a/dlls/bcryptprimitives/Makefile.in b/dlls/bcryptprimitives/Makefile.in new file mode 100644 index 00000000000..bb59597899a --- /dev/null +++ b/dlls/bcryptprimitives/Makefile.in @@ -0,0 +1,8 @@ +MODULE = bcryptprimitives.dll +IMPORTS = advapi32 +IMPORTLIB = bcryptprimitives +UNIXLIB = bcryptprimitives.so +UNIX_CFLAGS = $(GNUTLS_CFLAGS) + +C_SRCS = \ + bcryptprimitives_main.c diff --git a/dlls/bcryptprimitives/bcryptprimitives.spec b/dlls/bcryptprimitives/bcryptprimitives.spec new file mode 100644 index 00000000000..928cb06afcd --- /dev/null +++ b/dlls/bcryptprimitives/bcryptprimitives.spec @@ -0,0 +1 @@ +@ stdcall ProcessPrng(ptr long) diff --git a/dlls/bcryptprimitives/bcryptprimitives_main.c b/dlls/bcryptprimitives/bcryptprimitives_main.c new file mode 100644 index 00000000000..a09b6d613bc --- /dev/null +++ b/dlls/bcryptprimitives/bcryptprimitives_main.c @@ -0,0 +1,44 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windows.h" +#include "ntsecapi.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(bcrypt); + +BOOL WINAPI ProcessPrng(PBYTE pbData, SIZE_T cbData) +{ + if (RtlGenRandom(pbData, cbData)) return TRUE; + + /* ProcessPrng is documented as never failing. */ + FIXME("RtlGenRandom failed in ProcessPrng.\n"); + return FALSE; +} + +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(instance); + break; + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +}
Hans Leidekker (@hans) commented about configure:
enable_avifil32 enable_avrt enable_bcrypt +enable_bcryptprimitives
You don't need to include changes to configure, they will be regenerated from configure.ac when the patch is committed.
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/Makefile.in:
+MODULE = bcryptprimitives.dll +IMPORTS = advapi32 +IMPORTLIB = bcryptprimitives +UNIXLIB = bcryptprimitives.so +UNIX_CFLAGS = $(GNUTLS_CFLAGS)
These three lines are not needed in this patch.
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/Makefile.in:
+MODULE = bcryptprimitives.dll +IMPORTS = advapi32 +IMPORTLIB = bcryptprimitives +UNIXLIB = bcryptprimitives.so +UNIX_CFLAGS = $(GNUTLS_CFLAGS)
+C_SRCS = \
- bcryptprimitives_main.c
Please name the file main.c.
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/bcryptprimitives_main.c:
+/*
- This library is free software; you can redistribute it and/or
The license should have a copyright line.
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/bcryptprimitives_main.c:
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
+#include "windows.h"
windows.h is too much. This should be enough: ``` #include <stdarg.h> #include "windef.h" #include "winbase.h" ```
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/bcryptprimitives_main.c:
+#include "windows.h" +#include "ntsecapi.h"
+#include "wine/debug.h"
+WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
+BOOL WINAPI ProcessPrng(PBYTE pbData, SIZE_T cbData) +{
- if (RtlGenRandom(pbData, cbData)) return TRUE;
- /* ProcessPrng is documented as never failing. */
- FIXME("RtlGenRandom failed in ProcessPrng.\n");
- return FALSE;
+}
There's no need for the FIXME: ``` BOOL WINAPI ProcessPrng(BYTE *data, SIZE_T size) { return RtlGenRandom(data, size); } ``` And then you don't need the wine/debug.h include and debug channel declaration.
Hans Leidekker (@hans) commented about dlls/bcryptprimitives/bcryptprimitives_main.c:
- FIXME("RtlGenRandom failed in ProcessPrng.\n");
- return FALSE;
+}
+BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +{
- switch (reason)
- {
- case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(instance);
break;
- case DLL_PROCESS_DETACH:
break;
- }
- return TRUE;
+}
This is standard DllMain which can be omitted.