Esempio n. 1
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;
        }
    }
}
Esempio n. 2
0
//////////////////////////////////////////////////////////
//
// CheckAntiVirusStatus
//
// Maybe warn user if no anti-virus running
//
//////////////////////////////////////////////////////////
void CheckAntiVirusStatus( void )
{
    // Get data from WMI
    std::vector < SString > enabledList;
    std::vector < SString > disabledList;
    GetWMIAntiVirusStatus( enabledList, disabledList );

    // Get status from WSC
    WSC_SECURITY_PROVIDER_HEALTH health = (WSC_SECURITY_PROVIDER_HEALTH)-1;
    if ( _WscGetSecurityProviderHealth )
    {
        _WscGetSecurityProviderHealth( WSC_SECURITY_PROVIDER_ANTIVIRUS, &health );
    }

    // Dump results
    SString strStatus( "AV health: %s (%d)", *EnumToString( health ), health );
    for ( uint i = 0 ; i < enabledList.size() ; i++ )
        strStatus += SString( " [Ena%d:%s]", i, *enabledList[i] );
    for ( uint i = 0 ; i < disabledList.size() ; i++ )
        strStatus += SString( " [Dis%d:%s]", i, *disabledList[i] );
    WriteDebugEvent( strStatus ); 

    // Maybe show dialog if av not found
    if ( enabledList.empty() && health != WSC_SECURITY_PROVIDER_HEALTH_GOOD )
    {
        bool bEnableScaremongering = ( health != WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED );

        if ( bEnableScaremongering )
        {
            const char* avProducts[] = { "antivirus", "anti-virus", "Avast", "AVG", "Avira", 
                                         "NOD32", "ESET", "F-Secure", "Faronics", "Kaspersky",
                                         "McAfee", "Norton", "Symantec", "Panda", "Trend Micro", };

            // Check for anti-virus helper dlls before actual scaremongering
            HMODULE aModules[1024];
            DWORD cbNeeded;
            if ( EnumProcessModules( GetCurrentProcess(), aModules, sizeof(aModules), &cbNeeded) )
            {
                DWORD cModules = cbNeeded / sizeof(HMODULE);
                for ( uint i = 0 ; i < cModules ; i++ )
                {
                    if( aModules[i] != 0 )
                    {
                        WCHAR szModulePathFileName[1024] = L"";
                        GetModuleFileNameExW ( GetCurrentProcess(), aModules[i], szModulePathFileName, NUMELMS(szModulePathFileName) );
                        SLibVersionInfo libVersionInfo;
                        GetLibVersionInfo ( ToUTF8( szModulePathFileName ), &libVersionInfo );

                        for( uint i = 0 ; i < NUMELMS( avProducts ) ; i++ )
                        {
                            if ( libVersionInfo.strCompanyName.ContainsI( avProducts[i] )
                                 || libVersionInfo.strProductName.ContainsI( avProducts[i] ) )
                            {
                                bEnableScaremongering = false;
                                WriteDebugEvent( SString( "AV (module) maybe found %s [%d](%s,%s)", *WStringX( szModulePathFileName ).ToAnsi(), i, *libVersionInfo.strCompanyName, *libVersionInfo.strProductName ) );
                            }
                        }
                    }
                }

                if ( bEnableScaremongering )
                    WriteDebugEvent( SString( "AV Searched %d dlls, but could not find av helper", cModules ) );
            }

            if ( bEnableScaremongering )
            {
                std::vector < DWORD > processIdList = MyEnumProcesses();
                for ( uint i = 0; i < processIdList.size (); i++ )
                {
                    DWORD processId = processIdList[i];
                    // Skip 64 bit processes to avoid errors
                    if ( !Is32bitProcess ( processId ) )
                        continue;

                    std::vector < SString > filenameList = GetPossibleProcessPathFilenames ( processId );
                    for ( uint i = 0; i < filenameList.size (); i++ )
                    {
                        const SString& strProcessPathFileName = filenameList[i];
                        SLibVersionInfo libVersionInfo;
                        if ( GetLibVersionInfo ( strProcessPathFileName, &libVersionInfo ) )
                        {
                            for( uint i = 0 ; i < NUMELMS( avProducts ) ; i++ )
                            {
                                if ( libVersionInfo.strCompanyName.ContainsI( avProducts[i] )
                                     || libVersionInfo.strProductName.ContainsI( avProducts[i] ) )
                                {
                                    bEnableScaremongering = false;
                                    WriteDebugEvent( SString( "AV (process) maybe found %s [%d](%s,%s)", *strProcessPathFileName, i, *libVersionInfo.strCompanyName, *libVersionInfo.strProductName ) );
                                }
                            }
                        }
                    }
                }
                if ( bEnableScaremongering )
                    WriteDebugEvent( SString( "AV Searched %d processes, but could not find av helper", processIdList.size() ) );
            }
        }

        ShowNoAvDialog( g_hInstance, bEnableScaremongering );
        HideNoAvDialog ();
    }
}