@@ -262,6 +262,8 @@ pub const STACK_SIZE_PARAM_IS_A_RESERVATION: DWORD = 0x00010000;
262262
263263pub const STATUS_SUCCESS : NTSTATUS = 0x00000000 ;
264264
265+ pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG : DWORD = 0x00000002 ;
266+
265267#[ repr( C ) ]
266268#[ cfg( not( target_pointer_width = "64" ) ) ]
267269pub struct WSADATA {
@@ -678,10 +680,6 @@ if #[cfg(not(target_vendor = "uwp"))] {
678680
679681 #[ link( name = "advapi32" ) ]
680682 extern "system" {
681- // Forbidden when targeting UWP
682- #[ link_name = "SystemFunction036" ]
683- pub fn RtlGenRandom ( RandomBuffer : * mut u8 , RandomBufferLength : ULONG ) -> BOOLEAN ;
684-
685683 // Allowed but unused by UWP
686684 pub fn OpenProcessToken (
687685 ProcessHandle : HANDLE ,
@@ -743,8 +741,6 @@ if #[cfg(not(target_vendor = "uwp"))] {
743741// UWP specific functions & types
744742cfg_if:: cfg_if! {
745743if #[ cfg( target_vendor = "uwp" ) ] {
746- pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG : DWORD = 0x00000002 ;
747-
748744 #[ repr( C ) ]
749745 pub struct FILE_STANDARD_INFO {
750746 pub AllocationSize : LARGE_INTEGER ,
@@ -754,15 +750,6 @@ if #[cfg(target_vendor = "uwp")] {
754750 pub Directory : BOOLEAN ,
755751 }
756752
757- #[ link( name = "bcrypt" ) ]
758- extern "system" {
759- pub fn BCryptGenRandom (
760- hAlgorithm: LPVOID ,
761- pBuffer: * mut u8 ,
762- cbBuffer: ULONG ,
763- dwFlags: ULONG ,
764- ) -> LONG ;
765- }
766753 #[ link( name = "kernel32" ) ]
767754 extern "system" {
768755 pub fn GetFileInformationByHandleEx (
@@ -1085,6 +1072,18 @@ extern "system" {
10851072 ) -> c_int ;
10861073}
10871074
1075+ #[ link( name = "bcrypt" ) ]
1076+ extern "system" {
1077+ // >= Vista / Server 2008
1078+ // https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
1079+ pub fn BCryptGenRandom (
1080+ hAlgorithm : LPVOID ,
1081+ pBuffer : * mut u8 ,
1082+ cbBuffer : ULONG ,
1083+ dwFlags : ULONG ,
1084+ ) -> NTSTATUS ;
1085+ }
1086+
10881087// Functions that aren't available on every version of Windows that we support,
10891088// but we still use them and just provide some form of a fallback implementation.
10901089compat_fn ! {
0 commit comments