ReactOS 0.4.15-dev-8100-g1887773
rand_s.c File Reference
#include <precomp.h>
Include dependency graph for rand_s.c:

Go to the source code of this file.

Typedefs

typedef BOOLEAN(WINAPIPFN_SystemFunction036) (PVOID, ULONG)
 

Functions

int CDECL rand_s (unsigned int *pval)
 

Variables

PFN_SystemFunction036 g_pfnSystemFunction036 = NULL
 

Typedef Documentation

◆ PFN_SystemFunction036

typedef BOOLEAN(WINAPI * PFN_SystemFunction036) (PVOID, ULONG)

Definition at line 12 of file rand_s.c.

Function Documentation

◆ rand_s()

int CDECL rand_s ( unsigned int pval)

Definition at line 18 of file rand_s.c.

19{
20 HINSTANCE hadvapi32;
21
22 if (!pval)
23 {
24 _invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
25 *_errno() = EINVAL;
26 return EINVAL;
27 }
28
29 *pval = 0;
30
32 {
33 PFN_SystemFunction036 pSystemFunction036;
34
35 hadvapi32 = LoadLibraryA("advapi32.dll");
36 if (!hadvapi32)
37 {
38 _invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
39 *_errno() = EINVAL;
40 return EINVAL;
41 }
42
43 pSystemFunction036 = (void*)GetProcAddress(hadvapi32, "SystemFunction036");
44 if (!pSystemFunction036)
45 {
46 _invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
47 *_errno() = EINVAL;
48 FreeLibrary(hadvapi32);
49 return EINVAL;
50 }
51
52 g_pfnSystemFunction036 = pSystemFunction036;
53 }
54
55 if (!g_pfnSystemFunction036(pval, sizeof(*pval)))
56 {
57 _invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
58 *_errno() = EINVAL;
59 return EINVAL;
60 }
61
62 return 0;
63}
#define EINVAL
Definition: acclib.h:90
#define _CRT_WIDE(_String)
Definition: crtdefs.h:55
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
void _invalid_parameter(const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t pReserved)
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
PFN_SystemFunction036 g_pfnSystemFunction036
Definition: rand_s.c:13
BOOLEAN(WINAPI * PFN_SystemFunction036)(PVOID, ULONG)
Definition: rand_s.c:12

Referenced by START_TEST().

Variable Documentation

◆ g_pfnSystemFunction036

PFN_SystemFunction036 g_pfnSystemFunction036 = NULL

Definition at line 13 of file rand_s.c.

Referenced by rand_s().