}
#endif
// Get Windows version
+// note: We are trying to get Windows version starting from Windows Vista. Earlier OS versions
+// will fall into WINDOWS_UNKNOWN case.
static EWindowsVersion GetWindowsVersion()
{
#ifndef PA_WINRT
{
OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
- PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
-
if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS)
{
dwMajorVersion = ver.dwMajorVersion;
dwMinorVersion = ver.dwMinorVersion;
dwBuild = ver.dwBuildNumber;
}
+
+ PRINT(("WASAPI: getting Windows version with RtlGetVersion(): major=%d, minor=%d, build=%d\n", dwMajorVersion, dwMinorVersion, dwBuild));
}
#undef NTSTATUS_SUCCESS
if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL)
{
- DWORD dwVersion;
-
- PRINT(("WASAPI: getting Windows version with GetVersion()\n"));
-
- dwVersion = fnGetVersion();
+ DWORD dwVersion = fnGetVersion();
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if (dwVersion < 0x80000000)
dwBuild = (DWORD)(HIWORD(dwVersion));
+
+ PRINT(("WASAPI: getting Windows version with GetVersion(): major=%d, minor=%d, build=%d\n", dwMajorVersion, dwMinorVersion, dwBuild));
}
}
PaWasapiHostApiRepresentation *paWasapi;
#ifndef PA_WINRT
+ // Fail safely for any Windows version below Windows Vista
+ if (GetWindowsVersion() == WINDOWS_UNKNOWN)
+ {
+ PRINT(("WASAPI: Unsupported Windows version!\n"));
+ return paNoError;
+ }
+
if (!SetupAVRT())
{
- PRINT(("WASAPI: No AVRT! (not VISTA?)\n"));
+ PRINT(("WASAPI: avrt.dll missing! Windows integrity broken?\n"));
return paNoError;
}
#endif
// Fill basic interface info
*hostApi = &paWasapi->inheritedHostApiRep;
- (*hostApi)->info.structVersion = 1;
- (*hostApi)->info.type = paWASAPI;
- (*hostApi)->info.name = "Windows WASAPI";
+ (*hostApi)->info.structVersion = 1;
+ (*hostApi)->info.type = paWASAPI;
+ (*hostApi)->info.name = "Windows WASAPI";
(*hostApi)->info.deviceCount = 0;
- (*hostApi)->info.defaultInputDevice = paNoDevice;
+ (*hostApi)->info.defaultInputDevice = paNoDevice;
(*hostApi)->info.defaultOutputDevice = paNoDevice;
(*hostApi)->Terminate = Terminate;
(*hostApi)->OpenStream = OpenStream;