diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bbfa66c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/libvalinet"] + path = libs/libvalinet + url = https://github.com/valinet/libvalinet diff --git a/Win11DisableRoundedCorners.sln b/Win11DisableRoundedCorners.sln new file mode 100644 index 0000000..2314cfc --- /dev/null +++ b/Win11DisableRoundedCorners.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win11DisableRoundedCorners", "Win11DisableRoundedCorners\Win11DisableRoundedCorners.vcxproj", "{C4A6832A-9AE5-4AA5-A424-15CF8179F318}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Debug|x64.ActiveCfg = Debug|x64 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Debug|x64.Build.0 = Debug|x64 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Debug|x86.ActiveCfg = Debug|Win32 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Debug|x86.Build.0 = Debug|Win32 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Release|x64.ActiveCfg = Release|x64 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Release|x64.Build.0 = Release|x64 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Release|x86.ActiveCfg = Release|Win32 + {C4A6832A-9AE5-4AA5-A424-15CF8179F318}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {90C55F7D-8015-422B-A5E1-F1DC4F34418A} + EndGlobalSection +EndGlobal diff --git a/Win11DisableRoundedCorners/Resource.rc b/Win11DisableRoundedCorners/Resource.rc new file mode 100644 index 0000000..5ab68f2 --- /dev/null +++ b/Win11DisableRoundedCorners/Resource.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "VALINET Solutions SRL" + VALUE "FileDescription", "Disables rounded corners in Windows 11" + VALUE "FileVersion", "1.0.0.1" + 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" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Win11DisableRoundedCorners/Win11DisableRoundedCorners.c b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.c new file mode 100644 index 0000000..eb38a0f --- /dev/null +++ b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.c @@ -0,0 +1,246 @@ +#undef UNICODE +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + char szTaskkill[MAX_PATH]; + ZeroMemory( + szTaskkill, + (MAX_PATH) * sizeof(char) + ); + szTaskkill[0] = '\"'; + GetSystemDirectoryA( + szTaskkill + sizeof(char), + MAX_PATH + ); + strcat_s( + szTaskkill, + MAX_PATH, + "\\taskkill.exe\" /f /im dwm.exe" + ); + + char szPath[_MAX_PATH]; + ZeroMemory( + szPath, + (_MAX_PATH) * sizeof(char) + ); + GetModuleFileNameA( + GetModuleHandle(NULL), + szPath, + _MAX_PATH + ); + PathStripPathA(szPath); + + char szOriginalDWM[_MAX_PATH]; + ZeroMemory( + szOriginalDWM, + (_MAX_PATH) * sizeof(char) + ); + GetSystemDirectoryA( + szOriginalDWM, + MAX_PATH + ); + strcat_s( + szOriginalDWM, + MAX_PATH, + "\\uDWM_win11drc.bak" + ); + + char szModifiedDWM[_MAX_PATH]; + ZeroMemory( + szModifiedDWM, + (_MAX_PATH) * sizeof(char) + ); + if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe")) + { + GetSystemDirectoryA( + szModifiedDWM, + MAX_PATH + ); + strcat_s( + szModifiedDWM, + MAX_PATH, + "\\uDWMm.dll" + ); + } + else + { + GetModuleFileNameA( + GetModuleHandle(NULL), + szModifiedDWM, + _MAX_PATH + ); + PathRemoveFileSpecA(szModifiedDWM); + strcat_s( + szModifiedDWM, + MAX_PATH, + "\\uDWM.dll" + ); + } + + char szDWM[MAX_PATH]; + ZeroMemory( + szDWM, + (MAX_PATH) * sizeof(char) + ); + GetSystemDirectoryA( + szDWM, + MAX_PATH + ); + strcat_s( + szDWM, + MAX_PATH, + "\\uDWM.dll" + ); + + if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe")) + { + DeleteFileA(szModifiedDWM); + if (!MoveFileA(szDWM, szModifiedDWM)) + { + printf("Unable to restore DWM.\n"); + _getch(); + return 1; + } + if (!MoveFileA(szOriginalDWM, szDWM)) + { + printf("Unable to restore DWM.\n"); + _getch(); + return 2; + } + } + else + { + if (!CopyFileA(szDWM, szModifiedDWM, FALSE)) + { + printf( + "Temporary file copy failed. Make sure the application has write " + "access to the folder it runs from.\n" + ); + _getch(); + return 1; + } + if (VnDownloadSymbols( + NULL, + szModifiedDWM, + szModifiedDWM, + _MAX_PATH + )) + { + printf( + "Unable to download symbols. Make sure you have a working Internet " + "connection.\n" + ); + _getch(); + return 2; + } + DWORD addr[1] = { 0 }; + char* name[1] = { "CTopLevelWindow::GetEffectiveCornerStyle" }; + if (VnGetSymbols( + szModifiedDWM, + addr, + name, + 1 + )) + { + printf("Unable to determine function address.\n"); + _getch(); + return 3; + } + printf("Function address is: 0x%x\n", addr[0]); + DeleteFile(szModifiedDWM); + PathRemoveFileSpecA(szModifiedDWM); + strcat_s( + szModifiedDWM, + MAX_PATH, + "\\uDWM.dll" + ); + HANDLE hFile = CreateFileA( + szModifiedDWM, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + 0 + ); + if (!hFile) + { + printf("Unable to open system file.\n"); + _getch(); + return 4; + } + HANDLE hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL); + if (hFileMapping == 0) + { + printf("Unable to create file mapping.\n"); + _getch(); + return 5; + } + char* lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + if (lpFileBase == 0) + { + printf("Unable to memory map system file.\n"); + _getch(); + return 6; + } + char szPattern[9] = { 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)); + UnmapViewOfFile(lpFileBase); + CloseHandle(hFileMapping); + CloseHandle(hFile); + if (!VnTakeOwnership(szDWM)) + { + printf("Unable to take ownership of system file.\n"); + _getch(); + return 7; + } + DeleteFileA(szOriginalDWM); + if (!MoveFileA(szDWM, szOriginalDWM)) + { + printf("Unable to backup system file.\n"); + _getch(); + return 7; + } + if (!CopyFileA(szModifiedDWM, szDWM, FALSE)) + { + printf("Unable to replace system file.\n"); + _getch(); + return 1; + } + DeleteFileA(szModifiedDWM); + } + STARTUPINFO si = { sizeof(si) }; + PROCESS_INFORMATION pi; + BOOL b = CreateProcessA( + NULL, + szTaskkill, + NULL, + NULL, + TRUE, + CREATE_UNICODE_ENVIRONMENT, + NULL, + NULL, + &si, + &pi + ); + WaitForSingleObject(pi.hProcess, INFINITE); + Sleep(1000); + if (!strcmp(szPath, "Win11RestoreRoundedCorners.exe")) + { + DeleteFileA(szModifiedDWM); + } + printf("Operation successful.\n"); + return 0; +} \ No newline at end of file diff --git a/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj new file mode 100644 index 0000000..21596da --- /dev/null +++ b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {c4a6832a-9ae5-4aa5-a424-15cf8179f318} + Win11DisableRoundedCorners + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) + MultiThreadedDebug + + + Console + true + RequireAdministrator + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) + MultiThreaded + + + Console + true + true + true + RequireAdministrator + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) + MultiThreadedDebug + + + Console + true + RequireAdministrator + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) + MultiThreaded + + + Console + true + true + true + RequireAdministrator + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj.filters b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj.filters new file mode 100644 index 0000000..73cdd0e --- /dev/null +++ b/Win11DisableRoundedCorners/Win11DisableRoundedCorners.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/Win11DisableRoundedCorners/resource.h b/Win11DisableRoundedCorners/resource.h new file mode 100644 index 0000000..8ad984b --- /dev/null +++ b/Win11DisableRoundedCorners/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Resource.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/libs/libvalinet b/libs/libvalinet new file mode 160000 index 0000000..9910d17 --- /dev/null +++ b/libs/libvalinet @@ -0,0 +1 @@ +Subproject commit 9910d179c29ca443c3ae411c8243e4bd4d2ae424