////////////////////////////////////////////////////////////////
//
// CRenderItemManager::OnDeviceCreate
//
//
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::OnDeviceCreate ( IDirect3DDevice9* pDevice, float fViewportSizeX, float fViewportSizeY )
{
    m_pDevice = pDevice;
    m_uiDefaultViewportSizeX = fViewportSizeX;
    m_uiDefaultViewportSizeY = fViewportSizeY;

    m_pRenderWare = CCore::GetSingleton ().GetGame ()->GetRenderWare ();

    // Get some stats
    m_strVideoCardName = (const char*)g_pDeviceState->AdapterState.Name;
    m_iVideoCardMemoryKBTotal = g_pDeviceState->AdapterState.InstalledMemoryKB;

    m_iVideoCardMemoryKBForMTATotal = ( m_iVideoCardMemoryKBTotal - ( 64 * 1024 ) ) * 4 / 5;
    m_iVideoCardMemoryKBForMTATotal = std::max ( 0, m_iVideoCardMemoryKBForMTATotal );

    D3DCAPS9 caps;
    pDevice->GetDeviceCaps ( &caps );
    int iMinor = caps.PixelShaderVersion & 0xFF;
    int iMajor = ( caps.PixelShaderVersion & 0xFF00 ) >> 8;
    m_strVideoCardPSVersion = SString ( "%d", iMajor );
    if ( iMinor )
        m_strVideoCardPSVersion += SString ( ".%d", iMinor );

    UpdateMemoryUsage ();

    // Check if using SwiftShader dll
    SLibVersionInfo libVersionInfo;
    if ( GetLibVersionInfo( "d3d9.dll", &libVersionInfo ) )
    {
        if ( libVersionInfo.strProductName.ContainsI( "Swift" ) )
            m_bIsSwiftShader = true;
    }
}
Example #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;
        }
    }
Example #3
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 ();
    }
}