1
0
Fork 0
forked from suyu/suyu
suyu/src/core/hle/kernel
Lioncash 7fe27de26e svc: Use the current process' handle table for retrieving the process instance to act upon
The kernel uses the handle table of the current process to retrieve the
process that should be used to retrieve certain information. To someone
not familiar with the kernel, this might raise the question of "Ok,
sounds nice, but doesn't this make it impossible to retrieve information
about the current process?".

No, it doesn't, because HandleTable instances in the kernel have the
notion of a "pseudo-handle", where certain values allow the kernel to
lookup objects outside of a given handle table. Currently, there's only
a pseudo-handle for the current process (0xFFFF8001) and a pseudo-handle
for the current thread (0xFFFF8000), so to retrieve the current process,
one would just pass 0xFFFF8001 into svcGetInfo.

The lookup itself in the handle table would be something like:

template <typename T>
T* Lookup(Handle handle) {
    if (handle == PSEUDO_HANDLE_CURRENT_PROCESS) {
        return CurrentProcess();
    }

    if (handle == PSUEDO_HANDLE_CURRENT_THREAD) {
        return CurrentThread();
    }

    return static_cast<T*>(&objects[handle]);
}

which, as is shown, allows accessing the current process or current
thread, even if those two objects aren't actually within the HandleTable
instance.
2018-12-02 03:41:49 -05:00
..
address_arbiter.cpp core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrs 2018-10-15 14:15:56 -04:00
address_arbiter.h kernel: Remove unnecessary includes 2018-07-31 10:15:17 -04:00
client_port.cpp Added forward define for ServerPort 2018-10-06 17:47:33 +10:00
client_port.h Added forward define for ServerPort 2018-10-06 17:47:33 +10:00
client_session.cpp kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
client_session.h kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
errors.h kernel/errors: Clean up error codes 2018-11-16 14:32:30 -05:00
event.cpp kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
event.h kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
handle_table.cpp kernel/handle_table: Move private static functions into the cpp file 2018-11-21 18:31:01 -05:00
handle_table.h kernel/handle_table: Move private static functions into the cpp file 2018-11-21 18:31:01 -05:00
hle_ipc.cpp kernel/process: Make the handle table per-process 2018-10-20 16:38:32 -04:00
hle_ipc.h hle_ipc: Add member function for querying the existence of a domain header 2018-10-29 23:28:04 -04:00
kernel.cpp kernel/resource_limit: Clean up interface 2018-11-19 18:16:39 -05:00
kernel.h kernel/resource_limit: Clean up interface 2018-11-19 18:16:39 -05:00
mutex.cpp general: Remove unused boost inclusions where applicable 2018-10-30 00:09:46 -04:00
mutex.h kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
object.cpp kernel/process: Make CodeSet a regular non-inherited object 2018-10-12 12:07:32 -04:00
object.h kernel/process: Make CodeSet a regular non-inherited object 2018-10-12 12:07:32 -04:00
process.cpp kernel/process: Move <random> include to the cpp file 2018-11-20 17:46:20 -05:00
process.h kernel/process: Move <random> include to the cpp file 2018-11-20 17:46:20 -05:00
resource_limit.cpp kernel/resource_limit: Clean up interface 2018-11-19 18:16:39 -05:00
resource_limit.h svc: Implement svcGetResourceLimitLimitValue() 2018-11-26 21:12:13 -05:00
scheduler.cpp svc: Implement svcGetInfo command 0xF0000002 2018-10-26 12:49:11 -04:00
scheduler.h svc: Implement svcGetInfo command 0xF0000002 2018-10-26 12:49:11 -04:00
server_port.cpp kernel/server_port: Simplify emptiness check within ShouldWait() 2018-10-24 14:24:36 -04:00
server_port.h Ported #4296 from citra 2018-10-06 16:49:01 +10:00
server_session.cpp hle_ipc: Add member function for querying the existence of a domain header 2018-10-29 23:28:04 -04:00
server_session.h kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
session.cpp Format: Run the new clang format on everything 2018-01-20 16:45:11 -07:00
session.h kernel: Move object class to its own source files 2018-08-01 23:34:42 -04:00
shared_memory.cpp kernel/shared_memory: Make Map() and Unmap() take the target process by reference rather than as a pointer 2018-11-19 09:20:29 -05:00
shared_memory.h kernel/shared_memory: Make Map() and Unmap() take the target process by reference rather than as a pointer 2018-11-19 09:20:29 -05:00
svc.cpp svc: Use the current process' handle table for retrieving the process instance to act upon 2018-12-02 03:41:49 -05:00
svc.h svc: Localize the GetInfo enum class to the function itself 2018-10-26 12:49:14 -04:00
svc_wrap.h svc: Implement svcCreateResourceLimit() 2018-11-26 21:10:31 -05:00
thread.cpp kernel/thread: Deduplicate scheduler switching code 2018-11-14 00:02:42 -05:00
thread.h kernel/thread: Deduplicate scheduler switching code 2018-11-14 00:02:42 -05:00
timer.cpp kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
timer.h kernel: Eliminate kernel global state 2018-08-28 22:31:51 -04:00
vm_manager.cpp ldr_ro: Add error check for memory allocation failure 2018-11-17 21:40:26 -05:00
vm_manager.h ldr_ro: Add error check for memory allocation failure 2018-11-17 21:40:26 -05:00
wait_object.cpp kernel/thread: Make all instance variables private 2018-10-04 00:14:15 -04:00
wait_object.h kernel/object: Remove unnecessary std::move from DynamicObjectCast() 2018-09-28 02:17:57 -04:00