@@ -262,6 +262,8 @@ pub const STACK_SIZE_PARAM_IS_A_RESERVATION: DWORD = 0x00010000;
262
262
263
263
pub const STATUS_SUCCESS : NTSTATUS = 0x00000000 ;
264
264
265
+ pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG : DWORD = 0x00000002 ;
266
+
265
267
#[ repr( C ) ]
266
268
#[ cfg( not( target_pointer_width = "64" ) ) ]
267
269
pub struct WSADATA {
@@ -678,10 +680,6 @@ if #[cfg(not(target_vendor = "uwp"))] {
678
680
679
681
#[ link( name = "advapi32" ) ]
680
682
extern "system" {
681
- // Forbidden when targeting UWP
682
- #[ link_name = "SystemFunction036" ]
683
- pub fn RtlGenRandom ( RandomBuffer : * mut u8 , RandomBufferLength : ULONG ) -> BOOLEAN ;
684
-
685
683
// Allowed but unused by UWP
686
684
pub fn OpenProcessToken (
687
685
ProcessHandle : HANDLE ,
@@ -743,8 +741,6 @@ if #[cfg(not(target_vendor = "uwp"))] {
743
741
// UWP specific functions & types
744
742
cfg_if:: cfg_if! {
745
743
if #[ cfg( target_vendor = "uwp" ) ] {
746
- pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG : DWORD = 0x00000002 ;
747
-
748
744
#[ repr( C ) ]
749
745
pub struct FILE_STANDARD_INFO {
750
746
pub AllocationSize : LARGE_INTEGER ,
@@ -754,15 +750,6 @@ if #[cfg(target_vendor = "uwp")] {
754
750
pub Directory : BOOLEAN ,
755
751
}
756
752
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
- }
766
753
#[ link( name = "kernel32" ) ]
767
754
extern "system" {
768
755
pub fn GetFileInformationByHandleEx (
@@ -1085,6 +1072,18 @@ extern "system" {
1085
1072
) -> c_int ;
1086
1073
}
1087
1074
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
+
1088
1087
// Functions that aren't available on every version of Windows that we support,
1089
1088
// but we still use them and just provide some form of a fallback implementation.
1090
1089
compat_fn ! {
0 commit comments