From fd15556a2dcefed7d1f6aeb94c6429044336dd1e Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:08:36 +0300 Subject: [PATCH] i ma carhjsefdd --- src/Handler.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Handler.cpp b/src/Handler.cpp index 3183756..b700ff9 100644 --- a/src/Handler.cpp +++ b/src/Handler.cpp @@ -83,7 +83,14 @@ HookHandle Handler::createHook(void* address, HookMetadata m_metadata) { m_handles.insert({address, hook}); std::cout << "before functions size " << m_content->m_functions.size() << std::endl; - m_content->m_functions.push_back(address); + for (auto it = m_content->m_functions.begin(); it != m_content->m_functions.end(); ++it) { + std::cout << "function " << *it << std::endl; + if (m_hooks.at(m_handles[*it])->m_metadata.m_priority > m_metadata.m_priority) { + m_content->m_functions.insert(it, address); + break; + } + } + this->reorderFunctions(); @@ -117,10 +124,10 @@ void Handler::updateHookMetadata(HookHandle const& hook, HookMetadata const& met void Handler::reorderFunctions() { auto& vec = m_content->m_functions; std::cout << "functions size " << m_content->m_functions.size() << " this " << (void*)this << std::endl; - std::sort(m_content->m_functions.begin(), m_content->m_functions.end(), [this](auto const a, auto const b) { - // std::cout << "reordering this" << a << " " << b << " "<< (void*)this << std::endl; - return a < b; - }); + // std::sort(m_content->m_functions.begin(), m_content->m_functions.end(), [this](auto const a, auto const b) { + // // std::cout << "reordering this" << a << " " << b << " "<< (void*)this << std::endl; + // return a < b; + // }); // std::sort(vec.begin(), vec.end(), [this](auto const a, auto const b) { // std::cout << "reordering " << m_handles[a] << " " << m_handles[b] << std::endl; // return (m_hooks.at(m_handles[a])->m_metadata.m_priority < m_hooks.at(m_handles[b])->m_metadata.m_priority);