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)
|
||||
{
|
||||
DisableThreadLibraryCalls(h_instance);
|
||||
CreateThread(
|
||||
nullptr, 0,
|
||||
[](LPVOID) -> DWORD
|
||||
std::thread(
|
||||
[]()
|
||||
{
|
||||
while (!GetModuleHandle("d3d12.dll"))
|
||||
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);
|
||||
std::ignore = mgr.hook_dx12();
|
||||
return 0;
|
||||
},
|
||||
nullptr, 0, nullptr);
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
else if (reason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#include "omath/hooks/hooks_manager.hpp"
|
||||
#include <Windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx9.h>
|
||||
#include <imgui_impl_win32.h>
|
||||
|
||||
#include "omath/hooks/hooks_manager.hpp"
|
||||
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
namespace
|
||||
{
|
||||
bool g_initialized = false;
|
||||
bool g_initialized = false;
|
||||
bool g_init_attempted = false;
|
||||
|
||||
void init(IDirect3DDevice9* device)
|
||||
@@ -31,11 +30,13 @@ namespace
|
||||
ImGui_ImplDX9_Init(device);
|
||||
|
||||
auto& mgr = omath::hooks::HooksManager::get();
|
||||
mgr.set_on_wnd_proc([](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT> {
|
||||
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
|
||||
return 0;
|
||||
return std::nullopt;
|
||||
});
|
||||
mgr.set_on_wnd_proc(
|
||||
[](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT>
|
||||
{
|
||||
if (ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp))
|
||||
return 0;
|
||||
return std::nullopt;
|
||||
});
|
||||
std::ignore = mgr.hook_wnd_proc(params.hFocusWindow);
|
||||
|
||||
g_initialized = true;
|
||||
@@ -54,11 +55,8 @@ namespace
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::SetNextWindowSize({300.f, 80.f}, ImGuiCond_Once);
|
||||
ImGui::SetNextWindowPos({10.f, 10.f}, ImGuiCond_Once);
|
||||
ImGui::Begin("omath | DX9 hook");
|
||||
ImGui::Text("Hook active");
|
||||
ImGui::Text("FPS: %.1f", ImGui::GetIO().Framerate);
|
||||
ImGui::GetIO().MouseDrawCursor = true;
|
||||
ImGui::ShowDemoWindow();
|
||||
ImGui::End();
|
||||
|
||||
ImGui::EndFrame();
|
||||
@@ -78,17 +76,19 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
|
||||
if (reason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
DisableThreadLibraryCalls(h_instance);
|
||||
CreateThread(nullptr, 0, [](LPVOID) -> DWORD
|
||||
{
|
||||
while (!GetModuleHandle("d3d9.dll"))
|
||||
Sleep(100);
|
||||
std::thread(
|
||||
[]()
|
||||
{
|
||||
while (!GetModuleHandle("d3d9.dll"))
|
||||
Sleep(100);
|
||||
|
||||
auto& mgr = omath::hooks::HooksManager::get();
|
||||
mgr.set_on_dx9_present(on_present);
|
||||
mgr.set_on_dx9_reset(on_reset);
|
||||
std::ignore = mgr.hook_dx9();
|
||||
return 0;
|
||||
}, nullptr, 0, nullptr);
|
||||
auto& mgr = omath::hooks::HooksManager::get();
|
||||
mgr.set_on_dx9_present(on_present);
|
||||
mgr.set_on_dx9_reset(on_reset);
|
||||
std::ignore = mgr.hook_dx9();
|
||||
return 0;
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
else if (reason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user