fix MinGW build issues

This commit is contained in:
Mohmed abdel-fattah 2024-06-26 12:50:04 +03:00
parent 814c4df261
commit dba0b8c659
11 changed files with 244 additions and 73 deletions

View file

@ -19,7 +19,7 @@ TARGET := $(word 1,$(subst -, ,$(TUPLE)))
DEF_SUFFIX := $(if $(TARGET:x86_64=),.def,.def64)
.PHONY: all
all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib
all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib uxtheme-delaylib.lib
%.def64: %.def
$(AM_V_SED) "s/@.*//" $< >$@

View file

@ -367,7 +367,7 @@ uninstall-am:
.PHONY: all
all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib
all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib uxtheme-delaylib.lib
%.def64: %.def
$(AM_V_SED) "s/@.*//" $< >$@

View file

@ -1,2 +1,3 @@
EXPORTS
DwmGetWindowAttribute@16
DwmSetWindowAttribute@16

79
.mingw/uxtheme.def Normal file
View file

@ -0,0 +1,79 @@
;
; Definition file of UxTheme.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "UxTheme.dll"
EXPORTS
BeginPanningFeedback@4
EndPanningFeedback@8
UpdatePanningFeedback@16
BeginBufferedAnimation@32
BeginBufferedPaint@20
BufferedPaintClear@8
BufferedPaintInit@0
BufferedPaintRenderAnimation@8
BufferedPaintSetAlpha@12
DrawThemeBackgroundEx@24
BufferedPaintStopAllAnimations@4
BufferedPaintUnInit@0
CloseThemeData@4
DrawThemeBackground@24
DrawThemeEdge@32
DrawThemeIcon@28
DrawThemeParentBackground@12
DrawThemeParentBackgroundEx@16
DrawThemeText@36
OpenThemeDataEx@12
DrawThemeTextEx@36
EnableThemeDialogTexture@8
EnableTheming@4
EndBufferedAnimation@8
EndBufferedPaint@8
GetBufferedPaintBits@12
GetBufferedPaintDC@4
GetBufferedPaintTargetDC@4
GetBufferedPaintTargetRect@8
GetCurrentThemeName@24
GetThemeAppProperties@0
GetThemeBackgroundContentRect@24
GetThemeBackgroundExtent@24
GetThemeBackgroundRegion@24
GetThemeBitmap@24
GetThemeBool@20
GetThemeColor@20
GetThemeDocumentationProperty@16
GetThemeEnumValue@20
GetThemeFilename@24
GetThemeFont@24
GetThemeInt@20
GetThemeIntList@20
GetThemeMargins@28
GetThemeMetric@24
GetThemePartSize@28
GetThemePosition@20
GetThemePropertyOrigin@20
GetThemeRect@20
GetThemeStream@28
GetThemeString@24
GetThemeSysBool@8
GetThemeSysColor@8
GetThemeSysColorBrush@8
GetThemeSysFont@12
GetThemeSysInt@12
GetThemeSysSize@8
GetThemeSysString@16
GetThemeTextExtent@36
GetThemeTextMetrics@20
GetThemeTransitionDuration@24
GetWindowTheme@4
HitTestThemeBackground@40
IsAppThemed@0
IsCompositionActive@0
IsThemeActive@0
IsThemeBackgroundPartiallyTransparent@12
IsThemeDialogTextureEnabled@4
IsThemePartDefined@12
OpenThemeData@8
SetThemeAppProperties@4
SetWindowTheme@12

View file

@ -133,12 +133,12 @@
<AdditionalOptions>/utf-8 $(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -162,12 +162,12 @@
<AdditionalOptions>/utf-8 $(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\arm</AdditionalLibraryDirectories>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -193,12 +193,12 @@
<AdditionalOptions>/utf-8 $(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\arm64</AdditionalLibraryDirectories>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -229,12 +229,12 @@
<AdditionalOptions>/utf-8 $(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -260,13 +260,13 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -292,13 +292,13 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\arm</AdditionalLibraryDirectories>
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -326,13 +326,13 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\arm64</AdditionalLibraryDirectories>
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -363,13 +363,13 @@
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies)</AdditionalDependencies>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalOptions>/BREPRO %(AdditionalOptions)</AdditionalOptions>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<DelayLoadDLLs>advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View file

@ -280,7 +280,7 @@ NONVULNERABLE_LIBS = -lsetupapi -lole32 -lgdi32 -lshlwapi -lcrypt32 -lcomctl32 -
# Ideally there would also be virtdisk and wininet as delaylib's below, but the MinGW folks haven't quite sorted out delay-loading
# for x86_32 so as soon as you try to call APIs from these, the application will crash!
# See https://github.com/pbatard/rufus/issues/1877#issuecomment-1109683039 as well as https://github.com/pbatard/rufus/issues/2272
VULNERABLE_LIBS = -ldwmapi-delaylib -lversion-delaylib -lwintrust-delaylib
VULNERABLE_LIBS = -ldwmapi-delaylib -lversion-delaylib -lwintrust-delaylib -luxtheme-delaylib
AM_V_WINDRES_0 = @echo " RC $@";$(WINDRES)
AM_V_WINDRES_1 = $(WINDRES)
AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY))

View file

@ -26,10 +26,17 @@
#ifdef __cplusplus
extern "C" {
#endif
// disable all warnings until fix theme
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#define REGKEY_HKCU HKEY_CURRENT_USER
#define REGKEY_HKLM HKEY_LOCAL_MACHINE
/* Delete a registry key from <key_root>\Software and all its values
If the key has subkeys, this call will fail. */
static __inline BOOL DeleteRegistryKey(HKEY key_root, const char* key_name)

View file

@ -59,8 +59,9 @@
#include "../res/grub2/grub2_version.h"
#include<dwmapi.h>
#include <Richedit.h>
#pragma comment(lib,"UxTheme.lib")
#pragma comment(lib,"DwmApi.lib")
#include <uxtheme.h>
enum bootcheck_return {
BOOTCHECK_PROCEED = 0,
BOOTCHECK_CANCEL = -1,
@ -106,7 +107,7 @@ extern const char* old_c32_name[NB_OLD_C32];
extern const char* cert_name[3];
extern const char* FileSystemLabel[FS_MAX];
extern const char *bootmgr_efi_name, *efi_dirname, *efi_bootname[ARCH_MAX];
static UINT_PTR uIdSubclass = 1;
/*
* Globals
*/
@ -154,8 +155,7 @@ RUFUS_DRIVE rufus_drive[MAX_DRIVES] = { 0 };
// This function sets the alpha channel to 255 without
// affecting any of the color channels.
void MakeBitmapOpaque(
HDC hdc, int x, int y, int cx, int cy)
void MakeBitmapOpaque( HDC hdc, int x, int y, int cx, int cy)
{
BITMAPINFO bi = {0};
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@ -164,12 +164,8 @@ void MakeBitmapOpaque(
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;
RGBQUAD bitmapBits = { 0x00, 0x00, 0x00, 0xFF };
StretchDIBits(hdc, x, y, cx, cy,
0, 0, 1, 1, &bitmapBits, &bi,
DIB_RGB_COLORS, SRCPAINT);
StretchDIBits(hdc, x, y, cx, cy, 0, 0, 1, 1, &bitmapBits, &bi,DIB_RGB_COLORS, SRCPAINT);
}
// TODO: Remember to update copyright year in stdlg's AboutCallback() WM_INITDIALOG,
@ -963,10 +959,9 @@ out:
* DarkMode CheckBox Subclass Proc
*/
static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData)
{
if (!IsAppsUseDarkMode)
if (!IsAppsUseDarkMode())
{
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
@ -993,15 +988,15 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
rc1.left += siz.cx + 2;
FillRect(hDc, &rc1, CreateSolidBrush(ColorControlDark));
rc1.top += GetSystemMetrics(SM_CXPADDEDBORDER);
LPCWSTR* staticText[99] = {0};
GetWindowText(hWnd, staticText, ARRAYSIZE(staticText));
WCHAR szCaption[60];
GetWindowText(hWnd, szCaption, ARRAYSIZE(szCaption));
DTTOPTS opts;
opts.dwSize = sizeof(DTTOPTS);
opts.dwFlags = DTT_TEXTCOLOR;
opts.crText = RGB(255, 255, 255);
HFONT font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
SelectObject(hDc, font);
DrawThemeTextEx(btnTheme, hDc, 3, 0, &staticText, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts);
DrawThemeTextEx(btnTheme, hDc, 3, 0, szCaption, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts);
ReleaseDC(hWnd, hDc);
return true;
}
@ -1013,10 +1008,10 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
*/
static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
{
const char* str[255] = {0};
GetClassName(hWnd, &str, 255);
WCHAR str[20] = {0};
GetClassName(hWnd, str, 20);
bool isDarkmode = IsAppsUseDarkMode();
if (strcmp(str, L"Button") == 0)
if (_wcsicmp(str, L"Button") == 0)
{
LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
@ -1033,20 +1028,20 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
else
SetWindowTheme(hWnd, isDarkmode ? L"DarkMode_Explorer" : L"Explorer", NULL);
}
else if (strcmp(str, L"ComboBox") == 0)
else if (_wcsicmp(str, L"ComboBox") == 0)
{
SetWindowTheme(hWnd, isDarkmode ? L"DarkMode_CFD" : L"Explorer", NULL);
}
else if (strcmp(str, L"ToolBar") == 0)
else if (_wcsicmp(str, L"ToolbarWindow32") == 0)
{
wchar_t toolbarText[50];
wchar_t multiToolbarText[50] ;
utf8_to_wchar_no_alloc(lmprintf(MSG_315), multiToolbarText, ARRAYSIZE(multiToolbarText));
GetWindowText(hWnd, &toolbarText, 16);
if (strcmp(toolbarText, multiToolbarText) != 0)
if (_wcsicmp(toolbarText, multiToolbarText) != 0)
SetWindowTheme(hWnd, isDarkmode ? L"DarkMode" : L"Explorer", NULL);
}
else if (strcmp(str, L"EDIT") == 0)
else if (_wcsicmp(str, L"EDIT") == 0)
{
LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE);
if (((style & WS_VSCROLL) == WS_VSCROLL) || ((style & WS_HSCROLL) == WS_HSCROLL))
@ -1065,11 +1060,9 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
* DarkMod Dialog Subclass Proc
*/
static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData)
{
RECT rcDlg;
GetClientRect(hDlg, &rcDlg);
HDC dc;
switch (message)
{
@ -1088,16 +1081,17 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
int borderWidth = (rcWinWidth - rcrcClientWidth) / 2;
int captionHight = rcWinHieght - rcrcClientHieght - borderWidth;
OffsetRect(&rcWin, -rcWin.left, -rcWin.top);
OffsetRect(&rcClient, borderWidth, captionHight);
HRGN updateRgn = wParam != 1 ?(HRGN)wParam : CreateRectRgnIndirect(&rcWin);
OffsetRect(&rcClient, -rcWin.left, -rcWin.top);
HRGN copy =CreateRectRgn(0, 0, 0, 0);
HRGN updateRgn = wParam != 1 ? copy : CreateRectRgnIndirect(&rcWin);
HRGN clipRgn = CreateRectRgn(0, 0, 0, 0);
HRGN ncRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(copy, copy, (HRGN)wParam, RGN_COPY);
if (wParam == 1)
clipRgn = CreateRectRgnIndirect(&rcClient);
else
GetClipRgn(windowDC, clipRgn);
CombineRgn(ncRgn, updateRgn, clipRgn, RGN_DIFF);
CombineRgn(ncRgn, updateRgn, clipRgn, RGN_OR);
SelectClipRgn(windowDC, ncRgn);
FillRect(windowDC, &rcWin, CreateSolidBrush(RGB(63, 63, 63)));
HRGN hRgn= CreateRectRgnIndirect(&rcWin);
@ -1177,8 +1171,6 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
return (INT_PTR)CreateSolidBrush(ColorControlDark);
case WM_CTLCOLORSTATIC:
dc = GetDC((HWND)lParam);
RECT rcDlg;
GetClientRect((HWND)lParam, &rcDlg);
safe_release_dc((HWND)lParam, dc);
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LABEL))
{

View file

@ -44,6 +44,7 @@
#include "settings.h"
#include "license.h"
#include <Uxtheme.h>
#include <dwmapi.h>
/* Globals */
extern BOOL is_x86_64, appstore_version;
@ -61,6 +62,7 @@ static const char* notification_dont_display_setting;
static WNDPROC update_original_proc = NULL;
static HWINEVENTHOOK ap_weh = NULL;
static char title_str[2][128], button_str[128];
static UINT_PTR uIdSubclass = 1;
HWND hFidoDlg = NULL;
static int update_settings_reposition_ids[] = {
@ -76,6 +78,8 @@ static int update_settings_reposition_ids[] = {
IDCANCEL,
};
/*
* https://blogs.msdn.microsoft.com/oldnewthing/20040802-00/?p=38283/
*/
@ -88,10 +92,9 @@ void SetDialogFocus(HWND hDlg, HWND hCtrl)
* DarkMode CheckBox Subclass Proc
*/
static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData)
{
if (!IsAppsUseDarkMode)
if (!IsAppsUseDarkMode())
{
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
@ -118,15 +121,15 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
rc1.left += siz.cx + 2;
FillRect(hDc, &rc1, CreateSolidBrush(ColorControlDark));
rc1.top += GetSystemMetrics(SM_CXPADDEDBORDER);
LPCWSTR* staticText[99] = {0};
GetWindowText(hWnd, staticText, ARRAYSIZE(staticText));
WCHAR szCaption[60];
GetWindowText(hWnd, szCaption, ARRAYSIZE(szCaption));
DTTOPTS opts;
opts.dwSize = sizeof(DTTOPTS);
opts.dwFlags = DTT_TEXTCOLOR;
opts.crText = RGB(255, 255, 255);
HFONT font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
SelectObject(hDc, font);
DrawThemeTextEx(btnTheme, hDc, 3, 0, &staticText, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts);
DrawThemeTextEx(btnTheme, hDc, 3, 0, szCaption, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts);
ReleaseDC(hWnd, hDc);
return TRUE;
}
@ -140,11 +143,11 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,
static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
{
char* str[255];
GetClassName(hWnd, &str, 255);
WCHAR str[30] = { 0 };
GetClassName(hWnd, str, ARRAYSIZE(str));
BOOL isDarkMode = IsAppsUseDarkMode();
if (strcmp(str, L"Button") == 0)
if (_wcsicmp(str, L"Button") == 0)
{
LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
@ -161,18 +164,18 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
else
SetWindowTheme(hWnd, isDarkMode ? L"DarkMode_Explorer" : L"Explorer", NULL);
}
else if (strcmp(str, L"ComboBox") == 0)
else if (_wcsicmp(str, L"ComboBox") == 0)
{
SetWindowTheme(hWnd, isDarkMode ? L"DarkMode_CFD" : L"Explorer", NULL);
}
else if (strcmp(str, L"ToolBar") == 0)
else if (_wcsicmp(str, L"ToolBar") == 0)
{
char* title[16];
GetWindowText(hWnd, &title, 16);
if (strcmp(title, L"Multiple buttons") != 0)
WCHAR title[30] = {0};
GetWindowText(hWnd, title, ARRAYSIZE(title));
if (_wcsicmp(title, L"Multiple buttons") != 0)
SetWindowTheme(hWnd, isDarkMode ? L"DarkMode" : L"Explorer", NULL);
}
else if (strcmp(str, L"EDIT") == 0)
else if (_wcsicmp(str, L"EDIT") == 0)
{
LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE);
if(((style & WS_VSCROLL) == WS_VSCROLL) || ((style & WS_HSCROLL) == WS_HSCROLL))
@ -182,7 +185,7 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
}
else if (strcmp(str, L"RichEdit20W") == 0)
else if (_wcsicmp(str, L"RichEdit20W") == 0)
{
SendMessage(hWnd, EM_SETBKGNDCOLOR, 0, isDarkMode ? (LPARAM)ColorControlDark : (LPARAM)GetSysColor(COLOR_BTNFACE));
CHARFORMAT cf;
@ -204,8 +207,7 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam)
* DarkMod Dialog Subclass Proc
*/
static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData)
{
if (!IsAppsUseDarkMode())
{
@ -213,9 +215,94 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
}
switch (message)
{
case WM_NCPAINT:
{
LRESULT result = DefSubclassProc(hDlg, message, wParam, lParam);
HDC windowDC = GetWindowDC(hDlg);
RECT rcWin, rcClient;
GetWindowRect(hDlg, &rcWin);
GetClientRect(hDlg, &rcClient);
MapWindowPoints(hDlg, NULL, (LPPOINT)&rcWin, 2);
int rcWinWidth = rcWin.right - rcWin.left;
int rcWinHieght = rcWin.bottom - rcWin.top;
int rcrcClientWidth = rcClient.right - rcClient.left;
int rcrcClientHieght = rcClient.bottom - rcClient.top;
int borderWidth = (rcWinWidth - rcrcClientWidth) / 2;
int captionHight = rcWinHieght - rcrcClientHieght - borderWidth;
OffsetRect(&rcWin, -rcWin.left, -rcWin.top);
OffsetRect(&rcClient, -rcWin.left, -rcWin.top);
HRGN copy = CreateRectRgn(0, 0, 0, 0);
HRGN updateRgn = wParam != 1 ? copy : CreateRectRgnIndirect(&rcWin);
HRGN clipRgn = CreateRectRgn(0, 0, 0, 0);
HRGN ncRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(copy, copy, (HRGN)wParam, RGN_COPY);
if (wParam == 1)
clipRgn = CreateRectRgnIndirect(&rcClient);
else
GetClipRgn(windowDC, clipRgn);
CombineRgn(ncRgn, updateRgn, clipRgn, RGN_OR);
SelectClipRgn(windowDC, ncRgn);
FillRect(windowDC, &rcWin, CreateSolidBrush(RGB(63, 63, 63)));
HRGN hRgn = CreateRectRgnIndirect(&rcWin);
SelectClipRgn(windowDC, hRgn);
MakeBitmapOpaque(windowDC, 0, 0, rcWinWidth, rcWinHieght);
safe_release_dc(hDlg, windowDC);
return result;
}
case WM_NCCALCSIZE:
{
//TODO: get real caption Size
if (wParam)
{
NCCALCSIZE_PARAMS* ncParma = (NCCALCSIZE_PARAMS*)(lParam);
ncParma->rgrc[0].left += 1;//pr++;
ncParma->rgrc[0].top += 31;
ncParma->rgrc[0].right -= 1;
ncParma->rgrc[0].bottom -= 1;
return 0;
}
else
{
RECT* rect = (RECT*)lParam;
rect->top += 31;
rect->left += 1;
rect->right -= 1;
rect->bottom -= 1;
return 0;
}
}
case WM_SHOWWINDOW:
EnumChildWindows(hDlg, ThemeCallback, lParam);
return DefWindowProc(hDlg, message, wParam, lParam);
{
if (wParam)
{
EnumChildWindows(hDlg, ThemeCallback, lParam);
BOOL allowncpaint = TRUE;
COLORREF caption = RGB(0x0, 0x0, 0x0);
DwmSetWindowAttribute(hDlg, DWMWA_CAPTION_COLOR, &caption, sizeof caption);
DwmSetWindowAttribute(hDlg, DWMWA_BORDER_COLOR, &caption, sizeof caption);
DwmSetWindowAttribute(hDlg, DWMWA_ALLOW_NCPAINT, &allowncpaint, sizeof(int));
RECT rcDlg;
GetWindowRect(hDlg, &rcDlg);
SetWindowPos(hDlg, 0, 0, 0, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE);
if (hLog)
{
RECT rcLog;
GetWindowRect(hLog, &rcLog);
GetClientRect(hDlg, &rcDlg);
rcLog.left = rcDlg.left + 1;
rcLog.right = rcDlg.right - 1;
SetWindowPos(hLog, NULL, 0, 0, rcLog.right - rcLog.left, rcLog.bottom - rcLog.top, SWP_NOMOVE | SWP_NOZORDER);
}
RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW);
}
return DefSubclassProc(hDlg, message, wParam, lParam);
}
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC)wParam, RGB(25, 25, 25));
SetTextColor((HDC)wParam, RGB(255, 255, 255));
@ -228,6 +315,7 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam,
return (INT_PTR)CreateSolidBrush(RGB(25, 25, 25));
}
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
return (INT_PTR)CreateSolidBrush(ColorControlDark);

View file

@ -116,4 +116,4 @@ extern void ShowLanguageMenu(RECT rcExclude);
extern void SetPassesTooltip(void);
extern void SetBootTypeDropdownWidth(void);
extern void OnPaint(HDC hdc);
static UINT_PTR uIdSubclass = 1;
extern void MakeBitmapOpaque(HDC hdc, int x, int y, int cx, int cy);

View file

@ -20,6 +20,10 @@
#include <windows.h>
#include "resource.h"
// disable all warnings about unused variable
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#pragma once
// GUIDs needed to set a control's accessibility props