From ac995a77c048efb69adf67d9da94190001fa6173 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 16 Sep 2017 23:44:26 +0200 Subject: [PATCH 1/7] add nn_act_GetDefaultAccount --- nn_act_functions.c | 8 +++++--- nn_act_functions.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nn_act_functions.c b/nn_act_functions.c index 5c2a959..f51b8c9 100644 --- a/nn_act_functions.c +++ b/nn_act_functions.c @@ -29,6 +29,7 @@ u32 nn_act_handle __attribute__((section(".data"))) = 0; EXPORT_DECL(void, nn_act_Initialize, void); EXPORT_DECL(void, nn_act_Finalize, void); EXPORT_DECL(u8, nn_act_GetSlotNo, void); +EXPORT_DECL(u8, nn_act_GetDefaultAccount, void); EXPORT_DECL(u32, nn_act_GetPersistentIdEx, u8 slot); void InitAcquireACT(void) @@ -42,7 +43,8 @@ void InitACTFunctionPointers(void) InitAcquireACT(); OS_FIND_EXPORT_EX(nn_act_handle, Initialize__Q2_2nn3actFv, nn_act_Initialize) - OS_FIND_EXPORT_EX(nn_act_handle, Finalize__Q2_2nn3actFv, nn_act_Finalize) - OS_FIND_EXPORT_EX(nn_act_handle, GetSlotNo__Q2_2nn3actFv, nn_act_GetSlotNo) - OS_FIND_EXPORT_EX(nn_act_handle, GetPersistentIdEx__Q2_2nn3actFUc, nn_act_GetPersistentIdEx) + OS_FIND_EXPORT_EX(nn_act_handle, Finalize__Q2_2nn3actFv, nn_act_Finalize) + OS_FIND_EXPORT_EX(nn_act_handle, GetSlotNo__Q2_2nn3actFv, nn_act_GetSlotNo) + OS_FIND_EXPORT_EX(nn_act_handle, GetDefaultAccount__Q2_2nn3actFv, nn_act_GetDefaultAccount) + OS_FIND_EXPORT_EX(nn_act_handle, GetPersistentIdEx__Q2_2nn3actFUc, nn_act_GetPersistentIdEx) } diff --git a/nn_act_functions.h b/nn_act_functions.h index 9567bf7..a3cc26c 100644 --- a/nn_act_functions.h +++ b/nn_act_functions.h @@ -35,6 +35,7 @@ extern u32 nn_act_handle; extern void(* nn_act_Initialize)(void); extern void(* nn_act_Finalize)(void); extern u8(* nn_act_GetSlotNo)(void); +extern u8(* nn_act_GetDefaultAccount)(void); extern u32(*nn_act_GetPersistentIdEx)(u8 slot); void InitACTFunctionPointers(void); From e2482f9e322b174cfb1b1336720d0724e81ce455 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 16 Sep 2017 23:45:37 +0200 Subject: [PATCH 2/7] add _SYSLaunchMenuWithCheckingAccount and SYSLaunchSettings --- os_types.h | 9 ++++----- sys_functions.c | 4 ++++ sys_functions.h | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/os_types.h b/os_types.h index a600e51..d4956e7 100644 --- a/os_types.h +++ b/os_types.h @@ -113,7 +113,6 @@ typedef enum OSExceptionType OS_EXCEPTION_TYPE_ICI = 14, } OSExceptionType; - typedef int (*ThreadFunc)(int argc, void *argv); struct OSThread_ { @@ -129,12 +128,12 @@ struct OSThread_ { char _[0x394 - 0x330]; - void *stackBase; - void *stackEnd; + void *stackBase; + void *stackEnd; - ThreadFunc entryPoint; + ThreadFunc entryPoint; - char _3A0[0x6A0 - 0x3A0]; + char _3A0[0x6A0 - 0x3A0]; }; typedef struct _OSCalendarTime { diff --git a/sys_functions.c b/sys_functions.c index a4a568a..be4f281 100644 --- a/sys_functions.c +++ b/sys_functions.c @@ -28,8 +28,10 @@ u32 sysapp_handle __attribute__((section(".data"))) = 0; EXPORT_DECL(s32, _SYSLaunchTitleByPathFromLauncher, const char* path, s32 len, s32 zero); EXPORT_DECL(s32, SYSRelaunchTitle, s32 argc, char** argv); EXPORT_DECL(s32, SYSLaunchMenu, void); +EXPORT_DECL(s32, _SYSLaunchMenuWithCheckingAccount, unsigned char slot); EXPORT_DECL(s32, SYSCheckTitleExists, u64 titleId); EXPORT_DECL(s32, SYSLaunchTitle, u64 titleId); +EXPORT_DECL(s32, SYSLaunchSettings, s32 unk); void InitAcquireSys(void) { @@ -44,6 +46,8 @@ void InitSysFunctionPointers(void) OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher); OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle); OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu); + OS_FIND_EXPORT(sysapp_handle, _SYSLaunchMenuWithCheckingAccount); OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists); OS_FIND_EXPORT(sysapp_handle, SYSLaunchTitle); + OS_FIND_EXPORT(sysapp_handle, SYSLaunchSettings); } diff --git a/sys_functions.h b/sys_functions.h index e448410..56ebe87 100644 --- a/sys_functions.h +++ b/sys_functions.h @@ -38,8 +38,10 @@ void InitAcquireSys(void); extern int(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero); extern int (* SYSRelaunchTitle)(s32 argc, char** argv); extern int (* SYSLaunchMenu)(void); +extern int (* _SYSLaunchMenuWithCheckingAccount)(unsigned char slot); extern int (* SYSCheckTitleExists)(u64 titleId); extern int (* SYSLaunchTitle)(u64 titleId); +extern int (* SYSLaunchSettings)(s32 unk); #ifdef __cplusplus From 9d75f910f15a172c77ecdf2f02484bc3225bb4ec Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 16 Sep 2017 23:47:01 +0200 Subject: [PATCH 3/7] add OSScreenShutdown --- os_functions.c | 2 ++ os_functions.h | 1 + 2 files changed, 3 insertions(+) diff --git a/os_functions.c b/os_functions.c index 73737e2..d763a83 100644 --- a/os_functions.c +++ b/os_functions.c @@ -94,6 +94,7 @@ EXPORT_DECL(s32, __os_snprintf, char* s, s32 n, const char * format, ...); EXPORT_DECL(s32 *, __gh_errno_ptr, void); EXPORT_DECL(void, OSScreenInit, void); +EXPORT_DECL(void, OSScreenShutdown, void); EXPORT_DECL(u32, OSScreenGetBufferSizeEx, u32 bufferNum); EXPORT_DECL(s32, OSScreenSetBufferEx, u32 bufferNum, void * addr); EXPORT_DECL(s32, OSScreenClearBufferEx, u32 bufferNum, u32 temp); @@ -244,6 +245,7 @@ void InitOSFunctionPointers(void) OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); OS_FIND_EXPORT(coreinit_handle, OSScreenInit); + OS_FIND_EXPORT(coreinit_handle, OSScreenShutdown); OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); diff --git a/os_functions.h b/os_functions.h index 859fd85..4f1bbcb 100644 --- a/os_functions.h +++ b/os_functions.h @@ -132,6 +132,7 @@ extern s32 (* __os_snprintf)(char* s, s32 n, const char * format, ...); extern s32 * (* __gh_errno_ptr)(void); extern void (*OSScreenInit)(void); +extern void (*OSScreenShutdown)(void); extern u32 (*OSScreenGetBufferSizeEx)(u32 bufferNum); extern s32 (*OSScreenSetBufferEx)(u32 bufferNum, void * addr); extern s32 (*OSScreenClearBufferEx)(u32 bufferNum, u32 temp); From 501fa6a404bb512f6b7d855d749a803fff944ea5 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 17 Sep 2017 00:01:28 +0200 Subject: [PATCH 4/7] use s32 in sys_functions.h --- sys_functions.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys_functions.h b/sys_functions.h index 56ebe87..c68e506 100644 --- a/sys_functions.h +++ b/sys_functions.h @@ -35,13 +35,13 @@ extern u32 sysapp_handle; void InitSysFunctionPointers(void); void InitAcquireSys(void); -extern int(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero); -extern int (* SYSRelaunchTitle)(s32 argc, char** argv); -extern int (* SYSLaunchMenu)(void); -extern int (* _SYSLaunchMenuWithCheckingAccount)(unsigned char slot); -extern int (* SYSCheckTitleExists)(u64 titleId); -extern int (* SYSLaunchTitle)(u64 titleId); -extern int (* SYSLaunchSettings)(s32 unk); +extern s32(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero); +extern s32 (* SYSRelaunchTitle)(s32 argc, char** argv); +extern s32 (* SYSLaunchMenu)(void); +extern s32 (* _SYSLaunchMenuWithCheckingAccount)(unsigned char slot); +extern s32 (* SYSCheckTitleExists)(u64 titleId); +extern s32 (* SYSLaunchTitle)(u64 titleId); +extern s32 (* SYSLaunchSettings)(s32 unk); #ifdef __cplusplus From 18f241d53ce14e775e2a66111af2d461fb3f9f01 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 17 Sep 2017 00:02:00 +0200 Subject: [PATCH 5/7] use u8, u32, u64 in fs_defs.h --- fs_defs.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs_defs.h b/fs_defs.h index 1dc880b..588f0c0 100644 --- a/fs_defs.h +++ b/fs_defs.h @@ -44,17 +44,17 @@ typedef struct FSCmdBlock_ { typedef struct { - uint32_t flag; - uint32_t permission; - uint32_t owner_id; - uint32_t group_id; - uint32_t size; - uint32_t alloc_size; - uint64_t quota_size; - uint32_t ent_id; - uint64_t ctime; - uint64_t mtime; - uint8_t attributes[48]; + u32 flag; + u32 permission; + u32 owner_id; + u32 group_id; + u32 size; + u32 alloc_size; + u64 quota_size; + u32 ent_id; + u64 ctime; + u64 mtime; + u8 attributes[48]; } __attribute__((packed)) FSStat; typedef struct @@ -63,7 +63,7 @@ typedef struct char name[FS_MAX_ENTNAME_SIZE]; } FSDirEntry; -typedef void (*FSAsyncCallback)(FSClient * pClient, FSCmdBlock * pCmd, int result, void *context); +typedef void (*FSAsyncCallback)(FSClient * pClient, FSCmdBlock * pCmd, s32 result, void *context); typedef struct { FSAsyncCallback userCallback; From a227744f73a9397abf94f9d4489d72327566ba24 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 17 Sep 2017 00:02:54 +0200 Subject: [PATCH 6/7] unify types in fs_functions --- fs_functions.c | 4 ++-- fs_functions.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs_functions.c b/fs_functions.c index abf6f09..2526465 100644 --- a/fs_functions.c +++ b/fs_functions.c @@ -44,8 +44,8 @@ EXPORT_DECL(s32, FSRemove, void *pClient, void *pCmd, const char *path, s32 erro EXPORT_DECL(s32, FSRemoveAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); EXPORT_DECL(s32, FSFlushQuota, void *pClient, void *pCmd, const char* path, s32 error); EXPORT_DECL(s32, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); -EXPORT_DECL(s32, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); +EXPORT_DECL(s32, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error); +EXPORT_DECL(s32, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error, void *asyncParams); EXPORT_DECL(s32, FSRollbackQuota, void *pClient, void *pCmd, const char *path, s32 error); EXPORT_DECL(s32, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); diff --git a/fs_functions.h b/fs_functions.h index 4fefb59..4728359 100644 --- a/fs_functions.h +++ b/fs_functions.h @@ -57,8 +57,8 @@ extern s32 (* FSRemove)(void *pClient, void *pCmd, const char *path, s32 error); extern s32 (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); extern s32 (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, s32 error); extern s32 (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -extern s32 (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); -extern s32 (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); +extern s32 (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error); +extern s32 (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, u64 *returnedFreeSize, s32 error, void *asyncParams); extern s32 (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, s32 error); extern s32 (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); From 90c40a36c63f5819b0080d7a32fde2586445fd3a Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 17 Sep 2017 00:04:01 +0200 Subject: [PATCH 7/7] unify types in os_functions --- os_functions.c | 4 ++-- os_functions.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os_functions.c b/os_functions.c index d763a83..bcf0c7c 100644 --- a/os_functions.c +++ b/os_functions.c @@ -118,9 +118,9 @@ EXPORT_DECL(void *, MEMAllocFromExpHeapEx, s32 heap, u32 size, s32 align); EXPORT_DECL(s32 , MEMCreateExpHeapEx, void* address, u32 size, unsigned short flags); EXPORT_DECL(void *, MEMDestroyExpHeap, s32 heap); EXPORT_DECL(void, MEMFreeToExpHeap, s32 heap, void* ptr); -EXPORT_DECL(void *, OSAllocFromSystem, int size, int alignment); +EXPORT_DECL(void *, OSAllocFromSystem, u32 size, s32 alignment); EXPORT_DECL(void, OSFreeToSystem, void *addr); -EXPORT_DECL(int, OSIsAddressValid, void *ptr); +EXPORT_DECL(s32, OSIsAddressValid, void *ptr); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! MCP functions diff --git a/os_functions.h b/os_functions.h index 4f1bbcb..69eebe0 100644 --- a/os_functions.h +++ b/os_functions.h @@ -161,9 +161,9 @@ extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align); extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); extern void *(* MEMDestroyExpHeap)(s32 heap); extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); -extern void* (* OSAllocFromSystem)(int size, int alignment); +extern void* (* OSAllocFromSystem)(u32 size, s32 alignment); extern void (* OSFreeToSystem)(void *addr); -extern int (* OSIsAddressValid)(void *ptr); +extern s32 (* OSIsAddressValid)(void *ptr); //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! MCP functions