Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensound.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactX Diagnosis Application 00003 * LICENSE: LGPL - See COPYING in the top level directory 00004 * FILE: base/applications/dxdiag/sound.c 00005 * PURPOSE: ReactX diagnosis sound page 00006 * COPYRIGHT: Copyright 2008 Johannes Anderwald 00007 * 00008 */ 00009 00010 #include "precomp.h" 00011 #include <dsound.h> 00012 00013 #if 0 00014 BOOL 00015 GetCatFileFromDriverPath(LPWSTR szFileName, LPWSTR szCatFileName) 00016 { 00017 GUID VerifyGuid = DRIVER_ACTION_VERIFY; 00018 HANDLE hFile; 00019 DWORD dwHash; 00020 BYTE bHash[100]; 00021 HCATINFO hCatInfo; 00022 HCATADMIN hActAdmin; 00023 BOOL bRet = FALSE; 00024 CATALOG_INFO CatInfo; 00025 00026 /* attempt to open file */ 00027 hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 00028 if (hFile == INVALID_HANDLE_VALUE) 00029 return FALSE; 00030 00031 /* calculate hash from file handle */ 00032 dwHash = sizeof(bHash); 00033 if (!CryptCATAdminCalcHashFromFileHandle(hFile, &dwHash, bHash, 0)) 00034 { 00035 CloseHandle(hFile); 00036 return FALSE; 00037 } 00038 00039 /* try open the CAT admin */ 00040 if (!CryptCATAdminAcquireContext(&hActAdmin, &VerifyGuid, 0)) 00041 { 00042 CloseHandle(hFile); 00043 return FALSE; 00044 } 00045 00046 /* search catalog to find for catalog containing this hash */ 00047 hCatInfo = CryptCATAdminEnumCatalogFromHash(hActAdmin, bHash, dwHash, 0, NULL); 00048 if (hCatInfo != NULL) 00049 { 00050 /* theres a catalog get the filename */ 00051 bRet = CryptCATCatalogInfoFromContext(hCatInfo, &CatInfo, 0); 00052 if (bRet) 00053 wcscpy(szCatFileName, CatInfo.wszCatalogFile); 00054 CryptCATAdminReleaseCatalogContext(hActAdmin, hCatInfo, 0); 00055 } 00056 00057 /* perform cleanup */ 00058 CloseHandle(hFile); 00059 CryptCATAdminReleaseContext(hActAdmin, 0); 00060 return bRet; 00061 } 00062 00063 BOOL 00064 IsDriverWHQL(LPWSTR szFileName) 00065 { 00066 WCHAR szCatFile[MAX_PATH]; 00067 HANDLE hCat; 00068 BOOL bRet = FALSE; 00069 00070 /* get the driver's cat file */ 00071 if (!GetCatFileFromDriverPath(szFileName, szCatFile)) 00072 { 00073 /* driver has no cat so its definately not WHQL signed */ 00074 return FALSE; 00075 } 00076 00077 /* open the CAT file */ 00078 hCat = CryptCATOpen(szCatFile, CRYPTCAT_OPEN_EXISTING, 0, 0, 0); 00079 if (hCat == INVALID_HANDLE_VALUE) 00080 { 00081 /* couldnt open cat */ 00082 return FALSE; 00083 } 00084 00085 /* FIXME 00086 * build certificate chain with CertGetCertificateChain 00087 * verify certificate chain (WinVerifyTrust) 00088 * retrieve signer (WTHelperGetProvSignerFromChain) 00089 */ 00090 00091 00092 /* close CAT file */ 00093 CryptCATClose(hCat); 00094 return bRet; 00095 } 00096 #endif 00097 00098 static 00099 void 00100 SetDeviceDetails(HWND hwndDlg, LPCGUID classGUID, LPCWSTR lpcstrDescription) 00101 { 00102 HDEVINFO hInfo; 00103 DWORD dwIndex = 0; 00104 SP_DEVINFO_DATA InfoData; 00105 WCHAR szText[30]; 00106 HWND hDlgCtrls[3]; 00107 WAVEOUTCAPSW waveOut; 00108 UINT numDev; 00109 MMRESULT errCode; 00110 00111 00112 /* enumerate waveout devices */ 00113 numDev = waveOutGetNumDevs(); 00114 if (numDev) 00115 { 00116 do 00117 { 00118 ZeroMemory(&waveOut, sizeof(waveOut)); 00119 errCode = waveOutGetDevCapsW(dwIndex++, &waveOut, sizeof(waveOut)); 00120 if (!wcsncmp(lpcstrDescription, waveOut.szPname, min(MAXPNAMELEN, wcslen(waveOut.szPname)))) 00121 { 00122 /* set the product id */ 00123 SetDlgItemInt(hwndDlg, IDC_STATIC_DSOUND_PRODUCTID, waveOut.wPid, FALSE); 00124 /* set the vendor id */ 00125 SetDlgItemInt(hwndDlg, IDC_STATIC_DSOUND_VENDORID, waveOut.wMid, FALSE); 00126 /* check if its a wdm audio driver */ 00127 if (waveOut.wPid == MM_MSFT_WDMAUDIO_WAVEOUT) 00128 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_TYPE, WM_SETTEXT, 0, (LPARAM)L"WDM"); 00129 00130 /* check if device is default device */ 00131 szText[0] = L'\0'; 00132 if (dwIndex - 1 == 0) /* FIXME assume default playback device is device 0 */ 00133 LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR)); 00134 else 00135 LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR)); 00136 00137 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; 00138 /* set default device info */ 00139 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_STANDARD, WM_SETTEXT, 0, (LPARAM)szText); 00140 break; 00141 } 00142 }while(errCode == MMSYSERR_NOERROR && dwIndex < numDev); 00143 } 00144 00145 dwIndex = 0; 00146 /* create the setup list */ 00147 hInfo = SetupDiGetClassDevsW(classGUID, NULL, NULL, DIGCF_PRESENT|DIGCF_PROFILE); 00148 if (hInfo == INVALID_HANDLE_VALUE) 00149 return; 00150 00151 do 00152 { 00153 ZeroMemory(&InfoData, sizeof(InfoData)); 00154 InfoData.cbSize = sizeof(InfoData); 00155 00156 if (SetupDiEnumDeviceInfo(hInfo, dwIndex, &InfoData)) 00157 { 00158 /* set device name */ 00159 if (SetupDiGetDeviceInstanceId(hInfo, &InfoData, szText, sizeof(szText)/sizeof(WCHAR), NULL)) 00160 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_DEVICEID, WM_SETTEXT, 0, (LPARAM)szText); 00161 00162 /* set the manufacturer name */ 00163 if (SetupDiGetDeviceRegistryPropertyW(hInfo, &InfoData, SPDRP_MFG, NULL, (PBYTE)szText, sizeof(szText), NULL)) 00164 SendDlgItemMessageW(hwndDlg, IDC_STATIC_ADAPTER_PROVIDER, WM_SETTEXT, 0, (LPARAM)szText); 00165 00166 /* FIXME 00167 * we currently enumerate only the first adapter 00168 */ 00169 hDlgCtrls[0] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_DRIVER); 00170 hDlgCtrls[1] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_VERSION); 00171 hDlgCtrls[2] = GetDlgItem(hwndDlg, IDC_STATIC_DSOUND_DATE); 00172 EnumerateDrivers(hDlgCtrls, hInfo, &InfoData); 00173 break; 00174 } 00175 00176 if (GetLastError() == ERROR_NO_MORE_ITEMS) 00177 break; 00178 00179 dwIndex++; 00180 }while(TRUE); 00181 00182 /* destroy the setup list */ 00183 SetupDiDestroyDeviceInfoList(hInfo); 00184 } 00185 00186 00187 00188 BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext) 00189 { 00190 PDXDIAG_CONTEXT pContext = (PDXDIAG_CONTEXT)lpContext; 00191 HWND * hDlgs; 00192 HWND hwndDlg; 00193 WCHAR szSound[20]; 00194 WCHAR szText[30]; 00195 IDirectSound8 *pObj; 00196 HRESULT hResult; 00197 DWORD dwCertified; 00198 00199 if (!lpGuid) 00200 return TRUE; 00201 00202 if (pContext->NumSoundAdapter) 00203 hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hSoundWnd, (pContext->NumSoundAdapter + 1) * sizeof(HWND)); 00204 else 00205 hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumSoundAdapter + 1) * sizeof(HWND)); 00206 00207 if (!hDlgs) 00208 return FALSE; 00209 00210 pContext->hSoundWnd = hDlgs; 00211 hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_SOUND_DIALOG), pContext->hMainDialog, SoundPageWndProc, (LPARAM)pContext); 00212 if (!hwndDlg) 00213 return FALSE; 00214 00215 hResult = DirectSoundCreate8(lpGuid, (LPDIRECTSOUND8*)&pObj, NULL); 00216 if (hResult == DS_OK) 00217 { 00218 szText[0] = L'\0'; 00219 if (IDirectSound8_VerifyCertification(pObj, &dwCertified) == DS_OK) 00220 { 00221 if (dwCertified == DS_CERTIFIED) 00222 LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR)); 00223 else if (dwCertified == DS_UNCERTIFIED) 00224 LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR)); 00225 } 00226 else 00227 { 00228 LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR)); 00229 } 00230 szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0'; 00231 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_LOGO, WM_SETTEXT, 0, (LPARAM)szText); 00232 IDirectSound8_Release(pObj); 00233 } 00234 00235 /* set device name */ 00236 SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_NAME, WM_SETTEXT, 0, (LPARAM)lpcstrDescription); 00237 00238 /* set range for slider */ 00239 SendDlgItemMessageW(hwndDlg, IDC_SLIDER_DSOUND, TBM_SETRANGE, TRUE, MAKELONG(0, 3)); 00240 00241 /* FIXME set correct position */ 00242 SendDlgItemMessageW(hwndDlg, IDC_SLIDER_DSOUND, TBM_SETSEL, FALSE, 0); 00243 00244 /* set further device details */ 00245 SetDeviceDetails(hwndDlg, &GUID_DEVCLASS_MEDIA, lpcstrDescription); 00246 00247 00248 00249 /* load sound resource string */ 00250 szSound[0] = L'\0'; 00251 LoadStringW(hInst, IDS_SOUND_DIALOG, szSound, sizeof(szSound)/sizeof(WCHAR)); 00252 szSound[(sizeof(szSound)/sizeof(WCHAR))-1] = L'\0'; 00253 /* output the device id */ 00254 wsprintfW (szText, L"%s %u", szSound, pContext->NumSoundAdapter + 1); 00255 /* insert it into general tab */ 00256 InsertTabCtrlItem(pContext->hTabCtrl, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, szText); 00257 /* store dialog window */ 00258 hDlgs[pContext->NumSoundAdapter] = hwndDlg; 00259 pContext->NumSoundAdapter++; 00260 return TRUE; 00261 } 00262 00263 00264 void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext) 00265 { 00266 HRESULT hResult; 00267 00268 00269 /* create DSound object */ 00270 00271 // if (hResult != DS_OK) 00272 // return; 00273 hResult = DirectSoundEnumerateW(DSEnumCallback, pContext); 00274 00275 /* release the DSound object */ 00276 // pObj->lpVtbl->Release(pObj); 00277 (void)hResult; 00278 } 00279 00280 00281 INT_PTR CALLBACK 00282 SoundPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 00283 { 00284 switch (message) 00285 { 00286 case WM_INITDIALOG: 00287 { 00288 SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER); 00289 return TRUE; 00290 } 00291 case WM_COMMAND: 00292 { 00293 if (LOWORD(wParam) == IDC_BUTTON_TESTDSOUND) 00294 { 00295 return FALSE; 00296 } 00297 break; 00298 } 00299 } 00300 00301 return FALSE; 00302 } Generated on Sun May 27 2012 04:16:35 for ReactOS by
1.7.6.1
|