Skip to content

Conversation

@youlanan
Copy link

Add quick-hide-desktop-icons mod

  • Toggles desktop icon visibility with customizable mouse clicks (left/right/middle, single/double) or keyboard hotkeys
  • Supports English, Simplified Chinese, Traditional Chinese, and Japanese
  • Tested on Windows 11 24H2

Add quick-hide-desktop-icons mod
- Toggles desktop icon visibility with customizable mouse clicks (left/right/middle, single/double) or keyboard hotkeys
- Supports English, Simplified Chinese, Traditional Chinese, and Japanese
- Tested on Windows 11 24H2
Add quick-hide-desktop-icons mod
- Toggles desktop icon visibility with customizable mouse clicks (left/right/middle, single/double) or keyboard hotkeys
- Supports English, Simplified Chinese, Traditional Chinese, and Japanese
- Tested on Windows 11 24H2
Copy link
Member

@m417z m417z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission!

Fix some potential problems
Make some adjustments to the optional configuration.
Some new methods are referenced.

if (defView) {
DWORD pid;
GetWindowThreadProcessId(defView, &pid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be enough to check for the process id of one of the windows, e.g. shellWnd. All child windows are part of the same process.

HWND defView = FindWindowExW(workerW, nullptr, L"SHELLDLL_DefView", nullptr);
HWND worker = g_lastWorkerW && IsWindow(g_lastWorkerW) ? g_lastWorkerW : nullptr;
DWORD start = GetTickCount();
while ((worker = FindWindowExW(nullptr, worker, L"WorkerW", nullptr))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to add a delay in each iteration (e.g. use Sleep(20);) to avoid stressing the CPU unnecessarily.

if (DispatchMessageW_Original) {
#ifdef Wh_RemoveFunctionHook
Wh_RemoveFunctionHook((void*)DispatchMessageW, (void*)DispatchMessageW_Hook);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wh_RemoveFunctionHook is not a macro, so this #ifdef block will never be compiled. In addition, Wh_SetFunctionHook and Wh_RemoveFunctionHook don't have any effect until Wh_ApplyHookOperation is called, unless hooks are set in Wh_ModInit. Generally, it's recommended to set the hooks once in Wh_ModInit and then use them when needed, or just call the original function.

Refer to the documentation for details:
https://github.com/ramensoftware/windhawk/wiki/Creating-a-new-mod#wh_setfunctionhook

if (DispatchMessageW_Original) {
#ifdef Wh_RemoveFunctionHook
Wh_RemoveFunctionHook((void*)DispatchMessageW, (void*)DispatchMessageW_Hook);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooks are removed automatically before Wh_ModUninit is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants