#include "layer_settings_manager.hpp"
#include "layer_settings_util.hpp"
#include <sys/stat.h>
#if defined(_WIN32)
#include <windows.h>
#include <direct.h>
#define GetCurrentDir …
#else
#include <unistd.h>
#define GetCurrentDir …
#endif
#ifdef __ANDROID__
#include <sys/system_properties.h>
#endif
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <array>
#include <algorithm>
#if defined(__ANDROID__)
static std::string GetAndroidProperty(const char *name) {
std::string output;
const prop_info *pi = __system_property_find(name);
if (pi) {
__system_property_read_callback(
pi,
[](void *cookie, const char *name, const char *value, uint32_t serial) {
(void)name;
(void)serial;
reinterpret_cast<std::string *>(cookie)->assign(value);
},
reinterpret_cast<void *>(&output));
}
return output;
}
#endif
static std::string GetEnvironment(const char *variable) { … }
#if defined(WIN32)
static inline bool IsHighIntegrity() {
HANDLE process_token;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_QUERY_SOURCE, &process_token)) {
uint8_t mandatory_label_buffer[SECURITY_MAX_SID_SIZE + sizeof(DWORD)];
DWORD buffer_size;
if (GetTokenInformation(process_token, TokenIntegrityLevel, mandatory_label_buffer, sizeof(mandatory_label_buffer),
&buffer_size) != 0) {
const TOKEN_MANDATORY_LABEL *mandatory_label = (const TOKEN_MANDATORY_LABEL *)mandatory_label_buffer;
const DWORD sub_authority_count = *GetSidSubAuthorityCount(mandatory_label->Label.Sid);
const DWORD integrity_level = *GetSidSubAuthority(mandatory_label->Label.Sid, sub_authority_count - 1);
CloseHandle(process_token);
return integrity_level > SECURITY_MANDATORY_MEDIUM_RID;
}
CloseHandle(process_token);
}
return false;
}
#endif
static void AddWorkaroundLayerNames(std::vector<std::string> &layer_names) { … }
namespace vl {
LayerSettings::LayerSettings(const char *pLayerName, const VkLayerSettingsCreateInfoEXT *pFirstCreateInfo,
const VkAllocationCallbacks *pAllocator, VkuLayerSettingLogCallback pCallback)
: … { … }
LayerSettings::~LayerSettings() { … }
void LayerSettings::ParseSettingsFile(const std::filesystem::path &filename) { … }
std::filesystem::path LayerSettings::FindSettingsFile() { … }
const VkLayerSettingEXT *LayerSettings::FindLayerSettingValue(const char *pSettingName) { … }
void LayerSettings::Log(const char *pSettingName, const char *pMessage) { … }
std::vector<std::string> &LayerSettings::GetSettingCache(const std::string &settingName) { … }
bool LayerSettings::HasEnvSetting(const char *pSettingName) { … }
bool LayerSettings::HasFileSetting(const char *pSettingName) { … }
bool LayerSettings::HasAPISetting(const char *pSettingName) { … }
std::string LayerSettings::GetEnvSetting(const char *pSettingName) { … }
std::string LayerSettings::GetFileSetting(const char *pSettingName) { … }
void LayerSettings::SetFileSetting(const char *pSettingName, const std::string &pValues) { … }
const VkLayerSettingEXT *LayerSettings::GetAPISetting(const char *pSettingName) { … }
}