From bf0e20c571326f3b39d0bed0a3b5f2129cef81ea Mon Sep 17 00:00:00 2001
From: Subv <subv2112@gmail.com>
Date: Mon, 15 Jan 2018 15:42:57 -0500
Subject: [PATCH] SVC: Correct some return values in svcGetInfo and added
 TitleId and PrivilegedProcessId stubs.

# Conflicts:
#	src/core/hle/kernel/svc.cpp
---
 src/core/hle/kernel/svc.cpp | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 056ba28ef..088058ebc 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -255,8 +255,9 @@ static ResultCode CancelSynchronization(Handle thread_handle) {
 /// Attempts to locks a mutex, creating it if it does not already exist
 static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr,
                             Handle requesting_thread_handle) {
-    LOG_TRACE(Kernel_SVC, "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, "
-                          "requesting_current_thread_handle=0x%08X",
+    LOG_TRACE(Kernel_SVC,
+              "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, "
+              "requesting_current_thread_handle=0x%08X",
               holding_thread_handle, mutex_addr, requesting_thread_handle);
 
     SharedPtr<Thread> holding_thread = g_handle_table.Get<Thread>(holding_thread_handle);
@@ -304,8 +305,6 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
     LOG_TRACE(Kernel_SVC, "called info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id,
               info_sub_id, handle);
 
-    ASSERT(handle == 0 || handle == CurrentProcess);
-
     auto& vm_manager = g_current_process->vm_manager;
 
     switch (static_cast<GetInfoType>(info_id)) {
@@ -321,6 +320,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
     case GetInfoType::MapRegionSize:
         *result = vm_manager.GetAddressSpaceSize();
         break;
+    case GetInfoType::HeapRegionBaseAddr:
+        *result = vm_manager.GetNewMapRegionBaseAddr() + vm_manager.GetNewMapRegionSize();
+        break;
+    case GetInfoType::HeapRegionSize:
+        *result = Memory::HEAP_SIZE;
+        break;
     case GetInfoType::TotalMemoryUsage:
         *result = vm_manager.GetTotalMemoryUsage();
         break;
@@ -345,6 +350,15 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
     case GetInfoType::IsVirtualAddressMemoryEnabled:
         *result = g_current_process->is_virtual_address_memory_enabled;
         break;
+    case GetInfoType::TitleId:
+        LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query titleid, returned 0");
+        *result = 0;
+        break;
+    case GetInfoType::PrivilegedProcessId:
+        LOG_WARNING(Kernel_SVC,
+                    "(STUBBED) Attempted to query priviledged process id bounds, returned 0");
+        *result = 0;
+        break;
     default:
         UNIMPLEMENTED();
     }
@@ -533,8 +547,9 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
 
     Core::System::GetInstance().PrepareReschedule();
 
-    LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
-                          "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X",
+    LOG_TRACE(Kernel_SVC,
+              "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
+              "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X",
               entry_point, name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
 
     return RESULT_SUCCESS;