Left: | ||
Right: |
OLD | NEW |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
6 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
10 #include "PluginClient.h" | 10 #include "PluginClient.h" |
11 #include "PluginClientFactory.h" | 11 #include "PluginClientFactory.h" |
12 #include "PluginMutex.h" | 12 #include "PluginMutex.h" |
13 #include "sddl.h" | 13 #include "sddl.h" |
14 #include "PluginUtil.h" | 14 #include "PluginUtil.h" |
15 #include "PluginUserSettings.h" | 15 #include "PluginUserSettings.h" |
16 #include "../shared/Utils.h" | 16 #include "../shared/Utils.h" |
17 #include "../shared/Dictionary.h" | 17 #include "../shared/Dictionary.h" |
18 #include <thread> | 18 #include <thread> |
19 #include <array> | |
19 | 20 |
20 #ifdef DEBUG_HIDE_EL | 21 #ifdef DEBUG_HIDE_EL |
21 DWORD profileTime = 0; | 22 DWORD profileTime = 0; |
22 #endif | 23 #endif |
23 | 24 |
24 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 25 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
25 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); | 26 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); |
26 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 27 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
27 | 28 |
28 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 29 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 414 |
414 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | 415 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); |
415 } | 416 } |
416 | 417 |
417 bool CPluginClass::IsStatusBarEnabled() | 418 bool CPluginClass::IsStatusBarEnabled() |
418 { | 419 { |
419 DEBUG_GENERAL("IsStatusBarEnabled start"); | 420 DEBUG_GENERAL("IsStatusBarEnabled start"); |
420 HKEY pHkey; | 421 HKEY pHkey; |
421 HKEY pHkeySub; | 422 HKEY pHkeySub; |
422 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); | 423 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); |
423 DWORD trueth = 1; | 424 DWORD trueth = 1; |
Oleksandr
2014/10/06 20:19:32
That typo really jumps at me with this change. Min
| |
424 DWORD truethSize = sizeof(DWORD); | 425 DWORD truethSize = sizeof(trueth); |
425 RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub); | 426 RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\Main", &pHkeySub); |
426 LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&true th, &truethSize); | 427 LONG res = RegQueryValueEx(pHkeySub, L"StatusBarWeb", NULL, NULL, (BYTE*)&true th, &truethSize); |
427 RegCloseKey(pHkey); | 428 RegCloseKey(pHkey); |
428 if (res != ERROR_SUCCESS) | 429 if (res != ERROR_SUCCESS) |
429 { | 430 { |
430 res = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &p HkeySub); | 431 res = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\MINIE", &p HkeySub); |
431 if (res == ERROR_SUCCESS) | 432 if (res == ERROR_SUCCESS) |
432 { | 433 { |
433 LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*) &trueth, &truethSize); | 434 LONG res = RegQueryValueEx(pHkeySub, L"ShowStatusBar", NULL, NULL, (BYTE*) &trueth, &truethSize); |
434 if (res == ERROR_SUCCESS) | 435 if (res == ERROR_SUCCESS) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 } | 479 } |
479 // Ask if a user wants to enable a status bar automatically | 480 // Ask if a user wants to enable a status bar automatically |
480 LRESULT res = MessageBox((HWND)m_hTabWnd, | 481 LRESULT res = MessageBox((HWND)m_hTabWnd, |
481 dictionary->Lookup("status-bar", "question").c_str(), | 482 dictionary->Lookup("status-bar", "question").c_str(), |
482 dictionary->Lookup("status-bar", "title").c_str(), | 483 dictionary->Lookup("status-bar", "title").c_str(), |
483 MB_YESNO); | 484 MB_YESNO); |
484 if (res == IDYES) | 485 if (res == IDYES) |
485 { | 486 { |
486 DWORD trueth = 1; | 487 DWORD trueth = 1; |
487 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M INIE", &pHkeySub); | 488 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M INIE", &pHkeySub); |
488 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE *)&trueth, sizeof(DWORD)); | 489 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE *)&trueth, sizeof(trueth)); |
489 regRes = RegCloseKey(pHkeySub); | 490 regRes = RegCloseKey(pHkeySub); |
490 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M ain", &pHkeySub); | 491 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M ain", &pHkeySub); |
491 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE* )&trueth, sizeof(DWORD)); | 492 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE* )&trueth, sizeof(trueth)); |
492 regRes = RegCloseKey(pHkeySub); | 493 regRes = RegCloseKey(pHkeySub); |
493 hr = browser->put_StatusBar(TRUE); | 494 hr = browser->put_StatusBar(TRUE); |
494 if (FAILED(hr)) | 495 if (FAILED(hr)) |
495 { | 496 { |
496 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar"); | 497 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR, "Class::Enable statusbar"); |
497 } | 498 } |
498 CreateStatusBarPane(); | 499 CreateStatusBarPane(); |
499 | 500 |
500 // We need to restart the tab now, to enable the status bar properly | 501 // We need to restart the tab now, to enable the status bar properly |
501 VARIANT vFlags; | 502 VARIANT vFlags; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 } | 807 } |
807 } | 808 } |
808 } | 809 } |
809 s_criticalSectionLocal.Unlock(); | 810 s_criticalSectionLocal.Unlock(); |
810 | 811 |
811 // Register pane class | 812 // Register pane class |
812 if (!GetAtomPaneClass()) | 813 if (!GetAtomPaneClass()) |
813 { | 814 { |
814 WNDCLASSEX wcex; | 815 WNDCLASSEX wcex; |
815 | 816 |
816 wcex.cbSize = sizeof(WNDCLASSEX); | 817 wcex.cbSize = sizeof(wcex); |
817 wcex.style = 0; | 818 wcex.style = 0; |
818 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc; | 819 wcex.lpfnWndProc = (WNDPROC)PaneWindowProc; |
819 wcex.cbClsExtra = 0; | 820 wcex.cbClsExtra = 0; |
820 wcex.cbWndExtra = 0; | 821 wcex.cbWndExtra = 0; |
821 wcex.hInstance = _Module.m_hInst; | 822 wcex.hInstance = _Module.m_hInst; |
822 wcex.hIcon = NULL; | 823 wcex.hIcon = NULL; |
823 wcex.hCursor = NULL; | 824 wcex.hCursor = NULL; |
824 wcex.hbrBackground = NULL; | 825 wcex.hbrBackground = NULL; |
825 wcex.lpszMenuName = NULL; | 826 wcex.lpszMenuName = NULL; |
826 wcex.lpszClassName = STATUSBAR_PANE_NAME; | 827 wcex.lpszClassName = STATUSBAR_PANE_NAME; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 s_criticalSectionLocal.Unlock(); | 883 s_criticalSectionLocal.Unlock(); |
883 return true; | 884 return true; |
884 } | 885 } |
885 | 886 |
886 bool CPluginClass::CreateStatusBarPane() | 887 bool CPluginClass::CreateStatusBarPane() |
887 { | 888 { |
888 CriticalSection::Lock lock(m_csStatusBar); | 889 CriticalSection::Lock lock(m_csStatusBar); |
889 | 890 |
890 CPluginClient* client = CPluginClient::GetInstance(); | 891 CPluginClient* client = CPluginClient::GetInstance(); |
891 | 892 |
892 wchar_t szClassName[MAX_PATH]; | 893 std::array<wchar_t, MAX_PATH> className; |
893 // Get browser window and url | 894 // Get browser window and url |
894 HWND hBrowserWnd = GetBrowserHWND(); | 895 HWND hBrowserWnd = GetBrowserHWND(); |
895 if (!hBrowserWnd) | 896 if (!hBrowserWnd) |
896 { | 897 { |
897 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") | 898 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::CreateStatusBarPane - No status bar") |
898 return false; | 899 return false; |
899 } | 900 } |
900 | 901 |
901 // Looking for a TabWindowClass window in IE7 | 902 // Looking for a TabWindowClass window in IE7 |
902 // the last one should be parent for statusbar | 903 // the last one should be parent for statusbar |
903 HWND hWndStatusBar = NULL; | 904 HWND hWndStatusBar = NULL; |
904 | 905 |
905 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 906 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
906 UINT amoundOfNewTabs = 0; | 907 UINT amoundOfNewTabs = 0; |
907 HWND uniqueNewTab = NULL; | 908 HWND uniqueNewTab = NULL; |
908 while (hTabWnd) | 909 while (hTabWnd) |
909 { | 910 { |
910 memset(szClassName, 0, MAX_PATH); | 911 className.fill(L'\0'); |
Eric
2014/09/26 18:07:23
The title of the review says "wrong usage of memse
|
Eric
2014/09/26 18:07:23
Are these calls to 'fill' really necessary?
The o
|
911 GetClassName(hTabWnd, szClassName, MAX_PATH); | 912 GetClassName(hTabWnd, className.data(), className.size()); |
Eric
2014/09/26 18:07:23
As long as we're making a modification, we might a
Oleksandr
2014/10/06 20:19:32
+1
On 2014/09/26 18:07:23, Eric wrote:
sergei
2014/10/08 15:06:52
Despite it's not a real performance trouble, I've
| |
912 | 913 |
913 if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName,L"Fram e Tab") == 0) | 914 if (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.dat a(), L"Frame Tab") == 0) |
914 { | 915 { |
915 // IE8 support | 916 // IE8 support |
916 HWND hTabWnd2 = hTabWnd; | 917 HWND hTabWnd2 = hTabWnd; |
917 if (wcscmp(szClassName,L"Frame Tab") == 0) | 918 if (wcscmp(className.data(), L"Frame Tab") == 0) |
918 { | 919 { |
919 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); | 920 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); |
920 } | 921 } |
921 | 922 |
922 if (hTabWnd2) | 923 if (hTabWnd2) |
923 { | 924 { |
924 DWORD nProcessId; | 925 DWORD nProcessId; |
925 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); | 926 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); |
926 if (::GetCurrentProcessId() == nProcessId) | 927 if (::GetCurrentProcessId() == nProcessId) |
927 { | 928 { |
(...skipping 26 matching lines...) Expand all Loading... | |
954 } | 955 } |
955 } | 956 } |
956 } | 957 } |
957 | 958 |
958 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 959 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
959 } | 960 } |
960 | 961 |
961 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 962 HWND hWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
962 while (hWnd) | 963 while (hWnd) |
963 { | 964 { |
964 memset(szClassName, 0, MAX_PATH); | 965 className.fill(L'\0'); |
965 ::GetClassName(hWnd, szClassName, MAX_PATH); | 966 ::GetClassName(hWnd, className.data(), className.size()); |
966 | 967 |
967 if (wcscmp(szClassName,L"msctls_statusbar32") == 0) | 968 if (wcscmp(className.data(), L"msctls_statusbar32") == 0) |
968 { | 969 { |
969 hWndStatusBar = hWnd; | 970 hWndStatusBar = hWnd; |
970 break; | 971 break; |
971 } | 972 } |
972 | 973 |
973 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); | 974 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); |
974 } | 975 } |
975 | 976 |
976 if (!hWndStatusBar) | 977 if (!hWndStatusBar) |
977 { | 978 { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1154 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); | 1155 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); |
1155 | 1156 |
1156 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); | 1157 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); |
1157 | 1158 |
1158 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); | 1159 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); |
1159 | 1160 |
1160 SetMenuBar(hMenuTrackPopup, url); | 1161 SetMenuBar(hMenuTrackPopup, url); |
1161 | 1162 |
1162 return hMenuTrackPopup; | 1163 return hMenuTrackPopup; |
1163 } | 1164 } |
1164 BOOL CreateLowProcess(WCHAR* wszProcessName, WCHAR* cmdLine) | |
1165 { | |
1166 | |
1167 BOOL fRet; | |
1168 HANDLE hToken = NULL; | |
1169 HANDLE hNewToken = NULL; | |
1170 PSID pIntegritySid = NULL; | |
1171 TOKEN_MANDATORY_LABEL TIL = {0}; | |
1172 PROCESS_INFORMATION ProcInfo = {0}; | |
1173 STARTUPINFO StartupInfo = {0}; | |
1174 | |
1175 | |
1176 | |
1177 // Low integrity SID | |
1178 WCHAR wszIntegritySid[20] = L"S-1-16-4096"; | |
1179 | |
1180 | |
1181 fRet = OpenProcessToken(GetCurrentProcess(), | |
1182 TOKEN_DUPLICATE | | |
1183 TOKEN_ADJUST_DEFAULT | | |
1184 TOKEN_QUERY | | |
1185 TOKEN_ASSIGN_PRIMARY, | |
1186 &hToken); | |
1187 | |
1188 if (!fRet) | |
1189 { | |
1190 goto CleanExit; | |
1191 } | |
1192 | |
1193 fRet = DuplicateTokenEx(hToken, | |
1194 0, | |
1195 NULL, | |
1196 SecurityImpersonation, | |
1197 TokenPrimary, | |
1198 &hNewToken); | |
1199 | |
1200 if (!fRet) | |
1201 { | |
1202 goto CleanExit; | |
1203 } | |
1204 | |
1205 fRet = ConvertStringSidToSid(wszIntegritySid, &pIntegritySid); | |
1206 | |
1207 if (!fRet) | |
1208 { | |
1209 goto CleanExit; | |
1210 } | |
1211 | |
1212 | |
1213 TIL.Label.Attributes = SE_GROUP_INTEGRITY; | |
1214 TIL.Label.Sid = pIntegritySid; | |
1215 | |
1216 | |
1217 // | |
1218 // Set the process integrity level | |
1219 // | |
1220 | |
1221 fRet = SetTokenInformation(hNewToken, | |
1222 TokenIntegrityLevel, | |
1223 &TIL, | |
1224 sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(pIntegritySid)); | |
1225 | |
1226 if (!fRet) | |
1227 { | |
1228 goto CleanExit; | |
1229 } | |
1230 | |
1231 // | |
1232 // Create the new process at Low integrity | |
1233 // | |
1234 | |
1235 fRet = CreateProcessAsUser(hNewToken, | |
1236 wszProcessName, | |
1237 cmdLine, | |
1238 NULL, | |
1239 NULL, | |
1240 FALSE, | |
1241 0, | |
1242 NULL, | |
1243 NULL, | |
1244 &StartupInfo, | |
1245 &ProcInfo); | |
1246 | |
1247 | |
1248 CleanExit: | |
1249 | |
1250 if (ProcInfo.hProcess != NULL) | |
1251 { | |
1252 CloseHandle(ProcInfo.hProcess); | |
1253 } | |
1254 | |
1255 if (ProcInfo.hThread != NULL) | |
1256 { | |
1257 CloseHandle(ProcInfo.hThread); | |
1258 } | |
1259 | |
1260 LocalFree(pIntegritySid); | |
1261 | |
1262 if (hNewToken != NULL) | |
1263 { | |
1264 CloseHandle(hNewToken); | |
1265 } | |
1266 | |
1267 if (hToken != NULL) | |
1268 { | |
1269 CloseHandle(hToken); | |
1270 } | |
1271 | |
1272 return fRet; | |
1273 } | |
1274 | 1165 |
1275 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U INT nMenuFlags) | 1166 void CPluginClass::DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, U INT nMenuFlags) |
1276 { | 1167 { |
1277 CPluginClient* client = CPluginClient::GetInstance(); | 1168 CPluginClient* client = CPluginClient::GetInstance(); |
1278 | 1169 |
1279 // Create menu parent window | 1170 // Create menu parent window |
1280 HWND hMenuWnd = ::CreateWindowEx( | 1171 HWND hMenuWnd = ::CreateWindowEx( |
1281 NULL, | 1172 NULL, |
1282 MAKEINTATOM(GetAtomPaneClass()), | 1173 MAKEINTATOM(GetAtomPaneClass()), |
1283 L"", | 1174 L"", |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1395 { | 1286 { |
1396 #ifdef SUPPORT_WHITELIST | 1287 #ifdef SUPPORT_WHITELIST |
1397 s_menuDomains.clear(); | 1288 s_menuDomains.clear(); |
1398 #endif | 1289 #endif |
1399 } | 1290 } |
1400 s_criticalSectionLocal.Unlock(); | 1291 s_criticalSectionLocal.Unlock(); |
1401 | 1292 |
1402 | 1293 |
1403 Dictionary* dictionary = Dictionary::GetInstance(); | 1294 Dictionary* dictionary = Dictionary::GetInstance(); |
1404 | 1295 |
1405 MENUITEMINFOW fmii; | 1296 MENUITEMINFOW fmii = {}; |
1406 memset(&fmii, 0, sizeof(MENUITEMINFO)); | 1297 fmii.cbSize = sizeof(fmii); |
1407 fmii.cbSize = sizeof(MENUITEMINFO); | |
1408 | 1298 |
1409 MENUITEMINFOW miiSep; | 1299 MENUITEMINFOW miiSep = {}; |
1410 memset(&miiSep, 0, sizeof(MENUITEMINFO)); | 1300 miiSep.cbSize = sizeof(miiSep); |
1411 miiSep.cbSize = sizeof(MENUITEMINFO); | |
1412 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1301 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1413 miiSep.fType = MFT_SEPARATOR; | 1302 miiSep.fType = MFT_SEPARATOR; |
1414 | 1303 |
1415 CPluginClient* client = CPluginClient::GetInstance(); | 1304 CPluginClient* client = CPluginClient::GetInstance(); |
1416 | 1305 |
1417 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1306 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1418 | 1307 |
1419 #ifdef SUPPORT_WHITELIST | 1308 #ifdef SUPPORT_WHITELIST |
1420 { | 1309 { |
1421 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); | 1310 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1504 DWORD nProcessId; | 1393 DWORD nProcessId; |
1505 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); | 1394 ::GetWindowThreadProcessId(hWndToolBar, &nProcessId); |
1506 | 1395 |
1507 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) | 1396 if (hWndToolBar && ::GetCurrentProcessId() == nProcessId) |
1508 { | 1397 { |
1509 ::ScreenToClient(hWndToolBar, &pt); | 1398 ::ScreenToClient(hWndToolBar, &pt); |
1510 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); | 1399 int nButton = (int)::SendMessage(hWndToolBar, TB_HITTEST, 0, (LPARAM)&pt); |
1511 | 1400 |
1512 if (nButton > 0) | 1401 if (nButton > 0) |
1513 { | 1402 { |
1514 TBBUTTON pTBBtn; | 1403 TBBUTTON pTBBtn = {}; |
1515 memset(&pTBBtn, 0, sizeof(TBBUTTON)); | |
1516 | 1404 |
1517 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) | 1405 if (SendMessage(hWndToolBar, TB_GETBUTTON, nButton, (LPARAM)&pTBBtn)) |
1518 { | 1406 { |
1519 RECT rcButton; | 1407 RECT rcButton; |
1520 nIDCommand = pTBBtn.idCommand; | 1408 nIDCommand = pTBBtn.idCommand; |
1521 | 1409 |
1522 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) | 1410 if (SendMessage(hWndToolBar, TB_GETRECT, nIDCommand, (LPARAM)&rcButton)) |
1523 { | 1411 { |
1524 pt.x = rcButton.left; | 1412 pt.x = rcButton.left; |
1525 pt.y = rcButton.bottom; | 1413 pt.y = rcButton.bottom; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1934 return icon; | 1822 return icon; |
1935 } | 1823 } |
1936 | 1824 |
1937 ATOM CPluginClass::GetAtomPaneClass() | 1825 ATOM CPluginClass::GetAtomPaneClass() |
1938 { | 1826 { |
1939 return s_atomPaneClass; | 1827 return s_atomPaneClass; |
1940 } | 1828 } |
1941 | 1829 |
1942 HWND CPluginClass::GetTabHWND() const | 1830 HWND CPluginClass::GetTabHWND() const |
1943 { | 1831 { |
1944 wchar_t szClassName[MAX_PATH]; | 1832 std::array<wchar_t, MAX_PATH> className; |
1945 // Get browser window and url | 1833 // Get browser window and url |
1946 HWND hBrowserWnd = GetBrowserHWND(); | 1834 HWND hBrowserWnd = GetBrowserHWND(); |
1947 if (!hBrowserWnd) | 1835 if (!hBrowserWnd) |
1948 { | 1836 { |
1949 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") | 1837 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_BROWSER, "C lass::GetTabWindow - No tab window") |
1950 s_criticalSectionWindow.Unlock(); | 1838 s_criticalSectionWindow.Unlock(); |
1951 | 1839 |
1952 return false; | 1840 return false; |
1953 } | 1841 } |
1954 | 1842 |
1955 // Looking for a TabWindowClass window in IE7 | 1843 // Looking for a TabWindowClass window in IE7 |
1956 | 1844 |
1957 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); | 1845 HWND hTabWnd = ::GetWindow(hBrowserWnd, GW_CHILD); |
1958 while (hTabWnd) | 1846 while (hTabWnd) |
1959 { | 1847 { |
1960 memset(szClassName, 0, MAX_PATH); | 1848 className.fill(L'\0'); |
1961 GetClassName(hTabWnd, szClassName, MAX_PATH); | 1849 GetClassName(hTabWnd, className.data(), className.size()); |
1962 | 1850 |
1963 if (wcscmp(szClassName, L"TabWindowClass") == 0 || wcscmp(szClassName, L"Fra me Tab") == 0) | 1851 if (wcscmp(className.data(), L"TabWindowClass") == 0 || wcscmp(className.dat a(), L"Frame Tab") == 0) |
1964 { | 1852 { |
1965 // IE8 support | 1853 // IE8 support |
1966 HWND hTabWnd2 = hTabWnd; | 1854 HWND hTabWnd2 = hTabWnd; |
1967 if (wcscmp(szClassName, L"Frame Tab") == 0) | 1855 if (wcscmp(className.data(), L"Frame Tab") == 0) |
1968 { | 1856 { |
1969 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); | 1857 hTabWnd2 = ::FindWindowEx(hTabWnd2, NULL, L"TabWindowClass", NULL); |
1970 } | 1858 } |
1971 | 1859 |
1972 if (hTabWnd2) | 1860 if (hTabWnd2) |
1973 { | 1861 { |
1974 DWORD nProcessId; | 1862 DWORD nProcessId; |
1975 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); | 1863 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); |
1976 if (::GetCurrentProcessId() == nProcessId) | 1864 if (::GetCurrentProcessId() == nProcessId) |
1977 { | 1865 { |
(...skipping 23 matching lines...) Expand all Loading... | |
2001 } | 1889 } |
2002 } | 1890 } |
2003 } | 1891 } |
2004 | 1892 |
2005 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1893 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
2006 } | 1894 } |
2007 | 1895 |
2008 return hTabWnd; | 1896 return hTabWnd; |
2009 | 1897 |
2010 } | 1898 } |
OLD | NEW |