Compare commits

..

4 Commits

Author SHA1 Message Date
orange 78d92a3c0f improvement 2026-07-08 19:11:56 +03:00
orange d2ef40e0bd replaced with thread 2026-07-08 19:07:31 +03:00
orange d67d956aca showing mouse 2026-07-08 18:41:54 +03:00
orange 5e3bb0e961 fix stuff 2026-07-08 18:34:38 +03:00
3 changed files with 40 additions and 45 deletions
+12 -16
View File
@@ -5,6 +5,7 @@
#include <imgui.h> #include <imgui.h>
#include <imgui_impl_dx11.h> #include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h> #include <imgui_impl_win32.h>
#include <thread>
#include <tuple> #include <tuple>
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);
@@ -18,6 +19,7 @@ namespace
ID3D11DeviceContext* g_context = nullptr; ID3D11DeviceContext* g_context = nullptr;
ID3D11RenderTargetView* g_render_target_view = nullptr; ID3D11RenderTargetView* g_render_target_view = nullptr;
[[nodiscard]]
bool create_render_target(IDXGISwapChain* swap_chain) bool create_render_target(IDXGISwapChain* swap_chain)
{ {
ID3D11Texture2D* back_buffer = nullptr; ID3D11Texture2D* back_buffer = nullptr;
@@ -58,9 +60,9 @@ namespace
g_device->GetImmediateContext(&g_context); g_device->GetImmediateContext(&g_context);
DXGI_SWAP_CHAIN_DESC desc{}; DXGI_SWAP_CHAIN_DESC desc{};
swap_chain->GetDesc(&desc); std::ignore = swap_chain->GetDesc(&desc);
create_render_target(swap_chain); std::ignore = create_render_target(swap_chain);
ImGui::CreateContext(); ImGui::CreateContext();
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
@@ -73,7 +75,7 @@ namespace
auto& mgr = omath::hooks::HooksManager::get(); auto& mgr = omath::hooks::HooksManager::get();
mgr.set_on_wnd_proc( mgr.set_on_wnd_proc(
[](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT> [](const HWND h, const UINT msg, const WPARAM wp, const LPARAM lp) -> std::optional<LRESULT>
{ {
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp)) if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
return 0; return 0;
@@ -106,13 +108,8 @@ namespace
ImGui_ImplDX11_NewFrame(); ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame(); ImGui_ImplWin32_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
ImGui::GetIO().MouseDrawCursor = true;
ImGui::SetNextWindowSize({300.f, 80.f}, ImGuiCond_Once); ImGui::ShowDemoWindow();
ImGui::SetNextWindowPos({10.f, 10.f}, ImGuiCond_Once);
ImGui::Begin("omath | DX11 hook");
ImGui::Text("Hook active");
ImGui::Text("FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::End();
ImGui::Render(); ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
@@ -134,14 +131,13 @@ namespace
} }
} // namespace } // namespace
BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID) BOOL WINAPI DllMain(const HINSTANCE h_instance, const DWORD reason, LPVOID)
{ {
if (reason == DLL_PROCESS_ATTACH) if (reason == DLL_PROCESS_ATTACH)
{ {
DisableThreadLibraryCalls(h_instance); DisableThreadLibraryCalls(h_instance);
CreateThread( std::thread(
nullptr, 0, []()
[](LPVOID) -> DWORD
{ {
while (!GetModuleHandle("d3d11.dll")) while (!GetModuleHandle("d3d11.dll"))
Sleep(100); Sleep(100);
@@ -151,8 +147,8 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
mgr.set_on_resize_buffers(on_resize_buffers); mgr.set_on_resize_buffers(on_resize_buffers);
std::ignore = mgr.hook_dx11(); std::ignore = mgr.hook_dx11();
return 0; return 0;
}, })
nullptr, 0, nullptr); .detach();
} }
else if (reason == DLL_PROCESS_DETACH) else if (reason == DLL_PROCESS_DETACH)
{ {
+4 -5
View File
@@ -449,9 +449,8 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
if (reason == DLL_PROCESS_ATTACH) if (reason == DLL_PROCESS_ATTACH)
{ {
DisableThreadLibraryCalls(h_instance); DisableThreadLibraryCalls(h_instance);
CreateThread( std::thread(
nullptr, 0, []()
[](LPVOID) -> DWORD
{ {
while (!GetModuleHandle("d3d12.dll")) while (!GetModuleHandle("d3d12.dll"))
Sleep(100); Sleep(100);
@@ -462,8 +461,8 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
mgr.set_on_execute_command_lists(on_execute_command_lists); mgr.set_on_execute_command_lists(on_execute_command_lists);
std::ignore = mgr.hook_dx12(); std::ignore = mgr.hook_dx12();
return 0; return 0;
}, })
nullptr, 0, nullptr); .detach();
} }
else if (reason == DLL_PROCESS_DETACH) else if (reason == DLL_PROCESS_DETACH)
{ {
+12 -12
View File
@@ -1,11 +1,10 @@
#include "omath/hooks/hooks_manager.hpp"
#include <Windows.h> #include <Windows.h>
#include <d3d9.h> #include <d3d9.h>
#include <imgui.h> #include <imgui.h>
#include <imgui_impl_dx9.h> #include <imgui_impl_dx9.h>
#include <imgui_impl_win32.h> #include <imgui_impl_win32.h>
#include "omath/hooks/hooks_manager.hpp"
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);
namespace namespace
@@ -31,12 +30,14 @@ namespace
ImGui_ImplDX9_Init(device); ImGui_ImplDX9_Init(device);
auto& mgr = omath::hooks::HooksManager::get(); auto& mgr = omath::hooks::HooksManager::get();
mgr.set_on_wnd_proc([](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT> { mgr.set_on_wnd_proc(
[](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT>
{
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp)) if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
return 0; return 0;
return std::nullopt; return std::nullopt;
}); });
mgr.hook_wnd_proc(params.hFocusWindow); std::ignore = mgr.hook_wnd_proc(params.hFocusWindow);
g_initialized = true; g_initialized = true;
} }
@@ -54,11 +55,8 @@ namespace
ImGui_ImplWin32_NewFrame(); ImGui_ImplWin32_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
ImGui::SetNextWindowSize({300.f, 80.f}, ImGuiCond_Once); ImGui::GetIO().MouseDrawCursor = true;
ImGui::SetNextWindowPos({10.f, 10.f}, ImGuiCond_Once); ImGui::ShowDemoWindow();
ImGui::Begin("omath | DX9 hook");
ImGui::Text("Hook active");
ImGui::Text("FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::End(); ImGui::End();
ImGui::EndFrame(); ImGui::EndFrame();
@@ -78,7 +76,8 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
if (reason == DLL_PROCESS_ATTACH) if (reason == DLL_PROCESS_ATTACH)
{ {
DisableThreadLibraryCalls(h_instance); DisableThreadLibraryCalls(h_instance);
CreateThread(nullptr, 0, [](LPVOID) -> DWORD std::thread(
[]()
{ {
while (!GetModuleHandle("d3d9.dll")) while (!GetModuleHandle("d3d9.dll"))
Sleep(100); Sleep(100);
@@ -86,9 +85,10 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
auto& mgr = omath::hooks::HooksManager::get(); auto& mgr = omath::hooks::HooksManager::get();
mgr.set_on_dx9_present(on_present); mgr.set_on_dx9_present(on_present);
mgr.set_on_dx9_reset(on_reset); mgr.set_on_dx9_reset(on_reset);
mgr.hook_dx9(); std::ignore = mgr.hook_dx9();
return 0; return 0;
}, nullptr, 0, nullptr); })
.detach();
} }
else if (reason == DLL_PROCESS_DETACH) else if (reason == DLL_PROCESS_DETACH)
{ {