diff --git a/src/game/Game.h b/src/game/Game.h index 9a4283f..634ca74 100644 --- a/src/game/Game.h +++ b/src/game/Game.h @@ -8,6 +8,21 @@ struct MemCardInfo; struct Level; struct VertexPool; +enum MainState +{ + MS_NONE, + MS_PLAYGAME, + MS_LOADLEVEL, + MS_PLAY_CINEMATIC, + MS_SAMPLER_DEMO_DONE, + MS_ATTRACT_MODE, + MS_DISPLAY_MAIN_MENU, + MS_SHOW_STATIC_SCREEN, + MS_QUITGAME, + MS_PLAY_DARKCHRONICLE_CINEMATIC, + MS_PLAY_DARKCHRONICLE_CINEMATICMOVIE, +}; + struct WipeInfo { float wipeCur; diff --git a/src/modules/MainMenu.cpp b/src/modules/MainMenu.cpp index bb812fe..f615f27 100644 --- a/src/modules/MainMenu.cpp +++ b/src/modules/MainMenu.cpp @@ -3,6 +3,8 @@ #include "MainMenu.h" #include "level/Stream.h" #include "game/Game.h" +#include "util/Hooking.h" +#include "render/Font.h" void MainMenu::OnDraw() { @@ -45,4 +47,17 @@ void MainMenu::BirthObject(char* name) // Birth the instance at the player position INSTANCE_BirthObjectNoParent(game->StreamUnitID, &player->position, &player->rotation, nullptr, tracker->object, 0, 1); +} + +void MainMenu::OnFrame() +{ + auto mainState = *(int*)GET_ADDRESS(0x10E5868, 0x838838, 0x000000); + + if (mainState == MS_DISPLAY_MAIN_MENU) + { + auto font = Font::GetMainFont(); + + font->SetCursor(5.f, 430.f); + font->Print("TRLAU-Menu-Hook"); + } } \ No newline at end of file diff --git a/src/modules/MainMenu.h b/src/modules/MainMenu.h index dbfed32..7bfb723 100644 --- a/src/modules/MainMenu.h +++ b/src/modules/MainMenu.h @@ -9,4 +9,5 @@ class MainMenu : public Module public: void OnDraw(); + void OnFrame(); }; \ No newline at end of file diff --git a/src/render/Font.cpp b/src/render/Font.cpp index 016e9f0..340c366 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -21,22 +21,28 @@ char Font::s_formatted[1024]; Font* Font::GetMainFont() { - return *(Font**)0x7D1800; + return *(Font**)GET_ADDRESS(0x107F680, 0x7D1800, 0x9DE6D4); } void Font::SetCursor(float x, float y) { - Hooking::Call(0x433C70, x, y); + auto addr = GET_ADDRESS(0x431670, 0x433C70, 0x474C90); + + Hooking::Call(addr, x, y); } void Font::GetCursor(float* x, float* y) { - Hooking::Call(0x433C90, x, y); + auto addr = GET_ADDRESS(0x431690, 0x433C90, 0x474CB0); + + Hooking::Call(addr, x, y); } void Font::SetScale(float scaleX, float scaleY) { - Hooking::Call(0x433E60, scaleX, scaleY); + auto addr = GET_ADDRESS(0x431860, 0x433E60, 0x000000); + + Hooking::Call(addr, scaleX, scaleY); } void Font::Print(const char* fmt, ...) @@ -69,19 +75,26 @@ void Font::PrintCentered(const char* fmt, ...) void Font::PrintFormatted(const char* formatted, int backdrop) { - Hooking::ThisCall(0x434A70, this, formatted, backdrop); + auto addr = GET_ADDRESS(0x4323D0, 0x434A70, 0x476BC0); + + Hooking::ThisCall(addr, this, formatted, backdrop); } float Font::GetTextWidth(const char* text) { - return Hooking::ThisCallReturn(0x434510, this, text); + auto addr = GET_ADDRESS(0x431EA0, 0x434510, 0x000000); + + return Hooking::ThisCallReturn(addr, this, text); } void Font::OnFlush(std::function callback) { if (!s_callback) { - MH_CreateHook((void*)0x434C40, Flush, (void**)&s_Flush); + // TODO pattern + auto addr = GET_ADDRESS(0x432570, 0x434C40, 0x476D80); + + MH_CreateHook((void*)addr, Flush, (void**)&s_Flush); MH_EnableHook(MH_ALL_HOOKS); }