From adee775f443abfc17c0fe78a7487346e00b13ebc Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 20 Dec 2014 03:04:36 -0200 Subject: Kernel: Implement support for current thread pseudo-handle This boots a few (mostly Nintendo 1st party) games further. --- src/core/hle/kernel/kernel.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/hle/kernel/kernel.h') diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 7e0f15c8..861a8e69 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -14,6 +14,10 @@ typedef s32 Result; namespace Kernel { +// From kernel.h. Declarations duplicated here to avoid a circular header dependency. +class Thread; +Thread* GetCurrentThread(); + enum KernelHandle { CurrentThread = 0xFFFF8000, CurrentProcess = 0xFFFF8001, @@ -81,6 +85,10 @@ public: template T* Get(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast(GetCurrentThread()); + } + if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { if (handle != 0) { LOG_ERROR(Kernel, "Bad object handle %08x", handle); @@ -99,6 +107,10 @@ public: // ONLY use this when you know the handle is valid. template T *GetFast(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast(GetCurrentThread()); + } + const Handle realHandle = handle - HANDLE_OFFSET; _dbg_assert_(Kernel, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); return static_cast(pool[realHandle]); -- cgit v1.2.3