aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/FileManager/FM.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/FileManager/FM.cpp')
-rw-r--r--CPP/7zip/UI/FileManager/FM.cpp117
1 files changed, 70 insertions, 47 deletions
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index 812eff6..13189a7 100644
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -4,8 +4,13 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#if defined(__MINGW32__) || defined(__MINGW64__)
8#include <shlwapi.h>
9#else
7#include <Shlwapi.h> 10#include <Shlwapi.h>
11#endif
8 12
13#include "../../../../C/Compiler.h"
9#include "../../../../C/Alloc.h" 14#include "../../../../C/Alloc.h"
10#ifdef _WIN32 15#ifdef _WIN32
11#include "../../../../C/DllSecur.h" 16#include "../../../../C/DllSecur.h"
@@ -46,7 +51,9 @@ extern
46bool g_RAM_Size_Defined; 51bool g_RAM_Size_Defined;
47bool g_RAM_Size_Defined; 52bool g_RAM_Size_Defined;
48 53
49static bool g_LargePagesMode = false; 54extern
55bool g_LargePagesMode;
56bool g_LargePagesMode = false;
50// static bool g_OpenArchive = false; 57// static bool g_OpenArchive = false;
51 58
52static bool g_Maximized = false; 59static bool g_Maximized = false;
@@ -78,20 +85,23 @@ DWORD g_ComCtl32Version;
78static DWORD GetDllVersion(LPCTSTR dllName) 85static DWORD GetDllVersion(LPCTSTR dllName)
79{ 86{
80 DWORD dwVersion = 0; 87 DWORD dwVersion = 0;
81 HINSTANCE hinstDll = LoadLibrary(dllName); 88 const HMODULE hmodule = LoadLibrary(dllName);
82 if (hinstDll) 89 if (hmodule)
83 { 90 {
84 DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)(void *)GetProcAddress(hinstDll, "DllGetVersion"); 91 const
85 if (pDllGetVersion) 92 DLLGETVERSIONPROC f_DllGetVersion = Z7_GET_PROC_ADDRESS(
93 DLLGETVERSIONPROC, hmodule,
94 "DllGetVersion");
95 if (f_DllGetVersion)
86 { 96 {
87 DLLVERSIONINFO dvi; 97 DLLVERSIONINFO dvi;
88 ZeroMemory(&dvi, sizeof(dvi)); 98 ZeroMemory(&dvi, sizeof(dvi));
89 dvi.cbSize = sizeof(dvi); 99 dvi.cbSize = sizeof(dvi);
90 HRESULT hr = (*pDllGetVersion)(&dvi); 100 const HRESULT hr = f_DllGetVersion(&dvi);
91 if (SUCCEEDED(hr)) 101 if (SUCCEEDED(hr))
92 dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); 102 dwVersion = (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
93 } 103 }
94 FreeLibrary(hinstDll); 104 FreeLibrary(hmodule);
95 } 105 }
96 return dwVersion; 106 return dwVersion;
97} 107}
@@ -180,7 +190,7 @@ CApp g_App;
180 190
181LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 191LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
182 192
183static const wchar_t * const kWindowClass = L"FM"; 193static const wchar_t * const kWindowClass = L"7-Zip::FM";
184 194
185#ifdef UNDER_CE 195#ifdef UNDER_CE
186#define WS_OVERLAPPEDWINDOW ( \ 196#define WS_OVERLAPPEDWINDOW ( \
@@ -222,7 +232,7 @@ static BOOL InitInstance(int nCmdShow)
222 wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON)); 232 wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON));
223 233
224 // wc.hCursor = LoadCursor (NULL, IDC_ARROW); 234 // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
225 wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); 235 wc.hCursor = ::LoadCursor(NULL, IDC_SIZEWE);
226 // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); 236 // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
227 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); 237 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
228 238
@@ -236,7 +246,8 @@ static BOOL InitInstance(int nCmdShow)
236 246
237 wc.lpszClassName = kWindowClass; 247 wc.lpszClassName = kWindowClass;
238 248
239 MyRegisterClass(&wc); 249 if (MyRegisterClass(&wc) == 0)
250 return FALSE;
240 251
241 // RECT rect; 252 // RECT rect;
242 // GetClientRect(hWnd, &rect); 253 // GetClientRect(hWnd, &rect);
@@ -305,7 +316,7 @@ static BOOL InitInstance(int nCmdShow)
305 { 316 {
306 if (windowPosIsRead) 317 if (windowPosIsRead)
307 placement.rcNormalPosition = info.rect; 318 placement.rcNormalPosition = info.rect;
308 placement.showCmd = nCmdShow; 319 placement.showCmd = (UINT)nCmdShow;
309 wnd.SetPlacement(&placement); 320 wnd.SetPlacement(&placement);
310 } 321 }
311 else 322 else
@@ -343,6 +354,8 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands)
343 354
344#if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE) 355#if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE)
345 356
357extern
358bool g_Is_Wow64;
346bool g_Is_Wow64; 359bool g_Is_Wow64;
347 360
348typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL); 361typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
@@ -350,18 +363,27 @@ typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
350static void Set_Wow64() 363static void Set_Wow64()
351{ 364{
352 g_Is_Wow64 = false; 365 g_Is_Wow64 = false;
353 Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)(void *)GetProcAddress( 366 const
354 GetModuleHandleA("kernel32.dll"), "IsWow64Process"); 367 Func_IsWow64Process fn = Z7_GET_PROC_ADDRESS(
355 if (fnIsWow64Process) 368 Func_IsWow64Process, GetModuleHandleA("kernel32.dll"),
369 "IsWow64Process");
370 if (fn)
356 { 371 {
357 BOOL isWow; 372 BOOL isWow;
358 if (fnIsWow64Process(GetCurrentProcess(), &isWow)) 373 if (fn(GetCurrentProcess(), &isWow))
359 g_Is_Wow64 = (isWow != FALSE); 374 g_Is_Wow64 = (isWow != FALSE);
360 } 375 }
361} 376}
362 377
363#endif 378#endif
364 379
380#if _MSC_VER > 1400 /* && _MSC_VER <= 1900 */
381 // GetVersion was declared deprecated
382 #pragma warning(disable : 4996)
383#endif
384#ifdef __clang__
385 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
386#endif
365 387
366bool IsLargePageSupported(); 388bool IsLargePageSupported();
367bool IsLargePageSupported() 389bool IsLargePageSupported()
@@ -369,18 +391,17 @@ bool IsLargePageSupported()
369 #ifdef _WIN64 391 #ifdef _WIN64
370 return true; 392 return true;
371 #else 393 #else
372 OSVERSIONINFO vi; 394
373 vi.dwOSVersionInfoSize = sizeof(vi); 395 DWORD v = GetVersion();
374 if (!::GetVersionEx(&vi)) 396 // low byte is major version:
375 return false; 397 // next byte is minor version:
376 if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT) 398 v = ((v & 0xff) << 8) | ((v >> 8) & 0xFF);
377 return false; 399 return (v > 0x501);
378 if (vi.dwMajorVersion < 5) return false; 400 // if ((Byte)v < 5) return false;
379 if (vi.dwMajorVersion > 5) return true; 401 // if ((Byte)v > 5) return true;
380 if (vi.dwMinorVersion < 1) return false; 402 // return ((Byte)(v >> 8) > 1);
381 if (vi.dwMinorVersion > 1) return true; 403 /* large pages work in 5.1 (XP-32bit) if it's (g_Is_Wow64) mode;
382 // return g_Is_Wow64; 404 but here we don't enable them in (XP-32bit). */
383 return false;
384 #endif 405 #endif
385} 406}
386 407
@@ -407,12 +428,10 @@ bool g_SymLink_Supported = false;
407 428
408static void Set_SymLink_Supported() 429static void Set_SymLink_Supported()
409{ 430{
410 g_SymLink_Supported = false; 431 // g_SymLink_Supported = false;
411 OSVERSIONINFO vi; 432 const DWORD v = GetVersion();
412 vi.dwOSVersionInfoSize = sizeof(vi); 433 // low byte is major version:
413 if (!::GetVersionEx(&vi)) 434 if ((Byte)v < 6)
414 return;
415 if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT || vi.dwMajorVersion < 6)
416 return; 435 return;
417 g_SymLink_Supported = true; 436 g_SymLink_Supported = true;
418 // if (g_SymLink_Supported) 437 // if (g_SymLink_Supported)
@@ -444,7 +463,7 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
444 463
445static void ErrorMessage(const wchar_t *s) 464static void ErrorMessage(const wchar_t *s)
446{ 465{
447 MessageBoxW(0, s, L"7-Zip", MB_ICONERROR); 466 MessageBoxW(NULL, s, L"7-Zip", MB_ICONERROR);
448} 467}
449 468
450static void ErrorMessage(const char *s) 469static void ErrorMessage(const char *s)
@@ -488,11 +507,15 @@ static int WINAPI WinMain2(int nCmdShow)
488 */ 507 */
489 508
490 NT_CHECK 509 NT_CHECK
510 #ifdef Z7_LARGE_PAGES
491 SetLargePageSize(); 511 SetLargePageSize();
512 #endif
492 513
493 #endif 514 #endif
494 515
516 #ifdef Z7_LANG
495 LoadLangOneTime(); 517 LoadLangOneTime();
518 #endif
496 519
497 InitCommonControls(); 520 InitCommonControls();
498 521
@@ -516,7 +539,7 @@ static int WINAPI WinMain2(int nCmdShow)
516 // NCOM::CComInitializer comInitializer; 539 // NCOM::CComInitializer comInitializer;
517 540
518 UString commandsString; 541 UString commandsString;
519 // MessageBoxW(0, GetCommandLineW(), L"", 0); 542 // MessageBoxW(NULL, GetCommandLineW(), L"", 0);
520 543
521 #ifdef UNDER_CE 544 #ifdef UNDER_CE
522 commandsString = GetCommandLineW(); 545 commandsString = GetCommandLineW();
@@ -577,7 +600,7 @@ static int WINAPI WinMain2(int nCmdShow)
577 g_MainPath = paramString; 600 g_MainPath = paramString;
578 // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow); 601 // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
579 602
580 // MessageBoxW(0, paramString, L"", 0); 603 // MessageBoxW(NULL, paramString, L"", 0);
581 } 604 }
582 /* 605 /*
583 UStringVector commandStrings; 606 UStringVector commandStrings;
@@ -608,7 +631,7 @@ static int WINAPI WinMain2(int nCmdShow)
608 Set_SymLink_Supported(); 631 Set_SymLink_Supported();
609 #endif 632 #endif
610 633
611 g_App.ReloadLang(); 634 g_App.ReloadLangItems();
612 635
613 MSG msg; 636 MSG msg;
614 if (!InitInstance (nCmdShow)) 637 if (!InitInstance (nCmdShow))
@@ -654,7 +677,7 @@ static int WINAPI WinMain2(int nCmdShow)
654 // But we suppose that it's better to release DLLs here (before destructor). 677 // But we suppose that it's better to release DLLs here (before destructor).
655 FreeGlobalCodecs(); 678 FreeGlobalCodecs();
656 679
657 g_HWND = 0; 680 g_HWND = NULL;
658 #ifndef UNDER_CE 681 #ifndef UNDER_CE
659 OleUninitialize(); 682 OleUninitialize();
660 #endif 683 #endif
@@ -714,7 +737,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
714 catch(int v) 737 catch(int v)
715 { 738 {
716 AString e ("Error: "); 739 AString e ("Error: ");
717 e.Add_UInt32(v); 740 e.Add_UInt32((unsigned)v);
718 ErrorMessage(e); 741 ErrorMessage(e);
719 return 1; 742 return 1;
720 } 743 }
@@ -748,7 +771,7 @@ static void SaveWindowInfo(HWND aWnd)
748 771
749 info.numPanels = g_App.NumPanels; 772 info.numPanels = g_App.NumPanels;
750 info.currentPanel = g_App.LastFocusedPanel; 773 info.currentPanel = g_App.LastFocusedPanel;
751 info.splitterPos = g_Splitter.GetPos(); 774 info.splitterPos = (unsigned)g_Splitter.GetPos();
752 775
753 info.Save(); 776 info.Save();
754} 777}
@@ -825,23 +848,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
825 WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT 848 WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
826 baseID + 2, 11, 849 baseID + 2, 11,
827 (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, 850 (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
828 (LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb), 851 (LPCTBBUTTON)&tbb, Z7_ARRAY_SIZE(tbb),
829 0, 0, 100, 30, sizeof (TBBUTTON))); 852 0, 0, 100, 30, sizeof (TBBUTTON)));
830 */ 853 */
831 // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE); 854 // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
832 // ::SetCursor(cursor); 855 // ::SetCursor(cursor);
833 856
834 if (g_PanelsInfoDefined) 857 if (g_PanelsInfoDefined)
835 g_Splitter.SetPos(hWnd, g_SplitterPos); 858 g_Splitter.SetPos(hWnd, (int)g_SplitterPos);
836 else 859 else
837 { 860 {
838 g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2); 861 g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
839 g_SplitterPos = g_Splitter.GetPos(); 862 g_SplitterPos = (unsigned)g_Splitter.GetPos();
840 } 863 }
841 864
842 RECT rect; 865 RECT rect;
843 ::GetClientRect(hWnd, &rect); 866 ::GetClientRect(hWnd, &rect);
844 int xSize = rect.right; 867 const int xSize = rect.right;
845 int xSizes[2]; 868 int xSizes[2];
846 xSizes[0] = g_Splitter.GetPos(); 869 xSizes[0] = g_Splitter.GetPos();
847 xSizes[1] = xSize - kSplitterWidth - xSizes[0]; 870 xSizes[1] = xSize - kSplitterWidth - xSizes[0];
@@ -954,7 +977,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
954 g_Splitter.SetPosFromRatio(hWnd); 977 g_Splitter.SetPosFromRatio(hWnd);
955 else 978 else
956 { 979 {
957 g_Splitter.SetPos(hWnd, g_SplitterPos ); 980 g_Splitter.SetPos(hWnd, (int)g_SplitterPos );
958 g_CanChangeSplitter = true; 981 g_CanChangeSplitter = true;
959 } 982 }
960 983
@@ -1047,7 +1070,7 @@ void CApp::MoveSubWindows()
1047{ 1070{
1048 HWND hWnd = _window; 1071 HWND hWnd = _window;
1049 RECT rect; 1072 RECT rect;
1050 if (hWnd == 0) 1073 if (!hWnd)
1051 return; 1074 return;
1052 ::GetClientRect(hWnd, &rect); 1075 ::GetClientRect(hWnd, &rect);
1053 int xSize = rect.right; 1076 int xSize = rect.right;