MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / GetModuleProbe

Method GetModuleProbe

CrySystem/DataProbe.cpp:782–834  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

780
781//////////////////////////////////////////////////////////////////////////
782bool CDataProbe::GetModuleProbe( SDataProbeContext &ctx )
783{
784#ifndef WIN32
785 return false; // Not WIN32
786#else // WIN32
787 if (!ctx.pModuleBaseAddress)
788 {
789 // Try to find module handle from filename.
790 HMODULE hModule = GetModuleHandle( ctx.sFilename.c_str() );
791 if (!hModule)
792 return false;
793 ctx.pModuleBaseAddress = hModule;
794 }
795
796 void *pCodeAddress = 0;
797 int nCodeSize = 0;
798 // Get code sections pointers.
799 GetModuleCodeAddress( ctx.pModuleBaseAddress,&pCodeAddress,&nCodeSize );
800 if (!pCodeAddress || nCodeSize == 0)
801 return false;
802
803 ctx.pBuffer = pCodeAddress;
804 if (IsBadReadPtr( (char*)pCodeAddress+ctx.nOffset,ctx.nSize))
805 {
806 // Something wrong..., cant read code memory, skip it.
807 return false;
808 }
809
810 /*
811 //////////////////////////////////////////////////////////////////////////
812 // Write this to file....
813 CryLog( "[CodeModule] %s, base: %x",ctx.sFilename.c_str(),ctx.pModuleBaseAddress );
814 char *pBuf = (char*)malloc(ctx.nSize + 128);
815 memset(pBuf,0,ctx.nSize+64);
816 memcpy(pBuf,(char*)ctx.pBuffer+ctx.nOffset,ctx.nSize);
817 FILE *file;
818 if (!GetISystem()->IsDedicated())
819 file = fopen( (ctx.sFilename+".client_code").c_str(),"wb" );
820 else
821 file = fopen( (ctx.sFilename+".server_code").c_str(),"wb" );
822 fwrite( pBuf,ctx.nSize,1,file );
823 fclose(file);
824
825 unsigned int nCode = CRC_32( pBuf,ctx.nSize );
826 CryLog( "Code CRC32=%u, offset=%d,size=%d",nCode,ctx.nOffset,ctx.nSize );
827 free(pBuf);
828 //////////////////////////////////////////////////////////////////////////
829 */
830
831
832 return true;
833#endif //WIN32
834}
835
836//////////////////////////////////////////////////////////////////////////
837int CDataProbe::GetLoadedModules( SModuleInfo **pModules )

Callers 1

Calls 2

GetModuleCodeAddressFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected