-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to newest libnx and new dmntcht (#98)
* updated for new libnx, updated dmntcht * contents instead of titles * convert service names correctly * update libnx
- Loading branch information
1 parent
6970154
commit 44a30ce
Showing
20 changed files
with
426 additions
and
798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,92 @@ | ||
#pragma once | ||
|
||
#include <edizon.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
u64 base; | ||
u64 size; | ||
} DmntMemoryRegionExtents; | ||
|
||
typedef struct { | ||
u64 process_id; | ||
u64 title_id; | ||
DmntMemoryRegionExtents main_nso_extents; | ||
DmntMemoryRegionExtents heap_extents; | ||
DmntMemoryRegionExtents alias_extents; | ||
DmntMemoryRegionExtents address_space_extents; | ||
u8 main_nso_build_id[0x20]; | ||
} DmntCheatProcessMetadata; | ||
|
||
typedef struct { | ||
char readable_name[0x40]; | ||
uint32_t num_opcodes; | ||
uint32_t opcodes[0x100]; | ||
} DmntCheatDefinition; | ||
|
||
typedef struct { | ||
bool enabled; | ||
uint32_t cheat_id; | ||
DmntCheatDefinition definition; | ||
} DmntCheatEntry; | ||
|
||
typedef struct { | ||
u64 value; | ||
u8 width; | ||
} DmntFrozenAddressValue; | ||
|
||
typedef struct { | ||
u64 address; | ||
DmntFrozenAddressValue value; | ||
} DmntFrozenAddressEntry; | ||
|
||
Result dmntchtInitialize(void); | ||
void dmntchtExit(void); | ||
Service* dmntchtGetServiceSession(void); | ||
|
||
Result dmntchtHasCheatProcess(bool *out); | ||
Result dmntchtGetCheatProcessEvent(Event *event); | ||
Result dmntchtGetCheatProcessMetadata(DmntCheatProcessMetadata *out_metadata); | ||
Result dmntchtForceOpenCheatProcess(void); | ||
|
||
Result dmntchtGetCheatProcessMappingCount(u64 *out_count); | ||
Result dmntchtGetCheatProcessMappings(MemoryInfo *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtReadCheatProcessMemory(u64 address, void *buffer, size_t size); | ||
Result dmntchtWriteCheatProcessMemory(u64 address, const void *buffer, size_t size); | ||
Result dmntchtQueryCheatProcessMemory(MemoryInfo *mem_info, u64 address); | ||
|
||
Result dmntchtGetCheatCount(u64 *out_count); | ||
Result dmntchtGetCheats(DmntCheatEntry *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtGetCheatById(DmntCheatEntry *out_cheat, u32 cheat_id); | ||
Result dmntchtToggleCheat(u32 cheat_id); | ||
Result dmntchtAddCheat(DmntCheatDefinition *cheat, bool enabled, u32 *out_cheat_id); | ||
Result dmntchtRemoveCheat(u32 cheat_id); | ||
|
||
Result dmntchtGetFrozenAddressCount(u64 *out_count); | ||
Result dmntchtGetFrozenAddresses(DmntFrozenAddressEntry *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtGetFrozenAddress(DmntFrozenAddressEntry *out, u64 address); | ||
Result dmntchtEnableFrozenAddress(u64 address, u64 width, u64 *out_value); | ||
Result dmntchtDisableFrozenAddress(u64 address); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* | ||
* Copyright (c) 2018-2019 Atmosphère-NX | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <edizon.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
u64 base; | ||
u64 size; | ||
} DmntMemoryRegionExtents; | ||
|
||
typedef struct { | ||
u64 process_id; | ||
u64 title_id; | ||
DmntMemoryRegionExtents main_nso_extents; | ||
DmntMemoryRegionExtents heap_extents; | ||
DmntMemoryRegionExtents alias_extents; | ||
DmntMemoryRegionExtents address_space_extents; | ||
u8 main_nso_build_id[0x20]; | ||
} DmntCheatProcessMetadata; | ||
|
||
typedef struct { | ||
char readable_name[0x40]; | ||
uint32_t num_opcodes; | ||
uint32_t opcodes[0x100]; | ||
} DmntCheatDefinition; | ||
|
||
typedef struct { | ||
bool enabled; | ||
uint32_t cheat_id; | ||
DmntCheatDefinition definition; | ||
} DmntCheatEntry; | ||
|
||
typedef struct { | ||
u64 value; | ||
u8 width; | ||
} DmntFrozenAddressValue; | ||
|
||
typedef struct { | ||
u64 address; | ||
DmntFrozenAddressValue value; | ||
} DmntFrozenAddressEntry; | ||
|
||
Result dmntchtInitialize(void); | ||
void dmntchtExit(void); | ||
Service* dmntchtGetServiceSession(void); | ||
|
||
Result dmntchtHasCheatProcess(bool *out); | ||
Result dmntchtGetCheatProcessEvent(Event *event); | ||
Result dmntchtGetCheatProcessMetadata(DmntCheatProcessMetadata *out_metadata); | ||
Result dmntchtForceOpenCheatProcess(void); | ||
|
||
Result dmntchtGetCheatProcessMappingCount(u64 *out_count); | ||
Result dmntchtGetCheatProcessMappings(MemoryInfo *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtReadCheatProcessMemory(u64 address, void *buffer, size_t size); | ||
Result dmntchtWriteCheatProcessMemory(u64 address, const void *buffer, size_t size); | ||
Result dmntchtQueryCheatProcessMemory(MemoryInfo *mem_info, u64 address); | ||
|
||
Result dmntchtGetCheatCount(u64 *out_count); | ||
Result dmntchtGetCheats(DmntCheatEntry *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtGetCheatById(DmntCheatEntry *out_cheat, u32 cheat_id); | ||
Result dmntchtToggleCheat(u32 cheat_id); | ||
Result dmntchtAddCheat(DmntCheatDefinition *cheat, bool enabled, u32 *out_cheat_id); | ||
Result dmntchtRemoveCheat(u32 cheat_id); | ||
|
||
Result dmntchtGetFrozenAddressCount(u64 *out_count); | ||
Result dmntchtGetFrozenAddresses(DmntFrozenAddressEntry *buffer, u64 max_count, u64 offset, u64 *out_count); | ||
Result dmntchtGetFrozenAddress(DmntFrozenAddressEntry *out, u64 address); | ||
Result dmntchtEnableFrozenAddress(u64 address, u64 width, u64 *out_value); | ||
Result dmntchtDisableFrozenAddress(u64 address); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#pragma once | ||
#include <switch/types.h> | ||
#include <switch/result.h> | ||
#include <switch/kernel/mutex.h> | ||
#include <switch/sf/service.h> | ||
#include <switch/services/sm.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct ServiceGuard { | ||
Mutex mutex; | ||
u32 refCount; | ||
} ServiceGuard; | ||
|
||
NX_INLINE bool serviceGuardBeginInit(ServiceGuard* g) | ||
{ | ||
mutexLock(&g->mutex); | ||
return (g->refCount++) == 0; | ||
} | ||
|
||
NX_INLINE Result serviceGuardEndInit(ServiceGuard* g, Result rc, void (*cleanupFunc)(void)) | ||
{ | ||
if (R_FAILED(rc)) { | ||
cleanupFunc(); | ||
--g->refCount; | ||
} | ||
mutexUnlock(&g->mutex); | ||
return rc; | ||
} | ||
|
||
NX_INLINE void serviceGuardExit(ServiceGuard* g, void (*cleanupFunc)(void)) | ||
{ | ||
mutexLock(&g->mutex); | ||
if (g->refCount && (--g->refCount) == 0) | ||
cleanupFunc(); | ||
mutexUnlock(&g->mutex); | ||
} | ||
|
||
#define NX_GENERATE_SERVICE_GUARD_PARAMS(name, _paramdecl, _parampass) \ | ||
\ | ||
static ServiceGuard g_##name##Guard; \ | ||
NX_INLINE Result _##name##Initialize _paramdecl; \ | ||
static void _##name##Cleanup(void); \ | ||
\ | ||
Result name##Initialize _paramdecl \ | ||
{ \ | ||
Result rc = 0; \ | ||
if (serviceGuardBeginInit(&g_##name##Guard)) \ | ||
rc = _##name##Initialize _parampass; \ | ||
return serviceGuardEndInit(&g_##name##Guard, rc, _##name##Cleanup); \ | ||
} \ | ||
\ | ||
void name##Exit(void) \ | ||
{ \ | ||
serviceGuardExit(&g_##name##Guard, _##name##Cleanup); \ | ||
} | ||
|
||
#define NX_GENERATE_SERVICE_GUARD(name) NX_GENERATE_SERVICE_GUARD_PARAMS(name, (void), ()) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.