diff --git a/src/core/hooking/Hooking.cpp b/src/core/hooking/Hooking.cpp index 47b83b2..c22f774 100644 --- a/src/core/hooking/Hooking.cpp +++ b/src/core/hooking/Hooking.cpp @@ -38,6 +38,8 @@ namespace YimMenu BaseHook::Add(new DetourHook("WriteSyncTree", Pointers.WriteSyncTree, Hooks::Spoofing::WriteSyncTree)); BaseHook::Add(new DetourHook("GetPoolType", Pointers.GetPoolType, Hooks::Network::GetPoolType)); + + BaseHook::Add(new DetourHook("AssistedAimShouldReleaseEntity", Pointers.AssistedAimShouldReleaseEntity, Hooks::Misc::AssistedAimShouldReleaseEntity)); } Hooking::~Hooking() diff --git a/src/core/renderer/Renderer.cpp b/src/core/renderer/Renderer.cpp index 57bb593..91b3acf 100644 --- a/src/core/renderer/Renderer.cpp +++ b/src/core/renderer/Renderer.cpp @@ -23,10 +23,18 @@ namespace YimMenu void Renderer::DestroyImpl() { + // TODO: we aren't destroying resources properly ImGui_ImplWin32_Shutdown(); WaitForLastFrame(); + ImGui_ImplDX12_InvalidateDeviceObjects(); + + for (size_t i{}; i != GetInstance().m_SwapChainDesc.BufferCount; ++i) + { + REL(GetInstance().m_FrameContext[i].Resource); + } + ImGui_ImplDX12_Shutdown(); ImGui::DestroyContext(); @@ -195,15 +203,6 @@ namespace YimMenu }; ImGui_ImplDX12_Init(&init_info); - #if 0 - ImGui_ImplDX12_Init(m_Device.Get(), - m_SwapChainDesc.BufferCount, - DXGI_FORMAT_R8G8B8A8_UNORM, - m_DescriptorHeap.Get(), - m_DescriptorHeap->GetCPUDescriptorHandleForHeapStart(), - m_DescriptorHeap->GetGPUDescriptorHandleForHeapStart()); - #endif - ImGui::StyleColorsDark(); LOG(INFO) << "DirectX 12 renderer has finished initializing."; diff --git a/src/game/backend/SavedPlayers.cpp b/src/game/backend/SavedPlayers.cpp index 391c5cc..7c8110d 100644 --- a/src/game/backend/SavedPlayers.cpp +++ b/src/game/backend/SavedPlayers.cpp @@ -129,7 +129,7 @@ namespace YimMenu { while (g_Running) { - if (Features::_AutoUpdateEnabled.GetState() && m_LastPlayerInfoFetch + AUTO_REFRESH_TIME < std::chrono::system_clock::now() && Pointers.GetPresenceAttributes) + if (Features::_AutoUpdateEnabled.GetState() && std::chrono::system_clock::now() - m_LastPlayerInfoFetch > AUTO_REFRESH_TIME && Pointers.GetPresenceAttributes) { FetchPlayerInfo(true); m_LastPlayerInfoFetch = std::chrono::system_clock::now(); diff --git a/src/game/hooks/Hooks.hpp b/src/game/hooks/Hooks.hpp index fcd349a..446daae 100644 --- a/src/game/hooks/Hooks.hpp +++ b/src/game/hooks/Hooks.hpp @@ -78,4 +78,9 @@ namespace YimMenu::Hooks { extern LRESULT WndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam); } + + namespace Misc + { + extern bool AssistedAimShouldReleaseEntity(__int64 a1); + } } \ No newline at end of file diff --git a/src/game/hooks/Misc/AssistedAimShouldReleaseEntity.cpp b/src/game/hooks/Misc/AssistedAimShouldReleaseEntity.cpp new file mode 100644 index 0000000..d7c8f6f --- /dev/null +++ b/src/game/hooks/Misc/AssistedAimShouldReleaseEntity.cpp @@ -0,0 +1,19 @@ +#include "core/hooking/DetourHook.hpp" +#include "game/hooks/Hooks.hpp" +#include "types/entity/CDynamicEntity.hpp" +#include "game/gta/Ped.hpp" + +namespace YimMenu::Hooks +{ + bool Misc::AssistedAimShouldReleaseEntity(__int64 a1) + { + auto entity = *(CDynamicEntity**)(a1 + 0x38); + + if (entity && entity->IsPed() && Ped(entity).IsDead()) + { + return true; + } + + return BaseHook::Get>()->Original()(a1); + } +} \ No newline at end of file diff --git a/src/game/pointers/Pointers.cpp b/src/game/pointers/Pointers.cpp index 6cbe89b..6f4dfcd 100644 --- a/src/game/pointers/Pointers.cpp +++ b/src/game/pointers/Pointers.cpp @@ -379,6 +379,11 @@ namespace YimMenu BattlEyeServerProcessPlayerJoin = ptr.Sub(0x72).As(); }); + constexpr auto assistedAimShouldReleaseEntityPtrn = Pattern<"80 7F 28 04 75 6A">("AssistedAimShouldReleaseEntity"); + scanner.Add(assistedAimShouldReleaseEntityPtrn, [this](PointerCalculator ptr) { + AssistedAimShouldReleaseEntity = ptr.Sub(0xF).As(); + }); + if (!scanner.Scan()) { LOG(FATAL) << "Some patterns could not be found, unloading."; diff --git a/src/game/pointers/Pointers.hpp b/src/game/pointers/Pointers.hpp index 1de8f7e..2a34c41 100644 --- a/src/game/pointers/Pointers.hpp +++ b/src/game/pointers/Pointers.hpp @@ -150,6 +150,7 @@ namespace YimMenu CStatsMpCharacterMappingData* StatsMpCharacterMappingData; int* HasGTAPlus; PVOID BattlEyeServerProcessPlayerJoin; + PVOID AssistedAimShouldReleaseEntity; }; struct Pointers : PointerData