Skip to content

Commit

Permalink
Option to disable rounded corners for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
valinet committed Jan 21, 2022
1 parent 312fa7f commit 7cc02b7
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "libs/sws"]
path = libs/sws
url = https://github.com/valinet/sws
[submodule "ep_dwm"]
path = ep_dwm
url = https://github.com/valinet/ep_dwm
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Tested on OS build 22000.434.
* Support for screen readers in the Properties window (#627) (.1)
* 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)
* Option to disable rounded corners for windows (.7)

#### Feature enhancements

Expand Down
7 changes: 7 additions & 0 deletions ExplorerPatcher/ExplorerPatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@
</PreBuildEvent>
</ItemDefinitionGroup>
<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">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -292,6 +298,7 @@
</ClCompile>
</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_error.h" />
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h" />
Expand Down
12 changes: 12 additions & 0 deletions ExplorerPatcher/ExplorerPatcher.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
<Filter Include="Settings">
<UniqueIdentifier>{190d08ad-4a1d-4b58-81a1-6403eeb3cd2a}</UniqueIdentifier>
</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>
<ClInclude Include="resource.h">
Expand Down Expand Up @@ -123,6 +129,9 @@
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_IconPainter.h">
<Filter>Header Files\sws</Filter>
</ClInclude>
<ClInclude Include="..\libs\ep_dwm\ep_dwm\ep_dwm.h">
<Filter>Header Files\ep_dwm</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ExplorerPatcher.rc">
Expand Down Expand Up @@ -202,6 +211,9 @@
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_tshwnd.c">
<Filter>Source Files\sws</Filter>
</ClCompile>
<ClCompile Include="..\libs\ep_dwm\ep_dwm\ep_dwm.c">
<Filter>Source Files\ep_dwm</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="settings.reg">
Expand Down
188 changes: 184 additions & 4 deletions ExplorerPatcher/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,100 @@ LSTATUS GUI_RegSetValueExW(
);
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(
Expand Down Expand Up @@ -417,6 +511,34 @@ LSTATUS GUI_RegQueryValueExW(
{
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(
Expand Down Expand Up @@ -1185,8 +1307,34 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
{
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;
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
if ((hKey == NULL || hKey == INVALID_HANDLE_VALUE) && !bAreRoundedCornersDisabled)
{
dwError = 0;
// https://stackoverflow.com/questions/50298722/win32-launching-a-highestavailable-child-process-as-a-normal-user-process
Expand Down Expand Up @@ -1256,13 +1404,45 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
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 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = wszPath;
ShExecInfo.lpParameters = L"";
ShExecInfo.lpVerb = L"runas";
ShExecInfo.lpFile = wszCMD;
ShExecInfo.lpParameters = wszArguments;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
Expand Down
6 changes: 5 additions & 1 deletion ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ HRESULT WINAPI _DllGetClassObject(
REFIID riid,
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"
#ifdef _WIN64
Expand Down
2 changes: 2 additions & 0 deletions ExplorerPatcher/settings.reg
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@
"NoMenuAccelerator"=dword:00000000
;b Disable Office hotkeys (Ctrl+Alt+Shift+Windows key combinations) *
"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]
;c 6 Default action in the Alt+F4 dialog on the desktop
;x 256 Switch user
Expand Down
1 change: 1 addition & 0 deletions ExplorerPatcher/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define PRODUCT_NAME "ExplorerPatcher"
#define PRODUCT_PUBLISHER "VALINET Solutions SRL"
#define APP_RELATIVE_PATH "\\" PRODUCT_NAME
#define EP_CLSID_LITE "D17F1E1A-5919-4427-8F89-A1A8503CA3EB"
#define EP_CLSID "{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}"
#define DOSMODE_OFFSET 78
#define SETUP_UTILITY_NAME "ep_setup.exe"
Expand Down
1 change: 1 addition & 0 deletions ep_dwm
Submodule ep_dwm added at e058f2
29 changes: 29 additions & 0 deletions ep_setup/ep_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,27 @@ int WINAPI wWinMain(
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);
if (hWnd)
{
Expand Down Expand Up @@ -591,6 +612,14 @@ int WINAPI wWinMain(
wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME) L"\" /uninstall");
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)
{
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define VER_MAJOR 22000
#define VER_MINOR 434
#define VER_BUILD_HI 41
#define VER_BUILD_LO 6
#define VER_BUILD_LO 7
#define VER_FLAGS VS_FF_PRERELEASE


Expand All @@ -12,5 +12,5 @@
#define VER_STR(arg) #arg

// The String form of the version numbers
#define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.6"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.6"
#define VER_FILE_STRING VALUE "FileVersion", "22000.434.41.7"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.434.41.7"

0 comments on commit 7cc02b7

Please sign in to comment.