waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 10:16:42 GMT -8
This mod removes the command bar, without the need of using any external tools such as Resource Hacker. After the mod is compiled and enabled, restart explorer.exe for the changes to show.
It's available in the Windhawk repo: link
|
|
|
Post by anixx on Apr 16, 2024 11:49:24 GMT -8
This is great! This is exactly what we waited for!
But would not it be better to edit the small place in the text rather than to replace the whole file?
Also, having the copy of the whole file in the mod may raise copyright issues.
|
|
|
Post by anixx on Apr 16, 2024 12:29:16 GMT -8
Does not work for me, by the way.
|
|
|
Post by anixx on Apr 16, 2024 12:33:42 GMT -8
I think, this function is never called when the resource is loaded from shellstyle.dll. Only from shell32.dll. So, this approach is a dead end.
You can see this from inserting Beep like this:
WCHAR *slash = wcsrchr(szPath, L'\\'); if (slash && 0 == wcsicmp(slash, L"\\shellstyle.dll") && uResId == 1) { Beep(500,500); szReplacement = UIFILE_1033; }
It never gets control.
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 12:36:46 GMT -8
I changed it according to your suggestion. As a drawback of this change, it now requires that shellstyle.dll is not patched, because if it is, the patch from the dll will take precedence, and renders my mod useless. This will require users will already patched shellstyle.dll to use sfc to revert it. I have also changed the offset from -32 to -40, because -32 wasn't enough for some crazy themes like Pumpkin. Parts of the command bar were still visibile. -40 seems to be enough, it produces the same look as on Win2000 when using Pumpkin theme. Maybe the new version will work for you. Use sfc, compile the new version, reboot. Are there any errors? Maybe add some Wh_Log calls there and there to see what portions of the code get called, and what are not.
The UIFILE from shellstyle.dll gets loaded only once, when you first boot up a file explorer window, after that it stays in memory. To reload it you need to kill explorer process and restart it.
The mod works for me just fine, I've used sfc on shellstyle.dll, reboot, and now it's my mod doing the work.
|
|
|
Post by anixx on Apr 16, 2024 12:54:24 GMT -8
The mod does not work for me.
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 13:22:23 GMT -8
The mod does not work for me. You're running 11 23H2, right? I only tested on 10 22H2, so I thought that maybe your problem is related to different win versions. But alas, it works for me on 11 23H2 too, when I tested it. You should add some Wh_Log debugging prints to see what's wrong. Or maybe the shellstyle.dll is different in your system locale, somehow?
|
|
|
Post by anixx on Apr 16, 2024 13:29:41 GMT -8
Wh_Log("%s", szPath);
this always logs C:\WINDOWS\System32\SHELL32.dll, never shellstyle.dll. I have already faced with this problem when tried to make a similar mod.
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 13:55:35 GMT -8
I don't understand whats the problem. The only possible explanation I have is that you have not restarted the explorer process (by taskkill or full reboot) after the mod has been enabled. Once the UIFILE from shellstyle was loaded in the explorer process, it will stay there as long as explorer.exe is running, and will not be requested again using the hooked function, disabling/enabling my mod or opening/closing file explorer windows has no effect on this. Only taskkill or full reboot.
Let's wait for input from others, does it work or not.
|
|
|
Post by anixx on Apr 16, 2024 14:00:21 GMT -8
I don't understand whats the problem. The only possible explanation I have is that you have not restarted the explorer process (by taskkill or full reboot) after the mod has been enabled. Once the UIFILE from shellstyle was loaded in the explorer process, it will stay there as long as explorer.exe is running, and will not be requested again using the hooked function, disabling/enabling my mod or opening/closing file explorer windows has no effect on this. Only taskkill or full reboot. Let's wait for input from others, does it work or not.
I both taskkilled the explorer and rebooted the computer. This hooked function is only called when loading resources from shell32.dll. Here is my own attempt at making this mod:
// ==WindhawkMod== // @id commandbar-remover // @name Remove command bar // @description Removes Command bar // @version 0.1 // @author anixx // @include explorer.exe // @architecture x86-64 // ==/WindhawkMod==
#include <windhawk_utils.h>
/*Load UIFILE*/
typedef HRESULT (* __cdecl DUI_LoadUIFileFromResources_t)(HINSTANCE, UINT, LPWSTR *); DUI_LoadUIFileFromResources_t DUI_LoadUIFileFromResources_orig; HRESULT __cdecl DUI_LoadUIFileFromResources_hook( HINSTANCE hInstance, UINT uResId, LPWSTR *pszOut ) { Beep(500,500); WCHAR szPath[MAX_PATH]; if (GetModuleFileNameW(hInstance, szPath, MAX_PATH)) { WCHAR *slash = wcsrchr(szPath, L'\\');
Wh_Log("%s", szPath); Wh_Log("%u", uResId);
// if (slash && 0 == wcsicmp(slash, L"\\shellstyle.dll")) Beep(500,500); } return DUI_LoadUIFileFromResources_orig( hInstance, uResId, pszOut ); }
BOOL Wh_ModInit(void) { HMODULE hShell32 = LoadLibraryW(L"shell32.dll"); if (!hShell32) { Wh_Log(L"Failed to load shell32.dll"); return FALSE; }
WindhawkUtils::SYMBOL_HOOK hooks[] = {
{ { L"long __cdecl DUI_LoadUIFileFromResources(struct HINSTANCE__ *,unsigned int,unsigned short * *)" }, &DUI_LoadUIFileFromResources_orig, DUI_LoadUIFileFromResources_hook, false } };
if (!HookSymbols(hShell32, hooks, ARRAYSIZE(hooks))) { Wh_Log(L"Failed to hook one or more symbol functions"); return FALSE; } return TRUE; }
I also faced with this problem, this function gets control only when loading resource from shell32.dll.
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 14:26:58 GMT -8
Are you using my mod 'verbatim'? I see in your code that you've omitted the LoadLibraryW call for shellstyle.dll. I have found out that if shellstyle.dll is not loaded explicitly (even though it's not used anywhere in the code per se) the mod doesn't work, producing the same results you're experiencing.
|
|
|
Post by anixx on Apr 16, 2024 14:51:45 GMT -8
Are you using my mod 'verbatim'? I see in your code that you've omitted the LoadLibraryW call for shellstyle.dll. I have found out that if shellstyle.dll is not loaded explicitly (even though it's not used anywhere in the code per se) the mod doesn't work, producing the same results you're experiencing. This is the code I tried to get working before you made your mod.
I use your mod verbatim, without removing the block with loadlibrary.
But now I managed to make your code working by removing this condition: "if (GetModuleFileNameW(hInstance, szPath, MAX_PATH))". For some reason when it is in place, the block inside this if is not executed when loading resources from shellstyle.dll. Maybe, GetModuleFileNameA should be used?
|
|
|
Post by anixx on Apr 16, 2024 15:07:42 GMT -8
When shellstyle.dll is called, the module path is empty (this log should output module path and resource number):
02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: C:\WINDOWS\System32\SHELL32.dll 02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 21 02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: C:\WINDOWS\System32\SHELL32.dll 02:04:43.600 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 21 02:04:43.631 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:04:43.631 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: 02:04:43.631 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 1 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: C:\WINDOWS\System32\SHELL32.dll 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 21 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: C:\WINDOWS\System32\SHELL32.dll 02:04:43.762 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 12 02:05:15.630 5636 explorer.exe [WH] [local@remove-command-bar] [39:DUILoadUIFileFromResourcesHook]: called 02:05:15.630 5636 explorer.exe [WH] [local@remove-command-bar] [43:DUILoadUIFileFromResourcesHook]: C:\WINDOWS\System32\SHELL32.dll 02:05:15.630 5636 explorer.exe [WH] [local@remove-command-bar] [44:DUILoadUIFileFromResourcesHook]: 21
|
|
|
Post by anixx on Apr 16, 2024 15:14:43 GMT -8
So, if we remove the check for the module path but only keep the resource number check, the mod works:
// ==WindhawkMod== // @id remove-command-bar // @name Remove Command Bar // @description Removes the Command Bar from file explorer. // @version 1.0 // @author Waldemar // @github https://github.com/CyprinusCarpio // @include explorer.exe // @architecture x86-64 // ==/WindhawkMod==
// ==WindhawkModReadme== /* # Remove Command Bar This mod removes the Vista or 7 Command Bar from file explorer windows without having to patch shellstyle.dll using external tools. If your shellstyle.dll is already patched, restore it using the following command in a elevated command prompt:
sfc /scanfile=c:\windows\system32\shellstyle.dll
and reboot your system. If this is not done, the patch from the dll will take precedence over this mod. After the mod is enabled, restart explorer.exe for the change to take place.
32bit systems not supported. */ // ==/WindhawkModReadme==
#include <string>
#include <windhawk_api.h> #include <windhawk_utils.h>
const std::wstring toLookFor = L"<style resid=\"FolderBandStyle\">"; const std::wstring toAdd = L"\n<Element padding=\"rect(0rp,0rp,0rp,-40rp)\"/>\n";
typedef HRESULT(* _cdecl DUILoadUIFileFromResources_t)(HINSTANCE, unsigned int, LPWSTR*); DUILoadUIFileFromResources_t DUILoadUIFileFromResourcesOriginal; HRESULT _cdecl DUILoadUIFileFromResourcesHook(HINSTANCE hInstance, unsigned int uResId, LPWSTR *pszOut) { if (uResId == 1) { HRESULT hRes = DUILoadUIFileFromResourcesOriginal(hInstance, uResId, pszOut); std::wstring uifile = *pszOut; size_t pos = uifile.find(toLookFor);
if (pos != std::wstring::npos) { uifile.insert(pos + toLookFor.length(), toAdd); } *pszOut = (LPWSTR)LocalAlloc(LPTR, (uifile.length() + 1) * sizeof(WCHAR)); if (*pszOut) { wcscpy(*pszOut, uifile.c_str()); } return hRes; } return DUILoadUIFileFromResourcesOriginal(hInstance, uResId, pszOut); }
BOOL Wh_ModInit() { Wh_Log(L"Remove Command Bar Init");
HMODULE hShellstyle= LoadLibraryW(L"shellstyle.dll"); if (!hShellstyle) { Wh_Log(L"Failed to load shellstyle.dll"); return FALSE; }
HMODULE hShell32 = LoadLibraryW(L"shell32.dll"); if (!hShell32) { Wh_Log(L"Failed to load shell32.dll"); return FALSE; }
WindhawkUtils::SYMBOL_HOOK hooks[] = { { { L"long __cdecl DUI_LoadUIFileFromResources(struct HINSTANCE__ *,unsigned int,unsigned short * *)" }, (void**)&DUILoadUIFileFromResourcesOriginal, (void*)DUILoadUIFileFromResourcesHook, FALSE } };
if (!WindhawkUtils::HookSymbols(hShell32, hooks, 1)) { Wh_Log(L"Failed to hook the member function."); return FALSE; }
return TRUE; }
The #include <windhawk_api.h> header is not needed.
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 16, 2024 15:29:38 GMT -8
This makes zero sense, but your solution of doing away with the module name check does not pose any risks so it can be accepted. The only thing it does is add a slight overhead, because now every UIFILE with the index 1 has to be checked in full by the find function (and obviously only one will be a match). I think I'll add a fallback option to disable the module name check, so that the overhead can be avoided if it just works normally.
Besides, we've got a sample size of two, let's wait before jumping to conclusions.
|
|
|
Post by anixx on Apr 16, 2024 15:32:41 GMT -8
I checked again, and LoadLibrary part is still needed. Not needed! As to the overhead, from the log it seems that it does not load any other resources with number 1 at all. From shell32.dll it loads resources with numbers 12, 21 and 3. So, I think the unnecessary overhead happens when we check the path.
With removing the unnecessary debug output and other blocks, I get the following condensed working code:
// ==WindhawkMod== // @id remove-command-bar // @name Remove Command Bar // @description Removes the Command Bar from file explorer. // @version 1.0 // @author Waldemar // @github https://github.com/CyprinusCarpio // @include explorer.exe // @architecture x86-64 // ==/WindhawkMod==
// ==WindhawkModReadme== /* # Remove Command Bar This mod removes the Vista or 7 Command Bar from file explorer windows without having to patch shellstyle.dll using external tools. If your shellstyle.dll is already patched, restore it using the following command in a elevated command prompt:
sfc /scanfile=c:\windows\system32\shellstyle.dll
and reboot your system. If this is not done, the patch from the dll will take precedence over this mod. After the mod is enabled, restart explorer.exe for the change to take place.
32bit systems not supported. */ // ==/WindhawkModReadme==
#include <string> #include <windhawk_utils.h>
const std::wstring toLookFor = L"<style resid=\"FolderBandStyle\">"; const std::wstring toAdd = L"\n<Element padding=\"rect(0rp,0rp,0rp,-40rp)\"/>\n";
typedef HRESULT(* _cdecl DUILoadUIFileFromResources_t)(HINSTANCE, unsigned int, LPWSTR*); DUILoadUIFileFromResources_t DUILoadUIFileFromResourcesOriginal; HRESULT _cdecl DUILoadUIFileFromResourcesHook(HINSTANCE hInstance, unsigned int uResId, LPWSTR *pszOut) { HRESULT hRes = DUILoadUIFileFromResourcesOriginal(hInstance, uResId, pszOut); if (uResId == 1) { std::wstring uifile = *pszOut; size_t pos = uifile.find(toLookFor);
if (pos != std::wstring::npos) { uifile.insert(pos + toLookFor.length(), toAdd); } *pszOut = (LPWSTR)LocalAlloc(LPTR, (uifile.length() + 1) * sizeof(WCHAR)); if (*pszOut) { wcscpy(*pszOut, uifile.c_str()); } } return hRes; }
BOOL Wh_ModInit() {
HMODULE hShell32 = LoadLibraryW(L"shell32.dll");
WindhawkUtils::SYMBOL_HOOK hooks[] = { { {L"long __cdecl DUI_LoadUIFileFromResources(struct HINSTANCE__ *,unsigned int,unsigned short * *)"}, (void**)&DUILoadUIFileFromResourcesOriginal, (void*)DUILoadUIFileFromResourcesHook, FALSE } };
WindhawkUtils::HookSymbols(hShell32, hooks, 1); return TRUE; }
|
|
waldemar21214
Freshman Member
Posts: 94
OS: Windows 10
Theme: Classic
CPU: i5-12400f
RAM: 16 GB DDR4 3600mhz
GPU: PNY 3060TI
|
Post by waldemar21214 on Apr 17, 2024 2:43:49 GMT -8
Added 32 bit calling conventions. should now work on everything. I'll be making a pull request to the repo now.
On a side note, man, please use spoilers it makes the topic so much more readable.
|
|
|
Post by anixx on Apr 17, 2024 3:00:04 GMT -8
|
|
|
Post by anixx on Apr 17, 2024 3:35:32 GMT -8
It sounds weird, but on my system the shellstyle.dll library is loaded by the Intel bluetooth driver process (ibtsiva.exe), not by explorer.exe. That's why the function does not return the module's name.
|
|
|
Post by OrthodoxWin32 on Apr 19, 2024 5:22:37 GMT -8
This mod doesn't quite give the same result as editing shellstyle.dll. With this mod (the version published in the official mod list) :
With the edited shellstyle.dll file:
|
|