From 9cb64ba2151b213f5544b2e53c6668061f197b9c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jun 2015 13:43:01 +0000 Subject: MS_UTILS_GETRANDOM -> mir_core::Utils_GetRandom git-svn-id: http://svn.miranda-ng.org/main/trunk@14299 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + src/mir_core/src/miranda.cpp | 2 ++ src/mir_core/src/miranda.h | 15 ++++++++++++--- src/mir_core/src/utils.cpp | 12 ++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index a86369bacb..d12bbf2897 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -970,3 +970,4 @@ TimeZone_ToString @1127 TimeZone_ToStringW @1128 TimeZone_UtcToLocal @1129 Utils_ResizeDialog @1130 +Utils_GetRandom @1131 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 0bf6458503..3cd65aa139 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -970,3 +970,4 @@ TimeZone_ToString @1127 TimeZone_ToStringW @1128 TimeZone_UtcToLocal @1129 Utils_ResizeDialog @1130 +Utils_GetRandom @1131 diff --git a/src/mir_core/src/miranda.cpp b/src/mir_core/src/miranda.cpp index 610d5382c0..3cbbba3086 100644 --- a/src/mir_core/src/miranda.cpp +++ b/src/mir_core/src/miranda.cpp @@ -91,6 +91,8 @@ static void LoadCoreModule(void) InitTimeZones(); InitialiseModularEngine(); InitMetaContacts(); + + pfnRtlGenRandom = (PGENRANDOM)GetProcAddress(GetModuleHandleA("advapi32"), "SystemFunction036"); } MIR_CORE_DLL(void) UnloadCoreModule(void) diff --git a/src/mir_core/src/miranda.h b/src/mir_core/src/miranda.h index 74f8eed4dd..525a99d1d9 100644 --- a/src/mir_core/src/miranda.h +++ b/src/mir_core/src/miranda.h @@ -42,7 +42,8 @@ extern HWND hAPCWindow; extern HANDLE hStackMutex, hThreadQueueEmpty; extern MIDatabase *currDb; -/**** modules.cpp **********************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// +// modules.cpp struct THookSubscriber { @@ -81,11 +82,19 @@ struct THook extern LIST pluginListAddr; -/**** langpack.cpp *********************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// +// langpack.cpp char* LangPackTranslateString(MUUID* pUuid, const char *szEnglish, const int W); TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish); -/**** threads.cpp **********************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// +// threads.cpp extern DWORD mir_tls; + +///////////////////////////////////////////////////////////////////////////////////////// +// utils.cpp + +typedef BOOL(APIENTRY *PGENRANDOM)(PVOID, ULONG); +extern PGENRANDOM pfnRtlGenRandom; diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index 53c5f5c83f..af1685a63e 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -409,3 +409,15 @@ MIR_CORE_DLL(int) mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2) return 1; return CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, p1, -1, p2, -1) - 2; } + +///////////////////////////////////////////////////////////////////////////////////////// + +PGENRANDOM pfnRtlGenRandom; + +MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen) +{ + if (pszDest != 0 || cbLen != 0 && pfnRtlGenRandom != NULL) + pfnRtlGenRandom(pszDest, (ULONG)cbLen); + else + memset(pszDest, 0, cbLen); +} -- cgit v1.2.3