BOOLEAN FoundDevice( UCHAR DeviceType, PWSTR DevicePath) { MMRESULT Result; PSOUND_DEVICE SoundDevice = NULL; MMFUNCTION_TABLE FuncTable; PWSTR PathCopy; SND_TRACE(L"(Callback) Found device: %wS\n", DevicePath); PathCopy = AllocateWideString(wcslen(DevicePath)); if ( ! PathCopy ) return FALSE; CopyWideString(PathCopy, DevicePath); Result = ListSoundDevice(DeviceType, (PVOID) PathCopy, &SoundDevice); if ( ! MMSUCCESS(Result) ) return FALSE; /* Set up our function table */ ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE)); FuncTable.GetCapabilities = GetSoundBlasterDeviceCapabilities; FuncTable.QueryWaveFormatSupport = QueryNt4WaveDeviceFormatSupport; FuncTable.SetWaveFormat = SetNt4WaveDeviceFormat; FuncTable.Open = OpenNt4SoundDevice; FuncTable.Close = CloseNt4SoundDevice; FuncTable.CommitWaveBuffer = WriteFileEx_Committer; //FuncTable.SubmitWaveHeaderToDevice = SubmitWaveHeaderToDevice; SetSoundDeviceFunctionTable(SoundDevice, &FuncTable); return TRUE; }
MMRESULT GetSoundBlasterDeviceCapabilities( IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize) { MMRESULT Result; MMDEVICE_TYPE DeviceType; SND_ASSERT( SoundDevice ); SND_ASSERT( Capabilities ); SND_TRACE(L"Sndblst - GetSoundBlasterDeviceCapabilities\n"); Result = GetSoundDeviceType(SoundDevice, &DeviceType); SND_ASSERT( Result == MMSYSERR_NOERROR ); /* Use the default method of obtaining device capabilities */ Result = GetNt4SoundDeviceCapabilities(SoundDevice, Capabilities, CapabilitiesSize); if ( ! MMSUCCESS(Result) ) return Result; /* Inject the appropriate device name */ switch ( DeviceType ) { case WAVE_OUT_DEVICE_TYPE : { LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities; CopyWideString(WaveOutCaps->szPname, SBWaveOutDeviceName); break; } case WAVE_IN_DEVICE_TYPE : { LPWAVEINCAPS WaveInCaps = (LPWAVEINCAPS) Capabilities; CopyWideString(WaveInCaps->szPname, SBWaveInDeviceName); break; } case MIDI_OUT_DEVICE_TYPE : { LPMIDIOUTCAPS MidiOutCaps = (LPMIDIOUTCAPS) Capabilities; CopyWideString(MidiOutCaps->szPname, SBMidiOutDeviceName); break; } case MIDI_IN_DEVICE_TYPE : { LPMIDIINCAPS MidiInCaps = (LPMIDIINCAPS) Capabilities; CopyWideString(MidiInCaps->szPname, SBMidiInDeviceName); break; } case AUX_DEVICE_TYPE : { LPAUXCAPS AuxCaps = (LPAUXCAPS) Capabilities; CopyWideString(AuxCaps->szPname, SBAuxDeviceName); break; } case MIXER_DEVICE_TYPE : { LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities; CopyWideString(MixerCaps->szPname, SBMixerDeviceName); break; } } return MMSYSERR_NOERROR; }
/** * Allocates EAP_ERROR structure and fills it using the input parameters. * * The memory will be freed by EapPeerFreeErrorMemory() or EapMethodAuthenticatorFreeErrorMemory() * depending on who the caller of this API is. * * @param pEapError EAP_ERROR will be allocated at this pointer and * populated with above input parameters. * @param errCode Win32 error code * @param dwReasonCode Reason Code * @param pRootCauseGuid Root Cause GUID * @param pRepairGuid Repair GUID * @param pHelpLinkGuid Help Link GUID * @param pRootCauseString String describing the root cause * @param pRepairString String describing the repair mechanism * * @return A Win32 error code, indicating success or failure. */ DWORD AllocateandFillEapError( IN OUT EAP_ERROR** pEapError, IN DWORD errCode, IN DWORD dwReasonCode, IN LPCGUID pRootCauseGuid, IN LPCGUID pRepairGuid, IN LPCGUID pHelpLinkGuid, IN __in LPWSTR pRootCauseString, IN __in LPWSTR pRepairString ) { DWORD retCode = NO_ERROR; //Sanity Check if(!pEapError) { retCode = ERROR_INVALID_PARAMETER; goto Cleanup; } // // Allocate memory for EAP_ERROR. // retCode = AllocateMemory(sizeof(EAP_ERROR), (PVOID *)pEapError); if(retCode != NO_ERROR) goto Cleanup; ZeroMemory(*pEapError, sizeof(EAP_ERROR)); // // Assign the Win32 Error Code // (*pEapError)->dwWinError = errCode; // // Assign the EAP_METHOD_TYPE to indicate which EAP Method send the error. // (*pEapError)->type.eapType.type = EAPTYPE; (*pEapError)->type.eapType.dwVendorId = VENODR_ID; (*pEapError)->type.eapType.dwVendorType = VENDOR_TYPE; (*pEapError)->type.dwAuthorId = AUTHOR_ID; // // Assign the reason code // (*pEapError)->dwReasonCode = dwReasonCode; // // Assign the RootCause GUID // if(pRootCauseGuid != NULL) memcpy(&((*pEapError)->rootCauseGuid), pRootCauseGuid, sizeof(GUID)); // // Assign the Repair GUID // if(pRepairGuid != NULL) memcpy(&((*pEapError)->repairGuid), pRepairGuid, sizeof(GUID)); // // Assign the HelpLink GUID // if(pHelpLinkGuid!= NULL) memcpy(&((*pEapError)->helpLinkGuid), pHelpLinkGuid, sizeof(GUID)); // // Assign the Root Cause String // retCode = CopyWideString(pRootCauseString, &((*pEapError)->pRootCauseString)); if(retCode != NO_ERROR) goto Cleanup; // // Assign the Repair String // retCode = CopyWideString(pRepairString, &((*pEapError)->pRepairString)); if(retCode != NO_ERROR) goto Cleanup; Cleanup: if(retCode != NO_ERROR) FreeMemory((PVOID*)pEapError); return retCode; }
MMRESULT WdmAudGetCapabilitiesByLegacy( IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize) { MMRESULT Result; MMDEVICE_TYPE DeviceType; WDMAUD_DEVICE_INFO DeviceInfo; SND_ASSERT( SoundDevice ); SND_ASSERT( Capabilities ); Result = GetSoundDeviceType(SoundDevice, &DeviceType); SND_ASSERT( Result == MMSYSERR_NOERROR ); if ( ! MMSUCCESS(Result) ) return Result; SND_TRACE(L"WDMAUD - GetWdmDeviceCapabilities DeviceType %u DeviceId %u\n", DeviceType, DeviceId); ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO)); DeviceInfo.DeviceType = DeviceType; DeviceInfo.DeviceIndex = DeviceId; Result = SyncOverlappedDeviceIoControl(KernelHandle, IOCTL_GETCAPABILITIES, (LPVOID) &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO), (LPVOID) &DeviceInfo, sizeof(WDMAUD_DEVICE_INFO), NULL); if ( ! MMSUCCESS(Result) ) { return TranslateInternalMmResult(Result); } /* This is pretty much a big hack right now */ switch ( DeviceType ) { case MIXER_DEVICE_TYPE: { LPMIXERCAPSW MixerCaps = (LPMIXERCAPSW) Capabilities; DeviceInfo.u.MixCaps.szPname[MAXPNAMELEN-1] = L'\0'; CopyWideString(MixerCaps->szPname, DeviceInfo.u.MixCaps.szPname); MixerCaps->cDestinations = DeviceInfo.u.MixCaps.cDestinations; MixerCaps->fdwSupport = DeviceInfo.u.MixCaps.fdwSupport; MixerCaps->vDriverVersion = DeviceInfo.u.MixCaps.vDriverVersion; MixerCaps->wMid = DeviceInfo.u.MixCaps.wMid; MixerCaps->wPid = DeviceInfo.u.MixCaps.wPid; break; } case WAVE_OUT_DEVICE_TYPE : { LPWAVEOUTCAPSW WaveOutCaps = (LPWAVEOUTCAPSW) Capabilities; DeviceInfo.u.WaveOutCaps.szPname[MAXPNAMELEN-1] = L'\0'; WaveOutCaps->wMid = DeviceInfo.u.WaveOutCaps.wMid; WaveOutCaps->wPid = DeviceInfo.u.WaveOutCaps.wPid; WaveOutCaps->vDriverVersion = DeviceInfo.u.WaveOutCaps.vDriverVersion; CopyWideString(WaveOutCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname); WaveOutCaps->dwFormats = DeviceInfo.u.WaveOutCaps.dwFormats; WaveOutCaps->wChannels = DeviceInfo.u.WaveOutCaps.wChannels; WaveOutCaps->dwSupport = DeviceInfo.u.WaveOutCaps.dwSupport; break; } case WAVE_IN_DEVICE_TYPE : { LPWAVEINCAPSW WaveInCaps = (LPWAVEINCAPSW) Capabilities; DeviceInfo.u.WaveInCaps.szPname[MAXPNAMELEN-1] = L'\0'; WaveInCaps->wMid = DeviceInfo.u.WaveInCaps.wMid; WaveInCaps->wPid = DeviceInfo.u.WaveInCaps.wPid; WaveInCaps->vDriverVersion = DeviceInfo.u.WaveInCaps.vDriverVersion; CopyWideString(WaveInCaps->szPname, DeviceInfo.u.WaveInCaps.szPname); WaveInCaps->dwFormats = DeviceInfo.u.WaveInCaps.dwFormats; WaveInCaps->wChannels = DeviceInfo.u.WaveInCaps.wChannels; WaveInCaps->wReserved1 = 0; break; } case MIDI_IN_DEVICE_TYPE : { LPMIDIINCAPSW MidiInCaps = (LPMIDIINCAPSW)Capabilities; DeviceInfo.u.MidiInCaps.szPname[MAXPNAMELEN-1] = L'\0'; MidiInCaps->vDriverVersion = DeviceInfo.u.MidiInCaps.vDriverVersion; MidiInCaps->wMid = DeviceInfo.u.MidiInCaps.wMid; MidiInCaps->wPid = DeviceInfo.u.MidiInCaps.wPid; MidiInCaps->dwSupport = DeviceInfo.u.MidiInCaps.dwSupport; CopyWideString(MidiInCaps->szPname, DeviceInfo.u.MidiInCaps.szPname); break; } case MIDI_OUT_DEVICE_TYPE : { LPMIDIOUTCAPSW MidiOutCaps = (LPMIDIOUTCAPSW)Capabilities; DeviceInfo.u.MidiOutCaps.szPname[MAXPNAMELEN-1] = L'\0'; MidiOutCaps->vDriverVersion = DeviceInfo.u.MidiOutCaps.vDriverVersion; MidiOutCaps->wMid = DeviceInfo.u.MidiOutCaps.wMid; MidiOutCaps->wPid = DeviceInfo.u.MidiOutCaps.wPid; MidiOutCaps->dwSupport = DeviceInfo.u.MidiOutCaps.dwSupport; CopyWideString(MidiOutCaps->szPname, DeviceInfo.u.MidiOutCaps.szPname); break; } } return MMSYSERR_NOERROR; }