From dcf345febe605d2921487926f5ead337a798048f Mon Sep 17 00:00:00 2001
From: David Marcec <dmarcecguzman@gmail.com>
Date: Sun, 28 Jun 2020 16:51:28 +1000
Subject: [PATCH] am: Stub GetIndirectLayerConsumerHandle

Needed by Monster Hunter Generations Ultimate
---
 src/core/hle/service/am/am.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 20f366635..1bb544dd8 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -841,7 +841,7 @@ public:
             {110, nullptr, "NeedsToExitProcess"},
             {120, nullptr, "GetLibraryAppletInfo"},
             {150, nullptr, "RequestForAppletToGetForeground"},
-            {160, nullptr, "GetIndirectLayerConsumerHandle"},
+            {160, &ILibraryAppletAccessor::GetIndirectLayerConsumerHandle, "GetIndirectLayerConsumerHandle"},
         };
         // clang-format on
 
@@ -960,6 +960,18 @@ private:
         rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent());
     }
 
+    void GetIndirectLayerConsumerHandle(Kernel::HLERequestContext& ctx) {
+        LOG_WARNING(Service_AM, "(STUBBED) called");
+
+        // We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is
+        // actually used anywhere
+        constexpr u64 handle = 0xdeadbeef;
+
+        IPC::ResponseBuilder rb{ctx, 4};
+        rb.Push(RESULT_SUCCESS);
+        rb.Push(handle);
+    }
+
     std::shared_ptr<Applets::Applet> applet;
 };