mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 03:43:15 +08:00
fix(callhook): fix CallHook when other modules are resident
This commit is contained in:
@@ -4,7 +4,7 @@ namespace YimMenu
|
||||
{
|
||||
CallHookMemory::CallHookMemory()
|
||||
{
|
||||
m_Memory = VirtualAlloc((void*)((uintptr_t)GetModuleHandle(0) + 0x20000000), 1024, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
m_Memory = VirtualAlloc((void*)((uintptr_t)GetModuleHandle(0) + 0x40000000), 1024, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
m_Offset = 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,10 @@ namespace YimMenu
|
||||
{
|
||||
if (!m_Enabled)
|
||||
{
|
||||
DWORD oldProtect, temp;
|
||||
VirtualProtect(m_Location, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
memcpy(m_Location, m_PatchedBytes, 5);
|
||||
VirtualProtect(m_Location, 5, oldProtect, &temp);
|
||||
m_Enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +54,10 @@ namespace YimMenu
|
||||
{
|
||||
if (m_Enabled)
|
||||
{
|
||||
DWORD oldProtect, temp;
|
||||
VirtualProtect(m_Location, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
memcpy(m_Location, m_OriginalBytes, 5);
|
||||
VirtualProtect(m_Location, 5, oldProtect, &temp);
|
||||
m_Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
|
||||
namespace YimMenu
|
||||
{
|
||||
Renderer::Renderer()
|
||||
Renderer::Renderer() :
|
||||
m_Initialized(false),
|
||||
m_Resizing(false),
|
||||
m_FontsUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -340,6 +343,13 @@ namespace YimMenu
|
||||
|
||||
void Renderer::DX12NewFrame()
|
||||
{
|
||||
if (GetInstance().m_FontsUpdated)
|
||||
{
|
||||
DX12PreResize();
|
||||
DX12PostResize();
|
||||
GetInstance().m_FontsUpdated = false;
|
||||
}
|
||||
|
||||
ImGui_ImplDX12_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
@@ -151,6 +151,11 @@ namespace YimMenu
|
||||
GetInstance().ResizeImpl(scale);
|
||||
}
|
||||
|
||||
static void SetFontsUpdated()
|
||||
{
|
||||
GetInstance().m_FontsUpdated = true;
|
||||
}
|
||||
|
||||
private:
|
||||
static void DX12NewFrame();
|
||||
static void DX12EndFrame();
|
||||
@@ -206,6 +211,8 @@ namespace YimMenu
|
||||
HANDLE m_SwapchainWaitableObject{};
|
||||
UINT64 m_FrameIndex{};
|
||||
|
||||
bool m_FontsUpdated;
|
||||
|
||||
private:
|
||||
//Other
|
||||
std::map<joaat_t, RendererCallBack> m_RendererCallBacks;
|
||||
|
||||
@@ -93,6 +93,38 @@ namespace YimMenu
|
||||
style.GrabRounding = style.FrameRounding = style.ChildRounding = style.WindowRounding = 8.0f;
|
||||
}
|
||||
|
||||
static const ImWchar* GetGlyphRangesCyrillicOnly()
|
||||
{
|
||||
static const ImWchar ranges[] =
|
||||
{
|
||||
0x0400,
|
||||
0x052F, // Cyrillic + Cyrillic Supplement
|
||||
0x2DE0,
|
||||
0x2DFF, // Cyrillic Extended-A
|
||||
0xA640,
|
||||
0xA69F, // Cyrillic Extended-B
|
||||
0,
|
||||
};
|
||||
return &ranges[0];
|
||||
}
|
||||
|
||||
static ImFont* CreateFontWithCyrillicSupport(ImGuiIO& io, float size)
|
||||
{
|
||||
ImFontConfig FontCfg{};
|
||||
FontCfg.FontDataOwnedByAtlas = false;
|
||||
|
||||
auto font = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), size, &FontCfg, io.Fonts->GetGlyphRangesDefault());
|
||||
|
||||
// just use Arial for Cyrillic
|
||||
|
||||
FontCfg.MergeMode = true;
|
||||
io.Fonts->AddFontFromFileTTF((std::filesystem::path(std::getenv("SYSTEMROOT")) / "Fonts" / "arial.ttf").string().c_str(), size, &FontCfg, GetGlyphRangesCyrillicOnly());
|
||||
|
||||
io.Fonts->Build();
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void Menu::SetupFonts()
|
||||
{
|
||||
auto& IO = ImGui::GetIO();
|
||||
@@ -103,14 +135,16 @@ namespace YimMenu
|
||||
ImFontConfig FontCfg{};
|
||||
FontCfg.FontDataOwnedByAtlas = false;
|
||||
|
||||
Menu::Font::g_DefaultFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_DefaultFontSize, &FontCfg);
|
||||
Menu::Font::g_OptionsFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_OptionsFontSize, &FontCfg);
|
||||
Menu::Font::g_ChildTitleFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_ChildTitleFontSize, &FontCfg);
|
||||
Menu::Font::g_ChatFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_ChatFontSize, &FontCfg);
|
||||
Menu::Font::g_OverlayFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_OverlayFontSize, &FontCfg);
|
||||
IO.Fonts->Clear();
|
||||
Menu::Font::g_DefaultFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_DefaultFontSize);
|
||||
Menu::Font::g_OptionsFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_OptionsFontSize);
|
||||
Menu::Font::g_ChildTitleFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_ChildTitleFontSize);
|
||||
Menu::Font::g_ChatFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_ChatFontSize);
|
||||
Menu::Font::g_OverlayFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_OverlayFontSize);
|
||||
static const ImWchar full_range[] = {0x0020, 0xFFFF, 0};
|
||||
Menu::Font::g_AwesomeFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::IconFont), sizeof(Fonts::IconFont), Menu::Font::g_AwesomeFontSize, &FontCfg, full_range);
|
||||
|
||||
|
||||
UIManager::SetOptionsFont(Menu::Font::g_OptionsFont);
|
||||
Renderer::SetFontsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user