fix: hook GetRawInputData to block mouse clicks from reaching game through menu (#959)

* fix: hook GetRawInputData to block mouse clicks from reaching game

* fix: only block raw mouse clicks when over ImGui menu

Blocks clicks using ImGui::GetIO().WantCaptureMouse instead of
blanket-blocking all clicks when menu is open. Lets clicks pass
through to the game for areas outside the menu.

* fix: remove redundant GUI::IsOpen() check

WantCaptureMouse already implies menu is visible.
This commit is contained in:
Ali
2026-07-29 14:21:21 +02:00
committed by GitHub
parent b6543e61c4
commit 57378938d8
3 changed files with 32 additions and 0 deletions
+2
View File
@@ -12,6 +12,8 @@ namespace YimMenu
{
BaseHook::Add<Hooks::Window::WndProc>(new DetourHook("WndProc", Pointers.WndProc, Hooks::Window::WndProc));
BaseHook::Add<Hooks::RawInput::GetRawInputData>(new DetourHook("GetRawInputData", reinterpret_cast<void*>(GetProcAddress(LoadLibraryA("user32.dll"), "GetRawInputData")), Hooks::RawInput::GetRawInputData));
auto swapchain_vft = *reinterpret_cast<void***>(*Pointers.SwapChain);
BaseHook::Add<Hooks::SwapChain::Present>(new DetourHook("Present", swapchain_vft[Hooks::SwapChain::VMTPresentIdx], Hooks::SwapChain::Present));
BaseHook::Add<Hooks::SwapChain::ResizeBuffers>(new DetourHook("ResizeBuffers", swapchain_vft[Hooks::SwapChain::VMTResizeBuffersIdx], Hooks::SwapChain::ResizeBuffers));
+25
View File
@@ -0,0 +1,25 @@
#include "core/hooking/DetourHook.hpp"
#include "game/frontend/GUI.hpp"
#include "game/hooks/Hooks.hpp"
#include <imgui.h>
namespace YimMenu::Hooks
{
UINT RawInput::GetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader)
{
auto result = BaseHook::Get<RawInput::GetRawInputData, DetourHook<decltype(&RawInput::GetRawInputData)>>()->Original()(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader);
if (result > 0 && pData && uiCommand == RID_INPUT && ImGui::GetIO().WantCaptureMouse)
{
auto& raw = *(RAWINPUT*)pData;
if (raw.header.dwType == RIM_TYPEMOUSE && raw.data.mouse.usButtonFlags)
{
// Zero out button flags to prevent game from seeing clicks while menu is open
raw.data.mouse.usButtonFlags = 0;
}
}
return result;
}
}
+5
View File
@@ -98,6 +98,11 @@ namespace YimMenu::Hooks
extern LRESULT WndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam);
}
namespace RawInput
{
extern UINT GetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader);
}
namespace Misc
{
extern bool AssistedAimShouldReleaseEntity(__int64 a1);