diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec index 98bdd1ccf88..3a9c7cf5a8b 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.spec +++ b/reactos/dll/win32/msvcrt/msvcrt.spec @@ -1266,9 +1266,9 @@ @ cdecl memchr(ptr long long) @ cdecl memcmp(ptr ptr long) @ cdecl memcpy(ptr ptr long) -# @ cdecl memcpy_s(ptr long ptr long) memmove_s +@ cdecl memcpy_s(ptr long ptr long) memmove_s @ cdecl memmove(ptr ptr long) -# @ cdecl memmove_s(ptr long ptr long) +@ cdecl memmove_s(ptr long ptr long) @ cdecl memset(ptr long long) @ cdecl mktime(ptr) @ cdecl modf(double ptr) @@ -1285,7 +1285,7 @@ # stub qsort_s @ cdecl raise(long) @ cdecl rand() -# @ cdecl rand_s(ptr) +@ cdecl rand_s(ptr) @ cdecl realloc(ptr long) @ cdecl remove(str) @ cdecl rename(str str) @@ -1405,3 +1405,6 @@ @ varargs wscanf(wstr) # @ varargs wscanf_s(wstr) +# Functions not exported in native dll: +@ cdecl _get_invalid_parameter_handler() +@ cdecl _set_invalid_parameter_handler(ptr) diff --git a/reactos/lib/sdk/crt/math/rand.c b/reactos/lib/sdk/crt/math/rand.c index 4d560a2aac4..598d72b6d90 100644 --- a/reactos/lib/sdk/crt/math/rand.c +++ b/reactos/lib/sdk/crt/math/rand.c @@ -1,6 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include -//#include +#include #include /* @@ -31,12 +31,17 @@ srand(unsigned int seed) */ int CDECL rand_s(unsigned int *pval) { -#if 0 - if (!pval || !RtlGenRandom(pval, sizeof(*pval))) + BOOLEAN (WINAPI *pSystemFunction036)(PVOID, ULONG); // RtlGenRandom + HINSTANCE hadvapi32 = LoadLibraryA("advapi32.dll"); + pSystemFunction036 = (void*)GetProcAddress(hadvapi32, "SystemFunction036"); +#if 1 + if (!pval || (pSystemFunction036 && !pSystemFunction036(pval, sizeof(*pval)))) { + _invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0); *_errno() = EINVAL; return EINVAL; } #endif + if(hadvapi32) FreeLibrary(hadvapi32); return 0; }