MCPcopy Create free account
hub / github.com/Rat431/ColdAPI_Steam / Patch

Function Patch

src/ColdAPI_Steam/SteamStubBypass/SteamStub.cpp:481–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479 return true;
480 }
481 void Patch()
482 {
483 // Get main module base address, assuming is our target.
484 HMODULE hExe = GetModuleHandleA(NULL);
485
486 // Get module header informations.
487 auto DosHeader = (IMAGE_DOS_HEADER*)hExe;
488 auto ntheader = (IMAGE_NT_HEADERS*)((ULONG_PTR)hExe + DosHeader->e_lfanew);
489 auto psection = IMAGE_FIRST_SECTION(ntheader);
490
491 // Check if .bind section is present as usually used by Steam stub.
492 int stubdetected = 0;
493 ULONG_PTR strt1, end1;
494 for (int i = 0; i < ntheader->FileHeader.NumberOfSections; i++)
495 {
496 if (std::strcmp((char*)psection->Name, ".bind") == 0)
497 {
498 strt1 = (ULONG_PTR)hExe + psection->VirtualAddress;
499 end1 = (ULONG_PTR)strt1 + psection->Misc.VirtualSize;
500 stubdetected = 1;
501 break;
502 }
503 psection++;
504 }
505 // Check if the main module entrypoint is into the .bind section range.
506 ULONG_PTR entrypoint = (ULONG_PTR)hExe + ntheader->OptionalHeader.AddressOfEntryPoint;
507 for (ULONG_PTR i = strt1; i < end1; i++) {
508 if (entrypoint == i) {
509 stubdetected = 2;
510 break;
511 }
512 }
513 if (stubdetected == 2)
514 {
515#if (!_DEBUG)
516 PatchSteamStub(strt1, end1, (ULONG_PTR)hExe + ntheader->OptionalHeader.AddressOfEntryPoint);
517#else
518 MessageBoxA(NULL, "Please compile this DLL in release mode to use SteamStub bypass feature. It might be unstable with debug mode!", "Error", MB_ICONWARNING);
519 ExitProcess(NULL);
520#endif
521 }
522 }
523}

Callers 1

Calls 1

PatchSteamStubFunction · 0.85

Tested by

no test coverage detected