Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable blue highlight in context menus #18

Closed
valinet opened this issue Sep 6, 2021 · 12 comments
Closed

Disable blue highlight in context menus #18

valinet opened this issue Sep 6, 2021 · 12 comments
Labels

Comments

@valinet
Copy link
Owner

valinet commented Sep 6, 2021

As you probably know already, newer builds (including 22000.176 and 22449.1000) do not introduce many changes, if any, regarding the system theme, except another work-in-progress feature that it's said to look better but in reality does not necessarily do so: the blue highlight in the context menus:
image
Personally, I prefer the old gray highlight which also filled better the containing rectangle. This is all dictated by the theme that's currently in use. Not much can be done from inside the applications that we hook, as those usually call things like DrawThemeBackground from uxtheme which supply them with the required data from the theme file/draw some stuff acording to the theme file. Even the custom skinned menus Explorer uses (Win+X, every context menu on the taskbar) still use the blue highlight although there is a bit better represented, as shown above.

Anyway, for people that want to revert to the old gray highlight, I recommend using the theme file from previous Windows 11 builds (22000.51, for example). You could also edit the current theme file, but then of course, as you probably know, the digital signature of the file becomes invalid and Windows will refuse to load the theme file unless a uxtheme patcher is used. But the signature is not invalidated when you use a signed file, but from a previous OS version. I prefer this method since I do not use custom themes, I do not want to patch the theme service etc. I basically want the proper stock theme.

  1. To get the required file, download the core Windows Update file for build 22000.51 from Microsoft using a helper like UUP dump: https://uupdump.net/getfile.php?id=bfe6f0bd-fb83-442f-b225-7ad7a61b48f3&file=core_en-us.esd
  2. After that, open the file using 7-Zip or any other archive tool, and navigate to 2\Windows\resources\Themes\aero\. In there you will find the required aero.msstyles theme, grab that.
  3. On the system that you want to modify, go to C:\Windows\Resources\Themes\aero. In there, take ownership of the file, rename it to something like aero_original.msstyles and paste in the new aero.msstyles file.

Reboot and you should be good to go!
image

@valinet valinet closed this as completed Sep 6, 2021
@ErickWei
Copy link

ErickWei commented Sep 6, 2021

Not enough height is the reason of bule background looked so ugly.
Is there a way to change bule background height ( or maybe padding or margin)?

@valinet
Copy link
Owner Author

valinet commented Sep 6, 2021

I don’t know, maybe take a look on the theme file, aero.msstyles, tinker a bit with it and see what you get. Don’t forget to disable theme signing! Good luck!

@rxboy1983
Copy link

ErickWei,
Something can be changed in this menu, for example:

Change color of background for menu:
App MsstyleEditor > open your file .msstyles > ImmersiveStart::Menu > POPUPBACKGROUND > FILLCOLOR - here change color
App MsstyleEditor > open your file .msstyles > ImmersiveStartDark::Menu > POPUPBACKGROUND > FILLCOLOR - here change color

Change color of texts in menu:
App MsstyleEditor > open your file .msstyles > ImmersiveStart::Menu > POPUPITEM - here edit TEXTCOLOR
App MsstyleEditor > open your file .msstyles > ImmersiveStartDark::Menu > POPUPITEM > Common - here add Color/TEXTCOLOR

To change size of highlight, you need to replace a PNG file. I am 99% sure that this PNG file is not in MSSTYLES file.

@valinet
Copy link
Owner Author

valinet commented Oct 25, 2021

Also, do not forget to disable theme signing if you change the theme file.

@rxboy1983
Copy link

Also, do not forget to disable theme signing if you change the theme file.

I installed UXThemePatcher for use custom theme. How to signing/disable signing custom theme? What exactly is theme signing?
This answer might help me because I'm using browser Firefox and it doesn't work good with custom theme.

@valinet
Copy link
Owner Author

valinet commented Oct 25, 2021

UXThemePatcher

That. Why have you installed that? Why install stuff without reading about its purpose in the first place? It's not good computing practice at all.

The themes service (provided by uxtheme) only loads digitally signed theme files. If you edit the files or use custom themes, those do not have a Microsoft digital signature, so the theme service refuses to load them. Thus, you need a "uxtheme patcher", which is a program that patches the themes service to allow loading of 3rd party unsigned themes. Simple. That's why you need "UXThemePatcher" or something like that. That's what I mean by disabling theme signing - none of what you described works in practice unless you patch uxtheme to disable the signature checks. My original guide up top works because you replace the theme indeed, but you do so with a theme that's signed by Microsoft, since it comes from en earlier Windows version, so the themes service loads it just fine.

@rxboy1983
Copy link

The signed themes are just those named exactly "aero.msstyles" or "aerolite.msstyles"?

I copied the original aero.msstyles file and named the copy - "aerom.msstyles". Both files have identical content, but the copy is not signed because it just has a different name?

@valinet
Copy link
Owner Author

valinet commented Oct 25, 2021

No. The signature has nothing to do with the file name. A renamed file is still signed.

If you experience different behavior between the 2 files, it's something else at play which is not obvious at all: dwm (the desktop window manager, the program that composes the desktop image) has different code paths and behaviors depending on whether the theme file is specifically called aero.msstyles or not. I know, it's stupid, but that is how it is. If you rename the original aero.msstyles to something_else.msstyles and apply that, the theme service loads it just fine, as it is still signed, but dwm.exe then sees it is not called aero.msstyles and enables some different behavior, one of which being that it always shows color on the title bars of windows; or at least that's how it was in Windows 10, I don't know if that is still the case in Windows 11, but that's the idea; as stupid as it looks, the file name also matters for dwm.exe to behave a certain way.

@rxboy1983
Copy link

I have no problems using custom theme on Windows 11. Everything works fine and as it should. Only Firefox has a problem when using is custom theme. :P

@feeas
Copy link

feeas commented Oct 27, 2021

StartAllBack has an option called "colorize everything with accent color", you can change the color without modifying the system file. Use IDA to open StartAllBackX64.dll, the following pseudo code may be related to "colorize everything with accent color".

void __fastcall sub_18002B398(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work)
{
  unsigned int v3; // ebx
  int v4; // edi
  int i; // ecx
  int v6; // edi
  int j; // ecx
  int k; // edi
  int m; // edi
  int n; // edi
  int ii; // edi
  int jj; // edi
  int kk; // edi
  int mm; // edi
  int v15; // edi
  int nn; // er9
  int i1; // edi
  int v18; // er9
  int v19; // esi
  int i2; // edi
  COLORREF v21; // edi
  __int64 v22; // rax
  __int64 v23; // rax
  __int64 v24; // rdi
  COLORREF aRgbValues[4]; // [rsp+20h] [rbp-50h] BYREF
  int nIndex[4]; // [rsp+30h] [rbp-40h] BYREF
  char v27[16]; // [rsp+40h] [rbp-30h] BYREF
  int v28; // [rsp+50h] [rbp-20h] BYREF
  __int64 v29; // [rsp+58h] [rbp-18h]
  __int64 v30; // [rsp+60h] [rbp-10h]
  __int64 v31; // [rsp+B8h] [rbp+48h] BYREF

  v3 = 0;
  if ( !(unsigned int)sub_180020F7C(0i64, Context, Work) )
  {
    GetTickCount();
    v29 = 0i64;
    v28 = 1;
    v30 = 1i64;
    GdiplusStartup(&v31, &v28, v27);
    sub_180029D40();
    sub_180029F34();
    v4 = 3;
    for ( i = 3; (unsigned __int8)sub_18002A0F8(i); i = v4 )
      ++v4;
    v6 = 3;
    for ( j = 3; (unsigned __int8)sub_18002A65C(j); j = v6 )
      ++v6;
    sub_180029CC0(L"Button", 1, 0, 2);
    sub_180029CC0(L"Combobox", 1, 0, 2);
    sub_180029CC0(L"Combobox", 4, 0, 2);
    sub_180029CC0(L"Combobox", 5, 0, 2);
    sub_180029CC0(L"Combobox", 6, 0, 2);
    sub_180029CC0(L"Combobox", 7, 0, 2);
    for ( k = 1; k <= 5; ++k )
      sub_180029CC0(L"Listbox", k, 0, 2);
    for ( m = 1; m <= 4; ++m )
      sub_180029CC0(L"Toolbar", m, 0, 2);
    for ( n = 1; n <= 4; ++n )
      sub_180029CC0(L"BB::Toolbar", n, 0, 2);
    for ( ii = 2; ii <= 6; ++ii )
      sub_180029CC0(L"Explorer::TreeView", 1, ii, 2);
    for ( jj = 2; jj <= 6; ++jj )
      sub_180029CC0(L"Explorer::ListView", 1, jj, 2);
    for ( kk = 1; kk <= 16; ++kk )
      sub_180029CC0(L"ItemsView::ListView", 6, kk, 2);
    sub_180029CC0(L"Header", 1, 0, 2);
    sub_180029CC0(L"ItemsView::Header", 1, 0, 2);
    sub_180029CC0(L"ItemsView", 3, 1, 2);
    sub_180029CC0(L"ItemsView", 3, 2, 2);
    sub_180029CC0(L"BreadcrumbBar", 1, 0, 2);
    sub_180029CC0(L"PreviewPane", 1, 1, 2);
    sub_180029CC0(L"CommandModule", 1, 0, 2);
    for ( mm = 3; mm <= 5; ++mm )
      sub_180029CC0(L"CommandModule", mm, 0, 2);
    v15 = 3;
    for ( nn = 3; (unsigned __int8)sub_180029CC0(L"SearchBox", 2, 0, nn); nn = v15 )
      ++v15;
    for ( i1 = 3; i1 <= 8; ++i1 )
    {
      sub_180029CC0(L"Trackbar", i1, 0, 2);
      v18 = 3;
      v19 = 3;
      while ( (unsigned __int8)sub_180029CC0(L"Trackbar", i1, 0, v18) )
        v18 = ++v19;
    }
    for ( i2 = 1; i2 <= 4; ++i2 )
      sub_180029CC0(L"Spin", i2, 0, 2);
    *(__m128i *)nIndex = _mm_load_si128((const __m128i *)&xmmword_18006AA50);
    aRgbValues[0] = 16382457;
    v21 = 13924352;
    if ( (unsigned __int8)sub_18002B340(0i64) )
      v22 = sub_180020E84(4i64) & 0xFFFFFF;
    else
      LODWORD(v22) = 13924352;
    aRgbValues[1] = v22;
    if ( (unsigned __int8)sub_18002B340(0i64) )
      v23 = sub_180020E84(5i64) & 0xFFFFFF;
    else
      LODWORD(v23) = 12609280;
    aRgbValues[2] = v23;
    if ( (unsigned __int8)sub_18002B340(0i64) )
      v21 = sub_180020E84(4i64) & 0xFFFFFF;
    aRgbValues[3] = v21;
    v24 = 0i64;
    while ( GetSysColor(nIndex[v24]) == aRgbValues[v24] )
    {
      ++v3;
      ++v24;
      if ( v3 >= 4 )
        goto LABEL_45;
    }
    SetSysColors(4, nIndex, aRgbValues);
LABEL_45:
    GetTickCount();
    GdiplusShutdown(v31);
  }
}
__int64 __fastcall sub_180029CC0(LPCWSTR pszClassList, int iPartId, int iStateId, int iPropId)
{
  HTHEME v7; // rbx
  HBITMAP hbm; // [rsp+30h] [rbp-18h] BYREF

  hbm = 0i64;
  v7 = OpenThemeData(hwnd, pszClassList);
  GetThemeBitmap(v7, iPartId, iStateId, iPropId, 1u, &hbm);
  CloseThemeData(v7);
  return sub_180029A84(hbm);
}
char __fastcall sub_180029A84(HBITMAP hbm)
{
  char v2; // di
  void *v3; // rbx
  HDC CompatibleDC; // rsi
  void *v6; // rdi
  HDC v7; // rbx
  unsigned int v8; // eax
  __int128 pv; // [rsp+50h] [rbp-29h] BYREF
  __int128 v10; // [rsp+60h] [rbp-19h]
  WCHAR ValueName[48]; // [rsp+70h] [rbp-9h] BYREF
  DWORD cbData; // [rsp+E0h] [rbp+67h] BYREF
  HKEY hKey; // [rsp+E8h] [rbp+6Fh] BYREF
  void *pvBits; // [rsp+F0h] [rbp+77h] BYREF

  pv = 0i64;
  v10 = 0i64;
  GetObjectW(hbm, 32, &pv);
  if ( !hbm || WORD1(v10) != 32 )
    return 0;
  v2 = 0;
  sub_18002B868(ValueName, L"%p", hbm);
  RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\StartIsBack\\Recolor", 0, 0i64, 1u, 0xF003Fu, 0i64, &hKey, 0i64);
  cbData = 4 * DWORD1(pv) * DWORD2(pv);
  v3 = malloc(cbData);
  if ( v3 )
  {
    if ( RegQueryValueExW(hKey, ValueName, 0i64, 0i64, (LPBYTE)v3, &cbData) )
    {
      if ( (unsigned __int8)sub_18002B340(0i64) )
      {
        GetBitmapBits(hbm, cbData, v3);
        RegSetValueExW(hKey, ValueName, 0, 3u, (const BYTE *)v3, cbData);
      }
    }
    else
    {
      v2 = 1;
      SetBitmapBits(hbm, cbData, v3);
      if ( !(unsigned __int8)sub_18002B340(0i64) )
        RegDeleteValueW(hKey, ValueName);
    }
    free(v3);
  }
  RegCloseKey(hKey);
  if ( !(unsigned __int8)sub_18002B340(0i64) )
    return v2;
  CompatibleDC = CreateCompatibleDC(0i64);
  v6 = (void *)sub_1800556C0(DWORD1(pv), (unsigned int)-DWORD2(pv), &pvBits);
  SelectObject(CompatibleDC, v6);
  v7 = CreateCompatibleDC(0i64);
  SelectObject(v7, hbm);
  BitBlt(CompatibleDC, 0, 0, SDWORD1(pv), SDWORD2(pv), v7, 0, 0, 0xCC0020u);
  DeleteDC(v7);
  v8 = sub_180020E84(4i64);
  sub_180029784(v6, v8);
  SetBitmapBits(hbm, 4 * DWORD1(pv) * DWORD2(pv), pvBits);
  DeleteDC(CompatibleDC);
  DeleteObject(v6);
  return 1;
}

2021 10 27_10 11 54

Is it possible to add this feature to ExplorerPatcher?

@krlvm
Copy link

krlvm commented Nov 2, 2021

I'd like to have an ability to use accent color everywhere.

Unfortunately, the simple way to do this using SetSysColors works only with hyperlinks, selected text, explorer selection rectangle and some of list items. There's an open-source app for that: AccentApplicator.

To colorize the rest of Win32 UI, StartAllBack uses uxtheme API to get handle of UI controls bitmap and uses a complicated algorithm to replace the blue color (and its shades) with accent color.

I've made a working prototype that replaces the original bitmaps with colored ones, but it is worthless unless needs some changes are made to get the blue replacement to work correctly.

Implementing this functionality can also allow to replace the blue highlight with light gray without replacing .msstyles file.

This means that ExplorerPatcher (although it would be better to separate this into a separate project), could have this functionality after combining these two approaches, in the end, having received what StartAllBack provides. I don't have a lot of Win32 API knowledge, but I can share the prototype if it may be useful for @valinet.

EDIT: As I promised, here's a quick and dirty implementation of accent colorization feature based on replacing already-known color palette, it is primarily tested on Windows 10 and needs some work to get a more convenient lighter color based on accent color (plus, some elements need R=0 and A<255 to display correctly).

@valinet
Copy link
Owner Author

valinet commented Nov 2, 2021

Hi

I have looked on the disassembly of SAB before as well, basically what @nullnullnullnull0 posted above and some more even. Indeed, it's a combination of simply hooking the classic GetSysColors/SetSysColors and some custom stuff for the bitmaps, something like this maybe: #199 for the context menu color.

Idk, I mean, sure, this should be built-in, that would be indeed professional, but it's Windows, after all, I just have other things to work on and things being blue do not bother me that much. Also, as you have discovered, it's not that easy and getting to a useful implementation regarding this takes some work, indeed. I don't have much extra time anyway, so personally, I won't be taking on implementing this. Of course, if you want to work on it, and maybe even one day contribute it to EP so it can be offered as functionality and a reference implementation for how such a thing should be done, I'd be more than happy to receive such a contribution, sure. But regarding me, personally, I won't take on this endevour any time soon, especially since I also do not use this feature. As I said, it's nice, but not something vital, like taskbar label buttons :D

As well, if you want to, I encourage you to share any implementation that you have, maybe other people find it useful and something gets put together. You know, I am a single person as well, no matter how skilled one is, a day still has 24 hours of which you barely get a few, if any, to work on various stuff, so despite all my goodwill, enthusiasm and work I put, I can only do so much, so of course outside contributions are always welcome.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants