MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / FindRemoteStorageVtable

Method FindRemoteStorageVtable

src/platform/linux/vtable_hook.cpp:443–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443void** VtableHook::FindRemoteStorageVtable(uintptr_t steamBase, size_t steamSize)
444{
445 const size_t nameLen = strlen(RTTI_REMOTE_STORAGE);
446
447 // Find RTTI string
448 const uint8_t* rttiStr = FindBytes(RTTI_REMOTE_STORAGE, nameLen + 1, steamBase, steamSize);
449 if (!rttiStr)
450 {
451 Log::Error("RTTI string '%s' not found in steamclient.so", RTTI_REMOTE_STORAGE);
452 return nullptr;
453 }
454 uintptr_t rttiStrAddr = reinterpret_cast<uintptr_t>(rttiStr);
455 uintptr_t rttiStrVaddr = rttiStrAddr - steamBase;
456 Log::Debug("CUserRemoteStorage RTTI at %p (vaddr 0x%zx)", rttiStr, (size_t)rttiStrVaddr);
457
458 // Find typeinfo (relocations already waited on by Transport)
459 const uintptr_t* nameField = FindPointerValue(rttiStrAddr, rttiStrVaddr,
460 steamBase, steamSize);
461 if (!nameField)
462 {
463 Log::Error("typeinfo for CUserRemoteStorage not found");
464 return nullptr;
465 }
466 const uintptr_t* typeinfo = nameField - 1;
467 uintptr_t typeinfoAddr = reinterpret_cast<uintptr_t>(typeinfo);
468 Log::Debug("CUserRemoteStorage typeinfo at %p", typeinfo);
469
470 // Find vtable: [offset_to_top=0, typeinfo_ptr]
471 void** vtableFuncs = nullptr;
472 for (int r = 0; r < g_readableCount && !vtableFuncs; r++)
473 {
474 if (g_readableRanges[r].end <= steamBase ||
475 g_readableRanges[r].start >= steamBase + steamSize)
476 continue;
477
478 const uintptr_t* scanStart = reinterpret_cast<const uintptr_t*>(
479 (g_readableRanges[r].start + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1));
480 const uintptr_t* scanEnd = reinterpret_cast<const uintptr_t*>(
481 g_readableRanges[r].end & ~(sizeof(uintptr_t) - 1));
482
483 for (const uintptr_t* p = scanStart; p + 1 < scanEnd; p++)
484 {
485 if (*p == 0 && *(p + 1) == typeinfoAddr)
486 {
487 vtableFuncs = reinterpret_cast<void**>(const_cast<uintptr_t*>(p + 2));
488 break;
489 }
490 }
491 }
492
493 if (!vtableFuncs)
494 {
495 Log::Error("vtable for CUserRemoteStorage not found");
496 return nullptr;
497 }
498
499 if (!CanReadMemory(vtableFuncs, 25 * sizeof(void*)))
500 {

Callers

nothing calls this directly

Calls 4

FindBytesFunction · 0.85
FindPointerValueFunction · 0.85
CanReadMemoryFunction · 0.85
ResolveCloudEnabledSlotFunction · 0.85

Tested by

no test coverage detected