Skip to content

Commit 685e2db

Browse files
committed
refactor: move sigs
1 parent b194439 commit 685e2db

File tree

2 files changed

+54
-61
lines changed

2 files changed

+54
-61
lines changed

src/Modules/Client.cpp

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,65 +1208,17 @@ bool Client::Init() {
12081208

12091209
/* Boards integration, this gets messy lol */
12101210
if (sar.game->Is(SourceGame_Portal2) || sar.game->Is(SourceGame_PortalStoriesMel)) {
1211-
#ifdef _WIN32
1212-
/* left xrefs here so they are easier to find if different in linux mods */
1213-
1214-
// @ xref: "#PORTAL2_LeaderboardOnlineWarning_Steam"
1215-
auto CPortalLeaderboardPanel_OnThink = Memory::Scan(this->Name(), "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? 53 56 32 DB");
1216-
1217-
// @ xref: "OnProfilesChanged" [CPortalLeaderboardManager::OnEvent]
1218-
// .text:003DE52F 68 6C 87 76 00 push offset aOnprofileschan ; "OnProfilesChanged"
1219-
// .text:003DE534 E8 37 D0 25 00 call sub_63B570
1220-
// ... next fn call
1221-
// .text:003DE544 E8 37 FF FF FF call CUtlStringMap_CPortalLeaderboard_ptr__PurgeAndDeleteElements
1222-
Client::PurgeAndDeleteElements = Memory::Read<decltype(Client::PurgeAndDeleteElements)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 8D 4E 24 E8 ? ? ? ? 5F", 1));
1223-
1224-
// @ xref: "LocatorBG" [CLocatorPanel::PerformLayout]
1225-
// .text:00157EAB 68 C0 6A 78 00 push offset aLocatorbg ; "LocatorBG"
1226-
// ... last fn call
1227-
// .text:00157F0C E8 DF 7B 4F 00 call Panel__SetPos
1228-
Panel_SetPos = Memory::Read<decltype(Panel_SetPos)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 03 5D F0", 1));
1229-
1230-
// @ xref: "crosshair_default" [CHudCrosshair::ApplySchemeSettings]
1231-
// .text:00151B1F 68 6C 5E 78 00 push offset aCrosshairDefau ; "crosshair_default"
1232-
// ... last fn call
1233-
// .text:00151B52 E8 19 E0 4F 00 call Panel__SetSize
1234-
Panel_SetSize = Memory::Read<decltype(Panel_SetSize)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 01 7D EC", 1));
1235-
1236-
// @ xref: "portal_leaderboard_avatar_panel" [BaseModUI::AddAvatarPanelItem]
1237-
// .text:0036000E 68 18 06 80 00 push offset aPortalLeaderbo ; "portal_leaderboard_avatar_panel"
1238-
// ... next fn call
1239-
// .text:00360050 E8 6B DD FF FF call CAvatarPanelItem__SetPlayerData
1240-
Client::SetPlayerData = Memory::Read<decltype(Client::SetPlayerData)>(Memory::Scan(this->Name(), "E8 ? ? ? ? EB 2C A1 ? ? ? ?", 1));
1241-
1242-
// @ xref: "Avatar image for user %llX cached [refcount=%d]\n" [BaseModUI::CUIGameData::AccessAvatarImage]
1243-
// .text:00318CCF E8 8C 60 E5 FF call IMemAlloc__Alloc
1244-
// ... next fn call
1245-
// .text:00318CDD E8 8E B5 FF FF call CGameUiAvatarImage__CGameUiAvatarImage
1246-
// ...
1247-
// .text:00318D98 68 30 60 7E 00 push offset aAvatarImageFor ; "Avatar image for user %llX cached [refc"...
1248-
CGameUiAvatarImage_Ctor = (decltype(CGameUiAvatarImage_Ctor))Memory::Scan(this->Name(), "56 6A 00 8B F1 6A 00 C7 06");
1249-
1250-
// @ xref: "icon_lobby" (fn with Plat_FloatTime call)
1251-
CGameUiAvatarImage_InitFromRGBA = Memory::Read<decltype(CGameUiAvatarImage_InitFromRGBA)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 8A 46 1C", 1));
1252-
1253-
// @ xref: "steamid/%llu" (small fn with only one string)
1254-
Client::ActivateSelectedItem = (decltype(Client::ActivateSelectedItem))Memory::Scan(this->Name(), "55 8B EC 83 EC 40 56 8B F1 E8 ? ? ? ? 8B C8");
1255-
#else
1256-
/* I reversed these from mel binaries so idk how many work in base game */
1257-
1258-
auto CPortalLeaderboardPanel_OnThink = Memory::Scan(this->Name(), "55 89 E5 57 56 53 81 EC ? ? ? ? 65 A1 ? ? ? ? 89 45 E4 31 C0 A1 ? ? ? ? 8B 5D 08 8B 70 30");
1259-
Client::PurgeAndDeleteElements = Memory::Read<decltype(Client::PurgeAndDeleteElements)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 8B 46 10 89 46 20 89 3C 24", 1));
1260-
1261-
// XXX: these two had weird looking function signature in IDA, might not work
1262-
Panel_SetPos = Memory::Read<decltype(Panel_SetPos)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 2B 75 D8", 1));
1263-
Panel_SetSize = Memory::Read<decltype(Panel_SetSize)>(Memory::Scan(this->Name(), "E8 ? ? ? ? EB 68 66 90", 1));
1264-
1265-
Client::SetPlayerData = Memory::Read<decltype(Client::SetPlayerData)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 8B 45 D8 89 83 ? ? ? ? 8B 45 DC 85 C0 75 82", 1));
1266-
CGameUiAvatarImage_Ctor = Memory::Read<decltype(CGameUiAvatarImage_Ctor)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 8B 45 18 89 74 24 04 89 7C 24 08", 1));
1267-
CGameUiAvatarImage_InitFromRGBA = Memory::Read<decltype(CGameUiAvatarImage_InitFromRGBA)>(Memory::Scan(this->Name(), "E8 ? ? ? ? 0F B6 43 1C", 1));
1268-
Client::ActivateSelectedItem = (decltype(Client::ActivateSelectedItem))Memory::Scan(this->Name(), "55 89 E5 53 83 EC 74 65 A1");
1211+
auto CPortalLeaderboardPanel_OnThink = Memory::Scan(this->Name(), Offsets::CPortalLeaderboardPanel_OnThink);
1212+
Client::PurgeAndDeleteElements = Memory::Read<decltype(Client::PurgeAndDeleteElements)>(Memory::Scan(this->Name(), Offsets::PurgeAndDeleteElements, 1));
1213+
Panel_SetPos = Memory::Read<decltype(Panel_SetPos)>(Memory::Scan(this->Name(), Offsets::Panel_SetPos, 1));
1214+
Panel_SetSize = Memory::Read<decltype(Panel_SetSize)>(Memory::Scan(this->Name(), Offsets::Panel_SetSize, 1));
1215+
Client::SetPlayerData = Memory::Read<decltype(Client::SetPlayerData)>(Memory::Scan(this->Name(), Offsets::SetPlayerData, 1));
1216+
CGameUiAvatarImage_Ctor = (decltype(CGameUiAvatarImage_Ctor))Memory::Scan(this->Name(), Offsets::CGameUiAvatarImage_CtorSig, Offsets::CGameUiAvatarImage_CtorOff);
1217+
#ifndef _WIN32
1218+
CGameUiAvatarImage_Ctor = Memory::Read<decltype(CGameUiAvatarImage_Ctor)>((uintptr_t)CGameUiAvatarImage_Ctor);
12691219
#endif
1220+
CGameUiAvatarImage_InitFromRGBA = Memory::Read<decltype(CGameUiAvatarImage_InitFromRGBA)>(Memory::Scan(this->Name(), Offsets::CGameUiAvatarImage_InitFromRGBA, 1));
1221+
Client::ActivateSelectedItem = (decltype(Client::ActivateSelectedItem))Memory::Scan(this->Name(), Offsets::ActivateSelectedItem);
12701222
Client::GetLeaderboard = Memory::Read<decltype(Client::GetLeaderboard)>(CPortalLeaderboardPanel_OnThink + Offsets::GetLeaderboard);
12711223
Client::IsQuerying = Memory::Read<decltype(Client::IsQuerying)>(CPortalLeaderboardPanel_OnThink + Offsets::IsQuerying);
12721224
Client::SetPanelStats = Memory::Read<decltype(Client::SetPanelStats)>(CPortalLeaderboardPanel_OnThink + Offsets::SetPanelStats);

src/Offsets/Portal 2 8491.hpp

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ OFFSET_DEFAULT(IsQuerying, 366, 666)
375375
OFFSET_DEFAULT(SetPanelStats, 413, 1056)
376376
OFFSET_DEFAULT(StartSearching, 172, 262)
377377
OFFSET_DEFAULT(AddAvatarPanelItem, 1102, 1107)
378-
OFFSET_DEFAULT(PurgeAndDeleteElements, 37, 120)
379378

380379
OFFSET_DEFAULT(host_frametime, 92, 81)
381380

@@ -413,15 +412,57 @@ SIGSCAN_DEFAULT(UTIL_Portal_Color_Particles, "55 8B EC 51 8B 0D ? ? ? ? 8B 01 8B
413412
"53 83 EC 14 A1 ? ? ? ? 8B 5C 24 ? 8B 10 50 FF 92 ? ? ? ? 83 C4 10 84 C0 75")
414413
SIGSCAN_DEFAULT(GetNumChapters, "55 8B EC 80 7D 08 00 57 74 0C",
415414
"55 89 E5 56 80 7D")
416-
SIGSCAN_DEFAULT(CPortalLeaderboardPanel_OnThink, "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? 53 56 32 DB",
417-
"55 89 E5 57 56 53 81 EC ? ? ? ? 65 A1 ? ? ? ? 89 45 E4 31 C0 A1 ? ? ? ? 8B 5D 08 8B 70 30")
418415
SIGSCAN_DEFAULT(OnEvent, "55 8B EC 57 8B F9 8B 4D 08 E8",
419416
"55 89 E5 57 56 53 83 EC 1C 8B 45 0C 8B 7D 08 89 04 24 E8 ? ? ? ? C7 04 24")
420417
SIGSCAN_DEFAULT(OnCommand, "55 8B EC 56 57 8B 7D 08 57 68 ? ? ? ? 8B F1 E8 ? ? ? ? 83 C4 08 85 C0 0F 84",
421418
"55 89 E5 57 56 53 83 EC 2C 8B 75 0C C7 04 24 ? ? ? ? 8B 5D 08 89 74 24 04 E8 ? ? ? ? 85 C0 75 3D")
422419
SIGSCAN_EMPTY(GetHudSig)
423420
SIGSCAN_EMPTY(FindElementSig)
424421

422+
// @ xref: "#PORTAL2_LeaderboardOnlineWarning_Steam"
423+
SIGSCAN_DEFAULT(CPortalLeaderboardPanel_OnThink, "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? 53 56 32 DB",
424+
"55 89 E5 57 56 53 81 EC ? ? ? ? 65 A1 ? ? ? ? 89 45 E4 31 C0 A1 ? ? ? ? 8B 5D 08 8B 70 30")
425+
// @ xref: "OnProfilesChanged" [CPortalLeaderboardManager::OnEvent]
426+
// .text:003DE52F 68 6C 87 76 00 push offset aOnprofileschan ; "OnProfilesChanged"
427+
// .text:003DE534 E8 37 D0 25 00 call sub_63B570
428+
// ... next fn call
429+
// .text:003DE544 E8 37 FF FF FF call CUtlStringMap_CPortalLeaderboard_ptr__PurgeAndDeleteElements
430+
SIGSCAN_DEFAULT(PurgeAndDeleteElements, "E8 ? ? ? ? 8D 4E 24 E8 ? ? ? ? 5F",
431+
"E8 ? ? ? ? 8B 46 10 89 46 20 89 3C 24")
432+
// @ xref: "LocatorBG" [CLocatorPanel::PerformLayout]
433+
// .text:00157EAB 68 C0 6A 78 00 push offset aLocatorbg ; "LocatorBG"
434+
// ... last fn call
435+
// .text:00157F0C E8 DF 7B 4F 00 call Panel__SetPos
436+
SIGSCAN_DEFAULT(Panel_SetPos, "E8 ? ? ? ? 03 5D F0",
437+
"E8 ? ? ? ? 2B 75 D8")
438+
// @ xref: "crosshair_default" [CHudCrosshair::ApplySchemeSettings]
439+
// .text:00151B1F 68 6C 5E 78 00 push offset aCrosshairDefau ; "crosshair_default"
440+
// ... last fn call
441+
// .text:00151B52 E8 19 E0 4F 00 call Panel__SetSize
442+
SIGSCAN_DEFAULT(Panel_SetSize, "E8 ? ? ? ? 01 7D EC",
443+
"E8 ? ? ? ? EB 68 66 90")
444+
// @ xref: "portal_leaderboard_avatar_panel" [BaseModUI::AddAvatarPanelItem]
445+
// .text:0036000E 68 18 06 80 00 push offset aPortalLeaderbo ; "portal_leaderboard_avatar_panel"
446+
// ... next fn call
447+
// .text:00360050 E8 6B DD FF FF call CAvatarPanelItem__SetPlayerData
448+
SIGSCAN_DEFAULT(SetPlayerData, "E8 ? ? ? ? EB 2C A1 ? ? ? ?",
449+
"E8 ? ? ? ? 8B 45 D8 89 83 ? ? ? ? 8B 45 DC 85 C0 75 82")
450+
// @ xref: "Avatar image for user %llX cached [refcount=%d]\n" [BaseModUI::CUIGameData::AccessAvatarImage]
451+
// .text:00318CCF E8 8C 60 E5 FF call IMemAlloc__Alloc
452+
// ... next fn call
453+
// .text:00318CDD E8 8E B5 FF FF call CGameUiAvatarImage__CGameUiAvatarImage
454+
// ...
455+
// .text:00318D98 68 30 60 7E 00 push offset aAvatarImageFor ; "Avatar image for user %llX cached [refc"...
456+
SIGSCAN_DEFAULT(CGameUiAvatarImage_CtorSig, "56 6A 00 8B F1 6A 00 C7 06",
457+
"E8 ? ? ? ? 8B 45 18 89 74 24 04 89 7C 24 08")
458+
OFFSET_DEFAULT(CGameUiAvatarImage_CtorOff, 0, 1)
459+
// @ xref: "icon_lobby" (fn with Plat_FloatTime call)
460+
SIGSCAN_DEFAULT(CGameUiAvatarImage_InitFromRGBA, "E8 ? ? ? ? 8A 46 1C",
461+
"E8 ? ? ? ? 0F B6 43 1C")
462+
// @ xref: "steamid/%llu" (small fn with only one string)
463+
SIGSCAN_DEFAULT(ActivateSelectedItem, "55 8B EC 83 EC 40 56 8B F1 E8 ? ? ? ? 8B C8",
464+
"55 89 E5 53 83 EC 74 65 A1")
465+
425466
SIGSCAN_DEFAULT(GetChapterProgress, "56 8B 35 ? ? ? ? 57 8B F9 FF D6 8B 10 8B C8",
426467
"55 89 E5 57 56 53 83 EC 0C E8 ? ? ? ? 83 EC 08 8B 10")
427468

0 commit comments

Comments
 (0)