////////////////////////////////////////////////////////// // // MaybeRenameExe // // Figure out whether to use a renamed exe, and return filename to use. // Also tries file copy if required. // ////////////////////////////////////////////////////////// SString CInstallManager::MaybeRenameExe( const SString& strGTAPath ) { // Try patch/copy (may fail if not admin) _ProcessExePatchChecks(); SString strGTAEXEPath = PathJoin( strGTAPath, MTA_GTAEXE_NAME ); if ( ShouldUseExeCopy() ) { // See if exe copy seems usable SString strHTAEXEPath = PathJoin( strGTAPath, MTA_HTAEXE_NAME ); uint uiStdFileSize = FileSize( strGTAEXEPath ); if ( uiStdFileSize && uiStdFileSize == FileSize( strHTAEXEPath ) ) strGTAEXEPath = strHTAEXEPath; } return strGTAEXEPath; }
////////////////////////////////////////////////////////// // // CInstallManager::_ProcessExePatchChecks // // Check which changes need to be made to the exe and make a copy if required // ////////////////////////////////////////////////////////// SString CInstallManager::_ProcessExePatchChecks ( void ) { SExePatchedStatus reqStatus = GetExePatchRequirements(); if ( !ShouldUseExeCopy() ) { // Simple patching if won't be using a exe copy if ( !SetExePatchedStatus( false, reqStatus ) ) { m_strAdminReason = GetPatchExeAdminReason( false, reqStatus ); return "fail"; } } else { // Bit more complercated if will be using a exe copy // First check if we need to create/update the exe copy if ( GetExePatchedStatus( true ) != reqStatus || GetExeFileSize( false ) != GetExeFileSize( true ) ) { // Copy if ( !CopyExe() ) { m_strAdminReason = GetPatchExeAdminReason( true, reqStatus ); return "fail"; } // Apply patches if ( !SetExePatchedStatus( true, reqStatus ) ) { m_strAdminReason = GetPatchExeAdminReason( true, reqStatus ); return "fail"; } } } return "ok"; }
////////////////////////////////////////////////////////// // // GetUsingExePathFilename // // Return full path and filename of exe we will probably be using // ////////////////////////////////////////////////////////// SString GetUsingExePathFilename( void ) { return GetExePathFilename( ShouldUseExeCopy() ); }