Update for latest libnx (including new-ipc)

This commit is contained in:
fincs 2019-10-20 03:11:50 +02:00
parent b33c5df54b
commit 3510f74c77
No known key found for this signature in database
GPG Key ID: 62C7609ADA219C60

View File

@ -25,6 +25,10 @@ static u128 g_userIdStorage;
static u8 g_savedTls[0x100]; static u8 g_savedTls[0x100];
// Minimize fs resource usage
u32 __nx_fs_num_sessions = 1;
u32 __nx_fsdev_direntry_cache_size = 1;
// Used by trampoline.s // Used by trampoline.s
Result g_lastRet = 0; Result g_lastRet = 0;
@ -145,24 +149,19 @@ static void procHandleReceiveThread(void* arg)
Handle session = (Handle)(uintptr_t)arg; Handle session = (Handle)(uintptr_t)arg;
Result rc; Result rc;
u32* tls = (u32*)armGetTls(); void* base = armGetTls();
tls[0] = 0; hipcMakeRequestInline(base);
tls[1] = 0;
s32 idx = 0; s32 idx = 0;
rc = svcReplyAndReceive(&idx, &session, 1, INVALID_HANDLE, UINT64_MAX); rc = svcReplyAndReceive(&idx, &session, 1, INVALID_HANDLE, UINT64_MAX);
if (R_FAILED(rc)) if (R_FAILED(rc))
fatalSimple(MAKERESULT(Module_HomebrewLoader, 15)); fatalSimple(MAKERESULT(Module_HomebrewLoader, 15));
IpcParsedCommand ipc; HipcParsedRequest r = hipcParseRequest(base);
rc = ipcParse(&ipc); if (r.meta.num_copy_handles != 1)
if (R_FAILED(rc))
fatalSimple(MAKERESULT(Module_HomebrewLoader, 16));
if (ipc.NumHandles != 1)
fatalSimple(MAKERESULT(Module_HomebrewLoader, 17)); fatalSimple(MAKERESULT(Module_HomebrewLoader, 17));
g_procHandle = ipc.Handles[0]; g_procHandle = r.data.copy_handles[0];
svcCloseHandle(session); svcCloseHandle(session);
} }
@ -211,7 +210,6 @@ static void getIsAutomaticGameplayRecording(void) {
static void getOwnProcessHandle(void) static void getOwnProcessHandle(void)
{ {
static Thread t;
Result rc; Result rc;
Handle server_handle, client_handle; Handle server_handle, client_handle;
@ -219,7 +217,8 @@ static void getOwnProcessHandle(void)
if (R_FAILED(rc)) if (R_FAILED(rc))
fatalSimple(MAKERESULT(Module_HomebrewLoader, 12)); fatalSimple(MAKERESULT(Module_HomebrewLoader, 12));
rc = threadCreate(&t, &procHandleReceiveThread, (void*)(uintptr_t)server_handle, 0x1000, 0x20, 0); Thread t;
rc = threadCreate(&t, &procHandleReceiveThread, (void*)(uintptr_t)server_handle, NULL, 0x1000, 0x20, 0);
if (R_FAILED(rc)) if (R_FAILED(rc))
fatalSimple(MAKERESULT(Module_HomebrewLoader, 10)); fatalSimple(MAKERESULT(Module_HomebrewLoader, 10));
@ -227,12 +226,11 @@ static void getOwnProcessHandle(void)
if (R_FAILED(rc)) if (R_FAILED(rc))
fatalSimple(MAKERESULT(Module_HomebrewLoader, 13)); fatalSimple(MAKERESULT(Module_HomebrewLoader, 13));
IpcCommand ipc; hipcMakeRequestInline(armGetTls(),
ipcInitialize(&ipc); .num_copy_handles = 1,
ipcSendHandleCopy(&ipc, CUR_PROCESS_HANDLE); ).copy_handles[0] = CUR_PROCESS_HANDLE;
ipcPrepareHeader(&ipc, 0);
ipcDispatch(client_handle); svcSendSyncRequest(client_handle);
svcCloseHandle(client_handle); svcCloseHandle(client_handle);
threadWaitForExit(&t); threadWaitForExit(&t);