Always patch FS and P9, remove SM service checks

This commit is contained in:
TuxSH
2017-11-02 21:52:14 +01:00
parent 8258a98647
commit 22a8661fe1
12 changed files with 17 additions and 136 deletions

View File

@@ -13,13 +13,6 @@ This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for
#include "srv_pm.h"
#include "list.h"
extern u32 __ctru_heap;
extern u32 __ctru_linear_heap;
extern char (*serviceAccessListBuffers)[34][8];
u32 __ctru_heap_size = 0x4000;
u32 __ctru_linear_heap_size = 0;
u32 nbSection0Modules;
Handle resumeGetServiceHandleOrPortRegisteredSemaphore;
@@ -43,7 +36,6 @@ void __appInit(void)
svcGetSystemInfo(&out, 26, 0);
nbSection0Modules = out;
assertSuccess(svcCreateSemaphore(&resumeGetServiceHandleOrPortRegisteredSemaphore, 0, 64));
serviceAccessListBuffers = (char (*)[34][8])__ctru_heap;
buildList(&freeSessionDataList, sessionDataPool, sizeof(sessionDataPool) / sizeof(SessionData), sizeof(SessionData));
buildList(&freeProcessDataList, processDataPool, sizeof(processDataPool) / sizeof(ProcessData), sizeof(ProcessData));
@@ -53,16 +45,7 @@ void __appInit(void)
// this is called after main exits
void __appExit(void){}
void __system_allocateHeaps(void)
{
u32 tmp = 0;
// Allocate the application heap
__ctru_heap = 0x08000000;
svcControlMemory(&tmp, __ctru_heap, 0x0, __ctru_heap_size, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
__ctru_linear_heap = 0;
}
void __system_allocateHeaps(void){}
void __system_initSyscalls(void){}

View File

@@ -10,10 +10,6 @@ This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for
#include "services.h"
ProcessDataList processDataInUseList = { NULL, NULL }, freeProcessDataList = { NULL, NULL };
char (*serviceAccessListBuffers)[34][8];
// The kernel limits the number of processes to 47 anyways...
static u64 freeServiceAccessListBuffersIds = (1ULL << 59) - 1;
ProcessData *findProcessData(u32 pid)
{
@@ -28,20 +24,10 @@ ProcessData *findProcessData(u32 pid)
ProcessData *doRegisterProcess(u32 pid, char (*serviceAccessList)[8], u32 serviceAccessListSize)
{
(void)serviceAccessList; // Service access list checks removed for Luma3DS, see original 3ds_sm for implementation details.
(void)serviceAccessListSize;
ProcessData *processData = (ProcessData *)allocateNode(&processDataInUseList, &freeProcessDataList, sizeof(ProcessData), false);
if(serviceAccessListSize != 0)
{
s32 bufferId = 63 - __builtin_clzll(freeServiceAccessListBuffersIds);
if(bufferId == -1)
panic();
else
{
freeServiceAccessListBuffersIds &= ~(1ULL << bufferId);
processData->serviceAccessList = serviceAccessListBuffers[bufferId];
processData->serviceAccessListSize = serviceAccessListSize;
memcpy(processData->serviceAccessList, serviceAccessList, serviceAccessListSize);
}
}
assertSuccess(svcCreateSemaphore(&processData->notificationSemaphore, 0, 0x10));
processData->pid = pid;
@@ -81,8 +67,6 @@ Result UnregisterProcess(u32 pid)
}
}
freeServiceAccessListBuffersIds |= 1ULL << (u32)((processData->serviceAccessList - serviceAccessListBuffers[0]) / 34);
moveNode(processData, &freeProcessDataList, false);
return 0;
}

View File

@@ -38,20 +38,11 @@ static s32 findServicePortByName(bool isNamedPort, const char *name, s32 nameSiz
static bool checkServiceAccess(SessionData *sessionData, const char *name, s32 nameSize)
{
if(sessionData->pid < nbSection0Modules)
return true;
(void)sessionData;
(void)name;
(void)nameSize;
ProcessData *processData = findProcessData(sessionData->pid);
if(processData == NULL)
return false;
for(u32 i = 0; i < processData->serviceAccessListSize; i++)
{
if(areServiceNamesEqual(processData->serviceAccessList[i], name, nameSize))
return true;
}
return false;
return true; // Service access list checks removed for Luma3DS, see original 3ds_sm for implementation details.
}
static Result doRegisterServiceOrPort(u32 pid, Handle *serverPort, Handle clientPort, const char *name, s32 nameSize, s32 maxSessions, bool isNamedPort)