Skip to content

Commit

Permalink
Better patching strategy; simplified install/uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
valinet committed Oct 4, 2021
1 parent 1ad7ce0 commit c8e7097
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Win11DisableRoundedCorners
A simple utility that cold patches the Desktop Window Manager (uDWM.dll) in order to disable window rounded corners in Windows 11. Tested on build 22000.176.
# Win11DisableOrRestoreRoundedCorners
A simple utility that cold patches the Desktop Window Manager (uDWM.dll) in order to disable window rounded corners in Windows 11. Tested on build 22000.194.

Precompiled binaries are available in [Releases](https://github.com/valinet/Win11DisableRoundedCorners/releases).

To successfully patch and not brick your system, make sure you have only one dwm.exe process running. If you have multiple, connect normally to Windows, not using remote desktop or something similar.

Application requires active Internet connection when patching in order to download symbol files for `uDWM.dll`.

It is preferable but not mandatory to run the files from a separate directory. The app will temporarly place 2 files: `uDWM.dll` and `uDWM.pdb` in the directory they are in, overwriting any existing files.
It is preferable but not mandatory to run the files from a separate directory. The app will temporarily place 2 files: `uDWM.dll` and `uDWM.pdb` in the directory they are in, overwriting any existing files.

Original `uDWM.dll` is backed up as `uDWM_win11drc.bak` in `%windir%\System32`.

Consult the source code if you want to patch manually, which is also quite advisable, it only takes changing 2 bytes in the `uDWM.dll` file.
Consult the source code if you want to patch manually, which is also quite advisable, it only takes changing a few bytes in the `uDWM.dll` file.

Please make a backup of the original `uDWM.dll` file before using so you can restore properly in case something is messed up. Use this software at your own risk.

Expand Down
10 changes: 5 additions & 5 deletions Win11DisableRoundedCorners/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEVERSION 1,0,0,2
PRODUCTVERSION 1,0,0,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,13 +68,13 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "FileDescription", "Disables rounded corners in Windows 11"
VALUE "FileVersion", "1.0.0.1"
VALUE "FileDescription", "Disables or restores rounded corners in Windows 11"
VALUE "FileVersion", "1.0.0.2"
VALUE "InternalName", "Win11DisableRoundedCorners.exe"
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
VALUE "OriginalFilename", "Win11Dis.exe"
VALUE "ProductName", "Win11DisableRoundedCorners"
VALUE "ProductVersion", "1.0.0.1"
VALUE "ProductVersion", "1.0.0.2"
END
END
BLOCK "VarFileInfo"
Expand Down
26 changes: 11 additions & 15 deletions Win11DisableRoundedCorners/Win11DisableRoundedCorners.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

int main(int argc, char** argv)
{
BOOL bRestore = FALSE;

char szTaskkill[MAX_PATH];
ZeroMemory(
szTaskkill,
Expand Down Expand Up @@ -48,13 +50,14 @@ int main(int argc, char** argv)
MAX_PATH,
"\\uDWM_win11drc.bak"
);
bRestore = fileExists(szOriginalDWM);

char szModifiedDWM[_MAX_PATH];
ZeroMemory(
szModifiedDWM,
(_MAX_PATH) * sizeof(char)
);
if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe"))
if (bRestore)
{
GetSystemDirectoryA(
szModifiedDWM,
Expand Down Expand Up @@ -96,7 +99,7 @@ int main(int argc, char** argv)
"\\uDWM.dll"
);

if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe"))
if (bRestore)
{
DeleteFileA(szModifiedDWM);
if (!MoveFileA(szDWM, szModifiedDWM))
Expand All @@ -114,6 +117,7 @@ int main(int argc, char** argv)
}
else
{

if (!CopyFileA(szDWM, szModifiedDWM, FALSE))
{
printf(
Expand Down Expand Up @@ -150,7 +154,7 @@ int main(int argc, char** argv)
_getch();
return 3;
}
printf("Function address is: 0x%x\n", addr[0]);
printf("Function address is: 0x%x.\n", addr[0]);
DeleteFile(szModifiedDWM);
PathRemoveFileSpecA(szModifiedDWM);
strcat_s(
Expand Down Expand Up @@ -187,16 +191,8 @@ int main(int argc, char** argv)
_getch();
return 6;
}
char szPattern[8] = { 0x8B, 0xC1, 0x48, 0x83, 0xC4, 0x20, 0x5B, 0xC3 };
char szPayload[2] = { 0x31, 0xC0 }; // xor eax, eax
char* off = memmem(lpFileBase + addr[0], 1000, szPattern, 8);
if (!off)
{
printf("Unable to find pattern in file.\n");
_getch();
return 7;
}
memcpy(off, szPayload, sizeof(szPayload));
char szPayload[8] = { 0x48, 0xC7, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xc3}; // mov rax, 0; ret
memcpy(lpFileBase + addr[0], szPayload, sizeof(szPayload));
UnmapViewOfFile(lpFileBase);
CloseHandle(hFileMapping);
CloseHandle(hFile);
Expand Down Expand Up @@ -236,8 +232,8 @@ int main(int argc, char** argv)
&pi
);
WaitForSingleObject(pi.hProcess, INFINITE);
Sleep(1000);
if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe"))
Sleep(10000);
if (bRestore)
{
DeleteFileA(szModifiedDWM);
}
Expand Down
4 changes: 4 additions & 0 deletions Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>Win11DisableOrRestoreRoundedCorners</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>Win11DisableOrRestoreRoundedCorners</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>Win11DisableOrRestoreRoundedCorners</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>Win11DisableOrRestoreRoundedCorners</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down

0 comments on commit c8e7097

Please sign in to comment.