Skip to content

Commit 21c3c02

Browse files
committed
MHWilds: Fix UI code (VR, on_*_gui_draw_element, hide UI)
1 parent 1f522aa commit 21c3c02

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/mods/Hooks.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ std::optional<std::string> Hooks::hook_update_camera_controller2() {
275275
}
276276

277277
std::optional<std::string> Hooks::hook_gui_draw() {
278-
// TODO: FIX THIS!!!
279-
#if TDB_VER < 74
280278
spdlog::info("[Hooks] Attempting to hook GUI functions...");
281279

282280
auto game = g_framework->get_module().as<HMODULE>();
@@ -296,6 +294,7 @@ std::optional<std::string> Hooks::hook_gui_draw() {
296294
++*(_DWORD *)(gui_manager + 232);
297295
*(_QWORD *)&v35 = draw_task_function; <-- "gui_draw_call" is found within this function.
298296
*/
297+
size_t offset = 12;
299298
spdlog::info("[Hooks] Scanning for first GUI draw call...");
300299
auto gui_draw_call = utility::scan(game, "49 8B 0C CE 48 83 79 10 00 74 ? E8 ? ? ? ?");
301300

@@ -305,21 +304,28 @@ std::optional<std::string> Hooks::hook_gui_draw() {
305304
gui_draw_call = utility::scan(game, "49 8B 0C CE 48 83 79 20 00 74 ? E8 ? ? ? ?");
306305

307306
if (!gui_draw_call) {
308-
return "Unable to find gui_draw_call pattern.";
307+
// MHWILDS
308+
gui_draw_call = utility::scan(game, "48 8B 0C C3 48 83 79 ? 00 74 ? 48 89 ? E8 ? ? ? ?");
309+
offset = 15;
310+
311+
if (!gui_draw_call) {
312+
//return "Unable to find gui_draw_call pattern.";
313+
spdlog::error("[Hooks] Unable to find gui_draw_call pattern.");
314+
return std::nullopt; // Don't bother erroring out the entire mod just because of this
315+
}
309316
}
310317
}
311318

312319
spdlog::info("[Hooks] Found gui_draw_call at {:x}", *gui_draw_call);
313320

314-
auto gui_draw = utility::calculate_absolute(*gui_draw_call + 12);
321+
auto gui_draw = utility::calculate_absolute(*gui_draw_call + offset);
315322
spdlog::info("[Hooks] gui_draw: {:x}", gui_draw);
316323

317324
m_gui_draw_hook = std::make_unique<FunctionHook>(gui_draw, &gui_draw_hook);
318325

319326
if (!m_gui_draw_hook->create()) {
320327
return "Failed to hook GUI::draw";
321328
}
322-
#endif
323329

324330
return std::nullopt;
325331
}

0 commit comments

Comments
 (0)