2022-01-05 04:02:25 +01:00
|
|
|
#include <initguid.h>
|
|
|
|
DEFINE_GUID(LiveSetting_Property_GUID, 0xc12bcd8e, 0x2a8e, 0x4950, 0x8a, 0xe7, 0x36, 0x25, 0x11, 0x1d, 0x58, 0xeb);
|
|
|
|
#include <oleacc.h>
|
2021-10-02 03:02:07 +02:00
|
|
|
#include "GUI.h"
|
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
TCHAR GUI_title[260];
|
|
|
|
FILE* AuditFile = NULL;
|
2021-10-25 04:42:41 +02:00
|
|
|
LANGID locale;
|
2021-10-16 04:56:46 +02:00
|
|
|
void* GUI_FileMapping = NULL;
|
|
|
|
DWORD GUI_FileSize = 0;
|
2021-10-10 05:14:23 +02:00
|
|
|
BOOL g_darkModeEnabled = FALSE;
|
|
|
|
static void(*RefreshImmersiveColorPolicyState)() = NULL;
|
|
|
|
static BOOL(*ShouldAppsUseDarkMode)() = NULL;
|
2021-12-09 18:08:09 +01:00
|
|
|
DWORD dwTaskbarPosition = 3;
|
2021-12-24 02:35:14 +01:00
|
|
|
BOOL gui_bOldTaskbar = TRUE;
|
2021-12-24 14:43:53 +01:00
|
|
|
|
2022-01-05 04:02:25 +01:00
|
|
|
void PlayHelpMessage(GUI* _this)
|
|
|
|
{
|
|
|
|
unsigned int max_section = 0;
|
|
|
|
for (unsigned int i = 0; i < 100; ++i)
|
|
|
|
{
|
|
|
|
if (_this->sectionNames[i][0] == 0)
|
|
|
|
{
|
|
|
|
max_section = i - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR wszAccText[1000];
|
|
|
|
swprintf_s(
|
|
|
|
wszAccText,
|
|
|
|
1000,
|
|
|
|
L"Welcome to ExplorerPatcher. "
|
|
|
|
L"Selected page is: %s: %d out of %d. "
|
|
|
|
L"To switch pages, press the Left or Right arrow keys or press a number (%d to %d). "
|
|
|
|
L"To select an item, press the Up or Down arrow keys or Shift+Tab and Tab. "
|
|
|
|
L"To interact with the selected item, press Space or Return. "
|
|
|
|
L"To close this window, press Escape. "
|
|
|
|
L"Press a number to switch to the corresponding page: ",
|
|
|
|
_this->sectionNames[_this->section],
|
|
|
|
_this->section + 1,
|
|
|
|
max_section + 1,
|
|
|
|
1,
|
|
|
|
max_section + 1
|
|
|
|
);
|
|
|
|
for (unsigned int i = 0; i < 100; ++i)
|
|
|
|
{
|
|
|
|
if (_this->sectionNames[i][0] == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WCHAR wszAdd[100];
|
|
|
|
swprintf_s(wszAdd, 100, L"%d: %s, ", i + 1, _this->sectionNames[i]);
|
|
|
|
wcscat_s(wszAccText, 1000, wszAdd);
|
|
|
|
}
|
|
|
|
wcscat_s(wszAccText, 1000, L"\nTo listen to this message again, press the F1 key at any time.\n");
|
|
|
|
SetWindowTextW(_this->hAccLabel, wszAccText);
|
|
|
|
NotifyWinEvent(
|
|
|
|
EVENT_OBJECT_LIVEREGIONCHANGED,
|
|
|
|
_this->hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-24 14:43:53 +01:00
|
|
|
NTSTATUS NTAPI hookRtlQueryElevationFlags(DWORD* pFlags)
|
|
|
|
{
|
|
|
|
*pFlags = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PVOID pvRtlQueryElevationFlags;
|
|
|
|
|
|
|
|
LONG NTAPI OnVex(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
|
{
|
|
|
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP &&
|
|
|
|
ExceptionInfo->ExceptionRecord->ExceptionAddress == pvRtlQueryElevationFlags)
|
|
|
|
{
|
|
|
|
ExceptionInfo->ContextRecord->
|
|
|
|
#if defined(_X86_)
|
|
|
|
Eip
|
|
|
|
#elif defined (_AMD64_)
|
|
|
|
Rip
|
|
|
|
#else
|
|
|
|
#error not implemented
|
|
|
|
#endif
|
|
|
|
= (ULONG_PTR)hookRtlQueryElevationFlags;
|
|
|
|
|
|
|
|
return EXCEPTION_CONTINUE_EXECUTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
2021-10-10 05:14:23 +02:00
|
|
|
BOOL IsColorSchemeChangeMessage(LPARAM lParam)
|
|
|
|
{
|
|
|
|
BOOL is = FALSE;
|
|
|
|
if (lParam && CompareStringOrdinal(lParam, -1, L"ImmersiveColorSet", -1, TRUE) == CSTR_EQUAL)
|
|
|
|
{
|
|
|
|
is = TRUE;
|
|
|
|
}
|
|
|
|
return is;
|
|
|
|
}
|
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
LSTATUS GUI_Internal_RegSetValueExW(
|
2021-12-05 03:04:41 +01:00
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpValueName,
|
|
|
|
DWORD Reserved,
|
|
|
|
DWORD dwType,
|
|
|
|
const BYTE* lpData,
|
|
|
|
DWORD cbData
|
|
|
|
)
|
|
|
|
{
|
2021-12-07 16:35:06 +01:00
|
|
|
if (!lpValueName || wcsncmp(lpValueName, L"Virtualized_" _T(EP_CLSID), 50))
|
2021-12-05 03:04:41 +01:00
|
|
|
{
|
|
|
|
return RegSetValueExW(hKey, lpValueName, 0, dwType, lpData, cbData);
|
|
|
|
}
|
|
|
|
if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition"))
|
|
|
|
{
|
|
|
|
StuckRectsData srd;
|
|
|
|
DWORD pcbData = sizeof(StuckRectsData);
|
|
|
|
RegGetValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRectsLegacy",
|
|
|
|
L"Settings",
|
|
|
|
REG_BINARY,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData);
|
|
|
|
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
|
|
|
|
{
|
|
|
|
srd.pvData[3] = *(DWORD*)lpData;
|
2021-12-09 18:08:09 +01:00
|
|
|
dwTaskbarPosition = *(DWORD*)lpData;
|
2021-12-05 03:04:41 +01:00
|
|
|
RegSetKeyValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRectsLegacy",
|
|
|
|
L"Settings",
|
|
|
|
REG_BINARY,
|
|
|
|
&srd,
|
|
|
|
sizeof(StuckRectsData)
|
|
|
|
);
|
|
|
|
}
|
2021-12-24 02:35:14 +01:00
|
|
|
pcbData = sizeof(StuckRectsData);
|
|
|
|
RegGetValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3",
|
|
|
|
L"Settings",
|
|
|
|
REG_BINARY,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData);
|
|
|
|
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
|
|
|
|
{
|
|
|
|
srd.pvData[3] = *(DWORD*)lpData;
|
|
|
|
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
|
|
|
|
{
|
|
|
|
srd.pvData[3] = 3;
|
|
|
|
}
|
|
|
|
RegSetKeyValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3",
|
|
|
|
L"Settings",
|
|
|
|
REG_BINARY,
|
|
|
|
&srd,
|
|
|
|
sizeof(StuckRectsData)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
2021-12-05 03:04:41 +01:00
|
|
|
}
|
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_MMTaskbarPosition"))
|
|
|
|
{
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MMStuckRectsLegacy",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WRITE,
|
|
|
|
&hKey
|
|
|
|
);
|
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
DWORD cValues = 0;
|
|
|
|
RegQueryInfoKeyW(
|
|
|
|
hKey,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&cValues,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
WCHAR name[60];
|
|
|
|
DWORD szName = 60;
|
|
|
|
StuckRectsData srd;
|
|
|
|
DWORD pcbData = sizeof(StuckRectsData);
|
|
|
|
for (int i = 0; i < cValues; ++i)
|
|
|
|
{
|
|
|
|
RegEnumValueW(
|
|
|
|
hKey,
|
|
|
|
i,
|
|
|
|
name,
|
|
|
|
&szName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData
|
|
|
|
);
|
|
|
|
szName = 60;
|
|
|
|
srd.pvData[3] = *(DWORD*)lpData;
|
|
|
|
pcbData = sizeof(StuckRectsData);
|
|
|
|
RegSetKeyValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MMStuckRectsLegacy",
|
|
|
|
name,
|
|
|
|
REG_BINARY,
|
|
|
|
&srd,
|
|
|
|
sizeof(StuckRectsData)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings");
|
|
|
|
}
|
2021-12-24 02:35:14 +01:00
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MMStuckRects3",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WRITE,
|
|
|
|
&hKey
|
|
|
|
);
|
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
DWORD cValues = 0;
|
|
|
|
RegQueryInfoKeyW(
|
|
|
|
hKey,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&cValues,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
WCHAR name[60];
|
|
|
|
DWORD szName = 60;
|
|
|
|
StuckRectsData srd;
|
|
|
|
DWORD pcbData = sizeof(StuckRectsData);
|
|
|
|
for (int i = 0; i < cValues; ++i)
|
|
|
|
{
|
|
|
|
RegEnumValueW(
|
|
|
|
hKey,
|
|
|
|
i,
|
|
|
|
name,
|
|
|
|
&szName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData
|
|
|
|
);
|
|
|
|
szName = 60;
|
|
|
|
srd.pvData[3] = *(DWORD*)lpData;
|
|
|
|
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
|
|
|
|
{
|
|
|
|
srd.pvData[3] = 3;
|
|
|
|
}
|
|
|
|
pcbData = sizeof(StuckRectsData);
|
|
|
|
RegSetKeyValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MMStuckRects3",
|
|
|
|
name,
|
|
|
|
REG_BINARY,
|
|
|
|
&srd,
|
|
|
|
sizeof(StuckRectsData)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
2021-12-05 03:04:41 +01:00
|
|
|
}
|
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_AutoHideTaskbar"))
|
|
|
|
{
|
|
|
|
APPBARDATA abd;
|
|
|
|
abd.cbSize = sizeof(APPBARDATA);
|
|
|
|
abd.lParam = *(DWORD*)lpData;
|
|
|
|
SHAppBarMessage(ABM_SETSTATE, &abd);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2021-12-13 01:46:28 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_PeopleBand"))
|
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
DWORD dwData = 0, dwSize = sizeof(DWORD);
|
|
|
|
RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People", L"PeopleBand", RRF_RT_DWORD, NULL, &dwData, &dwSize);
|
|
|
|
if ((dwData && *(DWORD*)lpData) || (!dwData && !*(DWORD*)lpData))
|
|
|
|
{
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2021-12-13 01:46:28 +01:00
|
|
|
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 435, 0);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2021-12-22 23:56:20 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_Start_MaximumFrequentApps"))
|
|
|
|
{
|
|
|
|
RegSetKeyValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
2022-01-21 23:04:57 +01:00
|
|
|
TEXT(REGPATH_OLD),
|
2021-12-22 23:56:20 +01:00
|
|
|
L"Start_MaximumFrequentApps",
|
|
|
|
dwType,
|
|
|
|
lpData,
|
|
|
|
cbData
|
|
|
|
);
|
|
|
|
return RegSetValueExW(hKey, L"Start_MaximumFrequentApps", 0, dwType, lpData, cbData);
|
|
|
|
}
|
2022-01-21 12:06:46 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
|
|
|
|
{
|
2022-01-24 17:33:06 +01:00
|
|
|
return RegisterDWMService(*(DWORD*)lpData, 0);
|
2022-01-21 12:06:46 +01:00
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_RegisterAsShellExtension"))
|
|
|
|
{
|
|
|
|
HKEY hKey2 = NULL;
|
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Classes\\CLSID\\" _T(EP_CLSID) L"\\InprocServer32",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WOW64_64KEY,
|
|
|
|
&hKey2
|
|
|
|
);
|
|
|
|
WCHAR wszArgs[MAX_PATH];
|
|
|
|
if (((hKey2 == NULL || hKey2 == INVALID_HANDLE_VALUE) && !*(DWORD*)lpData) || !(hKey2 == NULL || hKey2 == INVALID_HANDLE_VALUE) && (*(DWORD*)lpData))
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey2);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (!(hKey2 == NULL || hKey2 == INVALID_HANDLE_VALUE))
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey2);
|
|
|
|
}
|
|
|
|
if (*(DWORD*)lpData)
|
|
|
|
{
|
|
|
|
wszArgs[0] = L'\"';
|
|
|
|
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszArgs + 1);
|
|
|
|
wcscat_s(wszArgs, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".amd64.dll\"");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wszArgs[0] = L'/';
|
|
|
|
wszArgs[1] = L'u';
|
|
|
|
wszArgs[2] = L' ';
|
|
|
|
wszArgs[3] = L'"';
|
|
|
|
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszArgs + 4);
|
|
|
|
wcscat_s(wszArgs, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".amd64.dll\"");
|
|
|
|
}
|
|
|
|
wprintf(L"%s\n", wszArgs);
|
|
|
|
WCHAR wszApp[MAX_PATH * 2];
|
|
|
|
GetSystemDirectoryW(wszApp, MAX_PATH * 2);
|
|
|
|
wcscat_s(wszApp, MAX_PATH * 2, L"\\regsvr32.exe");
|
|
|
|
wprintf(L"%s\n", wszApp);
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.hInstApp = NULL;
|
|
|
|
sei.lpVerb = L"runas";
|
|
|
|
sei.lpFile = wszApp;
|
|
|
|
sei.lpParameters = wszArgs;
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.nShow = SW_NORMAL;
|
|
|
|
if (ShellExecuteExW(&sei) && sei.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
|
|
DWORD dwExitCode = 0;
|
|
|
|
if (GetExitCodeProcess(sei.hProcess, &dwExitCode) && !dwExitCode)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
CloseHandle(sei.hProcess);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
if (dwError == ERROR_CANCELLED)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2021-12-05 03:04:41 +01:00
|
|
|
}
|
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
LSTATUS GUI_RegSetValueExW(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpValueName,
|
|
|
|
DWORD Reserved,
|
|
|
|
DWORD dwType,
|
|
|
|
const BYTE* lpData,
|
|
|
|
DWORD cbData
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LSTATUS lRes = GUI_Internal_RegSetValueExW(hKey, lpValueName, Reserved, dwType, lpData, cbData);
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
LSTATUS GUI_Internal_RegQueryValueExW(
|
2021-12-05 03:04:41 +01:00
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpValueName,
|
|
|
|
LPDWORD lpReserved,
|
|
|
|
LPDWORD lpType,
|
|
|
|
LPBYTE lpData,
|
|
|
|
LPDWORD lpcbData
|
|
|
|
)
|
|
|
|
{
|
2021-12-07 16:35:06 +01:00
|
|
|
if (!lpValueName || wcsncmp(lpValueName, L"Virtualized_" _T(EP_CLSID), 50))
|
2021-12-05 03:04:41 +01:00
|
|
|
{
|
|
|
|
return RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
|
|
|
}
|
|
|
|
if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition"))
|
|
|
|
{
|
|
|
|
StuckRectsData srd;
|
|
|
|
DWORD pcbData = sizeof(StuckRectsData);
|
|
|
|
RegGetValueW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRectsLegacy",
|
|
|
|
L"Settings",
|
|
|
|
REG_BINARY,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData);
|
|
|
|
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
|
|
|
|
{
|
2021-12-09 18:08:09 +01:00
|
|
|
dwTaskbarPosition = srd.pvData[3];
|
2021-12-24 02:35:14 +01:00
|
|
|
if (!gui_bOldTaskbar)
|
|
|
|
{
|
|
|
|
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
|
|
|
|
{
|
|
|
|
srd.pvData[3] = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*(DWORD*)lpData = srd.pvData[3];
|
2021-12-05 03:04:41 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
return ERROR_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_MMTaskbarPosition"))
|
|
|
|
{
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MMStuckRectsLegacy",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WRITE,
|
|
|
|
&hKey
|
|
|
|
);
|
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
WCHAR name[60];
|
|
|
|
DWORD szName = 60;
|
|
|
|
StuckRectsData srd;
|
|
|
|
DWORD pcbData = sizeof(StuckRectsData);
|
|
|
|
RegEnumValueW(
|
|
|
|
hKey,
|
|
|
|
0,
|
|
|
|
name,
|
|
|
|
&szName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&srd,
|
|
|
|
&pcbData
|
|
|
|
);
|
|
|
|
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
|
|
|
|
{
|
2021-12-24 02:35:14 +01:00
|
|
|
if (!gui_bOldTaskbar)
|
|
|
|
{
|
|
|
|
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
|
|
|
|
{
|
|
|
|
srd.pvData[3] = 3;
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 03:04:41 +01:00
|
|
|
*(DWORD*)lpData = srd.pvData[3];
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
return ERROR_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_AutoHideTaskbar"))
|
|
|
|
{
|
|
|
|
APPBARDATA abd;
|
|
|
|
abd.cbSize = sizeof(APPBARDATA);
|
|
|
|
*(DWORD*)lpData = (SHAppBarMessage(ABM_GETSTATE, &abd) == ABS_AUTOHIDE);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2021-12-13 01:46:28 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_PeopleBand"))
|
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
return RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People", L"PeopleBand", RRF_RT_DWORD, NULL, lpData, lpcbData);
|
2021-12-13 01:46:28 +01:00
|
|
|
}
|
2021-12-22 23:56:20 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_Start_MaximumFrequentApps"))
|
|
|
|
{
|
|
|
|
return RegQueryValueExW(hKey, L"Start_MaximumFrequentApps", lpReserved, lpType, lpData, lpcbData);
|
|
|
|
}
|
2022-01-21 12:06:46 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
|
|
|
|
{
|
2022-01-24 17:33:06 +01:00
|
|
|
HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, _T(EP_DWM_EVENTNAME));
|
2022-01-21 12:06:46 +01:00
|
|
|
if (h_exists)
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 0;
|
|
|
|
}
|
|
|
|
CloseHandle(h_exists);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_ACCESS_DENIED)
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_RegisterAsShellExtension"))
|
|
|
|
{
|
|
|
|
HKEY hKey2 = NULL;
|
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Classes\\CLSID\\" _T(EP_CLSID) L"\\InprocServer32",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WOW64_64KEY,
|
|
|
|
&hKey2
|
|
|
|
);
|
|
|
|
if (hKey2 == NULL || hKey2 == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(DWORD*)lpData = 1;
|
|
|
|
RegCloseKey(hKey2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LSTATUS GUI_RegCreateKeyExW(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpSubKey,
|
|
|
|
DWORD Reserved,
|
|
|
|
LPWSTR lpClass,
|
|
|
|
DWORD dwOptions,
|
|
|
|
REGSAM samDesired,
|
|
|
|
const LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
|
|
|
PHKEY phkResult,
|
|
|
|
LPDWORD lpdwDisposition
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LSTATUS lRes = RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
|
|
|
|
if (AuditFile)
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"[%s\\%s]\n", hKey == HKEY_CURRENT_USER ? L"HKEY_CURRENT_USER" : L"HKEY_LOCAL_MACHINE", lpSubKey);
|
|
|
|
}
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
LSTATUS GUI_RegOpenKeyExW(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpSubKey,
|
|
|
|
DWORD ulOptions,
|
|
|
|
REGSAM samDesired,
|
|
|
|
PHKEY phkResult
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LSTATUS lRes = RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
|
|
|
if (AuditFile)
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"[%s%s\\%s]\n", (*phkResult == NULL || *phkResult == INVALID_HANDLE_VALUE) ? L"-" : L"", hKey == HKEY_CURRENT_USER ? L"HKEY_CURRENT_USER" : L"HKEY_LOCAL_MACHINE", lpSubKey);
|
|
|
|
WCHAR wszDefVal[MAX_PATH];
|
|
|
|
ZeroMemory(wszDefVal, MAX_PATH);
|
|
|
|
DWORD dwLen = MAX_PATH;
|
|
|
|
RegGetValueW(hKey, lpSubKey, NULL, RRF_RT_REG_SZ, NULL, wszDefVal, &dwLen);
|
|
|
|
if (wszDefVal[0])
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"@=\"%s\"\n", wszDefVal);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"@=\"\"\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
LSTATUS GUI_RegQueryValueExW(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR lpValueName,
|
|
|
|
LPDWORD lpReserved,
|
|
|
|
LPDWORD lpType,
|
|
|
|
LPBYTE lpData,
|
|
|
|
LPDWORD lpcbData
|
|
|
|
)
|
|
|
|
{
|
2022-01-27 03:35:27 +01:00
|
|
|
DWORD dwSize = lpcbData ? *(DWORD*)lpcbData : sizeof(DWORD);
|
2022-01-21 23:04:57 +01:00
|
|
|
LSTATUS lRes = GUI_Internal_RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
|
|
|
if (AuditFile)
|
|
|
|
{
|
2022-01-27 03:35:27 +01:00
|
|
|
if (dwSize != sizeof(DWORD))
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"%s\"%s\"=\"%s\"\n", (lpValueName && wcsncmp(lpValueName, L"Virtualized_" _T(EP_CLSID), 50)) ? L"" : L";", lpValueName, lpData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"%s\"%s\"=dword:%08x\n", (lpValueName && wcsncmp(lpValueName, L"Virtualized_" _T(EP_CLSID), 50)) ? L"" : L";", lpValueName, *(DWORD*)lpData);
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
}
|
|
|
|
return lRes;
|
2021-12-05 03:04:41 +01:00
|
|
|
}
|
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
static HRESULT GUI_AboutProc(
|
|
|
|
HWND hwnd,
|
|
|
|
UINT uNotification,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam,
|
|
|
|
LONG_PTR lpRefData
|
|
|
|
)
|
|
|
|
{
|
|
|
|
switch (uNotification)
|
|
|
|
{
|
|
|
|
case TDN_BUTTON_CLICKED:
|
|
|
|
{
|
|
|
|
if (wParam == IDOK || wParam == IDCANCEL)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (wParam == IDS_VISITGITHUB)
|
|
|
|
{
|
|
|
|
ShellExecuteA(
|
|
|
|
NULL,
|
|
|
|
"open",
|
|
|
|
"https://github.com/valinet/ExplorerPatcher",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (wParam == IDS_VISITWEBSITE)
|
|
|
|
{
|
|
|
|
ShellExecuteA(
|
|
|
|
NULL,
|
|
|
|
"open",
|
|
|
|
"https://www.valinet.ro",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (wParam == IDS_LICENSEINFO)
|
|
|
|
{
|
|
|
|
ShellExecuteA(
|
|
|
|
NULL,
|
|
|
|
"open",
|
|
|
|
"mailto:valentingabrielradu@gmail.com",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-11-16 06:00:10 +01:00
|
|
|
static void GUI_SetSection(GUI* _this, BOOL bCheckEnablement, int dwSection)
|
|
|
|
{
|
|
|
|
_this->section = dwSection;
|
|
|
|
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
DWORD dwSize = sizeof(DWORD);
|
|
|
|
RegCreateKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
TEXT(REGPATH),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bEnabled = FALSE;
|
|
|
|
if (bCheckEnablement)
|
|
|
|
{
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("LastSectionInProperties"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&bEnabled,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
dwSection++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bEnabled = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bEnabled)
|
|
|
|
{
|
|
|
|
RegSetValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("LastSectionInProperties"),
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
&dwSection,
|
|
|
|
sizeof(DWORD)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
|
|
|
{
|
|
|
|
GUI* _this;
|
|
|
|
LONG_PTR ptr = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
|
|
_this = (int*)(ptr);
|
|
|
|
double dx = _this->dpi.x / 96.0, dy = _this->dpi.y / 96.0;
|
|
|
|
_this->padding.left = GUI_PADDING_LEFT * dx;
|
|
|
|
_this->padding.right = GUI_PADDING_RIGHT * dx;
|
|
|
|
_this->padding.top = GUI_PADDING_TOP * dy;
|
|
|
|
_this->padding.bottom = GUI_PADDING_BOTTOM * dy;
|
2021-10-15 12:50:52 +02:00
|
|
|
_this->sidebarWidth = GUI_SIDEBAR_WIDTH * dx;
|
2021-10-02 03:02:07 +02:00
|
|
|
|
|
|
|
RECT rc;
|
|
|
|
GetClientRect(hwnd, &rc);
|
2021-10-16 04:56:46 +02:00
|
|
|
|
|
|
|
PVOID pRscr = NULL;
|
|
|
|
DWORD cbRscr = 0;
|
|
|
|
if (GUI_FileMapping && GUI_FileSize)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-16 04:56:46 +02:00
|
|
|
pRscr = GUI_FileMapping;
|
|
|
|
cbRscr = GUI_FileSize;
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2021-10-16 04:56:46 +02:00
|
|
|
else
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-16 04:56:46 +02:00
|
|
|
HRSRC hRscr = FindResource(
|
|
|
|
hModule,
|
|
|
|
MAKEINTRESOURCE(IDR_REGISTRY1),
|
|
|
|
RT_RCDATA
|
|
|
|
);
|
|
|
|
if (!hRscr)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
HGLOBAL hgRscr = LoadResource(
|
|
|
|
hModule,
|
|
|
|
hRscr
|
|
|
|
);
|
|
|
|
if (!hgRscr)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pRscr = LockResource(hgRscr);
|
|
|
|
cbRscr = SizeofResource(
|
|
|
|
hModule,
|
|
|
|
hRscr
|
|
|
|
);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
|
2022-01-27 21:34:37 +01:00
|
|
|
UINT dpiX = 0, dpiY = 0;
|
|
|
|
HRESULT hr = GetDpiForMonitor(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), MDT_DEFAULT, &dpiX, &dpiY);
|
2021-10-02 03:02:07 +02:00
|
|
|
LOGFONT logFont;
|
|
|
|
memset(&logFont, 0, sizeof(logFont));
|
2021-10-10 05:14:23 +02:00
|
|
|
NONCLIENTMETRICS ncm;
|
|
|
|
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
2022-01-27 21:34:37 +01:00
|
|
|
SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpiX);
|
2021-10-10 05:14:23 +02:00
|
|
|
logFont = ncm.lfCaptionFont;
|
2022-01-27 21:34:37 +01:00
|
|
|
//logFont.lfHeight = GUI_CAPTION_FONT_SIZE * dy;
|
2021-12-24 01:06:08 +01:00
|
|
|
//logFont.lfWeight = FW_BOLD;
|
2021-10-02 03:02:07 +02:00
|
|
|
HFONT hFontCaption = CreateFontIndirect(&logFont);
|
2021-10-21 08:01:59 +02:00
|
|
|
logFont = ncm.lfMenuFont;
|
2022-01-27 21:34:37 +01:00
|
|
|
//logFont.lfHeight = GUI_TITLE_FONT_SIZE * dy;
|
2021-10-02 03:02:07 +02:00
|
|
|
HFONT hFontTitle = CreateFontIndirect(&logFont);
|
|
|
|
logFont.lfWeight = FW_REGULAR;
|
|
|
|
logFont.lfUnderline = 1;
|
|
|
|
HFONT hFontUnderline = CreateFontIndirect(&logFont);
|
|
|
|
logFont.lfWeight = FW_REGULAR;
|
|
|
|
logFont.lfUnderline = 0;
|
|
|
|
HFONT hFontRegular = CreateFontIndirect(&logFont);
|
2021-10-15 12:50:52 +02:00
|
|
|
logFont.lfWeight = FW_DEMIBOLD;
|
2022-01-27 21:34:37 +01:00
|
|
|
//logFont.lfHeight = GUI_SECTION_FONT_SIZE * dy;
|
2021-10-15 12:50:52 +02:00
|
|
|
HFONT hFontSection = CreateFontIndirect(&logFont);
|
|
|
|
logFont.lfUnderline = 1;
|
|
|
|
HFONT hFontSectionSel = CreateFontIndirect(&logFont);
|
2021-10-02 03:02:07 +02:00
|
|
|
HFONT hOldFont = NULL;
|
|
|
|
|
|
|
|
DTTOPTS DttOpts;
|
|
|
|
DttOpts.dwSize = sizeof(DTTOPTS);
|
|
|
|
DttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR;
|
2021-10-10 05:14:23 +02:00
|
|
|
//DttOpts.crText = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR;
|
2021-10-02 03:02:07 +02:00
|
|
|
DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS;
|
|
|
|
RECT rcText;
|
2021-10-10 05:14:23 +02:00
|
|
|
DWORD dwMaxHeight = 0, dwMaxWidth = 0;
|
2021-10-02 20:57:19 +02:00
|
|
|
BOOL bTabOrderHit = FALSE;
|
2021-10-15 12:50:52 +02:00
|
|
|
DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right;
|
|
|
|
DWORD dwInitialLeftPad = dwLeftPad;
|
2021-10-02 03:02:07 +02:00
|
|
|
|
|
|
|
HDC hdcPaint = NULL;
|
|
|
|
BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) };
|
|
|
|
params.dwFlags = BPPF_ERASE;
|
|
|
|
HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hDC, &rc, BPBF_TOPDOWNDIB, ¶ms, &hdcPaint);
|
|
|
|
|
|
|
|
if (!hDC || (hDC && hdcPaint))
|
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
if (!hDC)
|
|
|
|
{
|
|
|
|
hdcPaint = GetDC(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsThemeActive() && hDC)
|
2021-10-10 05:14:23 +02:00
|
|
|
{
|
2021-10-21 08:01:59 +02:00
|
|
|
COLORREF oldcr = SetBkColor(hdcPaint, GetSysColor(COLOR_MENU));
|
2021-10-10 05:14:23 +02:00
|
|
|
ExtTextOutW(hdcPaint, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0);
|
|
|
|
SetBkColor(hdcPaint, oldcr);
|
|
|
|
SetTextColor(hdcPaint, GetSysColor(COLOR_WINDOWTEXT));
|
2021-10-21 08:01:59 +02:00
|
|
|
SetBkMode(hdcPaint, TRANSPARENT);
|
2021-10-10 05:14:23 +02:00
|
|
|
}
|
|
|
|
|
2022-01-05 04:02:25 +01:00
|
|
|
BOOL bResetLastHeading = TRUE;
|
2021-11-16 06:00:10 +01:00
|
|
|
BOOL bWasSpecifiedSectionValid = FALSE;
|
2021-10-02 03:02:07 +02:00
|
|
|
FILE* f = fmemopen(pRscr, cbRscr, "r");
|
|
|
|
char* line = malloc(MAX_LINE_LENGTH * sizeof(char));
|
2021-10-15 12:50:52 +02:00
|
|
|
wchar_t* text = malloc((MAX_LINE_LENGTH + 3) * sizeof(wchar_t));
|
2021-10-02 03:02:07 +02:00
|
|
|
wchar_t* name = malloc(MAX_LINE_LENGTH * sizeof(wchar_t));
|
|
|
|
wchar_t* section = malloc(MAX_LINE_LENGTH * sizeof(wchar_t));
|
2021-10-15 12:50:52 +02:00
|
|
|
size_t bufsiz = MAX_LINE_LENGTH, numChRd = 0, tabOrder = 1, currentSection = -1, topAdj = 0;
|
2022-01-05 04:02:25 +01:00
|
|
|
wchar_t* lastHeading = calloc(MAX_LINE_LENGTH, sizeof(wchar_t));
|
2021-10-02 03:02:07 +02:00
|
|
|
while ((numChRd = getline(&line, &bufsiz, f)) != -1)
|
|
|
|
{
|
2021-11-16 06:00:10 +01:00
|
|
|
if (currentSection == _this->section)
|
|
|
|
{
|
|
|
|
bWasSpecifiedSectionValid = TRUE;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
if (!strncmp(line, ";q", 2))
|
|
|
|
{
|
|
|
|
bResetLastHeading = TRUE;
|
|
|
|
lastHeading[0] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2021-12-24 01:06:08 +01:00
|
|
|
if (strcmp(line, "Windows Registry Editor Version 5.00\r\n") &&
|
|
|
|
strcmp(line, "\r\n") &&
|
2022-01-21 23:04:57 +01:00
|
|
|
(currentSection == -1 || currentSection == _this->section || !strncmp(line, ";T ", 3) || !strncmp(line, ";f", 2) || AuditFile) &&
|
2021-12-24 01:06:08 +01:00
|
|
|
!(!IsThemeActive() && !strncmp(line, ";M ", 3))
|
|
|
|
)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-13 02:38:38 +02:00
|
|
|
#ifndef USE_PRIVATE_INTERFACES
|
|
|
|
if (!strncmp(line, ";p ", 3))
|
|
|
|
{
|
|
|
|
int num = atoi(line + 3);
|
|
|
|
for (int i = 0; i < num; ++i)
|
|
|
|
{
|
|
|
|
getline(&line, &bufsiz, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2021-10-15 12:50:52 +02:00
|
|
|
if (!strncmp(line, ";f", 2))
|
|
|
|
{
|
|
|
|
//if (topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy) > dwMaxHeight)
|
|
|
|
//{
|
|
|
|
// dwMaxHeight = topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy);
|
|
|
|
//}
|
|
|
|
if (_this->dwStatusbarY == 0)
|
|
|
|
{
|
2021-12-24 01:06:08 +01:00
|
|
|
//dwMaxHeight += GUI_STATUS_PADDING * dy;
|
2021-10-15 12:50:52 +02:00
|
|
|
_this->dwStatusbarY = dwMaxHeight / dy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwMaxHeight = _this->dwStatusbarY * dy;
|
|
|
|
}
|
|
|
|
currentSection = -1;
|
|
|
|
dwLeftPad = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2021-10-13 02:38:38 +02:00
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
if (!strncmp(line, "[", 1))
|
|
|
|
{
|
|
|
|
ZeroMemory(section, MAX_LINE_LENGTH * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line[1] == '-' ? line + 2 : line + 1,
|
|
|
|
numChRd - (line[1] == '-' ? 5 : 4),
|
|
|
|
section,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
|
|
|
//wprintf(L"%s\n", section);
|
|
|
|
}
|
|
|
|
|
2021-12-24 01:06:08 +01:00
|
|
|
DWORD dwLineHeight = !strncmp(line, ";M ", 3) ? _this->GUI_CAPTION_LINE_HEIGHT : GUI_LINE_HEIGHT;
|
2021-10-16 01:47:43 +02:00
|
|
|
DWORD dwBottom = _this->padding.bottom;
|
|
|
|
DWORD dwTop = _this->padding.top;
|
|
|
|
if (!strncmp(line, ";a ", 3) || !strncmp(line, ";e ", 3))
|
|
|
|
{
|
|
|
|
dwBottom = 0;
|
|
|
|
dwLineHeight -= 0.2 * dwLineHeight;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
|
2021-10-15 12:50:52 +02:00
|
|
|
rcText.left = dwLeftPad + _this->padding.left;
|
2021-12-24 01:06:08 +01:00
|
|
|
rcText.top = !strncmp(line, ";M ", 3) ? 0 : (dwTop + dwMaxHeight);
|
2021-10-02 03:02:07 +02:00
|
|
|
rcText.right = (rc.right - rc.left) - _this->padding.right;
|
2021-12-24 01:06:08 +01:00
|
|
|
rcText.bottom = !strncmp(line, ";M ", 3) ? _this->GUI_CAPTION_LINE_HEIGHT * dy : (dwMaxHeight + dwLineHeight * dy - dwBottom);
|
2021-10-02 03:02:07 +02:00
|
|
|
|
|
|
|
if (!strncmp(line, ";T ", 3))
|
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
if (currentSection + 1 == _this->section)
|
|
|
|
{
|
|
|
|
hOldFont = SelectObject(hdcPaint, hFontSectionSel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hOldFont = SelectObject(hdcPaint, hFontSection);
|
|
|
|
}
|
|
|
|
rcText.left = _this->padding.left;
|
|
|
|
rcText.right = _this->padding.left + _this->sidebarWidth;
|
|
|
|
rcText.top = topAdj + ((currentSection + 1) * GUI_SECTION_HEIGHT * dy);
|
|
|
|
rcText.bottom = topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy);
|
|
|
|
ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line + 3,
|
|
|
|
numChRd - 3,
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
2022-01-05 04:02:25 +01:00
|
|
|
if (_this->sectionNames[currentSection + 1][0] == 0)
|
|
|
|
{
|
|
|
|
wcscpy_s(_this->sectionNames[currentSection + 1], 20, text);
|
|
|
|
}
|
2021-10-15 12:50:52 +02:00
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
DrawThemeTextEx(
|
|
|
|
_this->hTheme,
|
|
|
|
hdcPaint,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
dwTextFlags,
|
|
|
|
&rcText,
|
|
|
|
&DttOpts
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcText,
|
|
|
|
dwTextFlags
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcTemp.bottom = rcText.bottom;
|
|
|
|
if (PtInRect(&rcTemp, pt))
|
|
|
|
{
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
|
|
|
_this->bRebuildIfTabOrderIsEmpty = FALSE;
|
|
|
|
_this->tabOrder = 0;
|
2021-11-16 06:00:10 +01:00
|
|
|
GUI_SetSection(_this, TRUE, currentSection + 1);
|
2021-10-15 12:50:52 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentSection++;
|
|
|
|
continue;
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else if (!strncmp(line, ";M ", 3))
|
|
|
|
{
|
2021-12-24 01:06:08 +01:00
|
|
|
UINT diff = (((_this->GUI_CAPTION_LINE_HEIGHT - 16) * dx) / 2.0);
|
|
|
|
rcText.left = diff + (int)(16.0 * dx) + diff / 2;
|
|
|
|
topAdj = dwMaxHeight + _this->GUI_CAPTION_LINE_HEIGHT * dy;
|
2021-10-15 12:50:52 +02:00
|
|
|
hOldFont = SelectObject(hdcPaint, hFontCaption);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
else if (!strncmp(line, ";u ", 3) || (!strncmp(line, ";y ", 3) && !strstr(line, "\xF0\x9F")))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
hOldFont = SelectObject(hdcPaint, hFontUnderline);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
hOldFont = SelectObject(hdcPaint, hFontRegular);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
|
2021-10-16 01:47:43 +02:00
|
|
|
if (!strncmp(line, ";e ", 3) || !strncmp(line, ";a ", 3) || !strncmp(line, ";T ", 3) || !strncmp(line, ";t ", 3) || !strncmp(line, ";u ", 3) || !strncmp(line, ";M ", 3))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-16 01:47:43 +02:00
|
|
|
if (!strncmp(line, ";t ", 3) || !strncmp(line, ";e ", 3) || !strncmp(line, ";a ", 3))
|
2021-10-15 12:50:52 +02:00
|
|
|
{
|
2021-12-05 03:04:41 +01:00
|
|
|
char* p = strstr(line, "%VERSIONINFORMATIONSTRING%");
|
2021-10-15 12:50:52 +02:00
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
DWORD dwLeftMost = 0;
|
|
|
|
DWORD dwSecondLeft = 0;
|
|
|
|
DWORD dwSecondRight = 0;
|
|
|
|
DWORD dwRightMost = 0;
|
|
|
|
|
|
|
|
QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
|
|
|
|
|
2021-12-05 03:04:41 +01:00
|
|
|
sprintf_s(p, MAX_PATH, "%d.%d.%d.%d%s", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost,
|
|
|
|
#if defined(DEBUG) | defined(_DEBUG)
|
|
|
|
" (Debug)"
|
|
|
|
#else
|
|
|
|
""
|
|
|
|
#endif
|
|
|
|
);
|
2021-10-15 12:50:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t));
|
2021-10-02 03:02:07 +02:00
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line + 3,
|
|
|
|
numChRd - 3,
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
2022-01-05 04:02:25 +01:00
|
|
|
if (bResetLastHeading)
|
|
|
|
{
|
|
|
|
wcscpy_s(lastHeading, MAX_LINE_LENGTH, text);
|
|
|
|
bResetLastHeading = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wcscat_s(lastHeading, MAX_LINE_LENGTH, L" ");
|
|
|
|
wcscat_s(lastHeading, MAX_LINE_LENGTH, text);
|
|
|
|
}
|
2021-10-16 01:47:43 +02:00
|
|
|
if (!strncmp(line, ";a ", 3))
|
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
L"\u2795 ",
|
|
|
|
3,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcText.left += rcTemp.right - rcTemp.left;
|
|
|
|
rcText.right += rcTemp.right - rcTemp.left;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
if (!strncmp(line, ";M ", 3))
|
|
|
|
{
|
2021-12-24 01:06:08 +01:00
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
UINT diff = (int)(((_this->GUI_CAPTION_LINE_HEIGHT - 16) * dx) / 2.0);
|
|
|
|
//printf("!!! %d %d\n", (int)(16.0 * dx), diff);
|
|
|
|
DrawIconEx(
|
|
|
|
hdcPaint,
|
|
|
|
diff,
|
|
|
|
diff,
|
|
|
|
_this->hIcon,
|
|
|
|
(int)(16.0 * dx),
|
|
|
|
(int)(16.0 * dy),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
DI_NORMAL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-02 18:46:01 +02:00
|
|
|
TCHAR exeName[MAX_PATH + 1];
|
|
|
|
GetProcessImageFileNameW(
|
|
|
|
OpenProcess(
|
|
|
|
PROCESS_QUERY_INFORMATION,
|
|
|
|
FALSE,
|
|
|
|
GetCurrentProcessId()
|
|
|
|
),
|
|
|
|
exeName,
|
|
|
|
MAX_PATH
|
|
|
|
);
|
|
|
|
PathStripPath(exeName);
|
2021-10-15 12:50:52 +02:00
|
|
|
//if (wcscmp(exeName, L"explorer.exe"))
|
|
|
|
//{
|
|
|
|
// LoadStringW(hModule, IDS_PRODUCTNAME, text, MAX_LINE_LENGTH);
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
2021-12-28 15:06:37 +01:00
|
|
|
//HMODULE hExplorerFrame = LoadLibraryExW(L"ExplorerFrame.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
LoadStringW(_this->hExplorerFrame, 50222, text, 260);
|
|
|
|
//FreeLibrary(hExplorerFrame);
|
2021-10-02 18:46:01 +02:00
|
|
|
wchar_t* p = wcschr(text, L'(');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
p--;
|
2021-10-03 03:05:27 +02:00
|
|
|
if (p == L' ')
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
*p = 0;
|
|
|
|
}
|
2021-10-02 18:46:01 +02:00
|
|
|
}
|
2021-10-15 12:50:52 +02:00
|
|
|
//}
|
2021-12-24 01:06:08 +01:00
|
|
|
//rcText.bottom += _this->GUI_CAPTION_LINE_HEIGHT - dwLineHeight;
|
|
|
|
dwLineHeight = _this->GUI_CAPTION_LINE_HEIGHT;
|
2021-10-02 03:02:07 +02:00
|
|
|
_this->extent.cyTopHeight = rcText.bottom;
|
|
|
|
}
|
|
|
|
if (hDC)
|
|
|
|
{
|
2021-10-10 05:14:23 +02:00
|
|
|
COLORREF cr;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (!strncmp(line, ";u ", 3) && tabOrder == _this->tabOrder)
|
|
|
|
{
|
|
|
|
bTabOrderHit = TRUE;
|
2021-10-10 05:14:23 +02:00
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
2021-10-21 08:01:59 +02:00
|
|
|
cr = SetTextColor(hdcPaint, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
2021-10-10 05:14:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_SELECTED_DARK : GUI_TEXTCOLOR_SELECTED;
|
|
|
|
//DttOpts.crText = GetSysColor(COLOR_HIGHLIGHT);
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
if (_this->bShouldAnnounceSelected)
|
|
|
|
{
|
|
|
|
WCHAR accText[1000];
|
|
|
|
swprintf_s(
|
|
|
|
accText,
|
|
|
|
1000,
|
|
|
|
L"%s %s - Button.",
|
|
|
|
(_this->dwPageLocation < 0 ?
|
|
|
|
L"Reached end of the page." :
|
|
|
|
(_this->dwPageLocation > 0 ?
|
|
|
|
L"Reached beginning of the page." : L"")),
|
|
|
|
text
|
|
|
|
);
|
|
|
|
_this->dwPageLocation = 0;
|
|
|
|
for (unsigned int i = 0; i < wcslen(accText) - 2; ++i)
|
|
|
|
{
|
|
|
|
if (accText[i] == L'(' && accText[i + 1] == L'*' && accText[i + 2] == L')')
|
|
|
|
{
|
|
|
|
accText[i] = L' ';
|
|
|
|
accText[i + 1] = L' ';
|
|
|
|
accText[i + 2] = L' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetWindowTextW(_this->hAccLabel, accText);
|
|
|
|
NotifyWinEvent(
|
|
|
|
EVENT_OBJECT_LIVEREGIONCHANGED,
|
|
|
|
_this->hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF);
|
|
|
|
_this->bShouldAnnounceSelected = FALSE;
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
RECT rcNew = rcText;
|
|
|
|
DrawTextW(
|
2021-10-02 03:02:07 +02:00
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
2021-10-10 05:14:23 +02:00
|
|
|
&rcNew,
|
|
|
|
DT_CALCRECT
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2021-10-10 05:14:23 +02:00
|
|
|
if (rcNew.right - rcNew.left > dwMaxWidth)
|
|
|
|
{
|
2021-10-16 01:47:43 +02:00
|
|
|
dwMaxWidth = rcNew.right - rcNew.left + 50 * dx;
|
2021-10-10 05:14:23 +02:00
|
|
|
}
|
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
DrawThemeTextEx(
|
|
|
|
_this->hTheme,
|
|
|
|
hdcPaint,
|
|
|
|
hOldFont ? 0 : 8,
|
|
|
|
0,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
dwTextFlags,
|
|
|
|
&rcText,
|
|
|
|
&DttOpts
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcText,
|
|
|
|
dwTextFlags
|
|
|
|
);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
if (!strncmp(line, ";u ", 3) && tabOrder == _this->tabOrder)
|
|
|
|
{
|
2021-10-10 05:14:23 +02:00
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
|
|
|
SetTextColor(hdcPaint, cr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR;
|
|
|
|
//DttOpts.crText = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
2021-10-10 05:14:23 +02:00
|
|
|
DrawTextW(
|
2021-10-15 12:50:52 +02:00
|
|
|
hdcPaint,
|
2021-10-02 03:02:07 +02:00
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcTemp.bottom = rcText.bottom;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (!strncmp(line, ";u ", 3) && (PtInRect(&rcTemp, pt) || (pt.x == 0 && pt.y == 0 && tabOrder == _this->tabOrder)))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
numChRd = getline(&line, &bufsiz, f);
|
|
|
|
char* p = strchr(line, '\r');
|
|
|
|
if (p) *p = 0;
|
|
|
|
p = strchr(line, '\n');
|
|
|
|
if (p) *p = 0;
|
|
|
|
if (!strncmp(line + 1, "restart", 7))
|
|
|
|
{
|
2021-12-10 01:35:26 +01:00
|
|
|
HWND hShellTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
|
|
|
|
if (hShellTrayWnd)
|
2021-10-25 04:42:03 +02:00
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
|
2021-12-12 19:33:22 +01:00
|
|
|
PDWORD_PTR res = -1;
|
2021-12-10 01:35:26 +01:00
|
|
|
if (!SendMessageTimeoutW(hShellTrayWnd, 1460, 0, 0, SMTO_ABORTIFHUNG, 2000, &res) && res)
|
|
|
|
{
|
|
|
|
HANDLE hExplorerRestartThread = CreateThread(NULL, 0, BeginExplorerRestart, NULL, 0, NULL);
|
|
|
|
if (hExplorerRestartThread)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(hExplorerRestartThread, 2000);
|
|
|
|
CloseHandle(hExplorerRestartThread);
|
|
|
|
hExplorerRestartThread = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BeginExplorerRestart();
|
|
|
|
}
|
2021-12-10 02:06:04 +01:00
|
|
|
}
|
|
|
|
Sleep(100);
|
|
|
|
GetSystemDirectoryW(wszPath, MAX_PATH);
|
|
|
|
wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe");
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.hInstApp = NULL;
|
|
|
|
sei.lpVerb = NULL;
|
|
|
|
sei.lpFile = wszPath;
|
|
|
|
sei.lpParameters = L"/f /im explorer.exe";
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.nShow = SW_SHOWMINIMIZED;
|
|
|
|
if (ShellExecuteExW(&sei) && sei.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
|
|
CloseHandle(sei.hProcess);
|
2021-12-10 01:35:26 +01:00
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
GetWindowsDirectoryW(wszPath, MAX_PATH);
|
|
|
|
wcscat_s(wszPath, MAX_PATH, L"\\explorer.exe");
|
|
|
|
Sleep(1000);
|
2021-12-10 03:01:42 +01:00
|
|
|
GUI_RegSetValueExW(NULL, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition", NULL, NULL, &dwTaskbarPosition, NULL);
|
2021-11-14 17:32:54 +01:00
|
|
|
ShellExecuteW(
|
|
|
|
NULL,
|
|
|
|
L"open",
|
|
|
|
wszPath,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL
|
|
|
|
);
|
2021-10-25 04:42:03 +02:00
|
|
|
}
|
|
|
|
else
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-25 04:42:03 +02:00
|
|
|
StartExplorer();
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(line + 1, "reset", 5))
|
|
|
|
{
|
|
|
|
wchar_t wszPath[MAX_PATH];
|
|
|
|
ZeroMemory(
|
|
|
|
wszPath,
|
|
|
|
MAX_PATH * sizeof(wchar_t)
|
|
|
|
);
|
|
|
|
SHGetFolderPathW(
|
|
|
|
NULL,
|
2021-11-15 23:07:33 +01:00
|
|
|
SPECIAL_FOLDER_LEGACY,
|
2021-10-02 03:02:07 +02:00
|
|
|
NULL,
|
|
|
|
SHGFP_TYPE_CURRENT,
|
|
|
|
wszPath
|
|
|
|
);
|
|
|
|
wcscat_s(
|
|
|
|
wszPath,
|
|
|
|
MAX_PATH,
|
|
|
|
TEXT(APP_RELATIVE_PATH)
|
|
|
|
);
|
|
|
|
CreateDirectoryW(wszPath, NULL);
|
|
|
|
wcscat_s(
|
|
|
|
wszPath,
|
|
|
|
MAX_PATH,
|
|
|
|
L"\\settings.reg"
|
|
|
|
);
|
|
|
|
wprintf(L"%s\n", wszPath);
|
|
|
|
HANDLE hFile = CreateFileW(
|
|
|
|
wszPath,
|
|
|
|
GENERIC_WRITE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (hFile)
|
|
|
|
{
|
2021-12-24 14:43:53 +01:00
|
|
|
void* buffer = NULL;
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
RegOpenKeyExW(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
L"Software\\Classes\\CLSID\\" _T(EP_CLSID) L"\\InprocServer32",
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WOW64_64KEY,
|
|
|
|
&hKey
|
|
|
|
);
|
2022-01-21 23:04:57 +01:00
|
|
|
buffer = pRscr;
|
2021-10-02 03:02:07 +02:00
|
|
|
DWORD dwNumberOfBytesWritten = 0;
|
|
|
|
if (WriteFile(
|
|
|
|
hFile,
|
2021-12-24 14:43:53 +01:00
|
|
|
buffer,
|
2021-10-02 03:02:07 +02:00
|
|
|
cbRscr,
|
|
|
|
&dwNumberOfBytesWritten,
|
|
|
|
NULL
|
|
|
|
))
|
|
|
|
{
|
|
|
|
CloseHandle(hFile);
|
2022-01-21 23:04:57 +01:00
|
|
|
DWORD dwOldTaskbarOld = 0, dwOldTaskbar = 0, dwSize = sizeof(DWORD);
|
|
|
|
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", RRF_RT_DWORD, NULL, &dwOldTaskbarOld, &dwSize);
|
|
|
|
RegSetKeyValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", REG_DWORD, &dwOldTaskbar, sizeof(DWORD));
|
2021-10-02 03:02:07 +02:00
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
DWORD dwError = 0;
|
|
|
|
// https://stackoverflow.com/questions/50298722/win32-launching-a-highestavailable-child-process-as-a-normal-user-process
|
|
|
|
if (pvRtlQueryElevationFlags = GetProcAddress(GetModuleHandleW(L"ntdll"), "RtlQueryElevationFlags"))
|
2022-01-21 12:06:46 +01:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
PVOID pv;
|
|
|
|
if (pv = AddVectoredExceptionHandler(TRUE, OnVex))
|
2022-01-21 12:06:46 +01:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
CONTEXT ctx;
|
|
|
|
ZeroMemory(&ctx, sizeof(CONTEXT));
|
|
|
|
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
|
|
|
|
ctx.Dr7 = 0x404;
|
|
|
|
ctx.Dr1 = (ULONG_PTR)pvRtlQueryElevationFlags;
|
2022-01-21 12:06:46 +01:00
|
|
|
|
2022-01-21 23:04:57 +01:00
|
|
|
if (SetThreadContext(GetCurrentThread(), &ctx))
|
2021-12-24 14:43:53 +01:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
WCHAR wszExec[MAX_PATH * 2];
|
|
|
|
ZeroMemory(wszExec, MAX_PATH * 2 * sizeof(WCHAR));
|
|
|
|
wszExec[0] = L'"';
|
|
|
|
GetWindowsDirectoryW(wszExec + 1, MAX_PATH);
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, L"\\regedit.exe\" \"");
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, wszPath);
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, L"\"");
|
|
|
|
STARTUPINFO si;
|
|
|
|
ZeroMemory(&si, sizeof(STARTUPINFO));
|
|
|
|
si.cb = sizeof(STARTUPINFO);
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
|
|
|
wprintf(L"%s\n", wszExec);
|
|
|
|
if (CreateProcessW(NULL, wszExec, 0, 0, 0, 0, 0, 0, &si, &pi))
|
2021-12-24 14:43:53 +01:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
//CloseHandle(pi.hProcess);
|
2021-12-24 14:43:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
|
|
|
|
ctx.Dr7 = 0x400;
|
|
|
|
ctx.Dr1 = 0;
|
|
|
|
SetThreadContext(GetCurrentThread(), &ctx);
|
|
|
|
|
|
|
|
if (pi.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
DWORD dwExitCode = 0;
|
|
|
|
GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
}
|
2021-12-24 14:43:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
RemoveVectoredExceptionHandler(pv);
|
2021-12-24 14:43:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
else
|
2021-12-24 14:43:53 +01:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", RRF_RT_DWORD, NULL, &dwOldTaskbar, &dwSize);
|
|
|
|
if (dwOldTaskbar == 1)
|
|
|
|
{
|
|
|
|
FILE* vf = NULL;
|
|
|
|
_wfopen_s(&vf, wszPath, L"r");
|
|
|
|
if (vf)
|
|
|
|
{
|
|
|
|
char* line2 = malloc(MAX_LINE_LENGTH * sizeof(char));
|
|
|
|
if (line2)
|
|
|
|
{
|
|
|
|
int numChRd2 = 0;
|
|
|
|
size_t bufsiz2 = MAX_LINE_LENGTH;
|
|
|
|
while ((numChRd2 = getline(&line2, &bufsiz2, vf)) != -1)
|
|
|
|
{
|
|
|
|
if (!strncmp(line2, ";\"Virtualized_" EP_CLSID, 52))
|
|
|
|
{
|
|
|
|
DWORD dwVal = 0;
|
|
|
|
WCHAR wszName[MAX_PATH];
|
|
|
|
ZeroMemory(wszName, MAX_PATH * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line2 + 2,
|
|
|
|
numChRd2 - 2,
|
|
|
|
wszName,
|
|
|
|
MAX_PATH
|
|
|
|
);
|
|
|
|
wchar_t* ddd = wcschr(wszName, L'=');
|
|
|
|
if (ddd) *ddd = 0;
|
|
|
|
wchar_t* ppp = wcschr(wszName, L'"');
|
|
|
|
if (ppp) *ppp = 0;
|
|
|
|
if (!wcsncmp(ddd + 1, L"dword:", 6))
|
|
|
|
{
|
|
|
|
wchar_t* xxx = wcschr(ddd + 1, L':');
|
|
|
|
xxx++;
|
|
|
|
dwVal = wcstol(xxx, NULL, 16);
|
|
|
|
wprintf(L"%s %d\n", wszName, dwVal);
|
|
|
|
GUI_RegSetValueExW(NULL, wszName, 0, RRF_RT_DWORD, &dwVal, sizeof(DWORD));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(line2);
|
|
|
|
}
|
|
|
|
fclose(vf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RegSetKeyValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", REG_DWORD, &dwOldTaskbarOld, sizeof(DWORD));
|
2021-12-24 14:43:53 +01:00
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
|
2021-10-02 22:13:33 +02:00
|
|
|
_this->tabOrder = 0;
|
2021-10-02 18:55:45 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2021-10-02 03:02:07 +02:00
|
|
|
DeleteFileW(wszPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(line + 1, "about", 5))
|
|
|
|
{
|
|
|
|
DWORD dwLeftMost = 0;
|
|
|
|
DWORD dwSecondLeft = 0;
|
|
|
|
DWORD dwSecondRight = 0;
|
|
|
|
DWORD dwRightMost = 0;
|
|
|
|
|
|
|
|
QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
|
|
|
|
|
|
|
|
TCHAR wszIDS_VISITGITHUB[100];
|
|
|
|
LoadString(hModule, IDS_VISITGITHUB, wszIDS_VISITGITHUB, 100);
|
|
|
|
TCHAR wszIDS_VISITWEBSITE[100];
|
|
|
|
LoadString(hModule, IDS_VISITWEBSITE, wszIDS_VISITWEBSITE, 100);
|
|
|
|
TCHAR wszIDS_LICENSEINFO[100];
|
|
|
|
LoadString(hModule, IDS_LICENSEINFO, wszIDS_LICENSEINFO, 100);
|
|
|
|
TCHAR wszIDS_PRODUCTNAME[100];
|
|
|
|
LoadString(hModule, IDS_PRODUCTNAME, wszIDS_PRODUCTNAME, 100);
|
|
|
|
TCHAR wszIDS_VERSION[100];
|
|
|
|
LoadString(hModule, IDS_VERSION, wszIDS_VERSION, 100);
|
|
|
|
TCHAR wszIDS_PRODUCTTAG[406];
|
|
|
|
wsprintf(wszIDS_PRODUCTTAG, wszIDS_VERSION, dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
|
|
|
|
wcscat_s(
|
|
|
|
wszIDS_PRODUCTTAG,
|
|
|
|
406,
|
|
|
|
L"\r\n"
|
|
|
|
);
|
|
|
|
LoadString(hModule, IDS_COPYRIGHT, wszIDS_PRODUCTTAG + wcslen(wszIDS_PRODUCTTAG), 100);
|
|
|
|
wcscat_s(
|
|
|
|
wszIDS_PRODUCTTAG,
|
|
|
|
406,
|
|
|
|
L"\r\n\r\n"
|
|
|
|
);
|
|
|
|
LoadString(hModule, IDS_PRODUCTTAG, wszIDS_PRODUCTTAG + wcslen(wszIDS_PRODUCTTAG), 200);
|
|
|
|
|
|
|
|
TASKDIALOG_BUTTON buttons[3];
|
|
|
|
buttons[0].nButtonID = IDS_VISITGITHUB;
|
|
|
|
buttons[0].pszButtonText = wszIDS_VISITGITHUB;
|
|
|
|
buttons[1].nButtonID = IDS_VISITWEBSITE;
|
|
|
|
buttons[1].pszButtonText = wszIDS_VISITWEBSITE;
|
|
|
|
buttons[2].nButtonID = IDS_LICENSEINFO;
|
|
|
|
buttons[2].pszButtonText = wszIDS_LICENSEINFO;
|
|
|
|
|
|
|
|
TASKDIALOGCONFIG td;
|
|
|
|
ZeroMemory(&td, sizeof(TASKDIALOGCONFIG));
|
|
|
|
td.cbSize = sizeof(TASKDIALOGCONFIG);
|
|
|
|
td.hwndParent = hwnd;
|
|
|
|
td.hInstance = hModule;
|
|
|
|
td.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_SIZE_TO_CONTENT | TDF_USE_COMMAND_LINKS;
|
|
|
|
td.dwCommonButtons = TDCBF_OK_BUTTON;
|
|
|
|
td.pszWindowTitle = L" ";
|
|
|
|
td.pszMainIcon = TD_INFORMATION_ICON;
|
|
|
|
td.pszMainInstruction = wszIDS_PRODUCTNAME;
|
|
|
|
td.pszContent = wszIDS_PRODUCTTAG;
|
|
|
|
td.cButtons = sizeof(buttons) / sizeof(buttons[0]);
|
|
|
|
td.pButtons = buttons;
|
|
|
|
td.nDefaultButton = IDOK;
|
|
|
|
td.cRadioButtons = 0;
|
|
|
|
td.pRadioButtons = NULL;
|
|
|
|
td.cxWidth = 0;
|
|
|
|
td.pszFooter = L"";
|
|
|
|
td.pfCallback = GUI_AboutProc;
|
|
|
|
td.lpCallbackData = 0;
|
|
|
|
int ret;
|
2021-10-02 18:18:07 +02:00
|
|
|
|
|
|
|
// If used directly, StartMenuExperienceHost.exe crashes badly and is unable to start; guess how I know...
|
|
|
|
(HRESULT(*)(const TASKDIALOGCONFIG*, int*, int*, BOOL*))(GetProcAddress(GetModuleHandleA("Comctl32.dll"), "TaskDialogIndirect"))(
|
2021-10-02 03:02:07 +02:00
|
|
|
&td,
|
|
|
|
&ret,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
else if (!strncmp(line + 1, "export", 6))
|
|
|
|
{
|
|
|
|
WCHAR title[MAX_PATH];
|
|
|
|
WCHAR filter[MAX_PATH];
|
|
|
|
WCHAR wszRegedit[MAX_PATH];
|
|
|
|
GetWindowsDirectoryW(wszRegedit, MAX_PATH);
|
|
|
|
wcscat_s(wszRegedit, MAX_PATH, L"\\regedit.exe");
|
|
|
|
HMODULE hRegedit = LoadLibraryExW(wszRegedit, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if (hRegedit)
|
|
|
|
{
|
|
|
|
LoadStringW(hRegedit, 301, title, MAX_PATH);
|
|
|
|
LoadStringW(hRegedit, 302, filter, MAX_PATH);
|
|
|
|
unsigned int j = 0;
|
|
|
|
for (unsigned int i = 0; i < MAX_PATH; ++i)
|
|
|
|
{
|
|
|
|
if (filter[i] == L'#')
|
|
|
|
{
|
|
|
|
filter[i] = L'\0';
|
|
|
|
j++;
|
|
|
|
if (j == 2)
|
|
|
|
{
|
|
|
|
filter[i + 1] = L'\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FreeLibrary(hRegedit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wcscpy_s(title, MAX_PATH, L"Export settings");
|
|
|
|
wcscpy_s(filter, MAX_PATH, L"Registration Files (*.reg)\0*.reg\0\0");
|
|
|
|
}
|
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
|
2022-01-23 18:26:36 +01:00
|
|
|
DWORD dwLeftMost = 0;
|
|
|
|
DWORD dwSecondLeft = 0;
|
|
|
|
DWORD dwSecondRight = 0;
|
|
|
|
DWORD dwRightMost = 0;
|
|
|
|
QueryVersionInfo(GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
|
|
|
|
swprintf_s(wszPath, MAX_PATH, _T(PRODUCT_NAME) L"_%d.%d.%d.%d.reg", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
|
2022-01-21 23:04:57 +01:00
|
|
|
OPENFILENAMEW ofn;
|
|
|
|
ZeroMemory(&ofn, sizeof(OPENFILENAMEW));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAMEW);
|
|
|
|
ofn.hwndOwner = hwnd;
|
|
|
|
ofn.hInstance = GetModuleHandleW(NULL);
|
|
|
|
ofn.lpstrFilter = filter;
|
|
|
|
ofn.lpstrCustomFilter = NULL;
|
|
|
|
ofn.nMaxCustFilter = 0;
|
|
|
|
ofn.nFilterIndex = 1;
|
|
|
|
ofn.lpstrFile = wszPath;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.lpstrFileTitle = NULL;
|
|
|
|
ofn.nMaxFileTitle = 0;
|
|
|
|
ofn.lpstrInitialDir = NULL;
|
|
|
|
ofn.lpstrTitle = title;
|
|
|
|
ofn.Flags = OFN_DONTADDTORECENT | OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
|
|
|
ofn.nFileOffset = 0;
|
|
|
|
ofn.nFileExtension = 0;
|
|
|
|
ofn.lpstrDefExt = L"reg";
|
|
|
|
ofn.lCustData = NULL;
|
|
|
|
ofn.lpfnHook = NULL;
|
|
|
|
ofn.lpTemplateName = NULL;
|
|
|
|
if (GetSaveFileNameW(&ofn))
|
|
|
|
{
|
|
|
|
_wfopen_s(&AuditFile, wszPath, L"w");
|
|
|
|
if (AuditFile)
|
|
|
|
{
|
|
|
|
fwprintf(AuditFile, L"Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\\Software\\ExplorerPatcher]\n\"ImportOK\"=dword:00000001\n");
|
|
|
|
POINT pt;
|
|
|
|
pt.x = 0;
|
|
|
|
pt.y = 0;
|
|
|
|
GUI_Build(0, hwnd, pt);
|
|
|
|
fclose(AuditFile);
|
|
|
|
AuditFile = NULL;
|
|
|
|
MessageBoxW(hwnd, L"Settings have been exported successfully.", GUI_title, MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(line + 1, "import", 6))
|
|
|
|
{
|
|
|
|
WCHAR title[MAX_PATH];
|
|
|
|
WCHAR filter[MAX_PATH];
|
|
|
|
WCHAR wszRegedit[MAX_PATH];
|
|
|
|
GetWindowsDirectoryW(wszRegedit, MAX_PATH);
|
|
|
|
wcscat_s(wszRegedit, MAX_PATH, L"\\regedit.exe");
|
|
|
|
HMODULE hRegedit = LoadLibraryExW(wszRegedit, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if (hRegedit)
|
|
|
|
{
|
|
|
|
LoadStringW(hRegedit, 300, title, MAX_PATH);
|
|
|
|
LoadStringW(hRegedit, 302, filter, MAX_PATH);
|
|
|
|
unsigned j = 0;
|
|
|
|
for (unsigned int i = 0; i < MAX_PATH; ++i)
|
|
|
|
{
|
|
|
|
if (filter[i] == L'#')
|
|
|
|
{
|
|
|
|
filter[i] = L'\0';
|
|
|
|
j++;
|
|
|
|
if (j == 2)
|
|
|
|
{
|
|
|
|
filter[i + 1] = L'\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FreeLibrary(hRegedit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wcscpy_s(title, MAX_PATH, L"Import settings");
|
|
|
|
wcscpy_s(filter, MAX_PATH, L"Registration Files (*.reg)\0*.reg\0\0");
|
|
|
|
}
|
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR));
|
2022-01-23 18:26:36 +01:00
|
|
|
DWORD dwLeftMost = 0;
|
|
|
|
DWORD dwSecondLeft = 0;
|
|
|
|
DWORD dwSecondRight = 0;
|
|
|
|
DWORD dwRightMost = 0;
|
|
|
|
QueryVersionInfo(GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost);
|
|
|
|
swprintf_s(wszPath, MAX_PATH, _T(PRODUCT_NAME) L"_%d.%d.%d.%d.reg", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost);
|
2022-01-21 23:04:57 +01:00
|
|
|
OPENFILENAMEW ofn;
|
|
|
|
ZeroMemory(&ofn, sizeof(OPENFILENAMEW));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAMEW);
|
|
|
|
ofn.hwndOwner = hwnd;
|
|
|
|
ofn.hInstance = GetModuleHandleW(NULL);
|
|
|
|
ofn.lpstrFilter = filter;
|
|
|
|
ofn.lpstrCustomFilter = NULL;
|
|
|
|
ofn.nMaxCustFilter = 0;
|
|
|
|
ofn.nFilterIndex = 1;
|
|
|
|
ofn.lpstrFile = wszPath;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.lpstrFileTitle = NULL;
|
|
|
|
ofn.nMaxFileTitle = 0;
|
|
|
|
ofn.lpstrInitialDir = NULL;
|
|
|
|
ofn.lpstrTitle = title;
|
2022-01-23 18:26:36 +01:00
|
|
|
ofn.Flags = OFN_DONTADDTORECENT | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST;
|
2022-01-21 23:04:57 +01:00
|
|
|
ofn.nFileOffset = 0;
|
|
|
|
ofn.nFileExtension = 0;
|
|
|
|
ofn.lpstrDefExt = L"reg";
|
|
|
|
ofn.lCustData = NULL;
|
|
|
|
ofn.lpfnHook = NULL;
|
|
|
|
ofn.lpTemplateName = NULL;
|
|
|
|
if (GetOpenFileNameW(&ofn))
|
|
|
|
{
|
|
|
|
RegDeleteKeyValueW(HKEY_CURRENT_USER, _T(REGPATH), L"ImportOK");
|
|
|
|
|
|
|
|
DWORD dwError = 0;
|
|
|
|
// https://stackoverflow.com/questions/50298722/win32-launching-a-highestavailable-child-process-as-a-normal-user-process
|
|
|
|
if (pvRtlQueryElevationFlags = GetProcAddress(GetModuleHandleW(L"ntdll"), "RtlQueryElevationFlags"))
|
|
|
|
{
|
|
|
|
PVOID pv;
|
|
|
|
if (pv = AddVectoredExceptionHandler(TRUE, OnVex))
|
|
|
|
{
|
|
|
|
CONTEXT ctx;
|
|
|
|
ZeroMemory(&ctx, sizeof(CONTEXT));
|
|
|
|
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
|
|
|
|
ctx.Dr7 = 0x404;
|
|
|
|
ctx.Dr1 = (ULONG_PTR)pvRtlQueryElevationFlags;
|
|
|
|
|
|
|
|
if (SetThreadContext(GetCurrentThread(), &ctx))
|
|
|
|
{
|
|
|
|
WCHAR wszExec[MAX_PATH * 2];
|
|
|
|
ZeroMemory(wszExec, MAX_PATH * 2 * sizeof(WCHAR));
|
|
|
|
wszExec[0] = L'"';
|
|
|
|
GetWindowsDirectoryW(wszExec + 1, MAX_PATH);
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, L"\\regedit.exe\" \"");
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, wszPath);
|
|
|
|
wcscat_s(wszExec, MAX_PATH * 2, L"\"");
|
|
|
|
STARTUPINFO si;
|
|
|
|
ZeroMemory(&si, sizeof(STARTUPINFO));
|
|
|
|
si.cb = sizeof(STARTUPINFO);
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
|
|
|
wprintf(L"%s\n", wszExec);
|
|
|
|
if (CreateProcessW(NULL, wszExec, 0, 0, 0, 0, 0, 0, &si, &pi))
|
|
|
|
{
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
//CloseHandle(pi.hProcess);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Dr7 = 0x400;
|
|
|
|
ctx.Dr1 = 0;
|
|
|
|
SetThreadContext(GetCurrentThread(), &ctx);
|
|
|
|
|
|
|
|
if (pi.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
DWORD dwExitCode = 0;
|
|
|
|
GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
RemoveVectoredExceptionHandler(pv);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = GetLastError();
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD dwData = 0, dwSize = sizeof(DWORD);
|
|
|
|
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"ImportOK", RRF_RT_DWORD, NULL, &dwData, &dwSize);
|
|
|
|
if (dwData)
|
|
|
|
{
|
|
|
|
RegDeleteKeyValueW(HKEY_CURRENT_USER, _T(REGPATH), L"ImportOK");
|
|
|
|
|
|
|
|
FILE* vf = NULL;
|
|
|
|
_wfopen_s(&vf, wszPath, L"r");
|
|
|
|
if (vf)
|
|
|
|
{
|
|
|
|
char* line2 = malloc(MAX_LINE_LENGTH * sizeof(char));
|
|
|
|
if (line2)
|
|
|
|
{
|
|
|
|
int numChRd2 = 0;
|
|
|
|
size_t bufsiz2 = MAX_LINE_LENGTH;
|
|
|
|
while ((numChRd2 = getline(&line2, &bufsiz2, vf)) != -1)
|
|
|
|
{
|
|
|
|
if (!strncmp(line2, ";\"Virtualized_" EP_CLSID, 52))
|
|
|
|
{
|
|
|
|
DWORD dwVal = 0;
|
|
|
|
WCHAR wszName[MAX_PATH];
|
|
|
|
ZeroMemory(wszName, MAX_PATH * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line2 + 2,
|
|
|
|
numChRd2 - 2,
|
|
|
|
wszName,
|
|
|
|
MAX_PATH
|
|
|
|
);
|
|
|
|
wchar_t* ddd = wcschr(wszName, L'=');
|
|
|
|
if (ddd) *ddd = 0;
|
|
|
|
wchar_t* ppp = wcschr(wszName, L'"');
|
|
|
|
if (ppp) *ppp = 0;
|
|
|
|
if (!wcsncmp(ddd + 1, L"dword:", 6))
|
|
|
|
{
|
|
|
|
wchar_t* xxx = wcschr(ddd + 1, L':');
|
|
|
|
xxx++;
|
|
|
|
dwVal = wcstol(xxx, NULL, 16);
|
|
|
|
wprintf(L"%s %d\n", wszName, dwVal);
|
|
|
|
GUI_RegSetValueExW(NULL, wszName, 0, RRF_RT_DWORD, &dwVal, sizeof(DWORD));
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR* wszTitle = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
wchar_t* x = wcschr(ddd + 2, L'"');
|
|
|
|
x[0] = 0;
|
|
|
|
//wprintf(L">>> %s\n", ddd + 2);
|
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
free(line2);
|
|
|
|
}
|
|
|
|
fclose(vf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (!strncmp(line + 1, "update_weather", 14))
|
|
|
|
{
|
|
|
|
PostMessageW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
dwMaxHeight += dwLineHeight * dy;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (!strncmp(line, ";u ", 3))
|
|
|
|
{
|
|
|
|
tabOrder++;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (!strncmp(line, ";l ", 3) || !strncmp(line, ";y ", 3) || !strncmp(line, ";c ", 3) || !strncmp(line, ";w ", 3) || !strncmp(line, ";z ", 3) || !strncmp(line, ";b ", 3) || !strncmp(line, ";i ", 3) || !strncmp(line, ";d ", 3) || !strncmp(line, ";v ", 3))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t));
|
2021-10-02 03:02:07 +02:00
|
|
|
text[0] = L'\u2795';
|
|
|
|
text[1] = L' ';
|
|
|
|
text[2] = L' ';
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
2021-11-14 17:32:54 +01:00
|
|
|
!strncmp(line, ";c ", 3) || !strncmp(line, ";z ", 3) ? strchr(line + 3, ' ') + 1 : line + 3,
|
2021-10-02 03:02:07 +02:00
|
|
|
numChRd - 3,
|
|
|
|
text + 3,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
2021-10-16 01:47:43 +02:00
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
wchar_t* x = wcschr(text, L'\n');
|
|
|
|
if (x) *x = 0;
|
|
|
|
x = wcschr(text, L'\r');
|
|
|
|
if (x) *x = 0;
|
2022-01-27 03:35:27 +01:00
|
|
|
if (!strncmp(line, ";w ", 3) || !strncmp(line, ";c ", 3) || !strncmp(line, ";z ", 3) || !strncmp(line, ";b ", 3) || !strncmp(line, ";i ", 3) || !strncmp(line, ";d ", 3) || !strncmp(line, ";v ", 3))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2022-01-27 03:35:27 +01:00
|
|
|
WCHAR* wszTitle = NULL;
|
|
|
|
WCHAR* wszPrompt = NULL;
|
|
|
|
WCHAR* wszDefault = NULL;
|
|
|
|
WCHAR* wszFallbackDefault = NULL;
|
2021-10-02 03:02:07 +02:00
|
|
|
HMENU hMenu = NULL;
|
2022-01-27 03:35:27 +01:00
|
|
|
BOOL bInput = !strncmp(line, ";w ", 3);
|
2021-10-02 03:02:07 +02:00
|
|
|
BOOL bChoice = !strncmp(line, ";c ", 3);
|
2021-11-14 17:32:54 +01:00
|
|
|
BOOL bChoiceLefted = !strncmp(line, ";z ", 3);
|
2021-10-02 03:02:07 +02:00
|
|
|
BOOL bInvert = !strncmp(line, ";i ", 3);
|
|
|
|
BOOL bJustCheck = !strncmp(line, ";d ", 3);
|
|
|
|
BOOL bBool = !strncmp(line, ";b ", 3);
|
|
|
|
BOOL bValue = !strncmp(line, ";v ", 3);
|
|
|
|
DWORD numChoices = 0;
|
2021-11-14 17:32:54 +01:00
|
|
|
if (bChoice || bChoiceLefted)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
char* p = strchr(line + 3, ' ');
|
|
|
|
if (p) *p = 0;
|
|
|
|
numChoices = atoi(line + 3);
|
|
|
|
hMenu = CreatePopupMenu();
|
|
|
|
for (unsigned int i = 0; i < numChoices; ++i)
|
|
|
|
{
|
|
|
|
char* l = malloc(MAX_LINE_LENGTH * sizeof(char));
|
|
|
|
numChRd = getline(&l, &bufsiz, f);
|
|
|
|
if (strncmp(l, ";x ", 3))
|
|
|
|
{
|
2021-12-24 02:35:14 +01:00
|
|
|
free(l);
|
2021-10-02 03:02:07 +02:00
|
|
|
i--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
char* p = strchr(l + 3, ' ');
|
|
|
|
if (p) *p = 0;
|
|
|
|
char* ln = p + 1;
|
|
|
|
p = strchr(p + 1, '\r');
|
|
|
|
if (p) *p = 0;
|
|
|
|
p = strchr(p + 1, '\n');
|
|
|
|
if (p) *p = 0;
|
|
|
|
|
2021-10-25 04:42:24 +02:00
|
|
|
wchar_t* miText = malloc((strlen(ln) + 1) * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
ln,
|
|
|
|
strlen(ln) + 1,
|
|
|
|
miText,
|
|
|
|
strlen(ln) + 1
|
|
|
|
);
|
|
|
|
|
|
|
|
MENUITEMINFOW menuInfo;
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOW);
|
2021-10-02 03:02:07 +02:00
|
|
|
menuInfo.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE;
|
|
|
|
menuInfo.wID = atoi(l + 3) + 1;
|
|
|
|
menuInfo.dwItemData = l;
|
|
|
|
menuInfo.fType = MFT_STRING;
|
2021-10-25 04:42:24 +02:00
|
|
|
menuInfo.dwTypeData = miText;
|
2021-10-02 03:02:07 +02:00
|
|
|
menuInfo.cch = strlen(ln);
|
2021-10-25 04:42:24 +02:00
|
|
|
InsertMenuItemW(
|
2021-10-02 03:02:07 +02:00
|
|
|
hMenu,
|
|
|
|
i,
|
|
|
|
TRUE,
|
|
|
|
&menuInfo
|
|
|
|
);
|
2021-10-25 04:42:24 +02:00
|
|
|
|
|
|
|
free(miText);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (bInput)
|
|
|
|
{
|
|
|
|
wszTitle = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
wszPrompt = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
wszDefault = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
wszFallbackDefault = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
char* l = malloc(MAX_LINE_LENGTH * sizeof(char));
|
|
|
|
numChRd = getline(&l, &bufsiz, f);
|
|
|
|
char* p = l;
|
|
|
|
p = strchr(p + 1, '\r');
|
|
|
|
if (p) *p = 0;
|
|
|
|
p = strchr(p + 1, '\n');
|
|
|
|
if (p) *p = 0;
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
l + 1,
|
|
|
|
numChRd - 1,
|
|
|
|
wszPrompt,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
|
|
|
numChRd = getline(&l, &bufsiz, f);
|
|
|
|
p = l;
|
|
|
|
p = strchr(p + 1, '\r');
|
|
|
|
if (p) *p = 0;
|
|
|
|
p = strchr(p + 1, '\n');
|
|
|
|
if (p) *p = 0;
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
l + 1,
|
|
|
|
numChRd - 1,
|
|
|
|
wszFallbackDefault,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
|
|
|
free(l);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
numChRd = getline(&line, &bufsiz, f);
|
2022-01-21 23:04:57 +01:00
|
|
|
if (!strncmp(line, ";\"Virtualized_" EP_CLSID, 52))
|
|
|
|
{
|
|
|
|
for (unsigned int kkkk = 1; kkkk < MAX_LINE_LENGTH; ++kkkk)
|
|
|
|
{
|
|
|
|
if (line[kkkk])
|
|
|
|
{
|
|
|
|
line[kkkk - 1] = line[kkkk];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line[kkkk - 1] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
////////printf("%s\n", line);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
ZeroMemory(name, MAX_LINE_LENGTH * sizeof(wchar_t));
|
|
|
|
MultiByteToWideChar(
|
|
|
|
CP_UTF8,
|
|
|
|
MB_PRECOMPOSED,
|
|
|
|
line[0] == '"' ? line + 1 : line,
|
|
|
|
numChRd,
|
|
|
|
name,
|
|
|
|
MAX_LINE_LENGTH
|
|
|
|
);
|
|
|
|
wchar_t* d = wcschr(name, L'=');
|
|
|
|
if (d) *d = 0;
|
|
|
|
wchar_t* p = wcschr(name, L'"');
|
|
|
|
if (p) *p = 0;
|
2021-12-24 02:35:48 +01:00
|
|
|
BOOL bShouldAlterTaskbarDa = FALSE;
|
|
|
|
if (!wcscmp(name, L"TaskbarDa"))
|
|
|
|
{
|
|
|
|
if (!gui_bOldTaskbar)
|
|
|
|
{
|
|
|
|
MENUITEMINFOA menuInfo;
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOA);
|
|
|
|
menuInfo.fMask = MIIM_DATA;
|
|
|
|
GetMenuItemInfoA(hMenu, 3, FALSE, &menuInfo);
|
|
|
|
if (menuInfo.dwItemData)
|
|
|
|
{
|
|
|
|
free(menuInfo.dwItemData);
|
|
|
|
}
|
|
|
|
RemoveMenu(hMenu, 3, MF_BYCOMMAND);
|
|
|
|
bShouldAlterTaskbarDa = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2021-12-24 02:35:14 +01:00
|
|
|
if (!wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition") || !wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_MMTaskbarPosition"))
|
|
|
|
{
|
|
|
|
if (!gui_bOldTaskbar)
|
|
|
|
{
|
|
|
|
MENUITEMINFOA menuInfo;
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOA);
|
|
|
|
menuInfo.fMask = MIIM_DATA;
|
|
|
|
GetMenuItemInfoA(hMenu, 1, FALSE, &menuInfo);
|
|
|
|
if (menuInfo.dwItemData)
|
|
|
|
{
|
|
|
|
free(menuInfo.dwItemData);
|
|
|
|
}
|
|
|
|
RemoveMenu(hMenu, 1, MF_BYCOMMAND);
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOA);
|
|
|
|
menuInfo.fMask = MIIM_DATA;
|
|
|
|
GetMenuItemInfoA(hMenu, 3, FALSE, &menuInfo);
|
|
|
|
if (menuInfo.dwItemData)
|
|
|
|
{
|
|
|
|
free(menuInfo.dwItemData);
|
|
|
|
}
|
|
|
|
RemoveMenu(hMenu, 3, MF_BYCOMMAND);
|
|
|
|
}
|
|
|
|
}
|
2021-10-10 21:37:47 +02:00
|
|
|
HKEY hKey = NULL;
|
2021-11-16 06:00:10 +01:00
|
|
|
wchar_t* bIsHKLM = wcsstr(section, L"HKEY_LOCAL_MACHINE");
|
|
|
|
bIsHKLM = !bIsHKLM ? NULL : ((bIsHKLM - section) < 3);
|
2021-10-02 03:02:07 +02:00
|
|
|
DWORD dwDisposition;
|
|
|
|
DWORD dwSize = sizeof(DWORD);
|
|
|
|
DWORD value = FALSE;
|
|
|
|
|
|
|
|
//wprintf(L"%s %s %s\n", section, name, d + 1);
|
2022-01-27 03:35:27 +01:00
|
|
|
if (!bInput && !wcsncmp(d + 1, L"dword:", 6))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
wchar_t* x = wcschr(d + 1, L':');
|
|
|
|
x++;
|
2021-10-15 12:50:52 +02:00
|
|
|
value = wcstol(x, NULL, 16);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
if (bInput)
|
|
|
|
{
|
|
|
|
wchar_t* x = wcschr(d + 2, L'"');
|
|
|
|
x[0] = 0;
|
|
|
|
wcscpy_s(wszDefault, MAX_LINE_LENGTH, d + 2);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
|
2022-01-27 03:35:27 +01:00
|
|
|
if (bInput)
|
|
|
|
{
|
|
|
|
dwSize = MAX_LINE_LENGTH;
|
|
|
|
GUI_RegCreateKeyExW(
|
|
|
|
bIsHKLM ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
|
|
|
wcschr(section, L'\\') + 1,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | (hDC ? 0 : (!bIsHKLM ? KEY_WRITE : 0)),
|
|
|
|
NULL,
|
|
|
|
& hKey,
|
|
|
|
& dwDisposition
|
|
|
|
);
|
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
|
|
|
GUI_RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
name,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
wszDefault,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (!bJustCheck)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
GUI_RegCreateKeyExW(
|
2021-11-14 17:32:54 +01:00
|
|
|
bIsHKLM ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
2021-10-02 03:02:07 +02:00
|
|
|
wcschr(section, L'\\') + 1,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
2021-11-14 17:32:54 +01:00
|
|
|
KEY_READ | (hDC ? 0 : (!bIsHKLM ? KEY_WRITE : 0)),
|
2021-10-02 03:02:07 +02:00
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
&dwDisposition
|
|
|
|
);
|
2021-10-10 22:06:49 +02:00
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
2021-12-05 03:04:41 +01:00
|
|
|
GUI_RegQueryValueExW(
|
2021-10-02 03:02:07 +02:00
|
|
|
hKey,
|
|
|
|
name,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&value,
|
|
|
|
&dwSize
|
|
|
|
);
|
2021-12-24 02:35:14 +01:00
|
|
|
if (!wcscmp(name, L"OldTaskbar"))
|
|
|
|
{
|
|
|
|
gui_bOldTaskbar = value;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
if (hDC && bInvert)
|
|
|
|
{
|
|
|
|
value = !value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
GUI_RegOpenKeyExW(
|
2021-11-14 17:32:54 +01:00
|
|
|
bIsHKLM ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
2021-10-02 03:02:07 +02:00
|
|
|
wcschr(section, L'\\') + 1,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
2021-11-14 17:32:54 +01:00
|
|
|
KEY_READ | (hDC ? 0 : (!bIsHKLM ? KEY_WRITE : 0)),
|
2021-10-02 03:02:07 +02:00
|
|
|
&hKey
|
|
|
|
);
|
2021-10-10 22:06:49 +02:00
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
value = hKey;
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
if (bInput)
|
|
|
|
{
|
|
|
|
wcscpy_s(wszTitle, MAX_LINE_LENGTH, text + 3);
|
|
|
|
wcscat_s(
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH,
|
|
|
|
L" : "
|
|
|
|
);
|
|
|
|
if (wszDefault[0] == 0)
|
|
|
|
{
|
|
|
|
wcscat_s(text, MAX_LINE_LENGTH, wszFallbackDefault);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wcscat_s(
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH,
|
|
|
|
wszDefault
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bInvert || bBool || bJustCheck)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
text[0] = L'\u2714';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text[0] = L'\u274C';
|
|
|
|
}
|
|
|
|
text[1] = L' ';
|
|
|
|
text[2] = L' ';
|
|
|
|
}
|
|
|
|
else if (bValue)
|
|
|
|
{
|
|
|
|
wcscat_s(
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH,
|
|
|
|
L" : "
|
|
|
|
);
|
|
|
|
wchar_t buf[100];
|
|
|
|
_itow_s(value, buf, 100, 10);
|
|
|
|
wcscat_s(
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH,
|
|
|
|
buf
|
|
|
|
);
|
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
else if (bChoice || bChoiceLefted)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
wcscat_s(
|
|
|
|
text,
|
|
|
|
MAX_LINE_LENGTH,
|
|
|
|
L" : "
|
|
|
|
);
|
2021-10-15 12:50:52 +02:00
|
|
|
MENUITEMINFOW menuInfo;
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOW);
|
2021-10-02 03:02:07 +02:00
|
|
|
menuInfo.fMask = MIIM_STRING;
|
2021-12-24 02:35:48 +01:00
|
|
|
int vvv = value + 1;
|
|
|
|
if (bShouldAlterTaskbarDa && vvv == 3) vvv = 2;
|
|
|
|
GetMenuItemInfoW(hMenu, vvv, FALSE, &menuInfo);
|
2021-10-02 03:02:07 +02:00
|
|
|
menuInfo.cch += 1;
|
2021-10-15 12:50:52 +02:00
|
|
|
menuInfo.dwTypeData = text + wcslen(text);
|
2021-12-24 02:35:48 +01:00
|
|
|
GetMenuItemInfoW(hMenu, vvv, FALSE, &menuInfo);
|
2021-10-15 12:50:52 +02:00
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOW);
|
|
|
|
menuInfo.fMask = MIIM_STATE;
|
|
|
|
menuInfo.fState = MFS_CHECKED;
|
2021-12-24 02:35:48 +01:00
|
|
|
SetMenuItemInfo(hMenu, vvv, FALSE, &menuInfo);
|
2021-10-15 12:50:52 +02:00
|
|
|
}
|
|
|
|
if (hDC && !bInvert && !bBool && !bJustCheck)
|
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
3,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2021-11-14 17:32:54 +01:00
|
|
|
rcText.left += (!bChoiceLefted ? (rcTemp.right - rcTemp.left) : 0);
|
2021-10-15 12:50:52 +02:00
|
|
|
for (unsigned int i = 0; i < wcslen(text); ++i)
|
|
|
|
{
|
|
|
|
text[i] = text[i + 3];
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
2021-10-10 05:14:23 +02:00
|
|
|
DrawTextW(
|
2021-10-15 12:50:52 +02:00
|
|
|
hdcPaint,
|
2021-10-02 03:02:07 +02:00
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcTemp.bottom = rcText.bottom;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (!hDC && (PtInRect(&rcTemp, pt) || (pt.x == 0 && pt.y == 0 && tabOrder == _this->tabOrder)))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
if (bJustCheck)
|
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
if (bIsHKLM && wcsstr(section, L"Software\\Classes\\CLSID\\" _T(EP_CLSID) L"\\InprocServer32"))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
WCHAR wszArgs[MAX_PATH];
|
|
|
|
if (!hKey)
|
|
|
|
{
|
|
|
|
wszArgs[0] = L'\"';
|
|
|
|
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszArgs + 1);
|
|
|
|
wcscat_s(wszArgs, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".amd64.dll\"");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wszArgs[0] = L'/';
|
|
|
|
wszArgs[1] = L'u';
|
|
|
|
wszArgs[2] = L' ';
|
|
|
|
wszArgs[3] = L'"';
|
|
|
|
SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszArgs + 4);
|
|
|
|
wcscat_s(wszArgs, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(PRODUCT_NAME) L".amd64.dll\"");
|
|
|
|
}
|
|
|
|
wprintf(L"%s\n", wszArgs);
|
|
|
|
WCHAR wszApp[MAX_PATH * 2];
|
|
|
|
GetSystemDirectoryW(wszApp, MAX_PATH * 2);
|
|
|
|
wcscat_s(wszApp, MAX_PATH * 2, L"\\regsvr32.exe");
|
|
|
|
wprintf(L"%s\n", wszApp);
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.hInstApp = NULL;
|
|
|
|
sei.lpVerb = L"runas";
|
|
|
|
sei.lpFile = wszApp;
|
|
|
|
sei.lpParameters = wszArgs;
|
|
|
|
sei.hwnd = NULL;
|
|
|
|
sei.nShow = SW_NORMAL;
|
|
|
|
if (ShellExecuteExW(&sei) && sei.hProcess)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
|
|
|
DWORD dwExitCode = 0;
|
|
|
|
if (GetExitCodeProcess(sei.hProcess, &dwExitCode) && !dwExitCode)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2021-11-15 04:54:54 +01:00
|
|
|
CloseHandle(sei.hProcess);
|
2021-11-14 17:32:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
if (dwError == ERROR_CANCELLED)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
if (hKey)
|
2021-10-10 22:06:49 +02:00
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
RegCloseKey(hKey);
|
2021-10-10 22:06:49 +02:00
|
|
|
hKey = NULL;
|
2021-11-14 17:32:54 +01:00
|
|
|
RegDeleteKeyExW(
|
|
|
|
bIsHKLM ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
|
|
|
wcschr(section, L'\\') + 1,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
0
|
|
|
|
);
|
2021-10-10 22:06:49 +02:00
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
else
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
GUI_RegCreateKeyExW(
|
2021-11-14 17:32:54 +01:00
|
|
|
bIsHKLM ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
|
|
|
wcschr(section, L'\\') + 1,
|
2021-10-02 03:02:07 +02:00
|
|
|
0,
|
2021-11-14 17:32:54 +01:00
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_WRITE,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
&dwDisposition
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2021-11-14 17:32:54 +01:00
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
|
|
|
if (d[1] == '"')
|
|
|
|
{
|
|
|
|
wchar_t* p = wcschr(d + 2, L'"');
|
|
|
|
if (p) *p = 0;
|
2021-12-05 03:04:41 +01:00
|
|
|
GUI_RegSetValueExW(
|
2021-11-14 17:32:54 +01:00
|
|
|
hKey,
|
|
|
|
!wcsncmp(name, L"@", 1) ? NULL : name,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
d + 2,
|
|
|
|
wcslen(d + 2) * sizeof(wchar_t)
|
|
|
|
);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 01:58:52 +01:00
|
|
|
DWORD val = 0;
|
2022-01-27 03:35:27 +01:00
|
|
|
if (bInput)
|
|
|
|
{
|
|
|
|
WCHAR* wszAnswer = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
|
|
|
InputBox(FALSE, hwnd, wszPrompt, wszTitle, wszDefault, wszAnswer, MAX_LINE_LENGTH);
|
|
|
|
GUI_RegSetValueExW(
|
|
|
|
hKey,
|
|
|
|
name,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
wszAnswer,
|
|
|
|
(wcslen(wszAnswer) + 1) * sizeof(WCHAR)
|
|
|
|
);
|
|
|
|
Sleep(100);
|
|
|
|
PostMessageW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
|
|
|
free(wszAnswer);
|
|
|
|
}
|
|
|
|
else if (bChoice || bChoiceLefted)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-10-15 12:50:52 +02:00
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
3,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
2021-10-02 03:02:07 +02:00
|
|
|
POINT p;
|
2021-11-14 17:32:54 +01:00
|
|
|
p.x = rcText.left + (bChoiceLefted ? 0 : (rcTemp.right - rcTemp.left));
|
2021-10-02 03:02:07 +02:00
|
|
|
p.y = rcText.bottom;
|
|
|
|
ClientToScreen(
|
|
|
|
hwnd,
|
|
|
|
&p
|
|
|
|
);
|
2021-12-24 01:58:52 +01:00
|
|
|
val = TrackPopupMenu(
|
2021-10-02 03:02:07 +02:00
|
|
|
hMenu,
|
|
|
|
TPM_RETURNCMD | TPM_RIGHTBUTTON,
|
|
|
|
p.x,
|
|
|
|
p.y,
|
|
|
|
0,
|
|
|
|
hwnd,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
if (val > 0) value = val - 1;
|
2022-01-05 04:02:25 +01:00
|
|
|
KillTimer(hwnd, GUI_TIMER_READ_REPEAT_SELECTION);
|
|
|
|
SetTimer(hwnd, GUI_TIMER_READ_REPEAT_SELECTION, GUI_TIMER_READ_REPEAT_SELECTION_TIMEOUT, NULL);
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else if (bValue)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = !value;
|
|
|
|
}
|
2021-11-16 06:00:10 +01:00
|
|
|
if (!wcscmp(name, L"LastSectionInProperties") && wcsstr(section, _T(REGPATH)) && value)
|
|
|
|
{
|
|
|
|
value = _this->section + 1;
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
if (!bInput && (!(bChoice || bChoiceLefted) || ((bChoice || bChoiceLefted) && val)))
|
2021-12-24 01:58:52 +01:00
|
|
|
{
|
|
|
|
GUI_RegSetValueExW(
|
|
|
|
hKey,
|
|
|
|
name,
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
&value,
|
|
|
|
sizeof(DWORD)
|
|
|
|
);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
}
|
2021-10-10 08:07:46 +02:00
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
if (bChoice || bChoiceLefted)
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < numChoices; ++i)
|
|
|
|
{
|
|
|
|
MENUITEMINFOA menuInfo;
|
|
|
|
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
|
|
|
|
menuInfo.cbSize = sizeof(MENUITEMINFOA);
|
|
|
|
menuInfo.fMask = MIIM_DATA;
|
|
|
|
GetMenuItemInfoA(hMenu, i, TRUE, &menuInfo);
|
|
|
|
if (menuInfo.dwItemData)
|
|
|
|
{
|
|
|
|
free(menuInfo.dwItemData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
if (wszTitle)
|
|
|
|
{
|
|
|
|
free(wszTitle);
|
|
|
|
}
|
|
|
|
if (wszPrompt)
|
|
|
|
{
|
|
|
|
free(wszPrompt);
|
|
|
|
}
|
|
|
|
if (wszDefault)
|
|
|
|
{
|
|
|
|
free(wszDefault);
|
|
|
|
}
|
|
|
|
if (wszFallbackDefault)
|
|
|
|
{
|
|
|
|
free(wszFallbackDefault);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
if (hDC && (!strncmp(line, ";l ", 3) || !strncmp(line, ";y ", 3)))
|
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
3,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcText.left += (!strncmp(line, ";l ", 3) ? (rcTemp.right - rcTemp.left) : 0);
|
|
|
|
for (unsigned int i = 0; i < wcslen(text); ++i)
|
|
|
|
{
|
|
|
|
text[i] = text[i + 3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!hDC && (!strncmp(line, ";l ", 3) || !strncmp(line, ";y ", 3)))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
RECT rcTemp;
|
|
|
|
rcTemp = rcText;
|
2021-10-10 05:14:23 +02:00
|
|
|
DrawTextW(
|
2021-10-15 12:50:52 +02:00
|
|
|
hdcPaint,
|
2021-10-02 03:02:07 +02:00
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcTemp,
|
|
|
|
DT_CALCRECT
|
|
|
|
);
|
|
|
|
rcTemp.bottom = rcText.bottom;
|
|
|
|
//printf("%d %d %d %d %d %d %d %d\n", rcText.left, rcText.top, rcText.right, rcText.bottom, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom);
|
2021-10-02 20:57:19 +02:00
|
|
|
if (PtInRect(&rcTemp, pt) || (pt.x == 0 && pt.y == 0 && tabOrder == _this->tabOrder))
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
|
|
|
numChRd = getline(&line, &bufsiz, f);
|
|
|
|
char* p = strchr(line, '\r');
|
|
|
|
if (p) *p = 0;
|
|
|
|
p = strchr(line, '\n');
|
|
|
|
if (p) *p = 0;
|
2021-10-16 01:47:43 +02:00
|
|
|
if (line[1] != 0)
|
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
if (line[1] == ';')
|
|
|
|
{
|
|
|
|
if (!strcmp(line + 2, ";EP_CHECK_FOR_UPDATES"))
|
|
|
|
{
|
|
|
|
HANDLE hEvent = CreateEventW(NULL, FALSE, FALSE, L"EP_Ev_CheckForUpdates_" _T(EP_CLSID));
|
|
|
|
if (hEvent)
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
CloseHandle(hEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetEvent(hEvent);
|
|
|
|
CloseHandle(hEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!strcmp(line + 2, ";EP_INSTALL_UPDATES"))
|
|
|
|
{
|
|
|
|
HANDLE hEvent = CreateEventW(NULL, FALSE, FALSE, L"EP_Ev_InstallUpdates_" _T(EP_CLSID));
|
|
|
|
if (hEvent)
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
CloseHandle(hEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetEvent(hEvent);
|
|
|
|
CloseHandle(hEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShellExecuteA(
|
|
|
|
NULL,
|
|
|
|
"open",
|
|
|
|
line + 1,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SW_SHOWNORMAL
|
|
|
|
);
|
|
|
|
}
|
2021-10-16 01:47:43 +02:00
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hDC)
|
|
|
|
{
|
2021-10-10 05:14:23 +02:00
|
|
|
COLORREF cr;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (tabOrder == _this->tabOrder)
|
|
|
|
{
|
|
|
|
bTabOrderHit = TRUE;
|
2021-10-10 05:14:23 +02:00
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
|
|
|
cr = SetTextColor(hdcPaint, GetSysColor(COLOR_HIGHLIGHT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_SELECTED_DARK : GUI_TEXTCOLOR_SELECTED;
|
|
|
|
//DttOpts.crText = GetSysColor(COLOR_HIGHLIGHT);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
RECT rcNew = rcText;
|
|
|
|
DrawTextW(
|
2021-10-02 03:02:07 +02:00
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
2021-10-10 05:14:23 +02:00
|
|
|
&rcNew,
|
|
|
|
DT_CALCRECT
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2021-10-10 05:14:23 +02:00
|
|
|
if (rcNew.right - rcNew.left > dwMaxWidth)
|
|
|
|
{
|
2021-10-16 01:47:43 +02:00
|
|
|
dwMaxWidth = rcNew.right - rcNew.left + 50 * dx;
|
2021-10-10 05:14:23 +02:00
|
|
|
}
|
2021-12-05 19:37:46 +01:00
|
|
|
if (!wcsncmp(text + 3, L"%PLACEHOLDER_0001%", 18))
|
|
|
|
{
|
|
|
|
WCHAR key = 0;
|
|
|
|
BYTE kb[256];
|
|
|
|
ZeroMemory(kb, 256);
|
|
|
|
ToUnicode(
|
|
|
|
MapVirtualKeyW(0x29, MAPVK_VSC_TO_VK_EX),
|
|
|
|
0x29,
|
|
|
|
kb,
|
|
|
|
&key,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
swprintf(text + 3, MAX_LINE_LENGTH, L"Disable per-application window list ( Alt + %c )", key);
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
if (tabOrder == _this->tabOrder)
|
|
|
|
{
|
|
|
|
if (_this->bShouldAnnounceSelected)
|
|
|
|
{
|
|
|
|
unsigned int accLen = wcslen(text);
|
|
|
|
DWORD dwType = 0;
|
|
|
|
if (!strncmp(line, ";y ", 3))
|
|
|
|
{
|
|
|
|
dwType = 4;
|
|
|
|
}
|
|
|
|
if (text[0] == L'\u2714') dwType = 1;
|
|
|
|
else if (text[0] == L'\u274C') dwType = 2;
|
|
|
|
else if (text[accLen - 1] == 56405) dwType = 3;
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (!strstr(line, "dword")) dwType = 5;
|
2022-01-05 04:02:25 +01:00
|
|
|
WCHAR accText[1000], accText2[1000];
|
|
|
|
ZeroMemory(accText, 1000 * sizeof(wchar_t));
|
|
|
|
ZeroMemory(accText2, 1000 * sizeof(wchar_t));
|
|
|
|
swprintf_s(
|
|
|
|
accText,
|
|
|
|
1000,
|
|
|
|
L"%s %s %s: %s",
|
|
|
|
(_this->dwPageLocation < 0 ?
|
|
|
|
L"Reached end of the page." :
|
|
|
|
(_this->dwPageLocation > 0 ?
|
|
|
|
L"Reached beginning of the page." : L"")),
|
|
|
|
(lastHeading[0] == 0) ? L"" : lastHeading,
|
|
|
|
(dwType == 1 || dwType == 2) ? text + 1 : text,
|
|
|
|
dwType == 1 ? L"Enabled" :
|
|
|
|
(dwType == 2 ? L"Disabled" :
|
|
|
|
(dwType == 3 ? L"Link" :
|
|
|
|
(dwType == 4 ? L"Button" :
|
2022-01-27 03:35:27 +01:00
|
|
|
(dwType == 5 ? L"Input" :
|
|
|
|
L"List"))))
|
2022-01-05 04:02:25 +01:00
|
|
|
);
|
|
|
|
accLen = wcslen(accText);
|
|
|
|
unsigned int j = 0;
|
|
|
|
for (unsigned int i = 0; i < accLen; ++i)
|
|
|
|
{
|
|
|
|
if (accText[i] == L'%')
|
|
|
|
{
|
|
|
|
accText2[j] = L'%';
|
|
|
|
accText2[j + 1] = L'%';
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
accText2[j] = accText[i];
|
|
|
|
}
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
_this->dwPageLocation = 0;
|
|
|
|
BOOL dwTypeRepl = 0;
|
|
|
|
accLen = wcslen(accText2);
|
|
|
|
for (unsigned int i = 0; i < accLen; ++i)
|
|
|
|
{
|
|
|
|
if (accText2[i] == L'*')
|
|
|
|
{
|
|
|
|
if (accText2[i + 1] == L'*')
|
|
|
|
{
|
|
|
|
dwTypeRepl = 1;
|
|
|
|
}
|
|
|
|
accText2[i] = L'%';
|
|
|
|
if (i + 1 >= accLen)
|
|
|
|
{
|
|
|
|
accText2[i + 2] = 0;
|
|
|
|
}
|
|
|
|
accText2[i + 1] = L's';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dwTypeRepl == 1)
|
|
|
|
{
|
|
|
|
swprintf_s(accText, 1000, accText2, L" - Requires registration as shell extension to work in Open or Save file dialogs - ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
swprintf_s(accText, 1000, accText2, L" - Requires File Explorer restart to apply - ");
|
|
|
|
}
|
|
|
|
//wprintf(L">>> %s\n", accText);
|
|
|
|
SetWindowTextW(_this->hAccLabel, accText);
|
|
|
|
NotifyWinEvent(
|
|
|
|
EVENT_OBJECT_LIVEREGIONCHANGED,
|
|
|
|
_this->hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF);
|
|
|
|
_this->bShouldAnnounceSelected = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
DrawThemeTextEx(
|
|
|
|
_this->hTheme,
|
|
|
|
hdcPaint,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
dwTextFlags,
|
|
|
|
&rcText,
|
|
|
|
&DttOpts
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTextW(
|
|
|
|
hdcPaint,
|
|
|
|
text,
|
|
|
|
-1,
|
|
|
|
&rcText,
|
|
|
|
dwTextFlags
|
|
|
|
);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
if (tabOrder == _this->tabOrder)
|
|
|
|
{
|
2021-10-10 05:14:23 +02:00
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
|
|
|
SetTextColor(hdcPaint, cr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR;
|
|
|
|
//DttOpts.crText = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
dwMaxHeight += dwLineHeight * dy;
|
2021-10-02 20:57:19 +02:00
|
|
|
tabOrder++;
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
2021-10-15 12:50:52 +02:00
|
|
|
free(section);
|
|
|
|
free(name);
|
|
|
|
free(text);
|
|
|
|
free(line);
|
2022-01-05 04:02:25 +01:00
|
|
|
free(lastHeading);
|
2021-11-16 06:00:10 +01:00
|
|
|
if (!bWasSpecifiedSectionValid)
|
|
|
|
{
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bRebuildIfTabOrderIsEmpty = FALSE;
|
|
|
|
_this->tabOrder = 0;
|
2021-11-16 06:00:10 +01:00
|
|
|
GUI_SetSection(_this, FALSE, 0);
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
|
2021-10-15 12:50:52 +02:00
|
|
|
SelectObject(hdcPaint, hOldFont);
|
|
|
|
if (!hDC)
|
|
|
|
{
|
|
|
|
ReleaseDC(hwnd, hdcPaint);
|
|
|
|
}
|
|
|
|
DeleteObject(hFontSectionSel);
|
|
|
|
DeleteObject(hFontSection);
|
|
|
|
DeleteObject(hFontRegular);
|
|
|
|
DeleteObject(hFontTitle);
|
|
|
|
DeleteObject(hFontUnderline);
|
|
|
|
DeleteObject(hFontCaption);
|
2022-01-05 04:02:25 +01:00
|
|
|
|
|
|
|
if (_this->bShouldAnnounceSelected)
|
|
|
|
{
|
|
|
|
int max_section = 100;
|
|
|
|
for (unsigned int i = 0; i < 100; ++i)
|
|
|
|
{
|
|
|
|
if (_this->sectionNames[i][0] == 0)
|
|
|
|
{
|
|
|
|
max_section = i - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WCHAR wszAccText[100];
|
|
|
|
swprintf_s(
|
|
|
|
wszAccText,
|
|
|
|
100,
|
|
|
|
L"Selected page: %s: %d out of %d.",
|
|
|
|
_this->sectionNames[_this->section],
|
|
|
|
_this->section + 1,
|
|
|
|
max_section + 1
|
|
|
|
);
|
|
|
|
SetWindowTextW(_this->hAccLabel, wszAccText);
|
|
|
|
if (!_this->bRebuildIfTabOrderIsEmpty)
|
|
|
|
{
|
|
|
|
NotifyWinEvent(
|
|
|
|
EVENT_OBJECT_LIVEREGIONCHANGED,
|
|
|
|
_this->hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
if (hDC)
|
|
|
|
{
|
2021-10-02 20:57:19 +02:00
|
|
|
if (_this->tabOrder == GUI_MAX_TABORDER)
|
|
|
|
{
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->tabOrder = tabOrder - 1;
|
|
|
|
_this->dwPageLocation = -1;
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
|
|
|
else if (!bTabOrderHit)
|
|
|
|
{
|
2022-01-05 04:02:25 +01:00
|
|
|
if (_this->bRebuildIfTabOrderIsEmpty)
|
|
|
|
{
|
|
|
|
_this->dwPageLocation = 1;
|
|
|
|
_this->bRebuildIfTabOrderIsEmpty = FALSE;
|
|
|
|
_this->tabOrder = 1;
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->tabOrder = 0;
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
|
|
|
|
if (_this->bRebuildIfTabOrderIsEmpty)
|
|
|
|
{
|
|
|
|
_this->bRebuildIfTabOrderIsEmpty = FALSE;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
if (_this->bCalcExtent)
|
|
|
|
{
|
|
|
|
RECT rcWin;
|
|
|
|
GetWindowRect(hwnd, &rcWin);
|
|
|
|
printf("%d %d - %d %d\n", rcWin.right - rcWin.left, rcWin.bottom - rcWin.top, dwMaxWidth, dwMaxHeight);
|
|
|
|
|
2021-10-15 12:50:52 +02:00
|
|
|
dwMaxWidth += dwInitialLeftPad + _this->padding.left + _this->padding.right;
|
2021-12-24 01:06:08 +01:00
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
|
|
|
dwMaxHeight += GUI_LINE_HEIGHT * dy + 20 * dy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwMaxHeight += GUI_PADDING * 2 * dy;
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
|
|
|
|
HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
MONITORINFO mi;
|
|
|
|
mi.cbSize = sizeof(MONITORINFO);
|
|
|
|
GetMonitorInfo(hMonitor, &mi);
|
|
|
|
SetWindowPos(
|
|
|
|
hwnd,
|
|
|
|
hwnd,
|
|
|
|
mi.rcWork.left + ((mi.rcWork.right - mi.rcWork.left) / 2 - (dwMaxWidth) / 2),
|
|
|
|
mi.rcWork.top + ((mi.rcWork.bottom - mi.rcWork.top) / 2 - (dwMaxHeight) / 2),
|
|
|
|
dwMaxWidth,
|
|
|
|
dwMaxHeight,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE
|
|
|
|
);
|
2021-11-16 06:00:10 +01:00
|
|
|
|
|
|
|
DWORD dwReadSection = 0;
|
|
|
|
|
|
|
|
HKEY hKey = NULL;
|
|
|
|
DWORD dwSize = sizeof(DWORD);
|
|
|
|
RegCreateKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
TEXT(REGPATH),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
dwReadSection = 0;
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("LastSectionInProperties"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&dwReadSection,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
if (dwReadSection)
|
|
|
|
{
|
|
|
|
_this->section = dwReadSection - 1;
|
|
|
|
}
|
|
|
|
dwReadSection = 0;
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("OpenPropertiesAtNextStart"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&dwReadSection,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
if (dwReadSection)
|
|
|
|
{
|
|
|
|
_this->section = dwReadSection - 1;
|
|
|
|
dwReadSection = 0;
|
|
|
|
RegSetValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("OpenPropertiesAtNextStart"),
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
&dwReadSection,
|
|
|
|
sizeof(DWORD)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2021-10-10 05:14:23 +02:00
|
|
|
_this->bCalcExtent = FALSE;
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
EndBufferedPaint(hBufferedPaint, TRUE);
|
2021-10-02 03:02:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-10-02 18:17:24 +02:00
|
|
|
static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
2021-10-02 03:02:07 +02:00
|
|
|
GUI* _this;
|
|
|
|
if (uMsg == WM_CREATE)
|
|
|
|
{
|
|
|
|
CREATESTRUCT* pCreate = (CREATESTRUCT*)(lParam);
|
|
|
|
_this = (int*)(pCreate->lpCreateParams);
|
|
|
|
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)_this);
|
|
|
|
UINT dpiX, dpiY, dpiXP, dpiYP;
|
|
|
|
POINT ptCursor, ptZero;
|
|
|
|
ptZero.x = 0;
|
|
|
|
ptZero.y = 0;
|
|
|
|
GetCursorPos(&ptCursor);
|
|
|
|
HMONITOR hMonitor = MonitorFromPoint(ptCursor, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
HMONITOR hPrimaryMonitor = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
HRESULT hr = GetDpiForMonitor(
|
|
|
|
hMonitor,
|
|
|
|
MDT_DEFAULT,
|
|
|
|
&dpiX,
|
|
|
|
&dpiY
|
|
|
|
);
|
|
|
|
hr = GetDpiForMonitor(
|
|
|
|
hPrimaryMonitor,
|
|
|
|
MDT_DEFAULT,
|
|
|
|
&dpiXP,
|
|
|
|
&dpiYP
|
|
|
|
);
|
|
|
|
MONITORINFO mi;
|
|
|
|
mi.cbSize = sizeof(MONITORINFO);
|
|
|
|
GetMonitorInfo(hMonitor, &mi);
|
|
|
|
double dx = dpiX / 96.0, dy = dpiY / 96.0, dxp = dpiXP / 96.0, dyp = dpiYP / 96.0;
|
|
|
|
_this->dpi.x = dpiX;
|
|
|
|
_this->dpi.y = dpiY;
|
2021-12-24 01:06:08 +01:00
|
|
|
SetRect(&_this->border_thickness, 2, 2, 2, 2);
|
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
BOOL bIsCompositionEnabled = TRUE;
|
|
|
|
DwmIsCompositionEnabled(&bIsCompositionEnabled);
|
|
|
|
if (bIsCompositionEnabled)
|
|
|
|
{
|
|
|
|
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
|
|
|
|
DwmExtendFrameIntoClientArea(hWnd, &marGlassInset);
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
SetWindowPos(
|
|
|
|
hWnd,
|
|
|
|
hWnd,
|
|
|
|
mi.rcWork.left + ((mi.rcWork.right - mi.rcWork.left) / 2 - (_this->size.cx * dx) / 2),
|
|
|
|
mi.rcWork.top + ((mi.rcWork.bottom - mi.rcWork.top) / 2 - (_this->size.cy * dy) / 2),
|
|
|
|
_this->size.cx * dxp,
|
|
|
|
_this->size.cy * dyp,
|
2021-12-24 01:06:08 +01:00
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2022-01-05 04:02:25 +01:00
|
|
|
SetTimer(hWnd, GUI_TIMER_READ_HELP, GUI_TIMER_READ_HELP_TIMEOUT, NULL);
|
2021-12-24 01:06:08 +01:00
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
RECT rcTitle;
|
|
|
|
DwmGetWindowAttribute(hWnd, DWMWA_CAPTION_BUTTON_BOUNDS, &rcTitle, sizeof(RECT));
|
|
|
|
_this->GUI_CAPTION_LINE_HEIGHT = rcTitle.bottom - rcTitle.top;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->GUI_CAPTION_LINE_HEIGHT = GUI_CAPTION_LINE_HEIGHT_DEFAULT;
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
if (IsThemeActive() && ShouldAppsUseDarkMode)
|
|
|
|
{
|
|
|
|
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
|
|
|
|
BOOL value = g_darkModeEnabled;
|
|
|
|
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
|
|
|
|
}
|
|
|
|
if (!IsThemeActive())
|
|
|
|
{
|
|
|
|
int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
|
|
|
|
SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LONG_PTR ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
|
|
|
_this = (int*)(ptr);
|
|
|
|
}
|
|
|
|
if (uMsg == WM_DESTROY)
|
|
|
|
{
|
|
|
|
PostQuitMessage(0);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-10-15 12:50:52 +02:00
|
|
|
else if (uMsg == WM_GETICON)
|
|
|
|
{
|
|
|
|
return _this->hIcon;
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
else if (uMsg == WM_SETTINGCHANGE)
|
|
|
|
{
|
|
|
|
if (IsColorSchemeChangeMessage(lParam))
|
|
|
|
{
|
|
|
|
if (IsThemeActive() && ShouldAppsUseDarkMode)
|
|
|
|
{
|
2021-10-21 08:01:59 +02:00
|
|
|
RefreshImmersiveColorPolicyState();
|
2021-10-10 05:14:23 +02:00
|
|
|
BOOL bIsCompositionEnabled = TRUE;
|
|
|
|
DwmIsCompositionEnabled(&bIsCompositionEnabled);
|
|
|
|
BOOL bDarkModeEnabled = IsThemeActive() && bIsCompositionEnabled && ShouldAppsUseDarkMode() && !IsHighContrast();
|
|
|
|
if (bDarkModeEnabled != g_darkModeEnabled)
|
|
|
|
{
|
|
|
|
g_darkModeEnabled = bDarkModeEnabled;
|
|
|
|
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
|
|
|
|
BOOL value = g_darkModeEnabled;
|
|
|
|
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
|
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
else if (uMsg == WM_KEYDOWN)
|
|
|
|
{
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bRebuildIfTabOrderIsEmpty = FALSE;
|
2021-10-02 20:57:19 +02:00
|
|
|
if (wParam == VK_ESCAPE)
|
|
|
|
{
|
|
|
|
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-04 17:48:47 +01:00
|
|
|
else if (wParam == VK_TAB || wParam == VK_DOWN || wParam == VK_UP)
|
2021-10-02 20:57:19 +02:00
|
|
|
{
|
2022-01-04 17:48:47 +01:00
|
|
|
if ((GetKeyState(VK_SHIFT) & 0x8000) || wParam == VK_UP)
|
2021-10-02 20:57:19 +02:00
|
|
|
{
|
|
|
|
if (_this->tabOrder == 0)
|
|
|
|
{
|
|
|
|
_this->tabOrder = GUI_MAX_TABORDER;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->tabOrder--;
|
|
|
|
if (_this->tabOrder == 0)
|
|
|
|
{
|
|
|
|
_this->tabOrder = GUI_MAX_TABORDER;
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->tabOrder++;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bRebuildIfTabOrderIsEmpty = TRUE;
|
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
2021-10-02 20:57:19 +02:00
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
else if (wParam == VK_SPACE || wParam == VK_RETURN)
|
2021-10-02 20:57:19 +02:00
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = 0;
|
|
|
|
pt.y = 0;
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
2021-10-02 20:57:19 +02:00
|
|
|
GUI_Build(0, hWnd, pt);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-10-15 12:50:52 +02:00
|
|
|
// this should be determined from the file, but for now it works
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (wParam >= '1' && wParam <= '9' || wParam == '0')
|
2021-10-15 12:50:52 +02:00
|
|
|
{
|
|
|
|
_this->tabOrder = 0;
|
2022-01-27 03:35:27 +01:00
|
|
|
GUI_SetSection(_this, TRUE, wParam == '0' ? 9 : wParam - '1');
|
2022-01-05 04:02:25 +01:00
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
2021-10-15 12:50:52 +02:00
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
else if (wParam == VK_LEFT || wParam == VK_RIGHT)
|
|
|
|
{
|
|
|
|
int min_section = 0;
|
|
|
|
int max_section = 100;
|
|
|
|
int new_section = _this->section;
|
|
|
|
for (unsigned int i = 0; i < 100; ++i)
|
|
|
|
{
|
|
|
|
if (_this->sectionNames[i][0] == 0)
|
|
|
|
{
|
|
|
|
max_section = i - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wParam == VK_LEFT)
|
|
|
|
{
|
|
|
|
new_section--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_section++;
|
|
|
|
}
|
|
|
|
if (new_section < min_section)
|
|
|
|
{
|
|
|
|
new_section = max_section;
|
|
|
|
}
|
|
|
|
if (new_section > max_section)
|
|
|
|
{
|
|
|
|
new_section = min_section;
|
|
|
|
}
|
|
|
|
_this->tabOrder = 0;
|
|
|
|
GUI_SetSection(_this, TRUE, new_section);
|
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (wParam == 'H' || wParam == VK_F1)
|
|
|
|
{
|
|
|
|
SetTimer(hWnd, GUI_TIMER_READ_HELP, 200, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-27 03:35:27 +01:00
|
|
|
else if (wParam == 'Z')
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (wParam == 'X')
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-12-24 01:06:08 +01:00
|
|
|
else if (uMsg == WM_NCMOUSELEAVE && IsThemeActive())
|
|
|
|
{
|
|
|
|
LRESULT lRes = 0;
|
|
|
|
if (DwmDefWindowProc(hWnd, uMsg, wParam, lParam, &lRes))
|
|
|
|
{
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (uMsg == WM_NCRBUTTONUP && IsThemeActive())
|
|
|
|
{
|
|
|
|
HMENU pSysMenu = GetSystemMenu(hWnd, FALSE);
|
|
|
|
if (pSysMenu != NULL)
|
|
|
|
{
|
|
|
|
int xPos = GET_X_LPARAM(lParam);
|
|
|
|
int yPos = GET_Y_LPARAM(lParam);
|
2022-01-02 00:14:44 +01:00
|
|
|
EnableMenuItem(pSysMenu, SC_RESTORE, MF_GRAYED);
|
|
|
|
EnableMenuItem(pSysMenu, SC_SIZE, MF_GRAYED);
|
|
|
|
EnableMenuItem(pSysMenu, SC_MAXIMIZE, MF_GRAYED);
|
|
|
|
BOOL cmd = TrackPopupMenu(pSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, xPos, yPos, NULL, hWnd, 0);
|
|
|
|
if (cmd)
|
|
|
|
{
|
|
|
|
PostMessageW(hWnd, WM_SYSCOMMAND, cmd, 0);
|
|
|
|
}
|
2021-12-24 01:06:08 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if ((uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP) && IsThemeActive())
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = GET_X_LPARAM(lParam);
|
|
|
|
pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
|
|
|
|
double dx = _this->dpi.x / 96.0, dy = _this->dpi.y / 96.0;
|
|
|
|
UINT diff = (int)(((_this->GUI_CAPTION_LINE_HEIGHT - 16) * dx) / 2.0);
|
|
|
|
RECT rc;
|
|
|
|
SetRect(&rc, diff, diff, diff + (int)(16.0 * dx), diff + (int)(16.0 * dy));
|
|
|
|
if (PtInRect(&rc, pt))
|
|
|
|
{
|
|
|
|
if (uMsg == WM_LBUTTONUP && _this->LeftClickTime != 0)
|
|
|
|
{
|
|
|
|
_this->LeftClickTime = milliseconds_now() - _this->LeftClickTime;
|
|
|
|
}
|
|
|
|
if (uMsg == WM_LBUTTONUP && _this->LeftClickTime != 0 && _this->LeftClickTime < GetDoubleClickTime())
|
|
|
|
{
|
|
|
|
_this->LeftClickTime = 0;
|
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (uMsg == WM_LBUTTONUP)
|
|
|
|
{
|
|
|
|
_this->LeftClickTime = milliseconds_now();
|
|
|
|
}
|
|
|
|
if (uMsg == WM_RBUTTONUP || !_this->LastClickTime || milliseconds_now() - _this->LastClickTime > 500)
|
|
|
|
{
|
|
|
|
HMENU pSysMenu = GetSystemMenu(hWnd, FALSE);
|
|
|
|
if (pSysMenu != NULL)
|
|
|
|
{
|
|
|
|
if (uMsg == WM_LBUTTONUP)
|
|
|
|
{
|
|
|
|
pt.x = 0;
|
|
|
|
pt.y = _this->GUI_CAPTION_LINE_HEIGHT * dy;
|
|
|
|
}
|
|
|
|
ClientToScreen(hWnd, &pt);
|
2022-01-02 00:14:44 +01:00
|
|
|
EnableMenuItem(pSysMenu, SC_RESTORE, MF_GRAYED);
|
|
|
|
EnableMenuItem(pSysMenu, SC_SIZE, MF_GRAYED);
|
|
|
|
EnableMenuItem(pSysMenu, SC_MAXIMIZE, MF_GRAYED);
|
|
|
|
BOOL cmd = TrackPopupMenu(pSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, NULL, hWnd, 0);
|
|
|
|
if (cmd)
|
|
|
|
{
|
|
|
|
PostMessageW(hWnd, WM_SYSCOMMAND, cmd, 0);
|
|
|
|
}
|
2021-12-24 01:06:08 +01:00
|
|
|
if (uMsg == WM_LBUTTONUP)
|
|
|
|
{
|
|
|
|
_this->LastClickTime = milliseconds_now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
else if (uMsg == WM_NCHITTEST && IsThemeActive())
|
2021-10-02 03:02:07 +02:00
|
|
|
{
|
2021-12-24 01:06:08 +01:00
|
|
|
LRESULT lRes = 0;
|
|
|
|
if (DwmDefWindowProc(hWnd, uMsg, wParam, lParam, &lRes))
|
|
|
|
{
|
|
|
|
return lRes;
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
POINT pt;
|
|
|
|
pt.x = GET_X_LPARAM(lParam);
|
|
|
|
pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
ScreenToClient(hWnd, &pt);
|
2021-12-24 01:06:08 +01:00
|
|
|
|
|
|
|
double dx = _this->dpi.x / 96.0, dy = _this->dpi.y / 96.0;
|
|
|
|
UINT diff = (int)(((_this->GUI_CAPTION_LINE_HEIGHT - 16) * dx) / 2.0);
|
|
|
|
RECT rc;
|
|
|
|
SetRect(&rc, diff, diff, diff + (int)(16.0 * dx), diff + (int)(16.0 * dy));
|
|
|
|
if (PtInRect(&rc, pt))
|
|
|
|
{
|
|
|
|
return HTCLIENT;
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
if (pt.y < _this->extent.cyTopHeight)
|
|
|
|
{
|
|
|
|
return HTCAPTION;
|
|
|
|
}
|
|
|
|
}
|
2021-12-24 01:06:08 +01:00
|
|
|
else if (uMsg == WM_NCCALCSIZE && wParam == TRUE && IsThemeActive())
|
|
|
|
{
|
|
|
|
NCCALCSIZE_PARAMS* sz = (NCCALCSIZE_PARAMS*)(lParam);
|
|
|
|
sz->rgrc[0].left += _this->border_thickness.left;
|
|
|
|
sz->rgrc[0].right -= _this->border_thickness.right;
|
|
|
|
sz->rgrc[0].bottom -= _this->border_thickness.bottom;
|
|
|
|
return 0;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
else if (uMsg == WM_LBUTTONDOWN)
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = GET_X_LPARAM(lParam);
|
|
|
|
pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
GUI_Build(0, hWnd, pt);
|
2022-01-05 04:02:25 +01:00
|
|
|
//InvalidateRect(hWnd, NULL, FALSE);
|
2021-10-02 03:02:07 +02:00
|
|
|
}
|
|
|
|
else if (uMsg == WM_DPICHANGED)
|
|
|
|
{
|
|
|
|
_this->dpi.x = LOWORD(wParam);
|
|
|
|
_this->dpi.y = HIWORD(wParam);
|
|
|
|
RECT* rc = lParam;
|
|
|
|
SetWindowPos(
|
|
|
|
hWnd,
|
|
|
|
hWnd,
|
|
|
|
rc->left,
|
|
|
|
rc->top,
|
|
|
|
rc->right - rc->left,
|
|
|
|
rc->bottom - rc->top,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS
|
|
|
|
);
|
2021-12-24 01:06:08 +01:00
|
|
|
RECT rcTitle;
|
|
|
|
DwmGetWindowAttribute(hWnd, DWMWA_CAPTION_BUTTON_BOUNDS, &rcTitle, sizeof(RECT));
|
|
|
|
_this->GUI_CAPTION_LINE_HEIGHT = (rcTitle.bottom - rcTitle.top) * (96.0 / _this->dpi.y);
|
2021-10-02 03:02:07 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (uMsg == WM_PAINT)
|
|
|
|
{
|
2021-10-10 05:14:23 +02:00
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
BOOL bIsCompositionEnabled = TRUE;
|
|
|
|
DwmIsCompositionEnabled(&bIsCompositionEnabled);
|
|
|
|
if (bIsCompositionEnabled)
|
|
|
|
{
|
|
|
|
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
|
|
|
|
DwmExtendFrameIntoClientArea(hWnd, &marGlassInset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hDC = BeginPaint(hWnd, &ps);
|
|
|
|
|
|
|
|
RECT rc;
|
|
|
|
GetClientRect(hWnd, &rc);
|
|
|
|
|
|
|
|
POINT pt;
|
|
|
|
pt.x = 0;
|
|
|
|
pt.y = 0;
|
|
|
|
GUI_Build(hDC, hWnd, pt);
|
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-05 19:37:46 +01:00
|
|
|
else if (uMsg == WM_INPUTLANGCHANGE)
|
|
|
|
{
|
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-11-16 06:00:10 +01:00
|
|
|
else if (uMsg == WM_MSG_GUI_SECTION && wParam == WM_MSG_GUI_SECTION_GET)
|
|
|
|
{
|
|
|
|
return _this->section + 1;
|
|
|
|
}
|
2022-01-05 04:02:25 +01:00
|
|
|
else if (uMsg == WM_TIMER && wParam == GUI_TIMER_READ_HELP)
|
|
|
|
{
|
|
|
|
PlayHelpMessage(_this);
|
|
|
|
KillTimer(hWnd, GUI_TIMER_READ_HELP);
|
|
|
|
}
|
|
|
|
else if (uMsg == WM_TIMER && wParam == GUI_TIMER_READ_REPEAT_SELECTION)
|
|
|
|
{
|
|
|
|
_this->bShouldAnnounceSelected = TRUE;
|
|
|
|
InvalidateRect(hWnd, NULL, FALSE);
|
|
|
|
KillTimer(hWnd, GUI_TIMER_READ_REPEAT_SELECTION);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
__declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
|
|
|
|
{
|
2021-11-14 17:32:54 +01:00
|
|
|
HWND hOther = NULL;
|
|
|
|
if (hOther = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL))
|
|
|
|
{
|
2021-11-25 13:23:13 +01:00
|
|
|
SwitchToThisWindow(hOther, TRUE);
|
2021-11-14 17:32:54 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-27 03:35:27 +01:00
|
|
|
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
|
2022-01-05 04:02:25 +01:00
|
|
|
|
2021-10-10 21:37:47 +02:00
|
|
|
HKEY hKey = NULL;
|
2021-10-02 20:57:19 +02:00
|
|
|
DWORD dwSize = sizeof(DWORD);
|
|
|
|
RegCreateKeyExW(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
TEXT(REGPATH),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
2021-11-16 06:00:10 +01:00
|
|
|
KEY_READ | KEY_WOW64_64KEY,
|
2021-10-02 20:57:19 +02:00
|
|
|
NULL,
|
|
|
|
&hKey,
|
2021-11-16 06:00:10 +01:00
|
|
|
NULL
|
2021-10-02 03:02:07 +02:00
|
|
|
);
|
2021-10-10 22:06:49 +02:00
|
|
|
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hKey = NULL;
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
DWORD bAllocConsole = FALSE;
|
2021-11-16 06:00:10 +01:00
|
|
|
if (hKey)
|
2021-10-02 20:57:19 +02:00
|
|
|
{
|
2021-11-16 06:00:10 +01:00
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("AllocConsole"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&bAllocConsole,
|
|
|
|
&dwSize
|
2021-10-02 20:57:19 +02:00
|
|
|
);
|
2021-11-16 06:00:10 +01:00
|
|
|
if (bAllocConsole)
|
|
|
|
{
|
|
|
|
FILE* conout;
|
|
|
|
AllocConsole();
|
|
|
|
freopen_s(
|
|
|
|
&conout,
|
|
|
|
"CONOUT$",
|
|
|
|
"w",
|
|
|
|
stdout
|
|
|
|
);
|
|
|
|
}
|
2021-10-02 20:57:19 +02:00
|
|
|
}
|
2021-10-25 04:42:41 +02:00
|
|
|
locale = GetUserDefaultUILanguage();
|
2021-11-16 06:00:10 +01:00
|
|
|
dwSize = LOCALE_NAME_MAX_LENGTH;
|
2021-10-10 21:37:47 +02:00
|
|
|
if (hKey)
|
|
|
|
{
|
2021-11-16 06:00:10 +01:00
|
|
|
RegQueryValueExW(
|
|
|
|
hKey,
|
|
|
|
TEXT("Language"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&locale,
|
|
|
|
&dwSize
|
|
|
|
);
|
2021-10-10 21:37:47 +02:00
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
|
2021-10-16 04:56:46 +02:00
|
|
|
wchar_t wszPath[MAX_PATH];
|
|
|
|
ZeroMemory(
|
|
|
|
wszPath,
|
|
|
|
(MAX_PATH) * sizeof(char)
|
|
|
|
);
|
|
|
|
GetModuleFileNameW(hModule, wszPath, MAX_PATH);
|
|
|
|
PathRemoveFileSpecW(wszPath);
|
|
|
|
wcscat_s(
|
|
|
|
wszPath,
|
|
|
|
MAX_PATH,
|
|
|
|
L"\\settings.reg"
|
|
|
|
);
|
|
|
|
wprintf(L"%s\n", wszPath);
|
|
|
|
if (FileExistsW(wszPath))
|
|
|
|
{
|
|
|
|
HANDLE hFile = CreateFileW(
|
|
|
|
wszPath,
|
|
|
|
GENERIC_READ | GENERIC_WRITE,
|
|
|
|
FILE_SHARE_READ,
|
|
|
|
NULL,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
if (hFile)
|
|
|
|
{
|
|
|
|
HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
|
|
|
|
if (hFileMapping)
|
|
|
|
{
|
|
|
|
GUI_FileMapping = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
|
|
|
GUI_FileSize = GetFileSize(hFile, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
printf("Started \"GUI\" thread.\n");
|
|
|
|
|
|
|
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
|
|
|
|
|
|
GUI _this;
|
2021-11-16 06:00:10 +01:00
|
|
|
ZeroMemory(&_this, sizeof(GUI));
|
2021-10-10 05:14:23 +02:00
|
|
|
_this.hBackgroundBrush = (HBRUSH)(CreateSolidBrush(RGB(255, 255, 255)));// (HBRUSH)GetStockObject(BLACK_BRUSH);
|
2021-10-02 03:02:07 +02:00
|
|
|
_this.location.x = GUI_POSITION_X;
|
|
|
|
_this.location.y = GUI_POSITION_Y;
|
|
|
|
_this.size.cx = GUI_POSITION_WIDTH;
|
|
|
|
_this.size.cy = GUI_POSITION_HEIGHT;
|
|
|
|
_this.padding.left = GUI_PADDING_LEFT;
|
|
|
|
_this.padding.right = GUI_PADDING_RIGHT;
|
|
|
|
_this.padding.top = GUI_PADDING_TOP;
|
|
|
|
_this.padding.bottom = GUI_PADDING_BOTTOM;
|
2021-10-15 12:50:52 +02:00
|
|
|
_this.sidebarWidth = GUI_SIDEBAR_WIDTH;
|
2021-10-02 03:02:07 +02:00
|
|
|
_this.hTheme = OpenThemeData(NULL, TEXT(GUI_WINDOWSWITCHER_THEME_CLASS));
|
2021-10-02 20:57:19 +02:00
|
|
|
_this.tabOrder = 0;
|
2021-10-10 05:14:23 +02:00
|
|
|
_this.bCalcExtent = TRUE;
|
2021-10-15 12:50:52 +02:00
|
|
|
_this.section = 0;
|
|
|
|
_this.dwStatusbarY = 0;
|
|
|
|
_this.hIcon = NULL;
|
2021-12-28 15:06:37 +01:00
|
|
|
_this.hExplorerFrame = NULL;
|
2021-10-15 12:50:52 +02:00
|
|
|
|
|
|
|
ZeroMemory(
|
|
|
|
wszPath,
|
|
|
|
(MAX_PATH) * sizeof(wchar_t)
|
|
|
|
);
|
2021-10-21 08:01:59 +02:00
|
|
|
GetSystemDirectoryW(
|
2021-10-15 12:50:52 +02:00
|
|
|
wszPath,
|
|
|
|
MAX_PATH
|
|
|
|
);
|
|
|
|
wcscat_s(
|
|
|
|
wszPath,
|
|
|
|
MAX_PATH,
|
2021-10-21 08:01:59 +02:00
|
|
|
L"\\shell32.dll"
|
2021-10-15 12:50:52 +02:00
|
|
|
);
|
2021-10-02 03:02:07 +02:00
|
|
|
|
|
|
|
WNDCLASS wc = { 0 };
|
|
|
|
ZeroMemory(&wc, sizeof(WNDCLASSW));
|
2021-12-24 01:06:08 +01:00
|
|
|
wc.style = 0;// CS_DBLCLKS;
|
2021-10-02 18:17:24 +02:00
|
|
|
wc.lpfnWndProc = GUI_WindowProc;
|
2021-10-02 03:02:07 +02:00
|
|
|
wc.hbrBackground = _this.hBackgroundBrush;
|
|
|
|
wc.hInstance = hModule;
|
2021-11-14 17:32:54 +01:00
|
|
|
wc.lpszClassName = L"ExplorerPatcher_GUI_" _T(EP_CLSID);
|
2021-10-02 03:02:07 +02:00
|
|
|
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
2021-10-21 08:01:59 +02:00
|
|
|
HMODULE hShell32 = LoadLibraryExW(wszPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if (hShell32)
|
2021-10-15 12:50:52 +02:00
|
|
|
{
|
2021-12-24 01:06:08 +01:00
|
|
|
_this.hIcon = LoadIconW(hShell32, MAKEINTRESOURCEW(40)); //40
|
2021-10-15 12:50:52 +02:00
|
|
|
wc.hIcon = _this.hIcon;
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
RegisterClassW(&wc);
|
|
|
|
|
2021-12-28 15:06:37 +01:00
|
|
|
_this.hExplorerFrame = LoadLibraryExW(L"ExplorerFrame.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
if (_this.hExplorerFrame)
|
2021-10-21 08:01:59 +02:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
LoadStringW(_this.hExplorerFrame, 50222, GUI_title, 260); // 726 = File Explorer
|
|
|
|
wchar_t* p = wcschr(GUI_title, L'(');
|
2021-12-28 15:06:37 +01:00
|
|
|
if (p)
|
2021-10-21 08:01:59 +02:00
|
|
|
{
|
2021-12-28 15:06:37 +01:00
|
|
|
p--;
|
|
|
|
if (p == L' ')
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
*p = 0;
|
|
|
|
}
|
2021-10-21 08:01:59 +02:00
|
|
|
}
|
2022-01-21 23:04:57 +01:00
|
|
|
if (GUI_title[0] == 0)
|
2021-10-21 08:01:59 +02:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
LoadStringW(hModule, IDS_PRODUCTNAME, GUI_title, 260);
|
2021-10-21 08:01:59 +02:00
|
|
|
}
|
|
|
|
}
|
2021-12-28 15:06:37 +01:00
|
|
|
else
|
2021-10-02 18:46:01 +02:00
|
|
|
{
|
2022-01-21 23:04:57 +01:00
|
|
|
LoadStringW(hModule, IDS_PRODUCTNAME, GUI_title, 260);
|
2021-10-02 18:46:01 +02:00
|
|
|
}
|
2021-10-10 05:14:23 +02:00
|
|
|
HANDLE hUxtheme = NULL;
|
|
|
|
BOOL bHasLoadedUxtheme = FALSE;
|
|
|
|
BOOL bIsCompositionEnabled = TRUE;
|
|
|
|
DwmIsCompositionEnabled(&bIsCompositionEnabled);
|
|
|
|
if (IsThemeActive() && bIsCompositionEnabled)
|
|
|
|
{
|
|
|
|
bHasLoadedUxtheme = TRUE;
|
|
|
|
hUxtheme = LoadLibraryW(L"uxtheme.dll");
|
|
|
|
if (hUxtheme)
|
|
|
|
{
|
|
|
|
RefreshImmersiveColorPolicyState = GetProcAddress(hUxtheme, (LPCSTR)104);
|
|
|
|
SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)135);
|
|
|
|
AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)133);
|
|
|
|
ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)132);
|
|
|
|
if (ShouldAppsUseDarkMode &&
|
|
|
|
SetPreferredAppMode &&
|
|
|
|
AllowDarkModeForWindow &&
|
|
|
|
RefreshImmersiveColorPolicyState
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SetPreferredAppMode(TRUE);
|
|
|
|
RefreshImmersiveColorPolicyState();
|
|
|
|
g_darkModeEnabled = IsThemeActive() && bIsCompositionEnabled && ShouldAppsUseDarkMode() && !IsHighContrast();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-09 18:08:09 +01:00
|
|
|
GUI_RegQueryValueExW(NULL, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition", NULL, NULL, &dwTaskbarPosition, NULL);
|
2021-10-02 03:02:07 +02:00
|
|
|
HWND hwnd = CreateWindowEx(
|
|
|
|
NULL,
|
2021-11-14 17:32:54 +01:00
|
|
|
L"ExplorerPatcher_GUI_" _T(EP_CLSID),
|
2022-01-21 23:04:57 +01:00
|
|
|
GUI_title,
|
2021-10-02 03:02:07 +02:00
|
|
|
WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL, NULL, hModule, &_this
|
|
|
|
);
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2021-11-14 17:32:54 +01:00
|
|
|
|
2022-01-05 04:02:25 +01:00
|
|
|
_this.hAccLabel = CreateWindowExW(
|
|
|
|
0,
|
|
|
|
L"Static",
|
|
|
|
L"",
|
|
|
|
WS_CHILD,
|
|
|
|
10,
|
|
|
|
10,
|
|
|
|
100,
|
|
|
|
100,
|
|
|
|
hwnd,
|
|
|
|
NULL,
|
|
|
|
(HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(
|
|
|
|
&CLSID_AccPropServices,
|
|
|
|
NULL,
|
|
|
|
CLSCTX_INPROC,
|
|
|
|
&IID_IAccPropServices,
|
|
|
|
&_this.pAccPropServices);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
VARIANT var;
|
|
|
|
var.vt = VT_I4;
|
|
|
|
var.lVal = 2; // Assertive;
|
|
|
|
|
|
|
|
hr = ((IAccPropServices*)(_this.pAccPropServices))->lpVtbl->SetHwndProp(
|
|
|
|
_this.pAccPropServices,
|
|
|
|
_this.hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF,
|
|
|
|
LiveSetting_Property_GUID,
|
|
|
|
var
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-10 05:14:23 +02:00
|
|
|
if (IsThemeActive())
|
|
|
|
{
|
|
|
|
if (bIsCompositionEnabled)
|
|
|
|
{
|
|
|
|
BOOL value = 1;
|
|
|
|
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL));
|
2021-12-24 01:06:08 +01:00
|
|
|
/*WTA_OPTIONS ops;
|
2021-10-10 05:14:23 +02:00
|
|
|
ops.dwFlags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
|
|
|
ops.dwMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
|
|
|
SetWindowThemeAttribute(
|
|
|
|
hwnd,
|
|
|
|
WTA_NONCLIENT,
|
|
|
|
&ops,
|
|
|
|
sizeof(WTA_OPTIONS)
|
2021-12-24 01:06:08 +01:00
|
|
|
);*/
|
2021-10-10 05:14:23 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
2021-11-16 06:00:10 +01:00
|
|
|
if (hKey)
|
|
|
|
{
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2021-10-02 03:02:07 +02:00
|
|
|
|
|
|
|
MSG msg = { 0 };
|
|
|
|
while (GetMessage(&msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
|
2022-01-05 04:02:25 +01:00
|
|
|
if (_this.pAccPropServices != NULL)
|
|
|
|
{
|
|
|
|
MSAAPROPID props[] = { LiveSetting_Property_GUID };
|
|
|
|
((IAccPropServices*)(_this.pAccPropServices))->lpVtbl->ClearHwndProps(
|
|
|
|
_this.pAccPropServices,
|
|
|
|
_this.hAccLabel,
|
|
|
|
OBJID_CLIENT,
|
|
|
|
CHILDID_SELF,
|
|
|
|
props,
|
|
|
|
ARRAYSIZE(props));
|
|
|
|
|
|
|
|
((IAccPropServices*)(_this.pAccPropServices))->lpVtbl->Release(_this.pAccPropServices);
|
|
|
|
_this.pAccPropServices = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(_this.hAccLabel);
|
|
|
|
|
2021-12-28 15:06:37 +01:00
|
|
|
if (_this.hExplorerFrame)
|
|
|
|
{
|
|
|
|
FreeLibrary(_this.hExplorerFrame);
|
|
|
|
}
|
|
|
|
|
2021-10-21 08:01:59 +02:00
|
|
|
if (hShell32)
|
2021-10-15 12:50:52 +02:00
|
|
|
{
|
|
|
|
CloseHandle(_this.hIcon);
|
2021-10-21 08:01:59 +02:00
|
|
|
FreeLibrary(hShell32);
|
2021-10-15 12:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bHasLoadedUxtheme && hUxtheme)
|
2021-10-10 05:14:23 +02:00
|
|
|
{
|
|
|
|
FreeLibrary(hUxtheme);
|
|
|
|
}
|
|
|
|
|
2021-10-15 12:50:52 +02:00
|
|
|
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
|
|
|
|
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
|
|
|
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
|
|
|
|
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
|
|
|
|
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
|
|
|
|
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
|
|
|
|
_CrtDumpMemoryLeaks();
|
|
|
|
#ifdef _DEBUG
|
|
|
|
_getch();
|
|
|
|
#endif
|
|
|
|
|
2021-10-02 03:02:07 +02:00
|
|
|
printf("Ended \"GUI\" thread.\n");
|
2021-10-10 21:37:47 +02:00
|
|
|
}
|