diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index bb2cbdb..6d92b0d 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -14,6 +14,40 @@ static BOOL(*ShouldAppsUseDarkMode)() = NULL; DWORD dwTaskbarPosition = 3; BOOL gui_bOldTaskbar = TRUE; +LSTATUS SetPolicy(HKEY hKey, LPCWSTR wszPolicyPath, LPCWSTR wszPolicyName, DWORD dwVal) +{ + WCHAR wszPath[MAX_PATH]; + GetSystemDirectoryW(wszPath, MAX_PATH); + wcscat_s(wszPath, MAX_PATH, L"\\reg.exe"); + WCHAR wszArguments[MAX_PATH]; + if (dwVal) + { + swprintf_s(wszArguments, MAX_PATH, L"ADD \"%s\\%s\" /V %s /T REG_DWORD /D %d /F", (hKey == HKEY_LOCAL_MACHINE ? L"HKLM" : L"HKCU"), wszPolicyPath, wszPolicyName, dwVal); + } + else + { + swprintf_s(wszArguments, MAX_PATH, L"DELETE \"%s\\%s\" /V %s /F", (hKey == HKEY_LOCAL_MACHINE ? L"HKLM" : L"HKCU"), wszPolicyPath, wszPolicyName); + } + SHELLEXECUTEINFO ShExecInfo = { 0 }; + ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); + ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + ShExecInfo.hwnd = NULL; + ShExecInfo.lpVerb = L"runas"; + ShExecInfo.lpFile = wszPath; + ShExecInfo.lpParameters = wszArguments; + ShExecInfo.lpDirectory = NULL; + ShExecInfo.nShow = SW_HIDE; + ShExecInfo.hInstApp = NULL; + if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess) + { + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + DWORD dwExitCode = 0; + GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode); + CloseHandle(ShExecInfo.hProcess); + } + return ERROR_SUCCESS; +} + int GUI_DeleteWeatherFolder() { WCHAR wszWorkFolder[MAX_PATH + 1]; @@ -420,36 +454,11 @@ LSTATUS GUI_Internal_RegSetValueExW( } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_ForceStartSize")) { - WCHAR wszPath[MAX_PATH]; - GetSystemDirectoryW(wszPath, MAX_PATH); - wcscat_s(wszPath, MAX_PATH, L"\\reg.exe"); - WCHAR wszArguments[MAX_PATH]; - if (*(DWORD*)lpData) - { - swprintf_s(wszArguments, MAX_PATH, L"ADD \"HKCU\\Software\\Policies\\Microsoft\\Windows\\Explorer\" /V ForceStartSize /T REG_DWORD /D %d /F", *(DWORD*)lpData); - } - else - { - swprintf_s(wszArguments, MAX_PATH, L"DELETE \"HKCU\\Software\\Policies\\Microsoft\\Windows\\Explorer\" /V ForceStartSize /F"); - } - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - ShExecInfo.hwnd = NULL; - ShExecInfo.lpVerb = L"runas"; - ShExecInfo.lpFile = wszPath; - ShExecInfo.lpParameters = wszArguments; - ShExecInfo.lpDirectory = NULL; - ShExecInfo.nShow = SW_HIDE; - ShExecInfo.hInstApp = NULL; - if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess) - { - WaitForSingleObject(ShExecInfo.hProcess, INFINITE); - DWORD dwExitCode = 0; - GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode); - CloseHandle(ShExecInfo.hProcess); - } - return ERROR_SUCCESS; + return SetPolicy(HKEY_CURRENT_USER, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer", L"ForceStartSize", *(DWORD*)lpData); + } + else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_NoStartMenuMorePrograms")) + { + return SetPolicy(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", L"NoStartMenuMorePrograms", *(DWORD*)lpData); } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners")) { @@ -658,6 +667,10 @@ LSTATUS GUI_Internal_RegQueryValueExW( { return RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer", L"ForceStartSize", RRF_RT_DWORD, NULL, lpData, lpcbData); } + else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_NoStartMenuMorePrograms")) + { + return RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", L"NoStartMenuMorePrograms", RRF_RT_DWORD, NULL, lpData, lpcbData); + } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners")) { HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, _T(EP_DWM_EVENTNAME)); diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 5603702..c288087 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -9000,6 +9000,7 @@ char VisibilityChangedEventArguments_GetVisible(__int64 a1) return v3[0]; } +DWORD Start_NoStartMenuMorePrograms = 0; DWORD Start_ForceStartSize = 0; DWORD StartMenu_maximumFreqApps = 6; DWORD StartMenu_ShowAllApps = 0; @@ -9194,6 +9195,43 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged) exit(0); } Start_ForceStartSize = dwVal; + + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); + dwVal = 0; + RegQueryValueExW( + hKey, + TEXT("NoStartMenuMorePrograms"), + 0, + NULL, + &dwVal, + &dwSize + ); + if (bRestartIfChanged && dwVal != Start_NoStartMenuMorePrograms) + { + exit(0); + } + Start_NoStartMenuMorePrograms = dwVal; + RegCloseKey(hKey); } } @@ -9874,7 +9912,7 @@ void InjectStartMenu() VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartDocked_SetWindowRgn); } - Setting* settings = calloc(5, sizeof(Setting)); + Setting* settings = calloc(6, sizeof(Setting)); settings[0].callback = NULL; settings[0].data = NULL; settings[0].hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); @@ -9905,10 +9943,16 @@ void InjectStartMenu() settings[4].hKey = NULL; wcscpy_s(settings[4].name, MAX_PATH, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Explorer"); settings[4].origin = HKEY_CURRENT_USER; + settings[5].callback = StartMenu_LoadSettings; + settings[5].data = TRUE; + settings[5].hEvent = NULL; + settings[5].hKey = NULL; + wcscpy_s(settings[5].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"); + settings[5].origin = HKEY_CURRENT_USER; SettingsChangeParameters* params = calloc(1, sizeof(SettingsChangeParameters)); params->settings = settings; - params->size = 5; + params->size = 6; CreateThread( 0, 0, diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 5fd895d..223b8b1 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -241,6 +241,11 @@ ;x 1 Start menu ;x 2 Full screen Start ;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_ForceStartSize"=dword:00000000 +;c 3 App list +;x 0 Display +;x 3 Hide +;x 1 Disable +;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_NoStartMenuMorePrograms"=dword:00000000 ;T Window switcher