From e94abc4b5e76b7adf1b6b2d1cd46242c645be884 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 17 Oct 2019 21:18:27 -0700 Subject: [PATCH] dmnt: update for new-ipc --- include/stratosphere/dmnt/dmnt_cheat_types.hpp | 11 ++++++++--- include/stratosphere/os/os_common_types.hpp | 10 +++++++--- include/stratosphere/os/os_thread.hpp | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/stratosphere/dmnt/dmnt_cheat_types.hpp b/include/stratosphere/dmnt/dmnt_cheat_types.hpp index 1edb9192..40413c30 100644 --- a/include/stratosphere/dmnt/dmnt_cheat_types.hpp +++ b/include/stratosphere/dmnt/dmnt_cheat_types.hpp @@ -16,7 +16,9 @@ #pragma once +#include "../os/os_common_types.hpp" #include "../ncm/ncm_types.hpp" +#include "../sf/sf_buffer_tags.hpp" namespace sts::dmnt::cheat { @@ -26,7 +28,7 @@ namespace sts::dmnt::cheat { u64 size; }; - u64 process_id; + os::ProcessId process_id; ncm::TitleId title_id; MemoryRegionExtents main_nso_extents; MemoryRegionExtents heap_extents; @@ -37,18 +39,21 @@ namespace sts::dmnt::cheat { static_assert(std::is_pod::value && sizeof(CheatProcessMetadata) == 0x70, "CheatProcessMetadata definition!"); - struct CheatDefinition { + struct CheatDefinition : sf::LargeData, sf::PrefersMapAliasTransferMode { char readable_name[0x40]; uint32_t num_opcodes; uint32_t opcodes[0x100]; }; - struct CheatEntry { + struct CheatEntry : sf::LargeData, sf::PrefersMapAliasTransferMode { bool enabled; uint32_t cheat_id; CheatDefinition definition; }; + static_assert(std::is_pod::value, "CheatDefinition"); + static_assert(std::is_pod::value, "CheatEntry"); + struct FrozenAddressValue { u64 value; u8 width; diff --git a/include/stratosphere/os/os_common_types.hpp b/include/stratosphere/os/os_common_types.hpp index afdab148..8740faed 100644 --- a/include/stratosphere/os/os_common_types.hpp +++ b/include/stratosphere/os/os_common_types.hpp @@ -46,10 +46,14 @@ namespace sts::os { inline constexpr const ProcessId InvalidProcessId = ProcessId::Invalid; + NX_INLINE Result GetProcessId(os::ProcessId *out, ::Handle process_handle) { + return svcGetProcessId(&out->value, process_handle); + } + NX_INLINE ProcessId GetCurrentProcessId() { - u64 current_process_id = 0; - R_ASSERT(svcGetProcessId(¤t_process_id, CUR_PROCESS_HANDLE)); - return os::ProcessId{current_process_id}; + os::ProcessId current_process_id; + R_ASSERT(GetProcessId(¤t_process_id, CUR_PROCESS_HANDLE)); + return current_process_id; } inline constexpr bool operator==(const ProcessId &lhs, const ProcessId &rhs) { diff --git a/include/stratosphere/os/os_thread.hpp b/include/stratosphere/os/os_thread.hpp index b0ab77f4..3d2b7f3c 100644 --- a/include/stratosphere/os/os_thread.hpp +++ b/include/stratosphere/os/os_thread.hpp @@ -52,4 +52,10 @@ namespace sts::os { } }; + NX_INLINE u32 GetCurrentThreadPriority() { + u32 prio; + R_ASSERT(svcGetThreadPriority(&prio, CUR_THREAD_HANDLE)); + return prio; + } + }