summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_core.libbin296866 -> 297086 bytes
-rw-r--r--bin10/lib/mir_core64.libbin298324 -> 298526 bytes
-rw-r--r--bin12/lib/mir_core.libbin296866 -> 297086 bytes
-rw-r--r--bin12/lib/mir_core64.libbin298324 -> 298526 bytes
-rw-r--r--include/delphi/m_utils.inc4
-rw-r--r--include/m_utils.h7
-rw-r--r--plugins/Exchange/src/utils.cpp5
-rw-r--r--plugins/MirLua/src/main.cpp3
-rw-r--r--protocols/AimOscar/src/client.cpp2
-rw-r--r--protocols/AimOscar/src/file.cpp2
-rw-r--r--protocols/AimOscar/src/utility.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp2
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp4
-rw-r--r--protocols/MSN/src/msn_auth.cpp5
-rw-r--r--protocols/MSN/src/msn_std.cpp2
-rw-r--r--src/mir_app/src/netlibbind.cpp2
-rw-r--r--src/mir_app/src/utils.cpp22
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/miranda.cpp2
-rw-r--r--src/mir_core/src/miranda.h15
-rw-r--r--src/mir_core/src/utils.cpp12
22 files changed, 47 insertions, 46 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index a972175503..875f73b744 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index 2cbed0f879..2d86f6d572 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index a972175503..875f73b744 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index 2cbed0f879..2d86f6d572 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/include/delphi/m_utils.inc b/include/delphi/m_utils.inc
index d420a05c7b..205f22d9ff 100644
--- a/include/delphi/m_utils.inc
+++ b/include/delphi/m_utils.inc
@@ -311,8 +311,8 @@ function PathIsAbsoluteW(const pSrc:PWideChar):int; stdcall;
Always returns 0
}
-const
- MS_UTILS_GETRANDOM:PAnsiChar = 'Utils/GetRandom';
+procedure Utils_GetRandom(pSrc:pointer; size:size_t); stdcall;
+ external CoreDLL name 'Utils_GetRandom';
//Replace variables in text
//wParam=(char*/TCHAR*/WCHAR*)string (depends on RVF_UNICODE/RVF_TCHAR flag)
diff --git a/include/m_utils.h b/include/m_utils.h
index 843685e2ac..3e8545f766 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -333,7 +333,7 @@ EXTERN_C MIR_CORE_DLL(int) PathIsAbsoluteW(const wchar_t *pSrc);
// lParam = (LPARAM)(char*)pszArray - pointer to array to fill with random number
// Always returns 0
-#define MS_UTILS_GETRANDOM "Utils/GetRandom"
+EXTERN_C MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen);
/////////////////////////////////////////////////////////////////////////////////////////
// Replace variables in text
@@ -440,7 +440,7 @@ __forceinline TCHAR* Utils_ReplaceVarsT(const TCHAR *szData) {
#define ESF_RICHEDIT 3
#define ESF_PASSWORD 4
-typedef struct
+struct ENTER_STRING
{
int cbSize; // structure size
int type; // one of ESF_* constants
@@ -453,8 +453,7 @@ typedef struct
};
int recentCount; // number of combobox strings to store
int timeout; // timeout for the form auto-close
-}
-ENTER_STRING;
+};
/////////////////////////////////////////////////////////////////////////////////////////
// enters one string
diff --git a/plugins/Exchange/src/utils.cpp b/plugins/Exchange/src/utils.cpp
index 2344840601..0919ac6651 100644
--- a/plugins/Exchange/src/utils.cpp
+++ b/plugins/Exchange/src/utils.cpp
@@ -112,12 +112,11 @@ int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult,
{
DBVARIANT dbv = {0};
int res = 1;
- int len;
dbv.type = DBVT_ASCIIZ;
if (db_get_ts(NULL, ModuleName, szSettingName, &dbv) == 0) {
res = 0;
size_t tmp = mir_tstrlen(dbv.ptszVal);
- len = (tmp < size - 1) ? tmp : size - 1;
+ size_t len = (tmp < size - 1) ? tmp : size - 1;
_tcsncpy(szResult, dbv.ptszVal, len);
szResult[len] = '\0';
mir_free(dbv.ptszVal);
@@ -125,7 +124,7 @@ int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult,
else {
res = 1;
size_t tmp = mir_tstrlen(szError);
- len = (tmp < size - 1) ? tmp : size - 1;
+ size_t len = (tmp < size - 1) ? tmp : size - 1;
_tcsncpy(szResult, szError, len);
szResult[len] = '\0';
}
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp
index 618ffb6c67..8e9c71c812 100644
--- a/plugins/MirLua/src/main.cpp
+++ b/plugins/MirLua/src/main.cpp
@@ -50,10 +50,9 @@ int OnOptionsInit(WPARAM wParam, LPARAM)
return 0;
}
-int OnModulesLoaded(WPARAM wParam, LPARAM)
+int OnModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_OPT_INITIALISE, OnOptionsInit);
-
return 0;
}
diff --git a/protocols/AimOscar/src/client.cpp b/protocols/AimOscar/src/client.cpp
index b17a0cdd39..e0c9a29ec7 100644
--- a/protocols/AimOscar/src/client.cpp
+++ b/protocols/AimOscar/src/client.cpp
@@ -345,7 +345,7 @@ int CAimProto::aim_send_message(HANDLE hServerConn,unsigned short &seqno,const c
char* tlv_buf=(char*)alloca(5+msg_len+8);
char icbm_cookie[8];
- CallService(MS_UTILS_GETRANDOM, 8, (LPARAM)icbm_cookie);
+ Utils_GetRandom(icbm_cookie, sizeof(icbm_cookie));
aim_writegeneric(5,"\x05\x01\x00\x01\x01",tlv_offset,tlv_buf); // icbm im capabilities
aim_writeshort(0x0101,tlv_offset,tlv_buf); // icbm im text tag
diff --git a/protocols/AimOscar/src/file.cpp b/protocols/AimOscar/src/file.cpp
index f98060d924..9e075e3f79 100644
--- a/protocols/AimOscar/src/file.cpp
+++ b/protocols/AimOscar/src/file.cpp
@@ -540,7 +540,7 @@ file_transfer::file_transfer(MCONTACT hCont, char* nick, char* cookie)
if (cookie)
memcpy(icbm_cookie, cookie, 8);
else
- CallService(MS_UTILS_GETRANDOM, 8, (LPARAM)icbm_cookie);
+ Utils_GetRandom(icbm_cookie, 8);
hResumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
}
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index 004e195359..d66e920b56 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -674,7 +674,7 @@ unsigned long char_ip_to_long_ip(char* ip)
unsigned short get_random(void)
{
unsigned short id;
- CallService(MS_UTILS_GETRANDOM, sizeof(id), (LPARAM)&id);
+ Utils_GetRandom(&id, sizeof(id));
id &= 0x7fff;
return id;
}
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index 19c74c0acf..4aad3c3838 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -222,7 +222,7 @@ int oauth_sign_request(LIST<OAUTHPARAMETER> &params, const char *httpmethod, con
char* oauth_generate_nonce()
{
char randnum[16];
- CallService(MS_UTILS_GETRANDOM, (WPARAM)sizeof(randnum), (LPARAM)randnum);
+ Utils_GetRandom(randnum, sizeof(randnum));
CMStringA str(FORMAT, "%ld%s", time(NULL), randnum);
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index 24c93439db..9edeb32d7e 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -154,7 +154,7 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
DWORD digest[4], hash1[4], hash2[4];
mir_md5_state_t ctx;
- CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
+ Utils_GetRandom(digest, sizeof(digest));
mir_snprintf(cnonce, _countof(cnonce), "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
T2Utf uname(info->conn.username), passw(info->conn.password);
@@ -306,7 +306,7 @@ char* TScramAuth::getInitialRequest()
T2Utf uname(info->conn.username);
unsigned char nonce[24];
- CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
+ Utils_GetRandom(nonce, sizeof(nonce));
cnonce = mir_base64_encode((PBYTE)nonce, sizeof(nonce));
char buf[4096];
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp
index c866135156..ce01104a1e 100644
--- a/protocols/MSN/src/msn_auth.cpp
+++ b/protocols/MSN/src/msn_auth.cpp
@@ -405,7 +405,7 @@ char* CMsnProto::GenerateLoginBlob(char* challenge)
p += sizeof(MsgrUsrKeyHdr);
unsigned char iv[8];
- CallService(MS_UTILS_GETRANDOM, sizeof(iv), (LPARAM)iv);
+ Utils_GetRandom(iv, sizeof(iv));
memcpy(p, iv, sizeof(iv));
p += sizeof(iv);
@@ -423,11 +423,10 @@ char* CMsnProto::GenerateLoginBlob(char* challenge)
return mir_base64_encode(userKey, (unsigned)pktsz);
}
-
CMStringA CMsnProto::HotmailLogin(const char* url)
{
unsigned char nonce[24];
- CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
+ Utils_GetRandom(nonce, sizeof(nonce));
unsigned key1len;
BYTE *key1 = (BYTE*)mir_base64_decode(hotSecretToken, &key1len);
diff --git a/protocols/MSN/src/msn_std.cpp b/protocols/MSN/src/msn_std.cpp
index c609a54391..a29db7b667 100644
--- a/protocols/MSN/src/msn_std.cpp
+++ b/protocols/MSN/src/msn_std.cpp
@@ -63,6 +63,6 @@ TCHAR* CMsnProto::GetContactNameT(MCONTACT hContact)
unsigned MSN_GenRandom(void)
{
unsigned rndnum;
- CallService(MS_UTILS_GETRANDOM, sizeof(rndnum), (LPARAM)&rndnum);
+ Utils_GetRandom(&rndnum, sizeof(rndnum));
return rndnum & 0x7FFFFFFF;
}
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);
+}