diff --git a/Benchmark/Benchmark.vcxproj b/Benchmark/Benchmark.vcxproj index f1c7f2d..74782f6 100644 --- a/Benchmark/Benchmark.vcxproj +++ b/Benchmark/Benchmark.vcxproj @@ -97,7 +97,7 @@ Console true - muparserxd.lib;version.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserxd.lib;version.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) @@ -110,7 +110,7 @@ Console true - muparserxd.lib;version.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserxd.lib;version.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) @@ -128,7 +128,7 @@ true true true - muparserx.lib;version.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserx.lib;version.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) @@ -146,7 +146,7 @@ true true true - muparserx.lib;version.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserx.lib;version.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) diff --git a/Configurator/Configurator.vcxproj b/Configurator/Configurator.vcxproj index 621d777..c848422 100644 --- a/Configurator/Configurator.vcxproj +++ b/Configurator/Configurator.vcxproj @@ -138,7 +138,7 @@ Windows true - audioeng.lib;version.lib;Shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + audioeng.lib;version.lib;Shlwapi.lib;authz.lib;comctl32.lib;%(AdditionalDependencies) @@ -151,7 +151,7 @@ Windows true - audioeng.lib;version.lib;Shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + audioeng.lib;version.lib;Shlwapi.lib;authz.lib;comctl32.lib;%(AdditionalDependencies) @@ -168,7 +168,7 @@ true true true - audioeng.lib;version.lib;Shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + audioeng.lib;version.lib;Shlwapi.lib;authz.lib;comctl32.lib;%(AdditionalDependencies) @@ -185,7 +185,7 @@ true true true - audioeng.lib;version.lib;Shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + audioeng.lib;version.lib;Shlwapi.lib;authz.lib;comctl32.lib;%(AdditionalDependencies) diff --git a/Editor/Editor.pro b/Editor/Editor.pro index 85b4131..4226fd9 100644 --- a/Editor/Editor.pro +++ b/Editor/Editor.pro @@ -234,7 +234,7 @@ FORMS += \ guis/StageFilterGUI.ui INCLUDEPATH += $$PWD/.. "C:/Program Files/libsndfile/include" "C:/Program Files/fftw3" "C:/Program Files/muparserx_v3_0_1/parser" -LIBS += advapi32.lib version.lib ole32.lib Shlwapi.lib libsndfile-1.lib libfftw3f-3.lib +LIBS += advapi32.lib version.lib ole32.lib Shlwapi.lib authz.lib libsndfile-1.lib libfftw3f-3.lib build_pass:CONFIG(debug, debug|release) { LIBS += muparserxd.lib diff --git a/Editor/guis/ConvolutionFilterGUI.cpp b/Editor/guis/ConvolutionFilterGUI.cpp index b88f27b..43fc33a 100644 --- a/Editor/guis/ConvolutionFilterGUI.cpp +++ b/Editor/guis/ConvolutionFilterGUI.cpp @@ -21,6 +21,7 @@ #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 #include +#include "helpers/RegistryHelper.h" #include "ConvolutionFilterGUI.h" #include "ui_ConvolutionFilterGUI.h" @@ -102,27 +103,45 @@ void ConvolutionFilterGUI::updateFileInfo() } else { - path = fileInfo.absoluteFilePath(); + path = QDir::toNativeSeparators(fileInfo.absoluteFilePath()); - SF_INFO info; - SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info); - if (file == NULL) + ACCESS_MASK mask = GENERIC_READ; + try { - error = tr("Unsupported file format"); + mask = RegistryHelper::getFileAccessForUser(path.toStdWString(), SECURITY_LOCAL_SERVICE_RID); + } + catch (RegistryException e) + { + // ignore + } + + if ((mask & GENERIC_READ) != GENERIC_READ && (mask & FILE_GENERIC_READ) != FILE_GENERIC_READ) + { + error = tr("The file is not readable for the audio service.\nChange the file permissions or copy the file to the config directory."); labelsVisible = false; } else { - int sampleRate = info.samplerate; - double length = info.frames * 1000.0 / sampleRate; - - ui->labelLengthValue->setText(tr("%0 ms (%1 samples)").arg(length).arg(info.frames)); - ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate)); - sf_close(file); - - if (sampleRate != deviceSampleRate) + SF_INFO info; + SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info); + if (file == NULL) { - error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate); + error = tr("Unsupported file format"); + labelsVisible = false; + } + else + { + int sampleRate = info.samplerate; + double length = info.frames * 1000.0 / sampleRate; + + ui->labelLengthValue->setText(tr("%0 ms (%1 samples)").arg(length).arg(info.frames)); + ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate)); + sf_close(file); + + if (sampleRate != deviceSampleRate) + { + error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate); + } } } } diff --git a/Editor/translations/Editor_de.qm b/Editor/translations/Editor_de.qm index 150511d..1486545 100644 Binary files a/Editor/translations/Editor_de.qm and b/Editor/translations/Editor_de.qm differ diff --git a/Editor/translations/Editor_de.ts b/Editor/translations/Editor_de.ts index 54e09b3..0d4628d 100644 --- a/Editor/translations/Editor_de.ts +++ b/Editor/translations/Editor_de.ts @@ -293,7 +293,7 @@ - + No file selected Keine Datei gewählt @@ -303,41 +303,48 @@ Länge: - + Select impulse response file Impulsantwort auswählen - + Impulse response (*.wav *.flac *.ogg) Impulsantwort (*.wav *.flac *.ogg) - + File not found Datei nicht gefunden - + + The file is not readable for the audio service. +Change the file permissions or copy the file to the config directory. + Die Datei ist für den Audiodienst nicht lesbar. +Ändern Sie die Dateiberechtigungen oder kopieren Sie die Datei in das config-Verzeichnis. + + + Unsupported file format Nicht unterstütztes Dateiformat - + %0 ms (%1 samples) %0 ms (%1 Samples) - + %0 Hz %0 Hz - + The file sample rate does not match the device sample rate (%0 Hz)! Select a different file or change the device configuration. Die Abtastrate der Datei stimmt nicht mit der Abtastrate des Geräts (%0 Hz) überein! -Wählen Sie eine andere Datei or ändern Sie die Konfiguration des Geräts. +Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts. @@ -773,18 +780,18 @@ Wählen Sie eine andere Datei or ändern Sie die Konfiguration des Geräts. - + Frequency response (*.csv) Frequenzgang (*.csv) - + All files (*.*) Alle Dateien (*.*) - + Export frequency response Frequenzgang exportieren @@ -1137,8 +1144,8 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben? - - + + Error Fehler @@ -1148,23 +1155,23 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?Fehler beim Lesen der Konfigurationsdatei: %0 - + Error while writing configuration file: %0 Fehler beim Schreiben der Konfigurationsdatei: %0 - + Only %0/%1 bytes have been written! Nur %0/%1 Bytes wurden geschrieben! + - From device Von Gerät - + %0 dB %0 dB @@ -1173,7 +1180,7 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?%0 ms (%1 Samp.) - + %0 ms (%1 s.) %0 ms (%1 S.) @@ -1182,46 +1189,46 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?%0 ms (%1 Samples) - + %0 ms %0 ms - + %0 % (one core) %0 % (ein Kern) - - - + + + Restart required Neustart erforderlich - - - + + + Configuration Editor will be restarted to apply the changed settings. Proceed? Konfigurationseditor wird neugestartet, um die geänderten Einstellungen zu übernehmen. Fortsetzen? - + Unsaved changes Ungespeicherte Änderungen - + The configuration file %0 has unsaved changes. Die Konfigurationsdatei %0 hat ungespeicherte Änderungen. - + Do you want to save the changes before closing the file? Möchten Sie die Änderungen speichern, bevor die Datei geschlossen wird? - + Open file Datei öffnen @@ -1231,18 +1238,18 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?Automatisch (%0) - - + + E-APO configurations (*.txt) E-APO-Konfigurationen (*.txt) - + Save file as Datei speichern unter - + Unsaved Ungespeichert diff --git a/EqualizerAPO.vcxproj b/EqualizerAPO.vcxproj index 1f80157..84b283c 100644 --- a/EqualizerAPO.vcxproj +++ b/EqualizerAPO.vcxproj @@ -99,7 +99,7 @@ Windows true - muparserxd.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserxd.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) EqualizerAPO.def @@ -116,7 +116,7 @@ Windows true - muparserxd.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserxd.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) EqualizerAPO.def @@ -138,7 +138,7 @@ true true true - muparserx.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserx.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) EqualizerAPO.def @@ -157,7 +157,7 @@ true true true - muparserx.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) + muparserx.lib;audioeng.lib;version.lib;wmcodecdspuuid.lib;AudioBaseProcessingObject.lib;audiomediatypecrt.lib;Shlwapi.lib;authz.lib;libsndfile-1.lib;libfftw3f-3.lib;%(AdditionalDependencies) EqualizerAPO.def diff --git a/helpers/RegistryHelper.cpp b/helpers/RegistryHelper.cpp index 265e269..7c3abaf 100644 --- a/helpers/RegistryHelper.cpp +++ b/helpers/RegistryHelper.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "StringHelper.h" #include "RegistryHelper.h" @@ -410,6 +411,57 @@ void RegistryHelper::takeOwnership(wstring key) LocalFree(sd); } +ACCESS_MASK RegistryHelper::getFileAccessForUser(std::wstring path, unsigned long rid) +{ + ACCESS_MASK result; + + PSECURITY_DESCRIPTOR sd; + if (GetNamedSecurityInfoW(path.c_str(), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION + | GROUP_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &sd) != ERROR_SUCCESS) + throw RegistryException(L"Error in GetNamedSecurityInfoW while getting file access"); + + AUTHZ_RESOURCE_MANAGER_HANDLE manager; + if (!AuthzInitializeResourceManager(AUTHZ_RM_FLAG_NO_AUDIT, NULL, NULL, NULL, NULL, &manager)) + throw RegistryException(L"Error in AuthzInitializeResourceManager while getting file access"); + + PSID sid = NULL; + SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY; + if (!AllocateAndInitializeSid(&authority, 1, rid, 0, 0, 0, 0, 0, 0, 0, &sid)) + throw RegistryException(L"Error in AllocateAndInitializeSid while getting file access"); + + LUID unusedId = {0}; + AUTHZ_CLIENT_CONTEXT_HANDLE context; + if (!AuthzInitializeContextFromSid(0, sid, manager, NULL, unusedId, NULL, &context)) + throw RegistryException(L"Error in AuthzInitializeContextFromSid while getting file access"); + + AUTHZ_ACCESS_REQUEST request = {0}; + + request.DesiredAccess = MAXIMUM_ALLOWED; + request.PrincipalSelfSid = NULL; + request.ObjectTypeList = NULL; + request.ObjectTypeListLength = 0; + request.OptionalArguments = NULL; + + AUTHZ_ACCESS_REPLY reply = {0}; + BYTE buf[1024]; + RtlZeroMemory(buf, sizeof(buf)); + reply.ResultListLength = 1; + reply.GrantedAccessMask = (ACCESS_MASK*)buf; + reply.Error = (DWORD*)(buf + sizeof(ACCESS_MASK)); + + if (!AuthzAccessCheck(0, context, &request, NULL, sd, NULL, 0, &reply, NULL)) + throw RegistryException(L"Error in AuthzAccessCheck while getting file access"); + + result = *reply.GrantedAccessMask; + + AuthzFreeContext(context); + FreeSid(sid); + AuthzFreeResourceManager(manager); + LocalFree(sd); + + return result; +} + bool RegistryHelper::keyExists(wstring key) { bool result; diff --git a/helpers/RegistryHelper.h b/helpers/RegistryHelper.h index ba0676a..af6fe1e 100644 --- a/helpers/RegistryHelper.h +++ b/helpers/RegistryHelper.h @@ -49,6 +49,7 @@ public: static void deleteKey(std::wstring key); static void makeWritable(std::wstring key); static void takeOwnership(std::wstring key); + static ACCESS_MASK getFileAccessForUser(std::wstring path, unsigned long rid); static std::vector enumSubKeys(std::wstring key); static bool keyExists(std::wstring key); static bool valueExists(std::wstring key, std::wstring valuename);