mirror of
https://github.com/orange-cpp/omath.git
synced 2026-08-07 21:42:05 +00:00
improvement
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
|
#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
|
||||||
{
|
{
|
||||||
bool g_initialized = false;
|
bool g_initialized = false;
|
||||||
bool g_init_attempted = false;
|
bool g_init_attempted = false;
|
||||||
|
|
||||||
void init(IDirect3DDevice9* device)
|
void init(IDirect3DDevice9* device)
|
||||||
@@ -31,11 +30,13 @@ 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(
|
||||||
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
|
[](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT>
|
||||||
return 0;
|
{
|
||||||
return std::nullopt;
|
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
|
||||||
});
|
return 0;
|
||||||
|
return std::nullopt;
|
||||||
|
});
|
||||||
std::ignore = 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,17 +76,19 @@ 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"))
|
{
|
||||||
Sleep(100);
|
while (!GetModuleHandle("d3d9.dll"))
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
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);
|
||||||
std::ignore = 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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user