MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / IsReturnAddressInModule

Method IsReturnAddressInModule

Process/Process.cpp:642–681  ·  view source on GitHub ↗

IsReturnAddressInModule - returns true if RetAddr is module's mem region Used to detect attackers calling our functions such as heartbeat generation, since they may try to spoof or emulate the net client */

Source from the content-addressed store, hash-verified

640 Used to detect attackers calling our functions such as heartbeat generation, since they may try to spoof or emulate the net client
641*/
642bool Process::IsReturnAddressInModule(__in const uintptr_t RetAddr, __in const wchar_t* module)
643{
644 if (RetAddr == 0)
645 {
646 Logger::logf(Err, "RetAddr was 0 @ : Process::IsReturnAddressInModule");
647 return false;
648 }
649
650 HMODULE retBase = 0;
651
652 if (module == nullptr)
653 {
654 retBase = (HMODULE)GetModuleHandleW(NULL);
655 }
656 else
657 {
658 retBase = (HMODULE)GetModuleHandleW(module);
659 }
660
661 if (retBase == 0)
662 {
663 Logger::logf(Err, "retBase was 0 @ : Process::IsReturnAddressInModule");
664 return false;
665 }
666
667 DWORD size = Process::GetModuleSize(retBase);
668
669 if (size == 0)
670 {
671 Logger::logf(Err, "size was 0 @ : Process::IsReturnAddressInModule");
672 return false;
673 }
674
675 if (RetAddr >= (uintptr_t)retBase && RetAddr < ((uintptr_t)retBase + size))
676 {
677 return true;
678 }
679
680 return false;
681}
682
683/*
684 GetProcessName - Returns the string name of a process with id `pid`

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected