From d500bdff964dd2be328ea9d1d4d1d143b0f7e97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 24 Nov 2022 17:38:40 +0800 Subject: [PATCH] WmTheme: convert known color values to readable strings --- src/detection/wmtheme/wmtheme_windows.c | 66 ++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/detection/wmtheme/wmtheme_windows.c b/src/detection/wmtheme/wmtheme_windows.c index 4713d7c92..e19e9bcbc 100644 --- a/src/detection/wmtheme/wmtheme_windows.c +++ b/src/detection/wmtheme/wmtheme_windows.c @@ -2,6 +2,62 @@ #include "wmtheme.h" #include "util/windows/register.h" +const char* colorHexToString(DWORD hex) +{ + switch(hex) + { + case 0x696cc3: return "Yellow gold"; + case 0xff8c00: return "Gold"; + case 0xf7630c: return "Orange bright"; + case 0xca5010: return "Orange dark"; + case 0xda3b01: return "Rust"; + case 0xef6950: return "Pale rust"; + case 0xd13438: return "Brick red"; + case 0xff4343: return "Mod red"; + case 0xe74856: return "Pale red"; + case 0xe81123: return "Red"; + case 0xea005e: return "Rose bright"; + case 0xc30052: return "Rose"; + case 0xe3008c: return "Plum light"; + case 0xbf0077: return "Plum"; + case 0xc239b3: return "Orchid light"; + case 0x9a0089: return "Orchid"; + case 0x0078d4: return "Blue"; + case 0x0063b1: return "Navy blue"; + case 0x8d8bd7: return "Purple shadow"; + case 0x6b69d6: return "Purple shadow dark"; + case 0x8764b8: return "Iris pastel"; + case 0x744da9: return "Iris Spring"; + case 0xb146c2: return "Violet red light"; + case 0x881798: return "Violet red"; + case 0x0099bc: return "Cool blue bright"; + case 0x2d7d9a: return "Cool blue"; + case 0x00b7c3: return "Seafoam"; + case 0x038387: return "Seafoam teal"; + case 0x00b294: return "Mint light"; + case 0x018574: return "Mint dark"; + case 0x00cc6a: return "Turf green"; + case 0x10893e: return "Sport green"; + case 0x7a7574: return "Gray"; + case 0x5d5a58: return "Gray brown"; + case 0x68768a: return "Steel blue"; + case 0x515c6b: return "Metal blue"; + case 0x567c73: return "Pale moss"; + case 0x486860: return "Moss"; + case 0x498205: return "Meadow green"; + case 0x107c10: return "Green"; + case 0x767676: return "Overcast"; + case 0x4c4a48: return "Storm"; + case 0x69797e: return "Blue gray"; + case 0x4a5459: return "Gray dark"; + case 0x647c64: return "Liddy green"; + case 0x4c574e: return "Sage"; + case 0x807143: return "Camouflage desert"; + case 0x766c59: return "Camouflage"; + default: return NULL; + } +} + bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) { FF_UNUSED(instance); @@ -10,7 +66,15 @@ bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) uint32_t bgrColor; DWORD bufSize = sizeof(bgrColor); if(RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", L"AccentColor", RRF_RT_REG_DWORD, NULL, &bgrColor, &bufSize) == ERROR_SUCCESS) - ffStrbufAppendF(themeOrError, "Accent Color - #%02X%02X%02X", bgrColor & 0xFF, (bgrColor >> 8) & 0xFF, (bgrColor >> 16) & 0xFF); + { + ffStrbufAppendS(themeOrError, "Accent Color - "); + DWORD rgbColor = ((bgrColor & 0xFF) << 16) | (bgrColor & 0xFF00) | ((bgrColor >> 16) & 0xFF); + const char* text = colorHexToString(rgbColor); + if(text) + ffStrbufAppendS(themeOrError, text); + else + ffStrbufAppendF(themeOrError, "#%06lX", rgbColor); + } } FF_HKEY_AUTO_DESTROY hKey = NULL;