diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-21 13:43:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-21 13:43:01 +0000 |
commit | 9cb64ba2151b213f5544b2e53c6668061f197b9c (patch) | |
tree | bf4c796a96df96a9875af9d772826937f66ee33c /src | |
parent | bc69e94ff28a1f7cd0c0b99fa7d2702b8807539f (diff) |
MS_UTILS_GETRANDOM -> mir_core::Utils_GetRandom
git-svn-id: http://svn.miranda-ng.org/main/trunk@14299 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/netlibbind.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/utils.cpp | 22 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/miranda.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/src/miranda.h | 15 | ||||
-rw-r--r-- | src/mir_core/src/utils.cpp | 12 |
7 files changed, 30 insertions, 25 deletions
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index 2627b0fc96..4613fab402 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -41,7 +41,7 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn) return false;
WORD num;
- CallService(MS_UTILS_GETRANDOM, sizeof(WORD), (LPARAM)&num);
+ Utils_GetRandom(&num, sizeof(WORD));
*portn = num % *portn;
}
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index 6022c3e87f..64b204da68 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -341,26 +341,6 @@ static INT_PTR RestartMiranda(WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-typedef BOOL (APIENTRY *PGENRANDOM)(PVOID, ULONG);
-
-static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam)
-{
- if (wParam == 0 || lParam == 0) return 0;
-
- PGENRANDOM pfnRtlGenRandom = NULL;
- HMODULE hModule = GetModuleHandleA("advapi32");
- if (hModule) {
- pfnRtlGenRandom = (PGENRANDOM)GetProcAddress(hModule, "SystemFunction036");
- if (pfnRtlGenRandom) {
- if (!pfnRtlGenRandom((PVOID)lParam, wParam))
- pfnRtlGenRandom = NULL;
- }
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
int LoadUtilsModule(void)
{
bModuleInitialized = TRUE;
@@ -368,7 +348,7 @@ int LoadUtilsModule(void) CreateServiceFunction(MS_UTILS_GETCOUNTRYBYNUMBER, GetCountryByNumber);
CreateServiceFunction(MS_UTILS_GETCOUNTRYBYISOCODE, GetCountryByISOCode);
CreateServiceFunction(MS_UTILS_GETCOUNTRYLIST, GetCountryList);
- CreateServiceFunction(MS_UTILS_GETRANDOM, GenerateRandom);
+
CreateServiceFunction(MS_UTILS_ENTERSTRING, svcEnterString);
CreateServiceFunction(MS_SYSTEM_RESTART, RestartMiranda);
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<HINSTANCE__> 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);
+}
|