@@ -275,8 +275,6 @@ std::optional<std::string> Hooks::hook_update_camera_controller2() {
275
275
}
276
276
277
277
std::optional<std::string> Hooks::hook_gui_draw () {
278
- // TODO: FIX THIS!!!
279
- #if TDB_VER < 74
280
278
spdlog::info (" [Hooks] Attempting to hook GUI functions..." );
281
279
282
280
auto game = g_framework->get_module ().as <HMODULE>();
@@ -296,6 +294,7 @@ std::optional<std::string> Hooks::hook_gui_draw() {
296
294
++*(_DWORD *)(gui_manager + 232);
297
295
*(_QWORD *)&v35 = draw_task_function; <-- "gui_draw_call" is found within this function.
298
296
*/
297
+ size_t offset = 12 ;
299
298
spdlog::info (" [Hooks] Scanning for first GUI draw call..." );
300
299
auto gui_draw_call = utility::scan (game, " 49 8B 0C CE 48 83 79 10 00 74 ? E8 ? ? ? ?" );
301
300
@@ -305,21 +304,28 @@ std::optional<std::string> Hooks::hook_gui_draw() {
305
304
gui_draw_call = utility::scan (game, " 49 8B 0C CE 48 83 79 20 00 74 ? E8 ? ? ? ?" );
306
305
307
306
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
+ }
309
316
}
310
317
}
311
318
312
319
spdlog::info (" [Hooks] Found gui_draw_call at {:x}" , *gui_draw_call);
313
320
314
- auto gui_draw = utility::calculate_absolute (*gui_draw_call + 12 );
321
+ auto gui_draw = utility::calculate_absolute (*gui_draw_call + offset );
315
322
spdlog::info (" [Hooks] gui_draw: {:x}" , gui_draw);
316
323
317
324
m_gui_draw_hook = std::make_unique<FunctionHook>(gui_draw, &gui_draw_hook);
318
325
319
326
if (!m_gui_draw_hook->create ()) {
320
327
return " Failed to hook GUI::draw" ;
321
328
}
322
- #endif
323
329
324
330
return std::nullopt;
325
331
}
0 commit comments