- check for WHQL for display adapters (using d3d9)

- destroy all dialogs on exit
- fix a bug in destroying the dialogs
- halfplement checking WHQL for audio drivers

svn path=/trunk/; revision=33313
This commit is contained in:
Johannes Anderwald 2008-05-06 07:46:58 +00:00
parent 611459f151
commit ec6486f26c
5 changed files with 171 additions and 10 deletions

View file

@ -215,6 +215,36 @@ InitializeDialog(HWND hwndDlg, PDISPLAY_DEVICEW pDispDevice)
HWND hDlgCtrls[5];
DWORD dwMemory;
DEVMODE DevMode;
IDirect3D9 * ppObj;
D3DADAPTER_IDENTIFIER9 Identifier;
HRESULT hResult;
szText[0] = L'\0';
ppObj = Direct3DCreate9(D3D_SDK_VERSION);
if (ppObj)
{
hResult = IDirect3D9_GetAdapterIdentifier(ppObj, D3DADAPTER_DEFAULT , 2/*D3DENUM_WHQL_LEVEL*/, &Identifier);
if (hResult == D3D_OK)
{
if (Identifier.WHQLLevel)
{
/* adapter is WHQL certified */
LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
}
else
{
LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
}
}
IDirect3D9_Release(ppObj);
}
else
{
LoadStringW(hInst, IDS_DEVICE_STATUS_UNKNOWN, szText, sizeof(szText)/sizeof(WCHAR));
}
szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_LOGO, WM_SETTEXT, 0, (LPARAM)szText);
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, &pDispDevice->DeviceKey[18], 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return FALSE;

View file

@ -19,11 +19,27 @@ DestroyTabCtrlDialogs(PDXDIAG_CONTEXT pContext)
{
UINT Index;
for(Index = 0; Index < 7; Index++)
/* destroy default dialogs */
for(Index = 0; Index < sizeof(pContext->hDialogs) / sizeof(HWND); Index++)
{
if (pContext->hDialogs[Index])
DestroyWindow(pContext->hDialogs[Index]);
}
/* destroy display dialogs */
for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
{
if (pContext->hDisplayWnd[Index])
DestroyWindow(pContext->hDisplayWnd[Index]);
}
/* destroy audio dialogs */
for(Index = 0; Index < pContext->NumSoundAdapter; Index++)
{
if (pContext->hSoundWnd[Index])
DestroyWindow(pContext->hSoundWnd[Index]);
}
}
//---------------------------------------------------------------

View file

@ -20,6 +20,8 @@
<library>version</library>
<library>gdi32</library>
<library>winmm</library>
<library>wintrust</library>
<library>d3d9</library>
<file>system.c</file>
<file>display.c</file>
<file>sound.c</file>

View file

@ -13,10 +13,15 @@
#include <setupapi.h>
#include <commctrl.h>
#include <dinput.h>
#include <d3d9.h>
#include <ddraw.h>
#include <dsound.h>
#include <mmreg.h>
#include <wintrust.h>
#include <softpub.h>
#include <mscat.h>
#include "resource.h"
typedef struct
@ -28,11 +33,8 @@ typedef struct
ULONG NumSoundAdapter;
HWND * hSoundWnd;
HWND hDialogs[5];
}DXDIAG_CONTEXT, *PDXDIAG_CONTEXT;
/* globals */
extern HINSTANCE hInst;
@ -44,10 +46,7 @@ INT_PTR CALLBACK MusicPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
INT_PTR CALLBACK InputPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK NetworkPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK HelpPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR Result, DWORD Size);
VOID InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId);
VOID EnumerateDrivers(PVOID Context, HDEVINFO hList, PSP_DEVINFO_DATA pInfoData);
/* DirectDraw tests */
VOID DDTests();
@ -57,6 +56,11 @@ void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext);
/* display adapter initialization */
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext);
/* general functions */
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize);
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
BOOL GetCatFileFromDriverPath(LPWSTR szFileName, LPWSTR szCatFileName);
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR Result, DWORD Size);
VOID InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId);
VOID EnumerateDrivers(PVOID Context, HDEVINFO hList, PSP_DEVINFO_DATA pInfoData);
#endif

View file

@ -11,6 +11,91 @@
//#include <initguid.h>
#include <devguid.h>
#if 0
BOOL
GetCatFileFromDriverPath(LPWSTR szFileName, LPWSTR szCatFileName)
{
GUID VerifyGuid = DRIVER_ACTION_VERIFY;
HANDLE hFile;
DWORD dwHash;
BYTE bHash[100];
HCATINFO hCatInfo;
HCATADMIN hActAdmin;
BOOL bRet = FALSE;
CATALOG_INFO CatInfo;
/* attempt to open file */
hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
/* calculate hash from file handle */
dwHash = sizeof(bHash);
if (!CryptCATAdminCalcHashFromFileHandle(hFile, &dwHash, bHash, 0))
{
CloseHandle(hFile);
return FALSE;
}
/* try open the CAT admin */
if (!CryptCATAdminAcquireContext(&hActAdmin, &VerifyGuid, 0))
{
CloseHandle(hFile);
return FALSE;
}
/* search catalog to find for catalog containing this hash */
hCatInfo = CryptCATAdminEnumCatalogFromHash(hActAdmin, bHash, dwHash, 0, NULL);
if (hCatInfo != NULL)
{
/* theres a catalog get the filename */
bRet = CryptCATCatalogInfoFromContext(hCatInfo, &CatInfo, 0);
if (bRet)
wcscpy(szCatFileName, CatInfo.wszCatalogFile);
CryptCATAdminReleaseCatalogContext(hActAdmin, hCatInfo, 0);
}
/* perform cleanup */
CloseHandle(hFile);
CryptCATAdminReleaseContext(hActAdmin, 0);
return bRet;
}
BOOL
IsDriverWHQL(LPWSTR szFileName)
{
WCHAR szCatFile[MAX_PATH];
HANDLE hCat;
BOOL bRet = FALSE;
/* get the driver's cat file */
if (!GetCatFileFromDriverPath(szFileName, szCatFile))
{
/* driver has no cat so its definately not WHQL signed */
return FALSE;
}
/* open the CAT file */
hCat = CryptCATOpen(szCatFile, CRYPTCAT_OPEN_EXISTING, 0, 0, 0);
if (hCat == INVALID_HANDLE_VALUE)
{
/* couldnt open cat */
return FALSE;
}
/* FIXME
* build certificate chain with CertGetCertificateChain
* verify certificate chain (WinVerifyTrust)
* retrieve signer (WTHelperGetProvSignerFromChain)
*/
/* close CAT file */
CryptCATClose(hCat);
return bRet;
}
#endif
static
void
SetDeviceDetails(HWND hwndDlg, LPCGUID classGUID, LPCWSTR lpcstrDescription)
@ -18,12 +103,13 @@ SetDeviceDetails(HWND hwndDlg, LPCGUID classGUID, LPCWSTR lpcstrDescription)
HDEVINFO hInfo;
DWORD dwIndex = 0;
SP_DEVINFO_DATA InfoData;
WCHAR szText[100];
WCHAR szText[30];
HWND hDlgCtrls[3];
WAVEOUTCAPSW waveOut;
UINT numDev;
MMRESULT errCode;
/* enumerate waveout devices */
numDev = waveOutGetNumDevs();
if (numDev)
@ -107,6 +193,9 @@ BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR l
HWND hwndDlg;
WCHAR szSound[20];
WCHAR szText[30];
IDirectSound8 *pObj;
HRESULT hResult;
DWORD dwCertified;
if (!lpGuid)
return TRUE;
@ -124,6 +213,26 @@ BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR l
if (!hwndDlg)
return FALSE;
hResult = DirectSoundCreate8(lpGuid, (LPDIRECTSOUND8*)&pObj, NULL);
if (hResult == DS_OK)
{
szText[0] = L'\0';
if (IDirectSound8_VerifyCertification(pObj, &dwCertified) == DS_OK)
{
if (dwCertified == DS_CERTIFIED)
LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
else if (dwCertified == DS_UNCERTIFIED)
LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
}
else
{
LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
}
szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_LOGO, WM_SETTEXT, 0, (LPARAM)szText);
IDirectSound8_Release(pObj);
}
/* set device name */
SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_NAME, WM_SETTEXT, 0, (LPARAM)lpcstrDescription);
@ -156,10 +265,10 @@ BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR l
void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext)
{
HRESULT hResult;
//IDirectSound8 *pObj;
/* create DSound object */
// hResult = DirectSoundCreate8(NULL, (LPDIRECTSOUND8*)&pObj, NULL);
// if (hResult != DS_OK)
// return;
hResult = DirectSoundEnumerateW(DSEnumCallback, pContext);