diff --git a/src/core/hooking/Hooking.cpp b/src/core/hooking/Hooking.cpp index f1967fd..24867e4 100644 --- a/src/core/hooking/Hooking.cpp +++ b/src/core/hooking/Hooking.cpp @@ -12,6 +12,8 @@ namespace YimMenu { BaseHook::Add(new DetourHook("WndProc", Pointers.WndProc, Hooks::Window::WndProc)); + BaseHook::Add(new DetourHook("GetRawInputData", reinterpret_cast(GetProcAddress(LoadLibraryA("user32.dll"), "GetRawInputData")), Hooks::RawInput::GetRawInputData)); + auto swapchain_vft = *reinterpret_cast(*Pointers.SwapChain); BaseHook::Add(new DetourHook("Present", swapchain_vft[Hooks::SwapChain::VMTPresentIdx], Hooks::SwapChain::Present)); BaseHook::Add(new DetourHook("ResizeBuffers", swapchain_vft[Hooks::SwapChain::VMTResizeBuffersIdx], Hooks::SwapChain::ResizeBuffers)); diff --git a/src/game/hooks/GUI/RawInput.cpp b/src/game/hooks/GUI/RawInput.cpp new file mode 100644 index 0000000..008d038 --- /dev/null +++ b/src/game/hooks/GUI/RawInput.cpp @@ -0,0 +1,25 @@ +#include "core/hooking/DetourHook.hpp" +#include "game/frontend/GUI.hpp" +#include "game/hooks/Hooks.hpp" + +#include + +namespace YimMenu::Hooks +{ + UINT RawInput::GetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader) + { + auto result = BaseHook::Get>()->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; + } +} diff --git a/src/game/hooks/Hooks.hpp b/src/game/hooks/Hooks.hpp index 8b16bac..ed001f4 100644 --- a/src/game/hooks/Hooks.hpp +++ b/src/game/hooks/Hooks.hpp @@ -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);