summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/vi/vi.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-02-26 23:49:32 +0100
committerLioncash <mathew1800@gmail.com>2019-02-27 02:16:23 +0100
commit92ea1c32d608cd258c3fc077f5aaf953536d7f45 (patch)
treea5a8bfa8c071f01f4c8cee5c9a2983a097c93f6d /src/core/hle/service/vi/vi.cpp
parentcore/ipc_helper: Allow popping all signed value types with RequestParser (diff)
downloadyuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.gz
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.bz2
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.lz
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.xz
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.tar.zst
yuzu-92ea1c32d608cd258c3fc077f5aaf953536d7f45.zip
Diffstat (limited to 'src/core/hle/service/vi/vi.cpp')
-rw-r--r--src/core/hle/service/vi/vi.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 99340e2ed..a5ad66a13 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -34,6 +34,7 @@
namespace Service::VI {
constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1};
+constexpr ResultCode ERR_PERMISSION_DENIED{ErrorModule::VI, 5};
constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6};
constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7};
@@ -1203,8 +1204,30 @@ IApplicationDisplayService::IApplicationDisplayService(
RegisterHandlers(functions);
}
+static bool IsValidServiceAccess(Permission permission, Policy policy) {
+ if (permission == Permission::User) {
+ return policy == Policy::User;
+ }
+
+ if (permission == Permission::System || permission == Permission::Manager) {
+ return policy == Policy::User || policy == Policy::Compositor;
+ }
+
+ return false;
+}
+
void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx,
- std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) {
+ std::shared_ptr<NVFlinger::NVFlinger> nv_flinger,
+ Permission permission) {
+ IPC::RequestParser rp{ctx};
+ const auto policy = rp.PopEnum<Policy>();
+
+ if (!IsValidServiceAccess(permission, policy)) {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(ERR_PERMISSION_DENIED);
+ return;
+ }
+
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationDisplayService>(std::move(nv_flinger));