summaryrefslogtreecommitdiff
path: root/protocols/Skype
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-02-24 16:04:55 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-02-24 16:04:55 +0000
commit83f05d582cdb837cef1b2c103ebb1e2a00568371 (patch)
treeb5b40d269f65e52efe432e6e913c5d6b8a06276a /protocols/Skype
parent4330f80c5e76c7cbc277ff27e57d3abc308bc915 (diff)
fixes crashes for work with last proto changes
git-svn-id: http://svn.miranda-ng.org/main/trunk@3756 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r--protocols/Skype/src/skype_account.cpp14
-rw-r--r--protocols/Skype/src/skype_netlib.cpp2
-rw-r--r--protocols/Skype/src/skype_proto.cpp8
-rw-r--r--protocols/Skype/src/skype_runtime.cpp2
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp69
5 files changed, 55 insertions, 40 deletions
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp
index 6002061a6f..e4e2887481 100644
--- a/protocols/Skype/src/skype_account.cpp
+++ b/protocols/Skype/src/skype_account.cpp
@@ -32,8 +32,11 @@ void CSkypeProto::OnAccountChanged(int prop)
if (this->rememberPassword && whyLogout == CAccount::INCORRECT_PASSWORD)
{
this->rememberPassword = false;
- if (this->password)
+ if (this->password)
+ {
::mir_free(this->password);
+ this->password = NULL;
+ }
}
}
}
@@ -81,7 +84,10 @@ bool CSkypeProto::IsOnline()
void __cdecl CSkypeProto::SignInAsync(void*)
{
if ( !this->rememberPassword)
+ {
::mir_free(this->password);
+ this->password = NULL;
+ }
else
{
::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), LPARAM(this->password));
@@ -109,12 +115,18 @@ bool CSkypeProto::SignIn(int status)
if ( !this->rememberPassword)
{
if (this->password)
+ {
::mir_free(this->password);
+ this->password = NULL;
+ }
this->password = ::DBGetString(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
if ( !this->password || !::strlen(this->password))
{
if (this->password)
+ {
::mir_free(this->password);
+ this->password = NULL;
+ }
PasswordRequestBoxParam param(this->login);
if ( !this->RequestPassword(param))
{
diff --git a/protocols/Skype/src/skype_netlib.cpp b/protocols/Skype/src/skype_netlib.cpp
index 0ff4e3c9e9..7401e8c84e 100644
--- a/protocols/Skype/src/skype_netlib.cpp
+++ b/protocols/Skype/src/skype_netlib.cpp
@@ -84,7 +84,7 @@ void CSkypeProto::Log(const wchar_t *fmt, ...)
wchar_t msg[1024];
va_start(va, fmt);
- ::mir_vsntprintf(msg, sizeof(msg), fmt, va);
+ ::mir_vsntprintf(msg, SIZEOF(msg), fmt, va);
va_end(va);
::CallService(MS_NETLIB_LOGW, (WPARAM)this->hNetLibUser, (LPARAM)msg);
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 18a8483897..c5014171b4 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -5,7 +5,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
ProtoConstructor(this, protoName, userName);
//this->login = NULL;
- this->password = NULL;
+ //this->password = NULL;
this->rememberPassword = false;
this->signin_lock = CreateMutex(0, false, 0);
@@ -27,7 +27,11 @@ CSkypeProto::~CSkypeProto()
::CloseHandle(this->signin_lock);
::mir_free(this->login);
- ::mir_free(this->password);
+ if (this->password)
+ {
+ ::mir_free(this->password);
+ this->password = NULL;
+ }
ProtoDestructor(this);
}
diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp
index ea2f11b835..eb0bf0ccfd 100644
--- a/protocols/Skype/src/skype_runtime.cpp
+++ b/protocols/Skype/src/skype_runtime.cpp
@@ -2,8 +2,6 @@
void CSkypeProto::InitSkype()
{
- int port = 8963;
-
wchar_t *profileName = ::Utils_ReplaceVarsT(L"%miranda_profilename%");
wchar_t *dbPath = ::Utils_ReplaceVarsT(L"%miranda_userdata%\\SkypeKit\\");
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index 7b7652c880..7c7d91d3eb 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -117,10 +117,10 @@ Cleanup:
char *CSkype::LoadKeyPair(HINSTANCE hInstance)
{
HRSRC hRes = FindResource(hInstance, MAKEINTRESOURCE(/*IDR_KEY*/107), L"BIN");
- if (hRes)
+ if (hRes)
{
HGLOBAL hResource = LoadResource(hInstance, hRes);
- if (hResource)
+ if (hResource)
{
aes_context ctx;
unsigned char key[128];
@@ -155,7 +155,7 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
PROCESS_INFORMATION pi;
wchar_t param[128];
- ::ZeroMemory(&cif, sizeof(STARTUPINFO));
+ ::ZeroMemory(&cif, sizeof(STARTUPINFO));
cif.cb = sizeof(STARTUPINFO);
cif.dwFlags = STARTF_USESHOWWINDOW;
cif.wShowWindow = SW_HIDE;
@@ -170,11 +170,11 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
HGLOBAL hResource = ::LoadResource(hInstance, hRes);
if (hResource)
{
- HANDLE hFile;
- char *pData = (char *)LockResource(hResource);
- DWORD dwSize = SizeofResource(hInstance, hRes), written = 0;
+ HANDLE hFile;
+ char *pData = (char *)LockResource(hResource);
+ DWORD dwSize = SizeofResource(hInstance, hRes), written = 0;
::GetModuleFileName(hInstance, fileName, MAX_PATH);
-
+
wchar_t *skypeKitPath = ::wcsrchr(fileName, '\\');
if (skypeKitPath != NULL)
*skypeKitPath = 0;
@@ -182,13 +182,13 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
if ( !::PathFileExists(fileName))
{
if ((hFile = ::CreateFile(
- fileName,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- 0)) != INVALID_HANDLE_VALUE)
+ fileName,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0)) != INVALID_HANDLE_VALUE)
{
::WriteFile(hFile, (void *)pData, dwSize, &written, NULL);
::CloseHandle(hFile);
@@ -202,10 +202,10 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
wchar_t path[MAX_PATH], cmdLine[100];
::GetModuleFileName(NULL, path, ARRAYSIZE(path));
::swprintf(
- cmdLine,
- SIZEOF(cmdLine),
- L" /restart:%d /profile=%s",
- ::GetCurrentProcessId(),
+ cmdLine,
+ SIZEOF(cmdLine),
+ L" /restart:%d /profile=%s",
+ ::GetCurrentProcessId(),
profileName);
// Launch itself as administrator.
@@ -237,27 +237,28 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
}
}
- PROCESSENTRY32 entry;
- entry.dwSize = sizeof(PROCESSENTRY32);
+ PROCESSENTRY32 entry;
+ entry.dwSize = sizeof(PROCESSENTRY32);
- HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
- if (::Process32First(snapshot, &entry) == TRUE) {
- while (::Process32Next(snapshot, &entry) == TRUE) {
- if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0) {
- HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
+ HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
+ if (::Process32First(snapshot, &entry) == TRUE) {
+ while (::Process32Next(snapshot, &entry) == TRUE) {
+ if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0) {
+ HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
port += rand() % 8963 + 1000;
- ::CloseHandle(hProcess);
+ ::CloseHandle(hProcess);
break;
- }
- }
- }
- ::CloseHandle(snapshot);
+ }
+ }
+ }
+ ::CloseHandle(snapshot);
- ::swprintf(param, SIZEOF(param), L"-p -P %d -f %s", port, dbPath);
+ //::swprintf(param, SIZEOF(param), L"-p -P %d -f %s", port, dbPath);
+ ::swprintf(param, SIZEOF(param), L"-p -P %d", port);
int startingrt = ::CreateProcess(
- fileName, param,
- NULL, NULL, FALSE,
- CREATE_NEW_CONSOLE,
+ fileName, param,
+ NULL, NULL, FALSE,
+ CREATE_NEW_CONSOLE,
NULL, NULL, &cif, &pi);
DWORD rterr = GetLastError();