Skip to content

Commit

Permalink
Merge pull request #388 from spelunky-fyi/steam-overlay
Browse files Browse the repository at this point in the history
Fix steam overlay hook patterns
  • Loading branch information
Dregu authored Jun 27, 2024
2 parents 1536e5b + 6354450 commit 287f63c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/game_api/window_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ void hook_steam_overlay()
// Lets detour the steam overlay instead!
DEBUG("Steam detected, hooking Steam Overlay...");

size_t present_offset = find_inst(steam_overlay, "\x48\x89\x74\x24\x20\x41\x56\x48\x83\xEC\x20\x41\x8B\xE8\x8B\xF2"sv, 0, 0x99999, "steam_overlay_present"sv);
size_t resize_offset = find_inst(steam_overlay, "\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x41\x56\x41\x57\x48\x83\xEC\x30\x44\x8B\xFA\x48\x8B\xF1\x48\x8B\xD1\x41\x8B\xE9"sv, 0, 0x99999, "steam_overlay_resize"sv);
size_t present_offset = find_inst(steam_overlay, "\x48\x8b\x4f\x40\x48\x8d\x15"sv, 0, 0x99999, "steam_overlay_present"sv, false);
size_t resize_offset = find_inst(steam_overlay, "\x48\x8b\x4f\x68\x48\x8d\x15"sv, 0, 0x99999, "steam_overlay_resize"sv, false);

if (present_offset == 0 || resize_offset == 0)
{
Expand All @@ -416,8 +416,13 @@ void hook_steam_overlay()
return;
}

g_OrigSwapChainPresent = (PresentPtr)(steam_overlay + present_offset - 5);
g_OrigSwapChainResizeBuffers = (ResizeBuffersPtr)(steam_overlay + resize_offset - 5);
auto present_offset2 = *(int*)(steam_overlay + present_offset + 7);
auto resize_offset2 = *(int*)(steam_overlay + resize_offset + 7);
present_offset = present_offset + 7 + 4 + present_offset2;
resize_offset = resize_offset + 7 + 4 + resize_offset2;

g_OrigSwapChainPresent = (PresentPtr)(steam_overlay + present_offset);
g_OrigSwapChainResizeBuffers = (ResizeBuffersPtr)(steam_overlay + resize_offset);

DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
Expand Down

0 comments on commit 287f63c

Please sign in to comment.