summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-23 18:43:11 -0400
committerGravatar GitHub2018-10-23 18:43:11 -0400
commite61a62066a1d7668a5e6a792463eccf33baf470e (patch)
tree6e58ea645719d31151168763fb9eb2b4196e7b30 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1552 from FearlessTobi/port-4336 (diff)
parentkernel/process: Make the handle table per-process (diff)
downloadyuzu-e61a62066a1d7668a5e6a792463eccf33baf470e.tar.gz
yuzu-e61a62066a1d7668a5e6a792463eccf33baf470e.tar.xz
yuzu-e61a62066a1d7668a5e6a792463eccf33baf470e.zip
Merge pull request #1540 from lioncash/handle
kernel/process: Make the handle table per-process
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp120
1 files changed, 60 insertions, 60 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 690b84930..67ea67666 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -189,14 +189,15 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address
189 CASCADE_RESULT(client_session, client_port->Connect()); 189 CASCADE_RESULT(client_session, client_port->Connect());
190 190
191 // Return the client session 191 // Return the client session
192 CASCADE_RESULT(*out_handle, kernel.HandleTable().Create(client_session)); 192 auto& handle_table = Core::CurrentProcess()->GetHandleTable();
193 CASCADE_RESULT(*out_handle, handle_table.Create(client_session));
193 return RESULT_SUCCESS; 194 return RESULT_SUCCESS;
194} 195}
195 196
196/// Makes a blocking IPC call to an OS service. 197/// Makes a blocking IPC call to an OS service.
197static ResultCode SendSyncRequest(Handle handle) { 198static ResultCode SendSyncRequest(Handle handle) {
198 auto& kernel = Core::System::GetInstance().Kernel(); 199 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
199 SharedPtr<ClientSession> session = kernel.HandleTable().Get<ClientSession>(handle); 200 SharedPtr<ClientSession> session = handle_table.Get<ClientSession>(handle);
200 if (!session) { 201 if (!session) {
201 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle); 202 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x{:08X}", handle);
202 return ERR_INVALID_HANDLE; 203 return ERR_INVALID_HANDLE;
@@ -215,8 +216,8 @@ static ResultCode SendSyncRequest(Handle handle) {
215static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) { 216static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) {
216 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 217 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
217 218
218 auto& kernel = Core::System::GetInstance().Kernel(); 219 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
219 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 220 const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
220 if (!thread) { 221 if (!thread) {
221 return ERR_INVALID_HANDLE; 222 return ERR_INVALID_HANDLE;
222 } 223 }
@@ -229,8 +230,8 @@ static ResultCode GetThreadId(u32* thread_id, Handle thread_handle) {
229static ResultCode GetProcessId(u32* process_id, Handle process_handle) { 230static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
230 LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle); 231 LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle);
231 232
232 auto& kernel = Core::System::GetInstance().Kernel(); 233 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
233 const SharedPtr<Process> process = kernel.HandleTable().Get<Process>(process_handle); 234 const SharedPtr<Process> process = handle_table.Get<Process>(process_handle);
234 if (!process) { 235 if (!process) {
235 return ERR_INVALID_HANDLE; 236 return ERR_INVALID_HANDLE;
236 } 237 }
@@ -273,11 +274,11 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64
273 274
274 using ObjectPtr = Thread::ThreadWaitObjects::value_type; 275 using ObjectPtr = Thread::ThreadWaitObjects::value_type;
275 Thread::ThreadWaitObjects objects(handle_count); 276 Thread::ThreadWaitObjects objects(handle_count);
276 auto& kernel = Core::System::GetInstance().Kernel(); 277 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
277 278
278 for (u64 i = 0; i < handle_count; ++i) { 279 for (u64 i = 0; i < handle_count; ++i) {
279 const Handle handle = Memory::Read32(handles_address + i * sizeof(Handle)); 280 const Handle handle = Memory::Read32(handles_address + i * sizeof(Handle));
280 const auto object = kernel.HandleTable().Get<WaitObject>(handle); 281 const auto object = handle_table.Get<WaitObject>(handle);
281 282
282 if (object == nullptr) { 283 if (object == nullptr) {
283 return ERR_INVALID_HANDLE; 284 return ERR_INVALID_HANDLE;
@@ -325,8 +326,8 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64
325static ResultCode CancelSynchronization(Handle thread_handle) { 326static ResultCode CancelSynchronization(Handle thread_handle) {
326 LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); 327 LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle);
327 328
328 auto& kernel = Core::System::GetInstance().Kernel(); 329 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
329 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 330 const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
330 if (!thread) { 331 if (!thread) {
331 return ERR_INVALID_HANDLE; 332 return ERR_INVALID_HANDLE;
332 } 333 }
@@ -354,7 +355,7 @@ static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
354 return ERR_INVALID_ADDRESS; 355 return ERR_INVALID_ADDRESS;
355 } 356 }
356 357
357 auto& handle_table = Core::System::GetInstance().Kernel().HandleTable(); 358 auto& handle_table = Core::CurrentProcess()->GetHandleTable();
358 return Mutex::TryAcquire(handle_table, mutex_addr, holding_thread_handle, 359 return Mutex::TryAcquire(handle_table, mutex_addr, holding_thread_handle,
359 requesting_thread_handle); 360 requesting_thread_handle);
360} 361}
@@ -499,13 +500,12 @@ static ResultCode SetThreadActivity(Handle handle, u32 unknown) {
499static ResultCode GetThreadContext(VAddr thread_context, Handle handle) { 500static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
500 LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle); 501 LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle);
501 502
502 auto& kernel = Core::System::GetInstance().Kernel(); 503 const auto* current_process = Core::CurrentProcess();
503 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(handle); 504 const SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle);
504 if (!thread) { 505 if (!thread) {
505 return ERR_INVALID_HANDLE; 506 return ERR_INVALID_HANDLE;
506 } 507 }
507 508
508 const auto* current_process = Core::CurrentProcess();
509 if (thread->GetOwnerProcess() != current_process) { 509 if (thread->GetOwnerProcess() != current_process) {
510 return ERR_INVALID_HANDLE; 510 return ERR_INVALID_HANDLE;
511 } 511 }
@@ -531,10 +531,11 @@ static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
531 531
532/// Gets the priority for the specified thread 532/// Gets the priority for the specified thread
533static ResultCode GetThreadPriority(u32* priority, Handle handle) { 533static ResultCode GetThreadPriority(u32* priority, Handle handle) {
534 auto& kernel = Core::System::GetInstance().Kernel(); 534 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
535 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(handle); 535 const SharedPtr<Thread> thread = handle_table.Get<Thread>(handle);
536 if (!thread) 536 if (!thread) {
537 return ERR_INVALID_HANDLE; 537 return ERR_INVALID_HANDLE;
538 }
538 539
539 *priority = thread->GetPriority(); 540 *priority = thread->GetPriority();
540 return RESULT_SUCCESS; 541 return RESULT_SUCCESS;
@@ -546,14 +547,15 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
546 return ERR_INVALID_THREAD_PRIORITY; 547 return ERR_INVALID_THREAD_PRIORITY;
547 } 548 }
548 549
549 auto& kernel = Core::System::GetInstance().Kernel(); 550 const auto* const current_process = Core::CurrentProcess();
550 SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(handle); 551 SharedPtr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle);
551 if (!thread) 552 if (!thread) {
552 return ERR_INVALID_HANDLE; 553 return ERR_INVALID_HANDLE;
554 }
553 555
554 // Note: The kernel uses the current process's resource limit instead of 556 // Note: The kernel uses the current process's resource limit instead of
555 // the one from the thread owner's resource limit. 557 // the one from the thread owner's resource limit.
556 const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit(); 558 const ResourceLimit& resource_limit = current_process->GetResourceLimit();
557 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { 559 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) {
558 return ERR_NOT_AUTHORIZED; 560 return ERR_NOT_AUTHORIZED;
559 } 561 }
@@ -595,15 +597,13 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s
595 return ERR_INVALID_MEMORY_PERMISSIONS; 597 return ERR_INVALID_MEMORY_PERMISSIONS;
596 } 598 }
597 599
598 auto& kernel = Core::System::GetInstance().Kernel(); 600 auto* const current_process = Core::CurrentProcess();
599 auto shared_memory = kernel.HandleTable().Get<SharedMemory>(shared_memory_handle); 601 auto shared_memory = current_process->GetHandleTable().Get<SharedMemory>(shared_memory_handle);
600 if (!shared_memory) { 602 if (!shared_memory) {
601 return ERR_INVALID_HANDLE; 603 return ERR_INVALID_HANDLE;
602 } 604 }
603 605
604 auto* const current_process = Core::CurrentProcess();
605 const auto& vm_manager = current_process->VMManager(); 606 const auto& vm_manager = current_process->VMManager();
606
607 if (!vm_manager.IsWithinASLRRegion(addr, size)) { 607 if (!vm_manager.IsWithinASLRRegion(addr, size)) {
608 return ERR_INVALID_MEMORY_RANGE; 608 return ERR_INVALID_MEMORY_RANGE;
609 } 609 }
@@ -627,15 +627,13 @@ static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64
627 return ERR_INVALID_ADDRESS_STATE; 627 return ERR_INVALID_ADDRESS_STATE;
628 } 628 }
629 629
630 auto& kernel = Core::System::GetInstance().Kernel(); 630 auto* const current_process = Core::CurrentProcess();
631 auto shared_memory = kernel.HandleTable().Get<SharedMemory>(shared_memory_handle); 631 auto shared_memory = current_process->GetHandleTable().Get<SharedMemory>(shared_memory_handle);
632 if (!shared_memory) { 632 if (!shared_memory) {
633 return ERR_INVALID_HANDLE; 633 return ERR_INVALID_HANDLE;
634 } 634 }
635 635
636 auto* const current_process = Core::CurrentProcess();
637 const auto& vm_manager = current_process->VMManager(); 636 const auto& vm_manager = current_process->VMManager();
638
639 if (!vm_manager.IsWithinASLRRegion(addr, size)) { 637 if (!vm_manager.IsWithinASLRRegion(addr, size)) {
640 return ERR_INVALID_MEMORY_RANGE; 638 return ERR_INVALID_MEMORY_RANGE;
641 } 639 }
@@ -646,9 +644,8 @@ static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64
646/// Query process memory 644/// Query process memory
647static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, 645static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/,
648 Handle process_handle, u64 addr) { 646 Handle process_handle, u64 addr) {
649 647 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
650 auto& kernel = Core::System::GetInstance().Kernel(); 648 SharedPtr<Process> process = handle_table.Get<Process>(process_handle);
651 SharedPtr<Process> process = kernel.HandleTable().Get<Process>(process_handle);
652 if (!process) { 649 if (!process) {
653 return ERR_INVALID_HANDLE; 650 return ERR_INVALID_HANDLE;
654 } 651 }
@@ -695,20 +692,19 @@ static void ExitProcess() {
695/// Creates a new thread 692/// Creates a new thread
696static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, VAddr stack_top, 693static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, VAddr stack_top,
697 u32 priority, s32 processor_id) { 694 u32 priority, s32 processor_id) {
698 std::string name = fmt::format("thread-{:X}", entry_point);
699
700 if (priority > THREADPRIO_LOWEST) { 695 if (priority > THREADPRIO_LOWEST) {
701 return ERR_INVALID_THREAD_PRIORITY; 696 return ERR_INVALID_THREAD_PRIORITY;
702 } 697 }
703 698
704 const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit(); 699 auto* const current_process = Core::CurrentProcess();
700 const ResourceLimit& resource_limit = current_process->GetResourceLimit();
705 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) { 701 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) {
706 return ERR_NOT_AUTHORIZED; 702 return ERR_NOT_AUTHORIZED;
707 } 703 }
708 704
709 if (processor_id == THREADPROCESSORID_DEFAULT) { 705 if (processor_id == THREADPROCESSORID_DEFAULT) {
710 // Set the target CPU to the one specified in the process' exheader. 706 // Set the target CPU to the one specified in the process' exheader.
711 processor_id = Core::CurrentProcess()->GetDefaultProcessorID(); 707 processor_id = current_process->GetDefaultProcessorID();
712 ASSERT(processor_id != THREADPROCESSORID_DEFAULT); 708 ASSERT(processor_id != THREADPROCESSORID_DEFAULT);
713 } 709 }
714 710
@@ -723,11 +719,13 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
723 return ERR_INVALID_PROCESSOR_ID; 719 return ERR_INVALID_PROCESSOR_ID;
724 } 720 }
725 721
722 const std::string name = fmt::format("thread-{:X}", entry_point);
726 auto& kernel = Core::System::GetInstance().Kernel(); 723 auto& kernel = Core::System::GetInstance().Kernel();
727 CASCADE_RESULT(SharedPtr<Thread> thread, 724 CASCADE_RESULT(SharedPtr<Thread> thread,
728 Thread::Create(kernel, name, entry_point, priority, arg, processor_id, stack_top, 725 Thread::Create(kernel, name, entry_point, priority, arg, processor_id, stack_top,
729 *Core::CurrentProcess())); 726 *current_process));
730 const auto new_guest_handle = kernel.HandleTable().Create(thread); 727
728 const auto new_guest_handle = current_process->GetHandleTable().Create(thread);
731 if (new_guest_handle.Failed()) { 729 if (new_guest_handle.Failed()) {
732 return new_guest_handle.Code(); 730 return new_guest_handle.Code();
733 } 731 }
@@ -748,8 +746,8 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
748static ResultCode StartThread(Handle thread_handle) { 746static ResultCode StartThread(Handle thread_handle) {
749 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); 747 LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
750 748
751 auto& kernel = Core::System::GetInstance().Kernel(); 749 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
752 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 750 const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
753 if (!thread) { 751 if (!thread) {
754 return ERR_INVALID_HANDLE; 752 return ERR_INVALID_HANDLE;
755 } 753 }
@@ -796,8 +794,8 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var
796 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", 794 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}",
797 mutex_addr, condition_variable_addr, thread_handle, nano_seconds); 795 mutex_addr, condition_variable_addr, thread_handle, nano_seconds);
798 796
799 auto& kernel = Core::System::GetInstance().Kernel(); 797 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
800 SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 798 SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
801 ASSERT(thread); 799 ASSERT(thread);
802 800
803 CASCADE_CODE(Mutex::Release(mutex_addr)); 801 CASCADE_CODE(Mutex::Release(mutex_addr));
@@ -908,9 +906,9 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
908 mutex_val | Mutex::MutexHasWaitersFlag)); 906 mutex_val | Mutex::MutexHasWaitersFlag));
909 907
910 // The mutex is already owned by some other thread, make this thread wait on it. 908 // The mutex is already owned by some other thread, make this thread wait on it.
911 auto& kernel = Core::System::GetInstance().Kernel(); 909 const Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask);
912 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); 910 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
913 auto owner = kernel.HandleTable().Get<Thread>(owner_handle); 911 auto owner = handle_table.Get<Thread>(owner_handle);
914 ASSERT(owner); 912 ASSERT(owner);
915 ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex); 913 ASSERT(thread->GetStatus() == ThreadStatus::WaitMutex);
916 thread->InvalidateWakeupCallback(); 914 thread->InvalidateWakeupCallback();
@@ -989,16 +987,16 @@ static u64 GetSystemTick() {
989static ResultCode CloseHandle(Handle handle) { 987static ResultCode CloseHandle(Handle handle) {
990 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); 988 LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
991 989
992 auto& kernel = Core::System::GetInstance().Kernel(); 990 auto& handle_table = Core::CurrentProcess()->GetHandleTable();
993 return kernel.HandleTable().Close(handle); 991 return handle_table.Close(handle);
994} 992}
995 993
996/// Reset an event 994/// Reset an event
997static ResultCode ResetSignal(Handle handle) { 995static ResultCode ResetSignal(Handle handle) {
998 LOG_WARNING(Kernel_SVC, "(STUBBED) called handle 0x{:08X}", handle); 996 LOG_WARNING(Kernel_SVC, "(STUBBED) called handle 0x{:08X}", handle);
999 997
1000 auto& kernel = Core::System::GetInstance().Kernel(); 998 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1001 auto event = kernel.HandleTable().Get<Event>(handle); 999 auto event = handle_table.Get<Event>(handle);
1002 1000
1003 ASSERT(event != nullptr); 1001 ASSERT(event != nullptr);
1004 1002
@@ -1017,8 +1015,8 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32
1017static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) { 1015static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) {
1018 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); 1016 LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
1019 1017
1020 auto& kernel = Core::System::GetInstance().Kernel(); 1018 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1021 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 1019 const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
1022 if (!thread) { 1020 if (!thread) {
1023 return ERR_INVALID_HANDLE; 1021 return ERR_INVALID_HANDLE;
1024 } 1022 }
@@ -1033,8 +1031,8 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) {
1033 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle, 1031 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle,
1034 mask, core); 1032 mask, core);
1035 1033
1036 auto& kernel = Core::System::GetInstance().Kernel(); 1034 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1037 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(thread_handle); 1035 const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
1038 if (!thread) { 1036 if (!thread) {
1039 return ERR_INVALID_HANDLE; 1037 return ERR_INVALID_HANDLE;
1040 } 1038 }
@@ -1095,7 +1093,7 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
1095 } 1093 }
1096 1094
1097 auto& kernel = Core::System::GetInstance().Kernel(); 1095 auto& kernel = Core::System::GetInstance().Kernel();
1098 auto& handle_table = kernel.HandleTable(); 1096 auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1099 auto shared_mem_handle = 1097 auto shared_mem_handle =
1100 SharedMemory::Create(kernel, handle_table.Get<Process>(KernelHandle::CurrentProcess), size, 1098 SharedMemory::Create(kernel, handle_table.Get<Process>(KernelHandle::CurrentProcess), size,
1101 local_perms, remote_perms); 1099 local_perms, remote_perms);
@@ -1107,10 +1105,12 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
1107static ResultCode ClearEvent(Handle handle) { 1105static ResultCode ClearEvent(Handle handle) {
1108 LOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle); 1106 LOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle);
1109 1107
1110 auto& kernel = Core::System::GetInstance().Kernel(); 1108 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1111 SharedPtr<Event> evt = kernel.HandleTable().Get<Event>(handle); 1109 SharedPtr<Event> evt = handle_table.Get<Event>(handle);
1112 if (evt == nullptr) 1110 if (evt == nullptr) {
1113 return ERR_INVALID_HANDLE; 1111 return ERR_INVALID_HANDLE;
1112 }
1113
1114 evt->Clear(); 1114 evt->Clear();
1115 return RESULT_SUCCESS; 1115 return RESULT_SUCCESS;
1116} 1116}
@@ -1123,8 +1123,8 @@ static ResultCode GetProcessInfo(u64* out, Handle process_handle, u32 type) {
1123 Status, 1123 Status,
1124 }; 1124 };
1125 1125
1126 const auto& kernel = Core::System::GetInstance().Kernel(); 1126 const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
1127 const auto process = kernel.HandleTable().Get<Process>(process_handle); 1127 const auto process = handle_table.Get<Process>(process_handle);
1128 if (!process) { 1128 if (!process) {
1129 return ERR_INVALID_HANDLE; 1129 return ERR_INVALID_HANDLE;
1130 } 1130 }