diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-02 23:55:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-02 23:55:15 +0300 |
commit | 4882bc420186a4aef19be699e3f621dec932417d (patch) | |
tree | 4bd45d158a1a1470d590edbbb71098721d650333 /src/mir_app | |
parent | 10091bbca1380a1d8e3b9d61b8c175490036af5b (diff) |
MS_SYSTEM_* services became functions
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/clui.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/lpopts.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/miranda.cpp | 64 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/netlibhttpproxy.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/netlibopenconn.cpp | 18 | ||||
-rw-r--r-- | src/mir_app/src/netlibpktrecver.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/netlibupnp.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 2 |
11 files changed, 52 insertions, 62 deletions
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 873caf139f..d884c372af 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -688,7 +688,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM switch (LOWORD(wParam)) {
case ID_TRAY_EXIT:
case ID_ICQ_EXIT:
- if (CallService(MS_SYSTEM_OKTOEXIT, 0, 0))
+ if (Miranda_OkToExit())
DestroyWindow(hwnd);
break;
@@ -1012,7 +1012,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0;
case WM_CLOSE:
- if (CallService(MS_SYSTEM_OKTOEXIT, 0, 0))
+ if (Miranda_OkToExit())
DestroyWindow(hwnd);
return FALSE;
diff --git a/src/mir_app/src/lpopts.cpp b/src/mir_app/src/lpopts.cpp index 8dc230808b..80f1466f49 100644 --- a/src/mir_app/src/lpopts.cpp +++ b/src/mir_app/src/lpopts.cpp @@ -127,7 +127,7 @@ void CLangpackDlg::LoadLangpacks() mir_wstrcpy(pack.tszLanguage, L"English");
pack.szAuthors = "Miranda NG Development Team";
pack.szAuthorEmail = "project-info@miranda-ng.org";
- DWORD v = CallService(MS_SYSTEM_GETVERSION, 0, 0);
+ DWORD v = Miranda_GetVersion();
pack.szLastModifiedUsing.Format("%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF));
if (GetModuleFileName(NULL, pack.tszFullPath, _countof(pack.tszFullPath))) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 2dcaf3ed1b..da19c3658d 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -339,3 +339,8 @@ Srmm_GetNthButton @339 Srmm_GetButtonCount @340
Srmm_ClickToolbarIcon @341
Miranda_WaitOnHandle @342
+Miranda_IsTerminated @343
+Miranda_OkToExit @344
+Miranda_GetVersion @345
+Miranda_GetFileVersion @346
+Miranda_GetVersionText @347
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 73b3111bf1..84a99f806f 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -339,3 +339,8 @@ Srmm_GetNthButton @339 Srmm_GetButtonCount @340
Srmm_ClickToolbarIcon @341
Miranda_WaitOnHandle @342
+Miranda_IsTerminated @343
+Miranda_OkToExit @344
+Miranda_GetVersion @345
+Miranda_GetFileVersion @346
+Miranda_GetVersionText @347
diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index e21b06339e..188785555e 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -102,33 +102,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID) }
/////////////////////////////////////////////////////////////////////////////////////////
-// exception handling
-
-static INT_PTR srvGetExceptionFilter(WPARAM, LPARAM)
-{
- return (INT_PTR)GetExceptionFilter();
-}
-
-static INT_PTR srvSetExceptionFilter(WPARAM, LPARAM lParam)
-{
- return (INT_PTR)SetExceptionFilter((pfnExceptionFilter)lParam);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
typedef LONG(WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG);
#define ThreadQuerySetWin32StartAddress 9
-INT_PTR MirandaIsTerminated(WPARAM, LPARAM)
-{
- return WaitForSingleObject(hMirandaShutdown, 0) == WAIT_OBJECT_0;
-}
-
static void __cdecl compactHeapsThread(void*)
{
Thread_SetName("compactHeapsThread");
- while (!Miranda_Terminated()) {
+ while (!Miranda_IsTerminated()) {
HANDLE hHeaps[256];
DWORD hc;
SleepEx((1000 * 60) * 5, TRUE); // every 5 minutes
@@ -382,12 +364,22 @@ int WINAPI mir_main(LPTSTR cmdLine) return result;
}
-static INT_PTR OkToExit(WPARAM, LPARAM)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(bool) Miranda_IsTerminated()
+{
+ return WaitForSingleObject(hMirandaShutdown, 0) == WAIT_OBJECT_0;
+}
+
+MIR_APP_DLL(bool) Miranda_OkToExit()
{
return NotifyEventHooks(hOkToExitEvent, 0, 0) == 0;
}
-static INT_PTR GetMirandaVersion(WPARAM, LPARAM)
+/////////////////////////////////////////////////////////////////////////////////////////
+// version functions
+
+MIR_APP_DLL(DWORD) Miranda_GetVersion()
{
wchar_t filename[MAX_PATH];
GetModuleFileName(g_hInst, filename, _countof(filename));
@@ -399,14 +391,13 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) UINT blockSize;
VS_FIXEDFILEINFO *vsffi;
VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize);
- DWORD ver = (((vsffi->dwProductVersionMS >> 16) & 0xFF) << 24) |
+ return (((vsffi->dwProductVersionMS >> 16) & 0xFF) << 24) |
((vsffi->dwProductVersionMS & 0xFF) << 16) |
(((vsffi->dwProductVersionLS >> 16) & 0xFF) << 8) |
(vsffi->dwProductVersionLS & 0xFF);
- return (INT_PTR)ver;
}
-static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam)
+MIR_APP_DLL(void) Miranda_GetFileVersion(MFileVersion *pVer)
{
wchar_t filename[MAX_PATH];
GetModuleFileName(g_hInst, filename, _countof(filename));
@@ -419,15 +410,13 @@ static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam) VS_FIXEDFILEINFO *vsffi;
VerQueryValue(pVerInfo, L"\\", (PVOID*)&vsffi, &blockSize);
- WORD* p = (WORD*)lParam;
- p[0] = HIWORD(vsffi->dwProductVersionMS);
- p[1] = LOWORD(vsffi->dwProductVersionMS);
- p[2] = HIWORD(vsffi->dwProductVersionLS);
- p[3] = LOWORD(vsffi->dwProductVersionLS);
- return 0;
+ *pVer[0] = HIWORD(vsffi->dwProductVersionMS);
+ *pVer[1] = LOWORD(vsffi->dwProductVersionMS);
+ *pVer[2] = HIWORD(vsffi->dwProductVersionLS);
+ *pVer[3] = LOWORD(vsffi->dwProductVersionLS);
}
-static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(void) Miranda_GetVersionText(char *pDest, size_t cbSize)
{
wchar_t filename[MAX_PATH], *productVersion;
GetModuleFileName(g_hInst, filename, _countof(filename));
@@ -438,11 +427,10 @@ static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam) UINT blockSize;
VerQueryValue(pVerInfo, L"\\StringFileInfo\\000004b0\\ProductVersion", (LPVOID*)&productVersion, &blockSize);
- strncpy((char*)lParam, _T2A(productVersion), wParam);
+ strncpy_s(pDest, cbSize, _T2A(productVersion), _TRUNCATE);
#if defined(_WIN64)
- strcat_s((char*)lParam, wParam, " x64");
+ strcat_s(pDest, cbSize, " x64");
#endif
- return 0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -455,13 +443,5 @@ int LoadSystemModule(void) hPreShutdownEvent = CreateHookableEvent(ME_SYSTEM_PRESHUTDOWN);
hModulesLoadedEvent = CreateHookableEvent(ME_SYSTEM_MODULESLOADED);
hOkToExitEvent = CreateHookableEvent(ME_SYSTEM_OKTOEXIT);
-
- CreateServiceFunction(MS_SYSTEM_TERMINATED, MirandaIsTerminated);
- CreateServiceFunction(MS_SYSTEM_OKTOEXIT, OkToExit);
- CreateServiceFunction(MS_SYSTEM_GETVERSION, GetMirandaVersion);
- CreateServiceFunction(MS_SYSTEM_GETFILEVERSION, GetMirandaFileVersion);
- CreateServiceFunction(MS_SYSTEM_GETVERSIONTEXT, GetMirandaVersionText);
- CreateServiceFunction(MS_SYSTEM_GETEXCEPTFILTER, srvGetExceptionFilter);
- CreateServiceFunction(MS_SYSTEM_SETEXCEPTFILTER, srvSetExceptionFilter);
return 0;
}
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index cc83510207..d229b1712b 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -97,7 +97,7 @@ static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, ch return NLRecv(nlc, buf, len, flags);
}
- if (nlc->termRequested || Miranda_Terminated())
+ if (nlc->termRequested || Miranda_IsTerminated())
return 0;
}
SetLastError(ERROR_TIMEOUT);
@@ -303,7 +303,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, SetLastError(ERROR_BUFFER_OVERFLOW);
return 0;
}
- if (Miranda_Terminated())
+ if (Miranda_IsTerminated())
return 0;
Sleep(10);
}
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp index 4f1caf3f2b..b8fd51fcb1 100644 --- a/src/mir_app/src/netlibhttpproxy.cpp +++ b/src/mir_app/src/netlibhttpproxy.cpp @@ -266,7 +266,7 @@ int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags) if (nlc->pHttpProxyPacketQueue != NULL && GetTickCount() - nlc->lastPost > 1000)
break;
- if (nlc->termRequested || (SleepEx(1000, TRUE) && Miranda_Terminated()))
+ if (nlc->termRequested || (SleepEx(1000, TRUE) && Miranda_IsTerminated()))
return SOCKET_ERROR;
}
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index 0dd4312c59..40feea10d5 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -367,7 +367,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) ReleaseMutex(hConnectionOpenMutex); // might of died in between the wait - if (Miranda_Terminated()) return false; + if (Miranda_IsTerminated()) return false; } PHOSTENT he; @@ -393,7 +393,7 @@ static bool my_connectIPv4(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) he = gethostbyname(nloc->szHost); } - for (char** har = he->h_addr_list; *har && !Miranda_Terminated(); ++har) { + for (char** har = he->h_addr_list; *har && !Miranda_IsTerminated(); ++har) { sin.sin_addr.s_addr = *(u_long*)*har; char* szIp = NetlibAddressToString((SOCKADDR_INET_M*)&sin); @@ -459,7 +459,7 @@ retry: } break; } - else if (Miranda_Terminated()) { + else if (Miranda_IsTerminated()) { rc = SOCKET_ERROR; lasterr = ERROR_TIMEOUT; break; @@ -510,7 +510,7 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) ReleaseMutex(hConnectionOpenMutex); // might of died in between the wait - if (Miranda_Terminated()) return false; + if (Miranda_IsTerminated()) return false; } char szPort[6]; @@ -553,7 +553,7 @@ static bool my_connectIPv6(NetlibConnection *nlc, NETLIBOPENCONNECTION *nloc) } } - for (ai = air; ai && !Miranda_Terminated(); ai = ai->ai_next) { + for (ai = air; ai && !Miranda_IsTerminated(); ai = ai->ai_next) { NetlibLogf(nlc->nlu, "(%p) Connecting to ip %s ....", nlc, ptrA(NetlibAddressToString((SOCKADDR_INET_M*)ai->ai_addr))); retry: nlc->s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); @@ -622,7 +622,7 @@ retry: } break; } - else if (Miranda_Terminated()) { + else if (Miranda_IsTerminated()) { rc = SOCKET_ERROR; lasterr = ERROR_TIMEOUT; break; @@ -804,7 +804,7 @@ bool NetlibReconnect(NetlibConnection *nlc) } if (!opened) { - if (Miranda_Terminated()) + if (Miranda_IsTerminated()) return false; if (nlc->usingHttpGateway) { @@ -888,8 +888,8 @@ NetlibConnection::~NetlibConnection() if (s != INVALID_SOCKET) closesocket(s); - mir_free(szNewUrl);
- mir_free(szProxyServer);
+ mir_free(szNewUrl); + mir_free(szProxyServer); mir_free(nlhpi.szHttpPostUrl); mir_free(nlhpi.szHttpGetUrl); diff --git a/src/mir_app/src/netlibpktrecver.cpp b/src/mir_app/src/netlibpktrecver.cpp index 4383ba841f..456ff10634 100644 --- a/src/mir_app/src/netlibpktrecver.cpp +++ b/src/mir_app/src/netlibpktrecver.cpp @@ -58,7 +58,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) SetLastError(ERROR_INVALID_PARAMETER);
return SOCKET_ERROR;
}
- if (Miranda_Terminated()) { /* HACK: Lame, break while loops of protocols that can't kill their while loops, (cough, ICQ, cough) */
+ if (Miranda_IsTerminated()) { /* HACK: Lame, break while loops of protocols that can't kill their while loops, (cough, ICQ, cough) */
SetLastError(ERROR_TIMEOUT);
return SOCKET_ERROR;
}
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp index 4107cd7958..5979624949 100644 --- a/src/mir_app/src/netlibupnp.cpp +++ b/src/mir_app/src/netlibupnp.cpp @@ -595,7 +595,7 @@ static void discoverUPnP(void) LongLog(buf);
}
- if (Miranda_Terminated()) break;
+ if (Miranda_IsTerminated()) break;
FD_ZERO(&readfd);
FD_SET(s, &readfd);
@@ -760,7 +760,7 @@ void NetlibUPnPCleanup(void*) num = atol(buf);
WORD ports[30];
- for (unsigned i = 0; i < num && !Miranda_Terminated(); i++) {
+ for (unsigned i = 0; i < num && !Miranda_IsTerminated(); i++) {
mir_snprintf(szData, 4096, get_port_mapping, i);
ReleaseMutex(portListMutex);
@@ -792,7 +792,7 @@ void NetlibUPnPCleanup(void*) ReleaseMutex(portListMutex);
- for (unsigned i = 0; i < j && !Miranda_Terminated(); i++)
+ for (unsigned i = 0; i < j && !Miranda_IsTerminated(); i++)
NetlibUPnPDeletePortMapping(ports[i], "TCP");
}
}
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 9fbb3e9b4a..aa948c6fb6 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -864,7 +864,7 @@ int LoadNewPluginsModuleInfos(void) LoadPluginOptions();
hPluginListHeap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
- mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
+ mirandaVersion = Miranda_GetVersion();
// remember where the mirandaboot.ini goes
PathToAbsoluteW(L"mirandaboot.ini", mirandabootini);
|