[CRT]
authorSylvain Petreolle <spetreolle@yahoo.fr>
Wed, 7 Jul 2010 20:05:47 +0000 (20:05 +0000)
committerSylvain Petreolle <spetreolle@yahoo.fr>
Wed, 7 Jul 2010 20:05:47 +0000 (20:05 +0000)
-Export memmove_s and memcpy_s
-Implement rnd_s

svn path=/trunk/; revision=47964

reactos/dll/win32/msvcrt/msvcrt.spec
reactos/lib/sdk/crt/math/rand.c

index 98bdd1c..3a9c7cf 100644 (file)
 @ 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)
 # 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)
 @ varargs wscanf(wstr) 
 # @ varargs wscanf_s(wstr)
 
+# Functions not exported in native dll:
+@ cdecl _get_invalid_parameter_handler()
+@ cdecl _set_invalid_parameter_handler(ptr)
index 4d560a2..598d72b 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <precomp.h>
-//#include <Ntsecapi.h>
+#include <ntsecapi.h>
 #include <internal/tls.h>
 
 /*
@@ -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;
 }