mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 03:43:15 +08:00
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:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user