Skip to content

Commit 92fd283

Browse files
fix(hook): check if def->hwnd is available to bypass background calls
fix #287
1 parent b03eb6d commit 92fd283

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/shell/contextmenu/hooks.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ void mb_shell::context_menu_hooks::install_SHCreateDefaultContextMenu_hook() {
221221
SHCreateDefaultContextMenuHook->uninstall();
222222
auto res = SHCreateDefaultContextMenu(def, riid, ppv);
223223
SHCreateDefaultContextMenuHook->install();
224+
if (riid != IID_IContextMenu || !ppv || !*ppv || !def || !def->hwnd) {
225+
return res;
226+
}
224227

225228
IContextMenu *pdcm = (IContextMenu *)(*ppv);
226229
if (SUCCEEDED(res) && pdcm) {
@@ -279,9 +282,6 @@ void mb_shell::context_menu_hooks::install_GetUIObjectOf_hook() {
279282
// For OneCommander
280283

281284
auto proc = blook::Process::self();
282-
auto shell32 = proc->module("shell32.dll");
283-
auto SHELL32_SHCreateDefaultContextMenu =
284-
shell32.value()->exports("SHELL32_SHCreateDefaultContextMenu");
285285

286286
static std::atomic_bool close_next_create_window_exw_window = false;
287287

0 commit comments

Comments
 (0)