1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-30 18:24:36 +01:00

Option to disable rounded corners for windows

This commit is contained in:
Valentin Radu 2022-01-21 13:06:46 +02:00
parent 312fa7f7fc
commit 7cc02b72d4
11 changed files with 248 additions and 8 deletions

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
[submodule "libs/sws"] [submodule "libs/sws"]
path = libs/sws path = libs/sws
url = https://github.com/valinet/sws url = https://github.com/valinet/sws
[submodule "ep_dwm"]
path = ep_dwm
url = https://github.com/valinet/ep_dwm

View File

@ -13,6 +13,7 @@ Tested on OS build 22000.434.
* Support for screen readers in the Properties window (#627) (.1) * Support for screen readers in the Properties window (#627) (.1)
* Option to disable `Office` hotkeys (`Ctrl`+`Alt`+`Shift`+`Windows` key combinations) (#661) (.4) * Option to disable `Office` hotkeys (`Ctrl`+`Alt`+`Shift`+`Windows` key combinations) (#661) (.4)
* Simple Window Switcher can switch applications instead of windows (#665) (.5, .6) * Simple Window Switcher can switch applications instead of windows (#665) (.5, .6)
* Option to disable rounded corners for windows (.7)
#### Feature enhancements #### Feature enhancements

View File

@ -201,6 +201,12 @@
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\ep_dwm\ep_dwm\ep_dwm.c">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">EP_DWM_NO_DLLMAIN;EP_DWM_NO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_error.c"> <ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_error.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -292,6 +298,7 @@
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\ep_dwm\ep_dwm\ep_dwm.h" />
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_def.h" /> <ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_def.h" />
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_error.h" /> <ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_error.h" />
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h" /> <ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h" />

View File

@ -28,6 +28,12 @@
<Filter Include="Settings"> <Filter Include="Settings">
<UniqueIdentifier>{190d08ad-4a1d-4b58-81a1-6403eeb3cd2a}</UniqueIdentifier> <UniqueIdentifier>{190d08ad-4a1d-4b58-81a1-6403eeb3cd2a}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\ep_dwm">
<UniqueIdentifier>{50a6ac61-12c4-460e-a9d1-cdaf9bf7e7b1}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ep_dwm">
<UniqueIdentifier>{fd25654b-7123-401a-86c7-90413d703f30}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
@ -123,6 +129,9 @@
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h"> <ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h">
<Filter>Header Files\sws</Filter> <Filter>Header Files\sws</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\libs\ep_dwm\ep_dwm\ep_dwm.h">
<Filter>Header Files\ep_dwm</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="ExplorerPatcher.rc"> <ResourceCompile Include="ExplorerPatcher.rc">
@ -202,6 +211,9 @@
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_tshwnd.c"> <ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_tshwnd.c">
<Filter>Source Files\sws</Filter> <Filter>Source Files\sws</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\libs\ep_dwm\ep_dwm\ep_dwm.c">
<Filter>Source Files\ep_dwm</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="settings.reg"> <None Include="settings.reg">

View File

@ -317,6 +317,100 @@ LSTATUS GUI_RegSetValueExW(
); );
return RegSetValueExW(hKey, L"Start_MaximumFrequentApps", 0, dwType, lpData, cbData); return RegSetValueExW(hKey, L"Start_MaximumFrequentApps", 0, dwType, lpData, cbData);
} }
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
{
WCHAR wszPath[MAX_PATH];
GetSystemDirectoryW(wszPath, MAX_PATH);
wcscat_s(wszPath, MAX_PATH, L"\\cmd.exe");
WCHAR wszSCPath[MAX_PATH];
GetSystemDirectoryW(wszSCPath, MAX_PATH);
wcscat_s(wszSCPath, MAX_PATH, L"\\sc.exe");
WCHAR wszRundll32[MAX_PATH];
GetSystemDirectoryW(wszRundll32, MAX_PATH);
wcscat_s(wszRundll32, MAX_PATH, L"\\rundll32.exe");
WCHAR wszEP[MAX_PATH];
GetWindowsDirectoryW(wszEP, MAX_PATH);
wcscat_s(wszEP, MAX_PATH, L"\\dxgi.dll");
WCHAR wszTaskkill[MAX_PATH];
GetSystemDirectoryW(wszTaskkill, MAX_PATH);
wcscat_s(wszTaskkill, MAX_PATH, L"\\taskkill.exe");
WCHAR wszArgumentsRegister[MAX_PATH * 10];
swprintf_s(
wszArgumentsRegister,
MAX_PATH * 10,
L"/c \""
L"\"%s\" create ep_dwm_" _T(EP_CLSID_LITE) L" binPath= \"\\\"%s\\\" \\\"%s\\\",ZZDWM\" DisplayName= \"ExplorerPatcher Desktop Window Manager Service\" start= auto & "
L"\"%s\" description ep_dwm_" _T(EP_CLSID_LITE) L" \"Implements functionality to disable rounded corners for windows\" & "
L"\"%s\" start ep_dwm_" _T(EP_CLSID_LITE)
L"\"",
wszSCPath,
wszRundll32,
wszEP,
wszSCPath,
wszSCPath
);
WCHAR wszArgumentsUnRegister[MAX_PATH * 10];
swprintf_s(
wszArgumentsUnRegister,
MAX_PATH * 10,
L"/c \""
L"\"%s\" stop ep_dwm_" _T(EP_CLSID_LITE) L" & "
L"\"%s\" delete ep_dwm_" _T(EP_CLSID_LITE) L" & "
L"\"",
wszSCPath,
wszSCPath
);
wprintf(L"%s\n", wszArgumentsRegister);
BOOL bAreRoundedCornersDisabled = FALSE;
HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, L"Global\\ep_dwm_" _T(EP_CLSID));
if (h_exists)
{
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
bAreRoundedCornersDisabled = TRUE;
}
else
{
bAreRoundedCornersDisabled = FALSE;
}
CloseHandle(h_exists);
}
else
{
if (GetLastError() == ERROR_ACCESS_DENIED)
{
bAreRoundedCornersDisabled = TRUE;
}
else
{
bAreRoundedCornersDisabled = FALSE;
}
}
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = wszPath;
ShExecInfo.lpParameters = !bAreRoundedCornersDisabled ? wszArgumentsRegister : wszArgumentsUnRegister;
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;
}
} }
LSTATUS GUI_RegQueryValueExW( LSTATUS GUI_RegQueryValueExW(
@ -417,6 +511,34 @@ LSTATUS GUI_RegQueryValueExW(
{ {
return RegQueryValueExW(hKey, L"Start_MaximumFrequentApps", lpReserved, lpType, lpData, lpcbData); return RegQueryValueExW(hKey, L"Start_MaximumFrequentApps", lpReserved, lpType, lpData, lpcbData);
} }
else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_DisableRoundedCorners"))
{
HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, L"Global\\ep_dwm_" _T(EP_CLSID));
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;
}
} }
static HRESULT GUI_AboutProc( static HRESULT GUI_AboutProc(
@ -1185,8 +1307,34 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
{ {
CloseHandle(hFile); CloseHandle(hFile);
BOOL bAreRoundedCornersDisabled = FALSE;
HANDLE h_exists = CreateEventW(NULL, FALSE, FALSE, L"Global\\ep_dwm_" _T(EP_CLSID));
if (h_exists)
{
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
bAreRoundedCornersDisabled = TRUE;
}
else
{
bAreRoundedCornersDisabled = FALSE;
}
CloseHandle(h_exists);
}
else
{
if (GetLastError() == ERROR_ACCESS_DENIED)
{
bAreRoundedCornersDisabled = TRUE;
}
else
{
bAreRoundedCornersDisabled = FALSE;
}
}
DWORD dwError = 1; DWORD dwError = 1;
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) if ((hKey == NULL || hKey == INVALID_HANDLE_VALUE) && !bAreRoundedCornersDisabled)
{ {
dwError = 0; dwError = 0;
// https://stackoverflow.com/questions/50298722/win32-launching-a-highestavailable-child-process-as-a-normal-user-process // https://stackoverflow.com/questions/50298722/win32-launching-a-highestavailable-child-process-as-a-normal-user-process
@ -1256,13 +1404,45 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
} }
if (dwError) if (dwError)
{ {
WCHAR wszCMD[MAX_PATH];
GetSystemDirectoryW(wszCMD, MAX_PATH);
wcscat_s(wszCMD, MAX_PATH, L"\\cmd.exe");
WCHAR wszRegedit[MAX_PATH];
GetWindowsDirectoryW(wszRegedit, MAX_PATH);
wcscat_s(wszRegedit, MAX_PATH, L"\\regedit.exe");
WCHAR wszSCPath[MAX_PATH];
GetSystemDirectoryW(wszSCPath, MAX_PATH);
wcscat_s(wszSCPath, MAX_PATH, L"\\sc.exe");
WCHAR wszTaskkill[MAX_PATH];
GetSystemDirectoryW(wszTaskkill, MAX_PATH);
wcscat_s(wszTaskkill, MAX_PATH, L"\\taskkill.exe");
WCHAR wszArguments[MAX_PATH * 10];
swprintf_s(
wszArguments,
MAX_PATH * 10,
L"/c \""
L"\"%s\" \"%s\" & "
L"\"%s\" stop ep_dwm_" _T(EP_CLSID_LITE) L" & "
L"\"%s\" delete ep_dwm_" _T(EP_CLSID_LITE)
L"\"",
wszRegedit,
wszPath,
wszSCPath,
wszSCPath
);
wprintf(L"%s\n", wszArguments);
SHELLEXECUTEINFO ShExecInfo = { 0 }; SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL; ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL; ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = wszPath; ShExecInfo.lpFile = wszCMD;
ShExecInfo.lpParameters = L""; ShExecInfo.lpParameters = wszArguments;
ShExecInfo.lpDirectory = NULL; ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW; ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL; ShExecInfo.hInstApp = NULL;

View File

@ -161,7 +161,11 @@ HRESULT WINAPI _DllGetClassObject(
REFIID riid, REFIID riid,
LPVOID* ppv LPVOID* ppv
); );
BOOL ep_dwm_StartService(LPWSTR wszServiceName, LPWSTR wszEventName);
__declspec(dllexport) int ZZDWM(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow)
{
ep_dwm_StartService(L"ep_dwm_Service_" _T(EP_CLSID), L"Global\\ep_dwm_" _T(EP_CLSID));
}
#pragma region "Updates" #pragma region "Updates"
#ifdef _WIN64 #ifdef _WIN64

View File

@ -364,6 +364,8 @@
"NoMenuAccelerator"=dword:00000000 "NoMenuAccelerator"=dword:00000000
;b Disable Office hotkeys (Ctrl+Alt+Shift+Windows key combinations) * ;b Disable Office hotkeys (Ctrl+Alt+Shift+Windows key combinations) *
"DisableOfficeHotkeys"=dword:00000000 "DisableOfficeHotkeys"=dword:00000000
;b Disable rounded corners for application windows
"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_DisableRoundedCorners"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
;c 6 Default action in the Alt+F4 dialog on the desktop ;c 6 Default action in the Alt+F4 dialog on the desktop
;x 256 Switch user ;x 256 Switch user

View File

@ -28,6 +28,7 @@
#define PRODUCT_NAME "ExplorerPatcher" #define PRODUCT_NAME "ExplorerPatcher"
#define PRODUCT_PUBLISHER "VALINET Solutions SRL" #define PRODUCT_PUBLISHER "VALINET Solutions SRL"
#define APP_RELATIVE_PATH "\\" PRODUCT_NAME #define APP_RELATIVE_PATH "\\" PRODUCT_NAME
#define EP_CLSID_LITE "D17F1E1A-5919-4427-8F89-A1A8503CA3EB"
#define EP_CLSID "{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}" #define EP_CLSID "{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}"
#define DOSMODE_OFFSET 78 #define DOSMODE_OFFSET 78
#define SETUP_UTILITY_NAME "ep_setup.exe" #define SETUP_UTILITY_NAME "ep_setup.exe"

1
ep_dwm Submodule

@ -0,0 +1 @@
Subproject commit e058f2e8cc13dc094ba55f472a1ade969d260526

View File

@ -434,6 +434,27 @@ int WINAPI wWinMain(
CloseHandle(sei.hProcess); CloseHandle(sei.hProcess);
} }
WCHAR wszSCPath[MAX_PATH];
GetSystemDirectoryW(wszSCPath, MAX_PATH);
wcscat_s(wszSCPath, MAX_PATH, L"\\sc.exe");
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = wszSCPath;
ShExecInfo.lpParameters = L"stop ep_dwm_" _T(EP_CLSID_LITE);
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);
}
HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL); HWND hWnd = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL);
if (hWnd) if (hWnd)
{ {
@ -591,6 +612,14 @@ int WINAPI wWinMain(
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME) L"\" /uninstall"); wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME) L"\" /uninstall");
bOk = SetupUninstallEntry(bInstall, wszPath); bOk = SetupUninstallEntry(bInstall, wszPath);
} }
ShExecInfo.lpParameters = bInstall ? L"start ep_dwm_" _T(EP_CLSID_LITE) : L"delete ep_dwm_" _T(EP_CLSID_LITE);
if (ShellExecuteExW(&ShExecInfo) && ShExecInfo.hProcess)
{
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
DWORD dwExitCode = 0;
GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);
CloseHandle(ShExecInfo.hProcess);
}
if (bOk) if (bOk)
{ {

View File

@ -1,7 +1,7 @@
#define VER_MAJOR 22000 #define VER_MAJOR 22000
#define VER_MINOR 434 #define VER_MINOR 434
#define VER_BUILD_HI 41 #define VER_BUILD_HI 41
#define VER_BUILD_LO 6 #define VER_BUILD_LO 7
#define VER_FLAGS VS_FF_PRERELEASE #define VER_FLAGS VS_FF_PRERELEASE
@ -12,5 +12,5 @@
#define VER_STR(arg) #arg #define VER_STR(arg) #arg
// The String form of the version numbers // The String form of the version numbers
#define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.6" #define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.7"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.6" #define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.7"