mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:32:57 +00:00
[CRT] Move rand_s into it's own file
This commit is contained in:
parent
0ea48e79fc
commit
f319538d98
4 changed files with 72 additions and 45 deletions
|
@ -26,48 +26,3 @@ srand(unsigned int seed)
|
|||
thread_data_t *data = msvcrt_get_thread_data();
|
||||
data->random_seed = seed;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* rand_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL rand_s(unsigned int *pval)
|
||||
{
|
||||
BOOLEAN (WINAPI *pSystemFunction036)(PVOID, ULONG); // RtlGenRandom
|
||||
HINSTANCE hadvapi32;
|
||||
|
||||
if (!pval)
|
||||
{
|
||||
_invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
|
||||
*_errno() = EINVAL;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*pval = 0;
|
||||
hadvapi32 = LoadLibraryA("advapi32.dll");
|
||||
if (!hadvapi32)
|
||||
{
|
||||
_invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
|
||||
*_errno() = EINVAL;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
pSystemFunction036 = (void*)GetProcAddress(hadvapi32, "SystemFunction036");
|
||||
if (!pSystemFunction036)
|
||||
{
|
||||
_invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
|
||||
*_errno() = EINVAL;
|
||||
FreeLibrary(hadvapi32);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (!pSystemFunction036(pval, sizeof(*pval)))
|
||||
{
|
||||
_invalid_parameter(NULL,_CRT_WIDE("rand_s"),_CRT_WIDE(__FILE__),__LINE__, 0);
|
||||
*_errno() = EINVAL;
|
||||
FreeLibrary(hadvapi32);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
FreeLibrary(hadvapi32);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue