Low Level Mouse Hook changes

This commit is contained in:
EricPlayZ
2024-12-30 17:39:17 +02:00
parent 92a84d71d1
commit 819b439d15
12 changed files with 124 additions and 40 deletions

View File

@ -92,7 +92,7 @@ namespace EGSDK {
AddOffset(TogglePhotoMode1, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? 38 91 ?? ?? ?? ?? 0F 84", Utils::SigScan::PatternType::Address, void*)
AddOffset(TogglePhotoMode2, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 57 48 83 EC ?? 48 8B D9 41 0F B6 F8 48 8B 0D", Utils::SigScan::PatternType::Address, void*)
//AddOffset(OnUpdate_ChangeMap, "gamedll_ph_x64_rwdi.dll", "E8 [?? ?? ?? ?? 88 44 24 20 48 8B 84 24 ?? ?? ?? ?? 48 83 78 ?? ??", PatternType::RelativePointer, void*)
AddOffset(ShowTPPModelFunc2, "gamedll_ph_x64_rwdi.dll", "40 53 48 83 EC ?? 48 8B 01 48 8B D9 FF 90 ?? ?? ?? ?? 84 C0 74 ?? 48 8B 83 ?? ?? ?? ?? 48 8B 88 ?? ?? ?? ?? 48 85 C9 74 ?? 48 83 B9 ?? ?? ?? ?? ?? 74 ?? 48 8B 81", Utils::SigScan::PatternType::Address, void*)
AddOffset(GetPlayerDI_PH, "gamedll_ph_x64_rwdi.dll", "40 53 48 83 EC ?? 48 8B 01 48 8B D9 FF 90 ?? ?? ?? ?? 84 C0 74 ?? 48 8B 83 ?? ?? ?? ?? 48 8B 88 ?? ?? ?? ?? 48 85 C9 74 ?? 48 83 B9 ?? ?? ?? ?? ?? 74 ?? 48 8B 81", Utils::SigScan::PatternType::Address, void*) // ShowTPPModelFunc2
AddOffset(ShowTPPModelFunc3, "gamedll_ph_x64_rwdi.dll", "48 83 EC ?? 38 91 ?? ?? ?? ?? 74 ?? 88 91", Utils::SigScan::PatternType::Address, void*)
//AddOffset(CalculateOutOfBoundsTimer, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 81 EC ?? ?? ?? ?? 0F B6 99", PatternType::Address, void*)
AddOffset(IsNotOutOfMapBounds, "gamedll_ph_x64_rwdi.dll", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC ?? 4C 8B F9 48 85 D2", Utils::SigScan::PatternType::Address, void*)

View File

@ -46,25 +46,15 @@ namespace EGSDK::GamePH {
return GameVerToStr(GetCurrentGameVersion());
}
static DWORD64 ShowTPPModelFunc2(GameDI_PH* pGameDI_PH) {
return Utils::Memory::_SafeCallFunctionOffset<DWORD64>(Offsets::Get_ShowTPPModelFunc2, 0, pGameDI_PH);
}
static void ShowTPPModelFunc3(DWORD64 tppFunc2Addr, bool showTPPModel) {
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH)
return;
Utils::Memory::_SafeCallFunctionOffsetVoid(Offsets::Get_ShowTPPModelFunc3, tppFunc2Addr, showTPPModel);
}
void ShowTPPModel(bool showTPPModel) {
GameDI_PH* pGameDI_PH = GameDI_PH::Get();
if (!pGameDI_PH)
return;
DWORD64 tppFunc2Addr = ShowTPPModelFunc2(pGameDI_PH);
if (!tppFunc2Addr)
PlayerDI_PH* pPlayerDI_PH = PlayerDI_PH::Get();
if (!pPlayerDI_PH)
return;
ShowTPPModelFunc3(tppFunc2Addr, showTPPModel);
Utils::Memory::_SafeCallFunctionOffsetVoid(Offsets::Get_ShowTPPModelFunc3, pPlayerDI_PH, showTPPModel);
}
bool ReloadJumps() {
return Utils::Memory::_SafeCallFunctionOffset<bool>(Offsets::Get_ReloadJumps, false);

View File

@ -39,8 +39,8 @@ Global
{152BCFEC-E42D-4370-AEDD-36F044085C0C}.Release|x64.Build.0 = Release|x64
{152BCFEC-E42D-4370-AEDD-36F044085C0C}.Release|x86.ActiveCfg = Release|x64
{152BCFEC-E42D-4370-AEDD-36F044085C0C}.Release|x86.Build.0 = Release|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x64.ActiveCfg = Debug|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x64.Build.0 = Debug|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x64.ActiveCfg = Debug_Release|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x64.Build.0 = Debug_Release|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x86.ActiveCfg = Debug|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Debug|x86.Build.0 = Debug|x64
{47F0BD81-B327-0619-BC31-6A3C28E82C12}.Release|x64.ActiveCfg = Release|x64

View File

@ -2,12 +2,6 @@
#include <atomic>
#include <EGSDK\Utils\Values.h>
#ifdef _DEBUG
#ifndef LLMH_IMPL_DISABLE_DEBUG
#define LLMH_IMPL_DISABLE_DEBUG // this is for disabling low-level mouse hook in case ure trying to debug and u dont want ur pc to die lol
#endif
#endif
namespace EGT {
constexpr const char* MOD_VERSION_STR = "v1.2.4";
constexpr unsigned long MOD_VERSION = 10204;

View File

@ -1,6 +1,13 @@
#pragma once
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
namespace EGT::ImGui_impl {
namespace Win32 {
extern void EnableMouseHook();
extern void DisableMouseHook();
extern void Init(HWND hwnd);
}
}

View File

@ -3,6 +3,8 @@
namespace EGT::Menu {
namespace Debug {
extern bool disableLowLevelMouseHook;
class Tab : MenuTab {
public:
Tab() : MenuTab("Debug", 6) {}

View File

@ -64,11 +64,7 @@ namespace EGT::ImGui_impl {
d3d11RenderTargetView = CreateRenderTargetView(pSwapChain);
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { Win32::Init(desc.OutputWindow); }).detach();
#else
Win32::Init(desc.OutputWindow);
#endif
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;

View File

@ -95,11 +95,7 @@ namespace EGT::ImGui_impl {
if (d3d12Device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, frameContext[0].commandAllocator, NULL, IID_PPV_ARGS(&d3d12CommandList)) != S_OK || d3d12CommandList->Close() != S_OK)
return;
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { Win32::Init(desc.OutputWindow); }).detach();
#else
Win32::Init(desc.OutputWindow);
#endif
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;

View File

@ -1,9 +1,11 @@
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <spdlog\spdlog.h>
#include <imgui_hotkey.h>
#include <EGSDK\Engine\CInput.h>
#include <EGT\Menu\Menu.h>
#include <EGT\Menu\Debug.h>
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@ -69,7 +71,6 @@ namespace EGT::ImGui_impl {
return CallWindowProc(oWndProc, hwnd, uMsg, wParam, lParam);
}
#ifndef LLMH_IMPL_DISABLE_DEBUG
static LRESULT CALLBACK hkMouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode != HC_ACTION)
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
@ -107,20 +108,38 @@ namespace EGT::ImGui_impl {
return CallNextHookEx(oMouseProc, nCode, wParam, lParam);
}
#endif
void MouseHkMsgLoop() {
MSG msg{};
while (true) {
if (oMouseProc && GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
void EnableMouseHook() {
if (oMouseProc)
return;
oMouseProc = SetWindowsHookEx(WH_MOUSE_LL, hkMouseProc, GetModuleHandle(nullptr), 0);
if (!oMouseProc)
SPDLOG_ERROR("Failed to enable low level mouse hook; mouse input-related functions (such as FreeCam speed changing through the scrollwheel) may not work");
}
void DisableMouseHook() {
if (!oMouseProc)
return;
UnhookWindowsHookEx(oMouseProc);
oMouseProc = nullptr;
}
void Init(HWND hwnd) {
gHwnd = hwnd;
oWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)hkWindowProc);
#ifndef LLMH_IMPL_DISABLE_DEBUG
oMouseProc = SetWindowsHookEx(WH_MOUSE_LL, hkMouseProc, GetModuleHandle(nullptr), 0);
Menu::Debug::disableLowLevelMouseHook ? DisableMouseHook() : EnableMouseHook();
MSG msg;
while (oMouseProc && GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#endif
std::thread([]() { MouseHkMsgLoop(); }).detach();
}
}
}

View File

@ -1,3 +1,5 @@
#include <imguiex.h>
#include <EGT\ImGui_impl\Win32_impl.h>
#include <EGT\Menu\Debug.h>
#include <EGSDK\GamePH\DayNightCycle.h>
@ -59,6 +61,12 @@ namespace EGT::Menu {
{ "CoPhysicsProperty", reinterpret_cast<void*(*)()>(&EGSDK::Engine::CoPhysicsProperty::Get) }
};
#ifdef _DEBUG
bool disableLowLevelMouseHook = true;
#else
bool disableLowLevelMouseHook = false;
#endif
static void RenderClassAddrPair(const std::pair<std::string_view, void*(*)()>* pair) {
const float maxInputTextWidth = ImGui::CalcTextSize("0x0000000000000000").x;
static std::string labelID{};
@ -88,6 +96,9 @@ namespace EGT::Menu {
Tab Tab::instance{};
void Tab::Update() {}
void Tab::Render() {
ImGui::SeparatorText("Misc##Debug");
if (ImGui::Checkbox("Disable Low Level Mouse Hook", &disableLowLevelMouseHook, "Disables the low level mouse hook that is used to capture mouse input in the game"))
disableLowLevelMouseHook ? ImGui_impl::Win32::DisableMouseHook() : ImGui_impl::Win32::EnableMouseHook();
ImGui::SeparatorText("Class addresses##Debug");
if (ImGui::CollapsingHeader("GamePH", ImGuiTreeNodeFlags_None)) {
ImGui::Indent();

View File

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug_Release|x64">
<Configuration>Debug_Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
@ -15,6 +19,7 @@
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Ultimate-ASI-Loader-x64</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
@ -23,6 +28,12 @@
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
@ -35,6 +46,9 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
@ -46,6 +60,13 @@
<TargetName>winmm</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\x64\Debug\</OutDir>
<IntDir>x64\Debug\</IntDir>
<TargetName>winmm</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\x64\Debug\</OutDir>
@ -80,6 +101,33 @@
<ModuleDefinitionFile>source/x64.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>rsc_CompanyName="ThirteenAG";rsc_LegalCopyright="MIT License";rsc_InternalName="Ultimate-ASI-Loader-x64";rsc_ProductName="Ultimate-ASI-Loader-x64";rsc_OriginalFilename="Ultimate-ASI-Loader-x64.dll";rsc_FileDescription="Ultimate ASI Loader";rsc_UpdateUrl="https://github.com/ThirteenAG/Ultimate-ASI-Loader";rsc_FileVersion_MAJOR=7;rsc_FileVersion_MINOR=0;rsc_FileVersion_BUILD=0;rsc_FileVersion_REVISION=0;rsc_FileVersion="7.0.0";rsc_ProductVersion="7.0.0";X64;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>source;external;external\injector\minhook\include;external\injector\utility;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ExceptionHandling>Async</ExceptionHandling>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>rsc_CompanyName=\"ThirteenAG\";rsc_LegalCopyright=\"MIT License\";rsc_InternalName=\"Ultimate-ASI-Loader-x64\";rsc_ProductName=\"Ultimate-ASI-Loader-x64\";rsc_OriginalFilename=\"Ultimate-ASI-Loader-x64.dll\";rsc_FileDescription=\"Ultimate ASI Loader\";rsc_UpdateUrl=\"https://github.com/ThirteenAG/Ultimate-ASI-Loader\";rsc_FileVersion_MAJOR=7;rsc_FileVersion_MINOR=0;rsc_FileVersion_BUILD=0;rsc_FileVersion_REVISION=0;rsc_FileVersion=\"7.0.0\";rsc_ProductVersion=\"7.0.0\";X64;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>source;external;external\injector\minhook\include;external\injector\utility;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ImportLibrary>..\x64\Release\winmm.lib</ImportLibrary>
<ModuleDefinitionFile>source/x64.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 ThirteenAG
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.