コード例 #1
0
bool CVboxAnti::CheckDXDiagSysInfo()
{
	using namespace std;
    HRESULT hr=CoInitialize(0);

    if(!SUCCEEDED(hr)) 
	{
		printf("CoInitializeEx Error\n");
		return false;
	}
	IDxDiagProvider* pProvider = NULL;
    hr=CoCreateInstance(CLSID_DxDiagProvider,0,CLSCTX_INPROC_SERVER,IID_IDxDiagProvider,(void**)&pProvider );
	
	if(!SUCCEEDED(hr))
     {
        CoUninitialize();
        return false;
     }
    DXDIAG_INIT_PARAMS InitParams={0};
    InitParams.dwSize=sizeof(DXDIAG_INIT_PARAMS);
    InitParams.dwDxDiagHeaderVersion=DXDIAG_DX9_SDK_VERSION;
    InitParams.bAllowWHQLChecks=false;
    hr=pProvider->Initialize(&InitParams);

    if(SUCCEEDED(hr))
        {
          IDxDiagContainer* pDxDiagRoot=0;
          IDxDiagContainer* pDxDiagSystemInfo=0;
          hr=pProvider->GetRootContainer(&pDxDiagRoot );
          if(SUCCEEDED(hr))
          {
                hr=pDxDiagRoot->GetChildContainer( L"DxDiag_SystemInfo", &pDxDiagSystemInfo );
                if(SUCCEEDED(hr) )
                {
                       VARIANT varX;
                                           hr=pDxDiagSystemInfo->GetProp( L"szSystemManufacturerEnglish",&varX);
                       if( SUCCEEDED(hr)&&varX.vt==VT_BSTR && SysStringLen(varX.bstrVal)!=0)
                       {
                                                   wchar_t* pMan=varX.bstrVal;
													//string s = pMan;
													wprintf(L"= Now DxDiagInfo : %s\n",pMan);
													printf("DxDiagInfo == innotek GmbH? Guest:Host\n");
													
													//wprintf(L"System Manufacturer is %s\r\n",pMan);
                                                   if(!_wcsicmp(pMan,L"innotek GmbH"))
                                                   {
                                                           //printf("VirtualBox detected\r\n");
															pDxDiagRoot->Release();
															pProvider->Release();
															CoUninitialize();
															return true;
                                                   }
                                       }
                       VariantClear(&varX);
                                           hr=pDxDiagSystemInfo->GetProp( L"szSystemModelEnglish",&varX);
                       if( SUCCEEDED(hr)&&varX.vt==VT_BSTR && SysStringLen(varX.bstrVal)!=0)
                       {
                                                   wchar_t* pMan=varX.bstrVal;
												   wprintf(L"= Now DxDiagInfo : %s\n",pMan);
												   printf("DxDiagInfo == VirtualBox? Guest:Host\n");
                          // wprintf(L"System Model is %s\r\n",pMan);
                                                   if(!_wcsicmp(pMan,L"VirtualBox"))
                                                   {
                                                          // printf("VirtualBox detected\r\n");
														pDxDiagRoot->Release();
														pProvider->Release();
														CoUninitialize();
													   return true;
                                                   }
                                       }
                       VariantClear(&varX);
                
                }
                
        }
       
    }

	//pDxDiagRoot->Release();
	pProvider->Release();
    CoUninitialize();
    return false;
}
コード例 #2
0
ファイル: displayinfo.cpp プロジェクト: gaoyakun/atom3d
ATOM_DisplayInfo::ATOM_DisplayInfo (void)
{
  IDxDiagProvider*  pDxDiagProvider = 0;
  IDxDiagContainer* pDxDiagRoot = 0;
  BOOL bComInitialized = FALSE;
  IDxDiagContainer* pContainer = NULL;
  IDxDiagContainer* pObject = NULL;
  IDxDiagContainer* pDxDiagSystemInfo = NULL;
  DWORD nInstanceCount = 0;
  DWORD nItem = 0;

  HRESULT hr = CoInitialize (NULL);
  bComInitialized = SUCCEEDED (hr);

  hr = CoCreateInstance (CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (LPVOID*)&pDxDiagProvider);
  if (FAILED(hr))
    goto LCleanup;

  if (!pDxDiagProvider)
  {
    hr = E_POINTER;
    goto LCleanup;
  }

  DXDIAG_INIT_PARAMS dxDiagInitParam;
  memset(&dxDiagInitParam, 0, sizeof(DXDIAG_INIT_PARAMS));

  dxDiagInitParam.dwSize = sizeof(DXDIAG_INIT_PARAMS);
  dxDiagInitParam.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
  dxDiagInitParam.bAllowWHQLChecks = false;
  dxDiagInitParam.pReserved = NULL;

  hr = pDxDiagProvider->Initialize( &dxDiagInitParam );
  if( FAILED(hr) )
    goto LCleanup;

  hr = pDxDiagProvider->GetRootContainer( &pDxDiagRoot );
  if( FAILED(hr) )
    goto LCleanup;

  if( FAILED( hr = pDxDiagRoot->GetChildContainer( L"DxDiag_DisplayDevices", &pContainer ) ) )
    goto LCleanup;

  if( FAILED( hr = pContainer->GetNumberOfChildContainers( &nInstanceCount ) ) )
    goto LCleanup;

  WCHAR wszContainer[256];

  for (nItem = 0; nItem < nInstanceCount; nItem++)
  {
    DisplayDeviceInfo *di = ATOM_NEW(DisplayDeviceInfo);
    devices.push_back (di);

    hr = pContainer->EnumChildContainerNames( nItem, wszContainer, 256 );
    if(FAILED(hr))
      goto LCleanup;

    hr = pContainer->GetChildContainer( wszContainer, &pObject );
    if( FAILED( hr ) || pObject == NULL )
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDescription", di->m_strDescription, ARRAY_SIZE(di->m_strDescription))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szManufacturer", di->m_strManufacturer, ARRAY_SIZE(di->m_strManufacturer))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szChipType", di->m_strChipType, ARRAY_SIZE(di->m_strChipType))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDisplayMemoryLocalized", di->m_strDisplayMemory, ARRAY_SIZE(di->m_strDisplayMemory))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDisplayModeLocalized", di->m_strATOM_DisplayMode, ARRAY_SIZE(di->m_strATOM_DisplayMode))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDriverName", di->m_strDriverName, ARRAY_SIZE(di->m_strDriverName))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDriverVersion", di->m_strDriverVersion, ARRAY_SIZE(di->m_strDriverVersion))))
      goto LCleanup;

    if( FAILED( hr = GetStringValue( pObject, L"szDriverDateLocalized", di->m_strDriverDate, ARRAY_SIZE(di->m_strDriverDate))))
      goto LCleanup;

	if( FAILED( hr = GetStringValue( pObject, L"szVendorId", di->m_strVendorId, ARRAY_SIZE(di->m_strVendorId))))
	  goto LCleanup;

	if( FAILED( hr = GetStringValue( pObject, L"szDeviceId", di->m_strDeviceId, ARRAY_SIZE(di->m_strDeviceId))))
	  goto LCleanup;

	if( FAILED( hr = GetStringValue( pObject, L"szSubSysId", di->m_strSubSysId, ARRAY_SIZE(di->m_strSubSysId))))
	  goto LCleanup;

	if( FAILED( hr = GetStringValue( pObject, L"szRevisionId", di->m_strRevisionId, ARRAY_SIZE(di->m_strRevisionId))))
	  goto LCleanup;

    if( FAILED( hr = GetBoolValue( pObject, L"bDDAccelerationEnabled", &di->m_bDDAccelerationEnabled)))
      goto LCleanup;

    if( FAILED( hr = GetBoolValue( pObject, L"b3DAccelerationExists", &di->m_b3DAccelerationExists)))
      goto LCleanup;

    if( FAILED( hr = GetBoolValue( pObject, L"b3DAccelerationEnabled", &di->m_b3DAccelerationEnabled)))
      goto LCleanup;

    if( FAILED( hr = GetBoolValue( pObject, L"bAGPEnabled", &di->m_bAGPEnabled)))
      goto LCleanup;

    if( FAILED( hr = GetBoolValue( pObject, L"bAGPExists", &di->m_bAGPExists)))
      goto LCleanup;

    SAFE_RELEASE(pObject);
  }

  //get dx version
  if( FAILED( hr = pDxDiagRoot->GetChildContainer( L"DxDiag_SystemInfo", &pDxDiagSystemInfo ) ) )
    goto LCleanup;

  if( FAILED( hr = GetIntValue( pDxDiagSystemInfo, L"dwDirectXVersionMajor", &dxverion.nDXVersionMajor)))
    goto LCleanup;

  if( FAILED( hr = GetIntValue( pDxDiagSystemInfo, L"dwDirectXVersionMinor", &dxverion.nDXVersionMinor)))
    goto LCleanup;

  if( FAILED( hr = GetStringValue( pDxDiagSystemInfo, L"szDirectXVersionLetter", dxverion.sDXVersionLetter, ARRAY_SIZE(dxverion.sDXVersionLetter))))
    goto LCleanup;

LCleanup:
  SAFE_RELEASE(pObject);
  SAFE_RELEASE(pContainer);
  SAFE_RELEASE(pDxDiagSystemInfo);
  SAFE_RELEASE(pDxDiagRoot);
  SAFE_RELEASE(pDxDiagProvider);

  if (FAILED(hr) && !devices.empty())
  {
    ATOM_DELETE(devices.back ());
    devices.pop_back ();
  }

  if (bComInitialized)
    CoUninitialize ();
}
コード例 #3
0
ファイル: zz_dx_version.cpp プロジェクト: eaglescv/znzin
//-----------------------------------------------------------------------------
// Name: GetDirectXVersionViaDxDiag()
// Desc: Tries to get the DirectX version from DxDiag's COM interface
//-----------------------------------------------------------------------------
HRESULT GetDirectXVersionViaDxDiag( DWORD* pdwDirectXVersionMajor, 
                                    DWORD* pdwDirectXVersionMinor, 
                                    TCHAR* pcDirectXVersionLetter )
{
    HRESULT hr;
    bool bCleanupCOM = false;

    bool bSuccessGettingMajor = false;
    bool bSuccessGettingMinor = false;
    bool bSuccessGettingLetter = false;
    
    // Init COM.  COM may fail if its already been inited with a different 
    // concurrency model.  And if it fails you shouldn't release it.
    hr = CoInitialize(NULL);
    bCleanupCOM = SUCCEEDED(hr);

    // Get an IDxDiagProvider
    bool bGotDirectXVersion = false;
    IDxDiagProvider* pDxDiagProvider = NULL;
    hr = CoCreateInstance( CLSID_DxDiagProvider,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IDxDiagProvider,
                           (LPVOID*) &pDxDiagProvider );
    if( SUCCEEDED(hr) )
    {
        // Fill out a DXDIAG_INIT_PARAMS struct
        DXDIAG_INIT_PARAMS dxDiagInitParam;
        ZeroMemory( &dxDiagInitParam, sizeof(DXDIAG_INIT_PARAMS) );
        dxDiagInitParam.dwSize                  = sizeof(DXDIAG_INIT_PARAMS);
        dxDiagInitParam.dwDxDiagHeaderVersion   = DXDIAG_DX9_SDK_VERSION;
        dxDiagInitParam.bAllowWHQLChecks        = false;
        dxDiagInitParam.pReserved               = NULL;

        // Init the m_pDxDiagProvider
        hr = pDxDiagProvider->Initialize( &dxDiagInitParam ); 
        if( SUCCEEDED(hr) )
        {
            IDxDiagContainer* pDxDiagRoot = NULL;
            IDxDiagContainer* pDxDiagSystemInfo = NULL;

            // Get the DxDiag root container
            hr = pDxDiagProvider->GetRootContainer( &pDxDiagRoot );
            if( SUCCEEDED(hr) ) 
            {
                // Get the object called DxDiag_SystemInfo
                hr = pDxDiagRoot->GetChildContainer( L"DxDiag_SystemInfo", &pDxDiagSystemInfo );
                if( SUCCEEDED(hr) )
                {
                    VARIANT var;
                    VariantInit( &var );

                    // Get the "dwDirectXVersionMajor" property
                    hr = pDxDiagSystemInfo->GetProp( L"dwDirectXVersionMajor", &var );
                    if( SUCCEEDED(hr) && var.vt == VT_UI4 )
                    {
                        if( pdwDirectXVersionMajor )
                            *pdwDirectXVersionMajor = var.ulVal; 
                        bSuccessGettingMajor = true;
                    }
                    VariantClear( &var );

                    // Get the "dwDirectXVersionMinor" property
                    hr = pDxDiagSystemInfo->GetProp( L"dwDirectXVersionMinor", &var );
                    if( SUCCEEDED(hr) && var.vt == VT_UI4 )
                    {
                        if( pdwDirectXVersionMinor )
                            *pdwDirectXVersionMinor = var.ulVal; 
                        bSuccessGettingMinor = true;
                    }
                    VariantClear( &var );

                    // Get the "szDirectXVersionLetter" property
                    hr = pDxDiagSystemInfo->GetProp( L"szDirectXVersionLetter", &var );
                    if( SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL )
                    {
#ifdef UNICODE
                        *pcDirectXVersionLetter = var.bstrVal[0]; 
#else
                        char strDestination[10];
                        WideCharToMultiByte( CP_ACP, 0, var.bstrVal, -1, strDestination, 10*sizeof(CHAR), NULL, NULL );
                        if( pcDirectXVersionLetter )
                            *pcDirectXVersionLetter = strDestination[0]; 
#endif
                        bSuccessGettingLetter = true;
                    }
                    VariantClear( &var );

                    // If it all worked right, then mark it down
                    if( bSuccessGettingMajor && bSuccessGettingMinor && bSuccessGettingLetter )
                        bGotDirectXVersion = true;

                    pDxDiagSystemInfo->Release();
                }

                pDxDiagRoot->Release();
            }
        }

        pDxDiagProvider->Release();
    }

    if( bCleanupCOM )
        CoUninitialize();
        
    if( bGotDirectXVersion )
        return S_OK;
    else
        return E_FAIL;
}
コード例 #4
0
ファイル: Utils.cpp プロジェクト: N2oBeef/vc_scan
HRESULT GetDirectXVersionViaDxDiag(CString& strDXVersionString)
{
    HRESULT hr;
    bool bCleanupCOM = false;

    bool bSuccessGettingLetter = false;

    // Init COM.  COM may fail if its already been inited with a different
    // concurrency model.  And if it fails you shouldn't release it.
    hr = CoInitialize(NULL);
    bCleanupCOM = SUCCEEDED(hr);

    // Get an IDxDiagProvider
    bool bGotDirectXVersion = false;
    IDxDiagProvider* pDxDiagProvider = NULL;
    hr = CoCreateInstance( CLSID_DxDiagProvider,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_IDxDiagProvider,
        (LPVOID*) &pDxDiagProvider );
    if( SUCCEEDED(hr) )
    {
        // Fill out a DXDIAG_INIT_PARAMS struct
        DXDIAG_INIT_PARAMS dxDiagInitParam;
        ZeroMemory( &dxDiagInitParam, sizeof(DXDIAG_INIT_PARAMS) );
        dxDiagInitParam.dwSize                  = sizeof(DXDIAG_INIT_PARAMS);
        dxDiagInitParam.dwDxDiagHeaderVersion   = DXDIAG_DX9_SDK_VERSION;
        dxDiagInitParam.bAllowWHQLChecks        = false;
        dxDiagInitParam.pReserved               = NULL;

        // Init the m_pDxDiagProvider
        hr = pDxDiagProvider->Initialize( &dxDiagInitParam );
        if( SUCCEEDED(hr) )
        {
            IDxDiagContainer* pDxDiagRoot = NULL;
            IDxDiagContainer* pDxDiagSystemInfo = NULL;

            // Get the DxDiag root container
            hr = pDxDiagProvider->GetRootContainer( &pDxDiagRoot );
            if( SUCCEEDED(hr) )
            {
                // Get the object called DxDiag_SystemInfo
                hr = pDxDiagRoot->GetChildContainer( L"DxDiag_SystemInfo", &pDxDiagSystemInfo );
                if( SUCCEEDED(hr) )
                {
                    VARIANT var;
                    VariantInit( &var );

                    // Get the "szDirectXVersionLetter" property
                    hr = pDxDiagSystemInfo->GetProp( L"szDirectXVersionLongEnglish", &var );
                    if( SUCCEEDED(hr) && var.vt == VT_BSTR && SysStringLen( var.bstrVal ) != 0 )
                    {
                        strDXVersionString = CComBSTR(var.bstrVal);

                        bSuccessGettingLetter = true;
                    }
                    VariantClear( &var );

                    // If it all worked right, then mark it down
                    if( bSuccessGettingLetter )
                        bGotDirectXVersion = true;

                    pDxDiagSystemInfo->Release();
                }

                pDxDiagRoot->Release();
            }
        }

        pDxDiagProvider->Release();
    }

    if( bCleanupCOM )
        CoUninitialize();

    if( bGotDirectXVersion )
        return S_OK;
    else
        return E_FAIL;
}