屏蔽托盘右键菜单

最近有个需求需要屏蔽托盘图标的右下角菜单项:

       经过Apimonitor进行hook Explorer进程,发现弹出菜单是通过explorer调用InserMenuItem函数来实现的。通过注入explorer并挂钩InserMenuItemW函数,并屏蔽自己想要屏蔽的菜单项:

(上图将“弹出Standard Enhanced PCI to USb Host Controller”以及“弹出Standard Universal PCI to USb Host Controller”两个Menu项屏蔽了)

hook代码大概如下:

static BOOL(WINAPI* OrgInsertMenuItemW)(
    HMENU            hmenu,
    UINT             item,
    BOOL             fByPosition,
    LPCMENUITEMINFOW lpmi
) = InsertMenuItemW;

BOOL WINAPI NewInsertMenuItemW(
    HMENU            hmenu,
    UINT             item,
    BOOL             fByPosition,
    LPCMENUITEMINFOW lpmi
)
{
    wchar_t szBuf[200] = { 0 };
    wsprintf(szBuf, L"NewInsertMenuItemW, item:%d fByPosition:%d dwTypeData:%s  ", item, fByPosition, lpmi->dwTypeData);
    OutputDebugStringW(szBuf);
    if (lpmi->dwTypeData && wcsstr(lpmi->dwTypeData, L"USB Host Controller"))
    {
        OutputDebugStringW(L"will shield this menu");
        return TRUE;
    }
    return OrgInsertMenuItemW(hmenu, item, fByPosition, lpmi);
}

bool HookMenu()
{
    // 相关的初始化信息
    DetourTransactionBegin();
    // 更新线程信息
    DetourUpdateThread(GetCurrentThread());

    DetourAttach(&(PVOID&)OrgInsertMenuItemW, NewInsertMenuItemW);
    return NO_ERROR == DetourTransactionCommit();
}

但这个Item是从哪里来的呢,在自己的代码里面打上断点,用ida Attach到Explorer进程,并打印所有堆栈,然后找到自己的那个线程堆栈:

 跳转转到stobject!DllCanUnloadNow+0xc294:

       InsertMenuItem的字符串变量dwTypeData来自v59:v48.dwTypeData = v59; 而v59来自:sub_7FFB7D7FD3CC(v59, 260i64, v54, pszIconPath);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值