Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default device override not working for Battle.net games? #13

Closed
pannal opened this issue Mar 30, 2017 · 17 comments
Closed

Default device override not working for Battle.net games? #13

pannal opened this issue Mar 30, 2017 · 17 comments

Comments

@pannal
Copy link

pannal commented Mar 30, 2017

I'm trying this with this guide. Added the Battle.net folder to the SAR applications and tried Overwatch. It keeps playing back on the "Application" device, not the "Games" device.

Is this known? Do you need more technical details?

Thank you!

Edit: Windows 10 pro with ASIO4ALL

@pannal pannal changed the title Default device override not working? Default device override not working for Battle.net? Mar 30, 2017
@pannal pannal changed the title Default device override not working for Battle.net? Default device override not working for Battle.net games? Mar 30, 2017
@pannal
Copy link
Author

pannal commented Mar 31, 2017

I think this is related: audiorouterdev/audio-router#24

@eiz
Copy link
Owner

eiz commented Mar 31, 2017

Not sure if related. SAR uses a very different method of overriding the default audio device than audio-router, but it's plausible that some anti-cheat software could break it. I don't have a copy of the game and haven't tested it.

Mind checking its handle list using Process Explorer? See if you see SarAsio.dll in its list of open files.

@pannal
Copy link
Author

pannal commented Mar 31, 2017

Yes it is (SarAsio_x64.dll).

@stkfd
Copy link

stkfd commented Apr 2, 2017

@pannal, you were saying you added the Battle.net folder to the SAR applications; could you share the exact expression you used? Adding whole folders only works by adding a regular expression that matches everything in it, maybe something went wrong with that expression.

I wrote that guide by the way ;)

@pannal
Copy link
Author

pannal commented Apr 2, 2017

Sure, but the regex is correct, as Hearthstone and other Battle.net games work in SAR.
I was so desperate at one point, because I thought my regex was wrong, that I ended up using .+GAMES.+, which is the root folder for Steam and Battle.net.

@eiz
Copy link
Owner

eiz commented Apr 3, 2017

This appears to have nothing to do with Overwatch specifically. The problem is that Overwatch is using the XAudio2 API, which appears to have some backdoor way of getting the default audio device. It only calls IMMDeviceEnumerator::GetDevice, never IMMDeviceEnumerator::GetDefaultAudioEndpoint. Same problem happens with the basic playback example from the XAudio2 SDK samples. I'll see if I can find a solution.

@pannal
Copy link
Author

pannal commented Apr 3, 2017

Awesome. I love the work you're doing here. Any news on a new beta?

@eiz
Copy link
Owner

eiz commented Apr 15, 2017

Need to complete a few bug fixes first. Kind of slow going atm due to work related reasons.

I'm taking a closer look now and it appears that XAudio2 is creating its renderer by calling ActivateAudioInterfaceAsync with DEVINTERFACE_AUDIO_RENDER, which goes straight into MMDevAPI's internal endpoint lookup code. ActivateAudioInterfaceAsync is implemented by an undocumented coclass ActivateAudioInterfaceWorker (E2F7A62A-862B-40AE-BBC2-5C0CA9A5B7E1) which could be intercepted, albeit at the cost of introducing a dependency on an undocumented interface. Going to give it a shot.

For completeness, other options would include hijacking the export out of MMDevAPI (very intrusive) or hijacking the top level XAudio2 COM interface (less comprehensive, other code that uses ActivateAudioInterfaceAsync wouldn't be covered). I consider CreateRemoteThread type approaches (e.g. used by audiorouter) off the table.

eiz added a commit that referenced this issue Apr 16, 2017
Adds some temporary debug logging to SarMMDeviceEnumerator to see
more API calls that clients are making. Since the problem with XAudio2
apps is its internal use of ActivateAudioInterfaceAsync, generalize the
registry filter to store mapped registry paths in a table instead of
just statically comparing strings.

Stub out an interceptor for ActiveAudioInterfaceWorker coclass.

All of this is pretty untested code.
eiz added a commit that referenced this issue Apr 16, 2017
Was setting a PUNICODE_STRING* instead of a PUNICODE_STRING as the value
in the registry mapping table. Caused some fun bugchecks.

Also adds logging of the registry mappings on startup.
eiz added a commit that referenced this issue Apr 16, 2017
- Fixes an issue where the registry filter could access paged memory
  while holding a spinlock, resulting in bugcheck.
- Adds lookup of redirected default device to
  SarActivateAudioInterfaceWorker.
- Adds free threaded marshaler support to
  SarActivateAudioInterfaceWorker for STA callers.
- Adds COM registration to installer.

With these changes, both the XAudio2 SDK samples and Overwatch appear to
work correctly. My guess is that applications which use the WinRT
functions like MediaDevice::GetDefaultAudioRenderId will still not work
correctly, but who uses UWP apps anyway, right?
@eiz
Copy link
Owner

eiz commented Apr 16, 2017

This is now fixed in master. Doing some more local testing and will get a package up soon.

@pannal
Copy link
Author

pannal commented Apr 16, 2017

You're the best. Do you have DEV instructions laying around somewhere for me to follow? I could test the latest master by myself.

I'm a developer myself (although, more Python-focused), so I should get through it.

Something like: install these requirements, build using that toolchain, sign with test key, fire away.

@eiz
Copy link
Owner

eiz commented Apr 17, 2017

Here is a build. This is not adequately tested for release. Should your machine catch fire, don't say I didn't warn you.

SynchronousAudioRouter_x64_0_13_debug_20170417.zip

Notes:

  • Not tested on anything but win10 x64
  • Contains a SAR NDIS driver for future networking support. Currently does nothing, should be harmless, but ymmv
  • There's significant changes to the installer
  • Debug logging is on, make sure your %APPDATA%\SynchronousAudioRouter\logs doesn't fill with too much spam
  • Seriously, if it bugchecks, don't be surprised, I haven't even run this under Driver Verifier yet.

I don't have actual development instructions, but basically you need VS 2015 with all the C++ and ATL/COM stuff installed, the Windows Driver Kit, and WiX 3.10. Build defaults to test signing which you can Google how to enable loading test signed drivers. Debugging is best done with a 2 machine setup (I use a pair of Firewire cards for 1394 debugging).

@pannal
Copy link
Author

pannal commented Apr 21, 2017

I'll try it, haven't had the time yet, sorry.

@eiz eiz mentioned this issue May 7, 2017
@pannal
Copy link
Author

pannal commented May 13, 2017

Works. Also I don't have to quit reaper before going into sleep with the newest release (resulted in a bugcheck bluescreen).

Seems to work well for now.

@pannal
Copy link
Author

pannal commented May 14, 2017

Yep, runs well.

@pannal
Copy link
Author

pannal commented May 15, 2017

Ok, no issues since 3 days. Runs well, works with all games yet, and survives standby.

Great job!

@eiz
Copy link
Owner

eiz commented May 16, 2017

Thanks for the feedback. I assume you were hitting the registry filter bugcheck I fixed. IRQL_NOT_LESS_OR_EQUAL or something to that effect?

Edit: actually I'm not sure you could have ever hit that. Do you have any files in C:\Windows\Minidump with the crash info? I could use that for verification purposes.

@pannal
Copy link
Author

pannal commented May 16, 2017

Exactly. I had to stop reaper before letting my PC go to standby before, otherwise I'd get exactly that bugcheck.

Edit: I had, yes. But that got cleaned up on the last cleanup run, I'm sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants