dllentry.cpp
上传用户:kittypts
上传日期:2018-02-11
资源大小:241k
文件大小:5k
- /*****************************************************************************
- Windows Live Messenger Plugin Demo
- Copyright (C) 2008 Hern醤 Di Pietro
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- /*****************************************************************************/
- #include "wlmplugin.h"
- #include "cinfownd.h"
- #include "clrzwind.h"
- #include "aboutdlg.h"
- #include "../resdll/resource.h"
- #include "shellapi.h"
- HMODULE hResLib = NULL; // Handle to resource DLL
- char * szXmlRes; // XML Resource string
- char * szStyle; // XML Resource style string
- HINSTANCE hDllInst; // Handle of this DLL
- // ---------------------------------------------------------------------------
- // DLL Entry point
- // ---------------------------------------------------------------------------
- BOOL APIENTRY DllMain (HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
- {
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- OutputDebugString (L"msnhacklib attaching...");
- hDllInst = hInstDll;
- break;
- case DLL_PROCESS_DETACH:
-
- // Shutdown
- OutputDebugString (L"msnhacklib detaching...");
- g_hookList.clear();
- UnhookWinEvent(g_wlmTopWindow.hwevh);
- g_wlmIfaces.pIMsn->Release();
- CoUninitialize();
- FreeLibrary(hResLib);
- delete[] szStyle;
- delete[] szXmlRes;
- break;
- }
- return TRUE;
- }
- void mplayrun(void* p)
- {
- ShellExecute(0, L"open", L"wmplayer.exe", 0, 0, SW_SHOWNA );
- }
- void webnkt(void* p)
- {
- ShellExecute(0, L"open", L"http://www.nektra.com/products/deviare/trappola/index.php", 0, 0, SW_SHOWNA );
- }
- // ---------------------------------------------------------------------------
- // Sets the current directory to WLM directory reading the setting from
- // registry key
- // ---------------------------------------------------------------------------
- void SetCurrentDirToWlmDir()
- {
- HKEY hk;
- DWORD bufSize = MAX_PATH;
- BYTE buf[MAX_PATH];
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\Microsoft\Windows Live\Messenger",0, KEY_READ, &hk);
- RegQueryValueEx(hk, L"InstallationDirectory", NULL, NULL, (BYTE*)buf, &bufSize);
- SetCurrentDirectory((WCHAR*)buf);
- RegCloseKey(hk);
- }
- // ---------------------------------------------------------------------------
- // Initializes the WLM injected library
- // ---------------------------------------------------------------------------
- void InitDLL()
- {
- OutputDebugString (L"InitDLL: Starting up...n");
- CoInitialize(0);
- // Load Resource DLL
- hResLib = LoadLibrary(wszResourceDll);
- // Set the WLM top level window info
- g_wlmTopWindow.szWndClass = wszWlmMainWndClass;
- g_wlmTopWindow.szWndName = wszWlmMainWndName;
- g_DUIWindow.szWndClass = wszWlmDUIWndClass;
- g_wlmTopWindow.fEnableInfoWnd = false;
- // Set current directory to WLM dir
- SetCurrentDirToWlmDir();
- // Initialize structures
- SecureZeroMemory(&g_wlmIfaces, sizeof(WLM_IFACES));
- // Create the colorized window instances (contact info, about dlg)
- // after registering the colorized window class
- if (RegisterColorizedWndClass())
- {
- CreateContactInfoWnd(&g_wlmContactInfoWindow.hwnd);
- CreateAboutDlg (&g_hwndNktAbout);
- }
- // test toolbar buttons
- WLM_TOOLBARBUTTON tbb[2];
-
- tbb[0].fExtBitmap = TRUE;
- tbb[0].hModule = hResLib;
- tbb[0].pfnAct = mplayrun;
- tbb[0].uPosition = TB_INSERT_FIRST;
- tbb[0].uResID = IDB_MPLAYER;
- wcscpy_s(tbb[0].wszResType, MAXSTRL, L"PNG");
- strcpy_s(tbb[0].szButtonId, MAXSTRL, "BUTTONMPLAYER");
- wcscpy_s(tbb[0].wszButtonId, MAXSTRL, L"BUTTONMPLAYER");
- strcpy_s(tbb[0].szTButtonId, MAXSTRL, "ToolButtonMplayer");
- strcpy_s(tbb[0].szTooltip , MAXSTRL, "Run Media Player");
- tbb[1].fExtBitmap = TRUE;
- tbb[1].hModule = hResLib;
- tbb[1].pfnAct = webnkt;
- tbb[1].uPosition = TB_INSERT_FIRST;
- tbb[1].uResID = IDB_NKT;
- wcscpy_s(tbb[1].wszResType, MAXSTRL, L"PNG");
- strcpy_s(tbb[1].szButtonId, MAXSTRL, "BUTTONWEB");
- wcscpy_s(tbb[1].wszButtonId, MAXSTRL, L"BUTTONWEB");
- strcpy_s(tbb[1].szTButtonId, MAXSTRL, "ToolButtonMSIE");
- strcpy_s(tbb[1].szTooltip, MAXSTRL, "Go Trappola Library Website");
- const size_t cbBufSz = 1024;
- char * szXmlRes = new char[cbBufSz];
- char * szStyle = new char[cbBufSz];
- AddToolbarButtons(tbb, 2, szXmlRes, szStyle, cbBufSz, cbBufSz);
- // attach our hooks
- AttachHookArray (hookArray, g_hookList);
- }
-