diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-02-24 16:04:55 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-02-24 16:04:55 +0000 |
commit | 83f05d582cdb837cef1b2c103ebb1e2a00568371 (patch) | |
tree | b5b40d269f65e52efe432e6e913c5d6b8a06276a /protocols/Skype/src/skype_subclassing.cpp | |
parent | 4330f80c5e76c7cbc277ff27e57d3abc308bc915 (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/src/skype_subclassing.cpp')
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 69 |
1 files changed, 35 insertions, 34 deletions
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();
|