davkean / audio-switcher

App that lets you easily switch Windows audio devices
MIT License
382 stars 53 forks source link

Crash on Windows 10 #32

Closed GeorgeHahn closed 9 years ago

GeorgeHahn commented 9 years ago

Crashes when setting a new default audio device. Exception details:

An unhandled exception of type 'System.InvalidCastException' occurred in AudioSwitcher.exe

Additional information: Unable to cast COM object of type
'AudioSwitcher.Audio.Interop.PolicyConfig' to interface type
'AudioSwitcher.Audio.Interop.IPolicyConfig'. This operation failed
because the QueryInterface call on the COM component for the
interface with IID '{F8679F50-850A-41CF-9C72-430F290290C8}'
failed due to the following error: No such interface supported
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Crash is in

AudioDeviceManager.SetDefaultAudioDevice Line 85 - called with one of my audio devices & AudioDeviceRole.Multimedia.

This is on Win10 Build 10041.

Let me know if there's anything I can do to investigate!

sirWest commented 9 years ago

Solution is to use guid on line 7 here: https://github.com/sirWest/AudioSwitch/blob/master/CoreAudioApi/Interfaces/IPolicyConfig.cs :+1:

GeorgeHahn commented 9 years ago

Spectacular! Works for me, thanks!

I'm curious, how did you find the new GUID? I tried pulling it out of mmcpl using frida without success.

sirWest commented 9 years ago

I used some tool to crawl in Windows interfaces first and then I also discovered it being mentioned in msdn doc for this interface that it uses the IUnknown guid, weird that it also works on previous Windows versions :P I didn't get my own AudioSwitch working otherwise on my home PC and had to find it :)

davkean commented 9 years ago

It works downlevel because you are basically casting it to IUnknown, and then calling a method at that particular v-table slot. Theoretically, if they were use to use something like COM aggregation underneath then this wouldn't work. Think like C#'s dynamic, but a little unsafer - if they change the layout of the underneath interface (move methods around) or add parameters to that method, bad things will occur. :)

I prefer a little more safer code, so I'm using the real GUID.

GeorgeHahn commented 9 years ago

Great news, thanks! I'm curious - how did you find the new GUID?