This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -4,8 +4,13 @@
#include "../../../Common/MyWindows.h"
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <shlwapi.h>
#else
#include <Shlwapi.h>
#endif
#include "../../../../C/Compiler.h"
#include "../../../../C/Alloc.h"
#ifdef _WIN32
#include "../../../../C/DllSecur.h"
@@ -46,7 +51,9 @@ extern
bool g_RAM_Size_Defined;
bool g_RAM_Size_Defined;
static bool g_LargePagesMode = false;
extern
bool g_LargePagesMode;
bool g_LargePagesMode = false;
// static bool g_OpenArchive = false;
static bool g_Maximized = false;
@@ -78,20 +85,23 @@ DWORD g_ComCtl32Version;
static DWORD GetDllVersion(LPCTSTR dllName)
{
DWORD dwVersion = 0;
HINSTANCE hinstDll = LoadLibrary(dllName);
if (hinstDll)
const HMODULE hmodule = LoadLibrary(dllName);
if (hmodule)
{
DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)(void *)GetProcAddress(hinstDll, "DllGetVersion");
if (pDllGetVersion)
const
DLLGETVERSIONPROC f_DllGetVersion = Z7_GET_PROC_ADDRESS(
DLLGETVERSIONPROC, hmodule,
"DllGetVersion");
if (f_DllGetVersion)
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
HRESULT hr = (*pDllGetVersion)(&dvi);
const HRESULT hr = f_DllGetVersion(&dvi);
if (SUCCEEDED(hr))
dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
dwVersion = (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
}
FreeLibrary(hinstDll);
FreeLibrary(hmodule);
}
return dwVersion;
}
@@ -180,7 +190,7 @@ CApp g_App;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static const wchar_t * const kWindowClass = L"FM";
static const wchar_t * const kWindowClass = L"7-Zip::FM";
#ifdef UNDER_CE
#define WS_OVERLAPPEDWINDOW ( \
@@ -222,7 +232,7 @@ static BOOL InitInstance(int nCmdShow)
wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON));
// wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
wc.hCursor = ::LoadCursor(NULL, IDC_SIZEWE);
// wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
@@ -236,7 +246,8 @@ static BOOL InitInstance(int nCmdShow)
wc.lpszClassName = kWindowClass;
MyRegisterClass(&wc);
if (MyRegisterClass(&wc) == 0)
return FALSE;
// RECT rect;
// GetClientRect(hWnd, &rect);
@@ -305,7 +316,7 @@ static BOOL InitInstance(int nCmdShow)
{
if (windowPosIsRead)
placement.rcNormalPosition = info.rect;
placement.showCmd = nCmdShow;
placement.showCmd = (UINT)nCmdShow;
wnd.SetPlacement(&placement);
}
else
@@ -343,6 +354,8 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands)
#if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE)
extern
bool g_Is_Wow64;
bool g_Is_Wow64;
typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
@@ -350,18 +363,27 @@ typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
static void Set_Wow64()
{
g_Is_Wow64 = false;
Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)(void *)GetProcAddress(
GetModuleHandleA("kernel32.dll"), "IsWow64Process");
if (fnIsWow64Process)
const
Func_IsWow64Process fn = Z7_GET_PROC_ADDRESS(
Func_IsWow64Process, GetModuleHandleA("kernel32.dll"),
"IsWow64Process");
if (fn)
{
BOOL isWow;
if (fnIsWow64Process(GetCurrentProcess(), &isWow))
if (fn(GetCurrentProcess(), &isWow))
g_Is_Wow64 = (isWow != FALSE);
}
}
#endif
#if _MSC_VER > 1400 /* && _MSC_VER <= 1900 */
// GetVersion was declared deprecated
#pragma warning(disable : 4996)
#endif
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
bool IsLargePageSupported();
bool IsLargePageSupported()
@@ -369,18 +391,17 @@ bool IsLargePageSupported()
#ifdef _WIN64
return true;
#else
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!::GetVersionEx(&vi))
return false;
if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT)
return false;
if (vi.dwMajorVersion < 5) return false;
if (vi.dwMajorVersion > 5) return true;
if (vi.dwMinorVersion < 1) return false;
if (vi.dwMinorVersion > 1) return true;
// return g_Is_Wow64;
return false;
DWORD v = GetVersion();
// low byte is major version:
// next byte is minor version:
v = ((v & 0xff) << 8) | ((v >> 8) & 0xFF);
return (v > 0x501);
// if ((Byte)v < 5) return false;
// if ((Byte)v > 5) return true;
// return ((Byte)(v >> 8) > 1);
/* large pages work in 5.1 (XP-32bit) if it's (g_Is_Wow64) mode;
but here we don't enable them in (XP-32bit). */
#endif
}
@@ -407,12 +428,10 @@ bool g_SymLink_Supported = false;
static void Set_SymLink_Supported()
{
g_SymLink_Supported = false;
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!::GetVersionEx(&vi))
return;
if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT || vi.dwMajorVersion < 6)
// g_SymLink_Supported = false;
const DWORD v = GetVersion();
// low byte is major version:
if ((Byte)v < 6)
return;
g_SymLink_Supported = true;
// if (g_SymLink_Supported)
@@ -444,7 +463,7 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
static void ErrorMessage(const wchar_t *s)
{
MessageBoxW(0, s, L"7-Zip", MB_ICONERROR);
MessageBoxW(NULL, s, L"7-Zip", MB_ICONERROR);
}
static void ErrorMessage(const char *s)
@@ -488,11 +507,15 @@ static int WINAPI WinMain2(int nCmdShow)
*/
NT_CHECK
#ifdef Z7_LARGE_PAGES
SetLargePageSize();
#endif
#endif
#ifdef Z7_LANG
LoadLangOneTime();
#endif
InitCommonControls();
@@ -516,7 +539,7 @@ static int WINAPI WinMain2(int nCmdShow)
// NCOM::CComInitializer comInitializer;
UString commandsString;
// MessageBoxW(0, GetCommandLineW(), L"", 0);
// MessageBoxW(NULL, GetCommandLineW(), L"", 0);
#ifdef UNDER_CE
commandsString = GetCommandLineW();
@@ -577,7 +600,7 @@ static int WINAPI WinMain2(int nCmdShow)
g_MainPath = paramString;
// return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
// MessageBoxW(0, paramString, L"", 0);
// MessageBoxW(NULL, paramString, L"", 0);
}
/*
UStringVector commandStrings;
@@ -608,7 +631,7 @@ static int WINAPI WinMain2(int nCmdShow)
Set_SymLink_Supported();
#endif
g_App.ReloadLang();
g_App.ReloadLangItems();
MSG msg;
if (!InitInstance (nCmdShow))
@@ -654,7 +677,7 @@ static int WINAPI WinMain2(int nCmdShow)
// But we suppose that it's better to release DLLs here (before destructor).
FreeGlobalCodecs();
g_HWND = 0;
g_HWND = NULL;
#ifndef UNDER_CE
OleUninitialize();
#endif
@@ -714,7 +737,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
catch(int v)
{
AString e ("Error: ");
e.Add_UInt32(v);
e.Add_UInt32((unsigned)v);
ErrorMessage(e);
return 1;
}
@@ -748,7 +771,7 @@ static void SaveWindowInfo(HWND aWnd)
info.numPanels = g_App.NumPanels;
info.currentPanel = g_App.LastFocusedPanel;
info.splitterPos = g_Splitter.GetPos();
info.splitterPos = (unsigned)g_Splitter.GetPos();
info.Save();
}
@@ -825,23 +848,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
baseID + 2, 11,
(HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
(LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb),
(LPCTBBUTTON)&tbb, Z7_ARRAY_SIZE(tbb),
0, 0, 100, 30, sizeof (TBBUTTON)));
*/
// HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
// ::SetCursor(cursor);
if (g_PanelsInfoDefined)
g_Splitter.SetPos(hWnd, g_SplitterPos);
g_Splitter.SetPos(hWnd, (int)g_SplitterPos);
else
{
g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
g_SplitterPos = g_Splitter.GetPos();
g_SplitterPos = (unsigned)g_Splitter.GetPos();
}
RECT rect;
::GetClientRect(hWnd, &rect);
int xSize = rect.right;
const int xSize = rect.right;
int xSizes[2];
xSizes[0] = g_Splitter.GetPos();
xSizes[1] = xSize - kSplitterWidth - xSizes[0];
@@ -954,7 +977,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
g_Splitter.SetPosFromRatio(hWnd);
else
{
g_Splitter.SetPos(hWnd, g_SplitterPos );
g_Splitter.SetPos(hWnd, (int)g_SplitterPos );
g_CanChangeSplitter = true;
}
@@ -1047,7 +1070,7 @@ void CApp::MoveSubWindows()
{
HWND hWnd = _window;
RECT rect;
if (hWnd == 0)
if (!hWnd)
return;
::GetClientRect(hWnd, &rect);
int xSize = rect.right;