Skip to content

Commit

Permalink
Remove Command Bar: limit to 64bit arch
Browse files Browse the repository at this point in the history
  • Loading branch information
CyprinusCarpio committed Oct 6, 2024
1 parent 5d24a3a commit b2f8ce6
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions mods/remove-command-bar.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// @id remove-command-bar
// @name Remove Command Bar
// @description Removes the Command Bar from file explorer.
// @version 1.0
// @version 1.0.1
// @author Waldemar
// @github https://github.com/CyprinusCarpio
// @include explorer.exe
// @architecture x86-64
// ==/WindhawkMod==

// ==WindhawkModReadme==
Expand Down Expand Up @@ -38,21 +39,13 @@ For issue reports, contact waldemar3194 on Discord, or file a report at my [gith
#include <string>
#include <windhawk_utils.h>

#ifdef _WIN64
#define CALCON __cdecl
#define SCALCON L"__cdecl"
#else
#define CALCON __stdcall
#define SCALCON L"__stdcall"
#endif

const std::wstring toLookFor = L"<style resid=\"FolderBandStyle\">";

int g_offsetSetting;

typedef HRESULT(* CALCON DUILoadUIFileFromResources_t)(HINSTANCE, unsigned int, LPWSTR*);
typedef HRESULT(* __cdecl DUILoadUIFileFromResources_t)(HINSTANCE, unsigned int, LPWSTR*);
DUILoadUIFileFromResources_t DUILoadUIFileFromResourcesOriginal;
HRESULT CALCON DUILoadUIFileFromResourcesHook(HINSTANCE hInstance, unsigned int uResId, LPWSTR *pszOut)
HRESULT __cdecl DUILoadUIFileFromResourcesHook(HINSTANCE hInstance, unsigned int uResId, LPWSTR *pszOut)
{
// We don't check the module name, only the resource id. It seems that the only resource with the id 1
// that explorer loads is the one we want, and even if that's not true the wstring::find function prevents
Expand Down Expand Up @@ -90,18 +83,18 @@ BOOL Wh_ModInit() {
return FALSE;
}

WindhawkUtils::SYMBOL_HOOK hooks[] =
WindhawkUtils::SYMBOL_HOOK shell32_dll_hooks[] =
{
{ {
L"long " SCALCON " DUI_LoadUIFileFromResources(struct HINSTANCE__ *,unsigned int,unsigned short * *)"
L"long __cdecl DUI_LoadUIFileFromResources(struct HINSTANCE__ *,unsigned int,unsigned short * *)"
},
(void**)&DUILoadUIFileFromResourcesOriginal,
(void*)DUILoadUIFileFromResourcesHook,
FALSE
}
};

if (!WindhawkUtils::HookSymbols(hShell32, hooks, 1))
if (!WindhawkUtils::HookSymbols(hShell32, shell32_dll_hooks, 1))
{
Wh_Log(L"Failed to hook the member function.");
return FALSE;
Expand Down

0 comments on commit b2f8ce6

Please sign in to comment.