eiz / SynchronousAudioRouter

Low latency application audio routing for Windows
http://sar.audio/
GNU General Public License v3.0
994 stars 136 forks source link

Backport to Vista? #100

Closed casper closed 3 years ago

casper commented 3 years ago

Since the Vista audio system should be pretty much identical to Windows 7, is there any chance to backport the driver code down to Vista? I was testing 0.13.1 on Vista, and it installs fine, but running SAR through ASIOConfig results in a missing method error:

image

I took a look at the drivers in Dependency Walker, and it seems there isn't a huge amount of methods that would need to be substituted for compatibility(?). Or is this still a lot of extra work? Is it something someone not familiar with the code could work on do you think?

paulheu commented 3 years ago

Are you _sure you run (at least) SP1 of Vista? The real question though is why are you running Vista at all in 2020?

casper commented 3 years ago

This is SP2, but I think the problem could be that that particular method is in Psapi.dll on Vista, while it is in Kernel32.dll on Win 7?

image

The real question though is why are you running Vista at all in 2020?

Hehe. Good question. There's still a bunch of us hard-core Vista users lurking around that prefer not to upgrade for various reasons. There's another similar group still running XP. All kinds of patches and workarounds being done to keep these platforms still running.

casper commented 3 years ago

It seems compatibility can be tweaked with PSAPI_VERSION. From MSDN:

Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.

If PSAPI_VERSION is 2 or greater, this function is defined as K32GetModuleFileNameEx in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetModuleFileNameEx in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetModuleFileNameEx.

Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetModuleFileNameEx. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with -DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.

Have to think about setting up a build environment to test it. Maybe it's enough to change this number.

casper commented 3 years ago

Ok. I almost have it working. It appears there is only one method call that is preventing conversion, and that is this one:

status = ObOpenObjectByPointerWithTag(
           newContext->process, OBJ_KERNEL_HANDLE,
           nullptr, GENERIC_ALL, nullptr,
           KernelMode, SAR_TAG, &newContext->processHandle);

I spent a long time trying to figure out what this does, but this appears to be a black voodoo method call. I cannot find any documentation on it anywhere?

Vista has the same method without the tag, with this signature:

NTSTATUS ObOpenObjectByPointer(
  PVOID           Object,
  ULONG           HandleAttributes,
  PACCESS_STATE   PassedAccessState,
  ACCESS_MASK     DesiredAccess,
  POBJECT_TYPE    ObjectType,
  KPROCESSOR_MODE AccessMode,
  PHANDLE         Handle
);

Is there any way to convert the tag call to a call without the tag? This is the only method which is missing now. The other changes were trivial to make (just needed to add some flags to the compiler).