Пример #1
0
//////////////////////////////////////////////////////////
//
// ValidateGTAPath
//
// Check GTA path looks good
//
//////////////////////////////////////////////////////////
void ValidateGTAPath( void )
{
    // Get path to GTA
    ePathResult iResult = DiscoverGTAPath( true );
    if ( iResult == GAME_PATH_MISSING ) {
        DisplayErrorMessageBox ( _("Registry entries are missing. Please reinstall Multi Theft Auto: San Andreas."), _E("CL12"), "reg-entries-missing" );
        return ExitProcess( EXIT_ERROR );
    }
    else if ( iResult == GAME_PATH_UNICODE_CHARS ) {
        DisplayErrorMessageBox ( _("The path to your installation of GTA: San Andreas contains unsupported (unicode) characters. Please move your Grand Theft Auto: San Andreas installation to a compatible path that contains only standard ASCII characters and reinstall Multi Theft Auto: San Andreas."), _E("CL13") );
        return ExitProcess( EXIT_ERROR );
    }
    else if ( iResult == GAME_PATH_STEAM ) {
        DisplayErrorMessageBox ( _("It appears you have a Steam version of GTA:SA, which is currently incompatible with MTASA.  You are now being redirected to a page where you can find information to resolve this issue."), _E("CL14") );
        BrowseToSolution ( "downgrade-steam" );
        return ExitProcess( EXIT_ERROR );
    }

    SString strGTAPath = GetGTAPath();

    // We can now set this
    SetCurrentDirectory ( strGTAPath );

    const SString strMTASAPath = GetMTASAPath ();
    if ( strGTAPath.Contains ( ";" ) || strMTASAPath.Contains ( ";" ) )
    {
        DisplayErrorMessageBox (_( "The path to your installation of 'MTA:SA' or 'GTA: San Andreas'\n"
                                   "contains a ';' (semicolon).\n\n"
                                   " If you experience problems when running MTA:SA,\n"
                                   " move your installation(s) to a path that does not contain a semicolon." ), _E("CL15"), "path-semicolon" );
    }
}
Пример #2
0
//////////////////////////////////////////////////////////
//
// CheckLibVersions
//
// Ensure DLLs are the correct version
//
//////////////////////////////////////////////////////////
void CheckLibVersions( void )
{
#if MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE

    const char* moduleList [] =     { "MTA\\loader.dll"
                                     ,"MTA\\cgui.dll"
                                     ,"MTA\\core.dll"
                                     ,"MTA\\game_sa.dll"
                                     ,"MTA\\multiplayer_sa.dll"
                                     ,"MTA\\netc.dll"
                                     ,"MTA\\xmll.dll"
                                     ,"MTA\\game_sa.dll"
                                     ,"mods\\deathmatch\\client.dll"
                                     ,"mods\\deathmatch\\pcre3.dll"
                                    };
    SString strReqFileVersion;
    for ( uint i = 0 ; i < NUMELMS( moduleList ) ; i++ )
    {
        SString strFilename = moduleList[i];
#ifdef MTA_DEBUG
        strFilename = ExtractBeforeExtension( strFilename ) + "_d." + ExtractExtension( strFilename );
#endif
        SLibVersionInfo fileInfo;
        if ( FileExists( CalcMTASAPath( strFilename ) ) )
        {
            SString strFileVersion = "0.0.0.0";
            if ( GetLibVersionInfo( CalcMTASAPath( strFilename ), &fileInfo ) )
                strFileVersion = SString( "%d.%d.%d.%d", fileInfo.dwFileVersionMS >> 16, fileInfo.dwFileVersionMS & 0xFFFF
                                                       , fileInfo.dwFileVersionLS >> 16, fileInfo.dwFileVersionLS & 0xFFFF );
            if ( strReqFileVersion.empty() )
                strReqFileVersion = strFileVersion;
            else
            if ( strReqFileVersion != strFileVersion )
            {
                DisplayErrorMessageBox ( SStringX(_( "File version mismatch error."
                                            " Reinstall MTA:SA if you experience problems.\n" )
                                            + SString( "\n[%s %s/%s]\n", *strFilename, *strFileVersion, *strReqFileVersion )
                                            ), _E("CL40"), "bad-file-version" );
                break;
            }
        }
        else
        {
            DisplayErrorMessageBox ( SStringX(_( "Some files are missing."
                                        " Reinstall MTA:SA if you experience problems.\n" )
                                        + SString( "\n[%s]\n", *strFilename )
                                        ), _E("CL41"), "missing-file" );
            break;
        }
    }
Пример #3
0
int CRegistry::GetInt(LPCTSTR pszSection, LPCTSTR pszName, int nDefault)
{
	int nValue = nDefault;
	DWORD nErrorCode;
	CString strKey;
	HKEY hKey;
	
	strKey.Format( _T("Software\\%s\\%s\\%s"), gcszCopyright, theApp.m_pszProfileName, pszSection );
	
	nErrorCode = RegOpenKeyEx( HKEY_CURRENT_USER, strKey, 0, KEY_READ, &hKey );
	
	if ( nErrorCode == ERROR_SUCCESS )
	{
		DWORD nType = 0, nSize = sizeof(nValue);
		
		nErrorCode = RegQueryValueEx( hKey, pszName, 0, &nType, (PBYTE)&nValue, &nSize ); 
		
		if ( nType != REG_DWORD || nSize != sizeof(nValue) )
		{
			nErrorCode = ERROR_MORE_DATA;
			nValue = nDefault;
		}
		
		RegCloseKey( hKey );
	}
	
	if ( nErrorCode != ERROR_SUCCESS ) DisplayErrorMessageBox( nErrorCode );
	
	return nValue;
}
Пример #4
0
CString CRegistry::GetString(LPCTSTR pszSection, LPCTSTR pszName, LPCTSTR pszDefault)
{
	CString strKey, strValue;
	DWORD nErrorCode;
	HKEY hKey;
	
	if ( pszDefault != NULL ) strValue = pszDefault;
	strKey.Format( _T("Software\\%s\\%s\\%s"), gcszCopyright, theApp.m_pszProfileName, pszSection );
	
	nErrorCode = RegOpenKeyEx( HKEY_CURRENT_USER, strKey, 0, KEY_READ, &hKey );

	if ( nErrorCode == ERROR_SUCCESS )
	{
		DWORD nType = 0, nSize = 0;
		
		nErrorCode = RegQueryValueEx( hKey, pszName, 0, &nType, NULL, &nSize ); 

		if ( nErrorCode == ERROR_SUCCESS && nType == REG_SZ && nSize >= sizeof(TCHAR) )
		{
			LPTSTR pszValue = strValue.GetBuffer( nSize / sizeof(TCHAR) - 1 );
			nErrorCode = RegQueryValueEx( hKey, pszName, 0, &nType, (PBYTE)pszValue, &nSize ); 
			strValue.ReleaseBuffer( nSize / sizeof(TCHAR) - 1 );
		}
		
		RegCloseKey( hKey );
	}
	
	if ( nErrorCode != ERROR_SUCCESS ) DisplayErrorMessageBox( nErrorCode );
	
	return strValue;
}
Пример #5
0
BOOL CRegistry::SetInt(LPCTSTR pszSection, LPCTSTR pszName, int nValue)
{
	DWORD nErrorCode;
	CString strKey;
	HKEY hKey;
	
	strKey.Format( _T("Software\\%s\\%s\\%s"), gcszCopyright, theApp.m_pszProfileName, pszSection );
	
	nErrorCode = RegCreateKeyEx( HKEY_CURRENT_USER, strKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL );
	
	if ( nErrorCode == ERROR_SUCCESS )
	{
		nErrorCode = RegSetValueEx( hKey, pszName, 0, REG_DWORD,
							(const BYTE *)&nValue, sizeof(nValue) );
		
		RegCloseKey( hKey );
	}
	
	if ( nErrorCode == ERROR_SUCCESS )
	{
		return TRUE;
	}
	else
	{
		DisplayErrorMessageBox( nErrorCode );
		return FALSE;
	}
}
Пример #6
0
//////////////////////////////////////////////////////////
//
// HandleNotUsedMainMenu
//
// Called when a problem occured before the main menu was used by user
// If fullscreen, then maybe change fullscreen mode
//
//////////////////////////////////////////////////////////
void HandleNotUsedMainMenu ( void )
{
    AddReportLog( 9310, "Loader - HandleNotUsedMainMenu" );
    {
        // Slighty hacky way of checking in-game settings
        SString strCoreConfigFilename = CalcMTASAPath( PathJoin( "mta", "config", "coreconfig.xml" ) );
        SString strCoreConfig;
        FileLoad( strCoreConfigFilename, strCoreConfig );
        SString strWindowed        = strCoreConfig.SplitRight( "<display_windowed>" ).Left( 1 );
        SString strFullscreenStyle = strCoreConfig.SplitRight( "<display_fullscreen_style>" ).Left( 1 );
        if ( strFullscreenStyle == "1" )
        {
            AddReportLog( 9315, "Loader - HandleNotUsedMainMenu - Already Borderless window" );
        }
        else
        if ( !strWindowed.empty() && !strFullscreenStyle.empty())
        {
            if ( strWindowed == "0" && strFullscreenStyle == "0" )   // 0=FULLSCREEN_STANDARD
            {
                // Inform user
                SString strMessage = _("Are you having problems running MTA:SA?.\n\nDo you want to change the following setting?");
                strMessage += "\n" + _("Fullscreen mode:") + " -> " + _("Borderless window");
                HideSplash();
                int iResponse = MessageBoxUTF8 ( NULL, strMessage, "MTA: San Andreas", MB_YESNO | MB_ICONQUESTION | MB_TOPMOST );
                if ( iResponse == IDYES )
                {
                    // Very hacky way of changing in-game settings
                    strCoreConfig = strCoreConfig.Replace( "<display_fullscreen_style>0", "<display_fullscreen_style>1" );
                    FileSave( strCoreConfigFilename, strCoreConfig );
                    AddReportLog( 9311, "Loader - HandleNotUsedMainMenu - User change to Borderless window" );
                }
                else
                    AddReportLog( 9313, "Loader - HandleNotUsedMainMenu - User said no" );
            }
            else
                AddReportLog( 9314, "Loader - HandleNotUsedMainMenu - Mode not fullscreen standard" );
        }
        else
        {
            // If no valid settings file yet, do the change without asking
            strCoreConfig = "<mainconfig><settings><display_fullscreen_style>1</display_fullscreen_style></settings></mainconfig>";
            FileSave( strCoreConfigFilename, strCoreConfig );
            AddReportLog( 9312, "Loader - HandleNotUsedMainMenu - Set Borderless window" );
        }
    }

    // Check if Evolve is active
    for ( auto processId : MyEnumProcesses( true ) )
    {
        SString strFilename = ExtractFilename( GetProcessPathFilename( processId ) );
        if ( strFilename.BeginsWithI( "Evolve" ) )
        {
            SString strMessage = _("Are you having problems running MTA:SA?.\n\nTry disabling the following products for GTA and MTA:");
            strMessage += "\n\nEvolve";
            DisplayErrorMessageBox ( strMessage, _E("CL43"), "not-used-menu-evolve" );
            break;
        }
    }
}
Пример #7
0
BOOL CRegistry::RemoveValue(LPCTSTR pszSection, LPCTSTR pszName)
{
	DWORD nErrorCode;
	CString strKey;
	HKEY hKey;
	
	strKey.Format( _T("Software\\%s\\%s\\%s"), gcszCopyright, theApp.m_pszProfileName, pszSection );
	
	nErrorCode = RegOpenKeyEx( HKEY_CURRENT_USER, strKey, 0, KEY_ALL_ACCESS, &hKey );
	
	if ( nErrorCode == ERROR_SUCCESS )
	{
		nErrorCode = RegDeleteValue( hKey, pszName );
		RegCloseKey( hKey );
	}
	
	if ( nErrorCode != ERROR_SUCCESS ) DisplayErrorMessageBox( nErrorCode );
	
	return TRUE;
}
Пример #8
0
//////////////////////////////////////////////////////////
//
// HandleCustomStartMessage
//
//
//
//////////////////////////////////////////////////////////
void HandleCustomStartMessage ( void )
{
    SString strStartMessage = GetApplicationSetting( "diagnostics", "start-message" );
    SString strTrouble = GetApplicationSetting( "diagnostics", "start-message-trouble" );

    if ( strStartMessage.empty() )
        return;

    SetApplicationSetting( "diagnostics", "start-message", "" );
    SetApplicationSetting( "diagnostics", "start-message-trouble", "" );

    if ( strStartMessage.BeginsWith( "vdetect" ) )
    {
        SString strFilename = strStartMessage.SplitRight( "name=" );
        strStartMessage = _( "WARNING\n\n"
                             "MTA:SA has detected unusual activity.\n"
                             "Please run a virus scan to ensure your system is secure.\n\n" );
        strStartMessage += SString( _( "The detected file was:  %s\n" ), *strFilename );
    }

    DisplayErrorMessageBox( strStartMessage, _E("CL37"), strTrouble );
}
Пример #9
0
//////////////////////////////////////////////////////////
//
// CheckDataFiles
//
// Basic check for some essential files
//
//////////////////////////////////////////////////////////
void CheckDataFiles( void )
{
    const SString strMTASAPath = GetMTASAPath();
    const SString strGTAPath = GetGTAPath();

    const char* dataFilesFiles [] = { "MTA\\cgui\\images\\background_logo.png"
                                     ,"MTA\\cgui\\images\\radarset\\up.png"
                                     ,"MTA\\cgui\\images\\busy_spinner.png"
                                     ,"MTA\\cgui\\images\\rect_edge.png"
                                     ,"MTA\\D3DX9_42.dll"
                                     ,"MTA\\D3DCompiler_42.dll"
                                     ,"MTA\\bass.dll"
                                     ,"MTA\\bass_fx.dll"
                                     ,"MTA\\tags.dll"
                                     ,"MTA\\sa.dat"
                                     ,"MTA\\XInput9_1_0_mta.dll"
                                     ,"MTA\\vea.dll"};

    for ( uint i = 0 ; i < NUMELMS( dataFilesFiles ) ; i++ )
    {
        if ( !FileExists ( PathJoin( strMTASAPath, dataFilesFiles [ i ] ) ) )
        {
            DisplayErrorMessageBox ( _("Load failed. Please ensure that the latest data files have been installed correctly."), _E("CL16"), "mta-datafiles-missing" );
            return ExitProcess( EXIT_ERROR );
        }
    }

    if ( FileSize ( PathJoin( strMTASAPath, "MTA", "bass.dll" ) ) != 0x0001A440 )
    {
        DisplayErrorMessageBox ( _("Load failed. Please ensure that the latest data files have been installed correctly."), _E("CL17"), "mta-datafiles-missing" );
        return ExitProcess( EXIT_ERROR );
    }

    // Check for client file
    if ( !FileExists ( PathJoin( strMTASAPath, CHECK_DM_CLIENT_NAME ) ) )
    {
        DisplayErrorMessageBox ( SString(_("Load failed. Please ensure that %s is installed correctly."),CHECK_DM_CLIENT_NAME), _E("CL18"), "client-missing" );
        return ExitProcess( EXIT_ERROR );
    }

    // Make sure the gta executable exists
    if ( !FileExists( PathJoin( strGTAPath, MTA_GTAEXE_NAME ) ) )
    {
        DisplayErrorMessageBox ( SString ( _("Load failed. Could not find gta_sa.exe in %s."), strGTAPath.c_str () ), _E("CL20"), "gta_sa-missing" );
        return ExitProcess( EXIT_ERROR );
    }

    // Make sure important dll's do not exist in the wrong place
    const char* dllCheckList[] = { "xmll.dll", "cgui.dll", "netc.dll", "libcurl.dll", "pthread.dll" };
    for ( int i = 0 ; i < NUMELMS ( dllCheckList ); i++ )
    {
        if ( FileExists( PathJoin( strGTAPath, dllCheckList[i] ) ) )
        {
            DisplayErrorMessageBox ( SString ( _("Load failed. %s exists in the GTA directory. Please delete before continuing."), dllCheckList[i] ), _E("CL21"), "file-clash" );
            return ExitProcess( EXIT_ERROR );
        }    
    }

    // Check main exe has the correct name
    if ( GetLaunchFilename().CompareI( MTA_EXE_NAME ) == false )
    {
        SString strMessage( _("Main file has an incorrect name (%s)"), *GetLaunchFilename() );
        int iResponse = MessageBoxUTF8 ( NULL, strMessage, _("Error")+_E("CL33"), MB_RETRYCANCEL | MB_ICONERROR | MB_TOPMOST  );
        ReleaseSingleInstanceMutex ();
        if ( iResponse == IDRETRY )
            ShellExecuteNonBlocking( "open", PathJoin ( strMTASAPath, MTA_EXE_NAME ) );            
        return ExitProcess( EXIT_ERROR );
    }

    // Check for possible virus file changing activities
    if ( !VerifyEmbeddedSignature( PathJoin( strMTASAPath, MTA_EXE_NAME ) ) )
    {
        SString strMessage( _("Main file is unsigned. Possible virus activity.\n\nSee online help if MTA does not work correctly.") );
        #if MTASA_VERSION_BUILD > 0 && defined(MTA_DM_CONNECT_TO_PUBLIC) && !defined(MTA_DEBUG)
            DisplayErrorMessageBox( strMessage, _E("CL29"), "maybe-virus1" );
        #endif
    }

    struct {
        const char* szMd5;
        const char* szFilename;
    } integrityCheckList[] = { { "9586E7BE6AE8016932038932D1417241", "bass.dll", },
                               { "B2E49F0C22C8B7D92D615F942BA19353", "bass_aac.dll", },
                               { "569C60F8397C34034E685A303B7404C0", "bass_ac3.dll", },
                               { "0E44BCAC0E940DB2BFB13448E96E4B29", "bass_fx.dll", },
                               { "50AF8A7D49E83A723ED0F70FB682DCFB", "bassflac.dll", },
                               { "BEBA64522AA8265751187E38D1FC0653", "bassmidi.dll", },
                               { "99F4F38007D347CEED482B7C04FDD122", "bassmix.dll", },
                               { "7B52BE6D702AA590DB57A0E135F81C45", "basswma.dll", }, 
                               { "38D7679D3B8B6D7F16A0AA9BF2A60043", "tags.dll", },
                               { "309D860FC8137E5FE9E7056C33B4B8BE", "vea.dll", },
                               { "0602F672BA595716E64EC4040E6DE376", "vog.dll", },
                               { "B37D7DF4A1430DB65AD3EA84801F9EC3", "vvo.dll", },
                               { "47FF3EE45DE53528F1AFD9F5982DF8C7", "vvof.dll", },
                               { "ADFB6D7B61E301761C700652B6FE7CCD", "XInput9_1_0_mta.dll", }, };
    for ( int i = 0 ; i < NUMELMS ( integrityCheckList ); i++ )
    {
        SString strMd5 = CMD5Hasher::CalculateHexString( PathJoin( strMTASAPath, "mta", integrityCheckList[i].szFilename ) );
        if ( !strMd5.CompareI( integrityCheckList[i].szMd5 ) )
        {
            DisplayErrorMessageBox( _("Data files modified. Possible virus activity.\n\nSee online help if MTA does not work correctly."), _E("CL30"), "maybe-virus2" );
            break;
        }    
    }

    // Check for asi files
    {
        bool bFoundInGTADir = !FindFiles( PathJoin( strGTAPath, "*.asi" ), true, false ).empty();
        bool bFoundInMTADir = !FindFiles( PathJoin( strMTASAPath, "mta", "*.asi" ), true, false ).empty();
        if ( bFoundInGTADir || bFoundInMTADir )
        {
            DisplayErrorMessageBox (_( ".asi files are in the 'MTA:SA' or 'GTA: San Andreas' installation directory.\n\n"
                                       "Remove these .asi files if you experience problems with MTA:SA." ), _E("CL28"), "asi-files" );
        }
    }

    // Warning if d3d9.dll exists in the GTA install directory
    if ( FileExists( PathJoin ( strGTAPath, "d3d9.dll" ) ) )
    {
        ShowD3dDllDialog ( g_hInstance, PathJoin ( strGTAPath, "d3d9.dll" ) );
        HideD3dDllDialog ();
    }

    // Remove old log files saved in the wrong place
    SString strMtaDir = PathJoin( strMTASAPath, "mta" );
    if ( strGTAPath.CompareI( strMtaDir ) == false )
    {
        FileDelete( PathJoin( strGTAPath, "CEGUI.log" ) );
        FileDelete( PathJoin( strGTAPath, "logfile.txt" ) );
        FileDelete( PathJoin( strGTAPath, "shutdown.log" ) );
    }
}
Пример #10
0
//////////////////////////////////////////////////////////
//
// InitLocalization
//
// Start localization thingmy
//
//////////////////////////////////////////////////////////
void InitLocalization( bool bNoFail )
{
    static bool bDone = false;
    if ( bDone )
        return;

    // Check for and load core.dll for localization
    // Use launch relative path so core.dll can get updated
    SString strCoreDLL = PathJoin( GetLaunchPath(), "mta", MTA_DLL_NAME );
    if ( !FileExists ( strCoreDLL ) )
    {
        if ( !bNoFail )
            return;
        DisplayErrorMessageBox ( ("Load failed.  Please ensure that "
                            "the file core.dll is in the modules "
                            "directory within the MTA root directory."), _E("CL23"), "core-missing" ); // Core.dll missing

        return ExitProcess( EXIT_ERROR );
    }

    // Use registry setting of mta path for dlls, as they will not be present in update files
    const SString strMTASAPath = GetMTASAPath ();
    SetDllDirectory( PathJoin( strMTASAPath, "mta" ) );

    // See if xinput is loadable (XInput9_1_0.dll is core.dll dependency)
    HMODULE hXInputModule = LoadLibrary( "XInput9_1_0.dll" );
    if ( hXInputModule )
        FreeLibrary( hXInputModule );
    else
    {
        // If not, do hack to use dll supplied with MTA
        SString strDest = PathJoin( strMTASAPath, "mta", "XInput9_1_0.dll" );
        if ( !FileExists( strDest ) )
        {
            SString strSrc = PathJoin( strMTASAPath, "mta", "XInput9_1_0_mta.dll" );       
            FileCopy( strSrc, strDest );
        }
    }

    // Check if the core can be loaded - failure may mean msvcr90.dll or d3dx9_40.dll etc is not installed
    HMODULE hCoreModule = LoadLibrary( strCoreDLL );
    if ( hCoreModule == NULL )
    {
        if ( !bNoFail )
            return;
        DisplayErrorMessageBox ( ("Loading core failed.  Please ensure that \n"
                            "Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) \n"
                            "and the latest DirectX is correctly installed."), _E("CL24"), "vc-redist-missing" );  // Core.dll load failed.  Ensure VC++ Redists and DX are installed
        return ExitProcess( EXIT_ERROR );
    }

    // Grab our locale from the registry if possible, if not Windows
    SString strLocale = GetApplicationSetting ( "locale" );
    if ( strLocale.empty() )
    {
        setlocale(LC_ALL, "");
        char* szLocale = setlocale(LC_ALL, NULL);
        strLocale = szLocale;
    }

    typedef CLocalizationInterface* (__cdecl *FUNC_CREATELOCALIZATIONFROMENVIRONMENT)(SString strLocale);
    FUNC_CREATELOCALIZATIONFROMENVIRONMENT pFunc = (FUNC_CREATELOCALIZATIONFROMENVIRONMENT)GetProcAddress ( hCoreModule, "L10n_CreateLocalization" );
    CLocalizationInterface* pLocalization = pFunc(strLocale);
    if ( pLocalization == NULL )
    {
        if ( !bNoFail )
            return;

        DisplayErrorMessageBox ( ("Loading core failed.  Please ensure that \n"
                            "Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) \n"
                            "and the latest DirectX is correctly installed."), _E("CL26"), "vc-redist-missing" );  // Core.dll load failed.  Ensure VC++ Redists and DX are installed
        FreeLibrary ( hCoreModule );
        return ExitProcess( EXIT_ERROR );
    }

    SAFE_DELETE( g_pLocalization );
    g_pLocalization = pLocalization;
    bDone = true;

#ifdef MTA_DEBUG
    TestDialogs();
#endif
}