diff --git a/k11_extension/include/kernel.h b/k11_extension/include/kernel.h index 2c0e941..807529f 100644 --- a/k11_extension/include/kernel.h +++ b/k11_extension/include/kernel.h @@ -1178,6 +1178,20 @@ static inline KDebug *debugOfProcess(KProcess *process) return KPROCESS_GET_RVALUE(process, debug); } +static inline const char *classNameOfAutoObject(KAutoObject *object) +{ + const char *name; + if(kernelVersion >= SYSTEM_VERSION(2, 46, 0)) + { + KClassToken tok; + object->vtable->GetClassToken(&tok, object); + name = tok.name; + } + else + name = object->vtable->GetClassName(object); + return name; +} + extern Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token); static inline Result createHandleForProcess(Handle *out, KProcess *process, KAutoObject *obj) diff --git a/k11_extension/source/svc/ControlService.c b/k11_extension/source/svc/ControlService.c index 1eb46cd..c356e1b 100644 --- a/k11_extension/source/svc/ControlService.c +++ b/k11_extension/source/svc/ControlService.c @@ -42,20 +42,12 @@ Result ControlService(ServiceOp op, u32 varg1, u32 varg2) KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTable, (Handle)varg2); if(obj == NULL) return 0xD8E007F7; // invalid handle - else if(kernelVersion >= SYSTEM_VERSION(2, 46, 0)) - { - KClassToken tok; - obj->vtable->GetClassToken(&tok, obj); - if(tok.flags == 0x95) - session = ((KServerSession *)obj)->parentSession; - else if(tok.flags == 0xA5) - session = ((KClientSession *)obj)->parentSession; - } else - { // not the exact same tests but it should work - if(strcmp(obj->vtable->GetClassName(obj), "KServerSession") == 0) + { + // not the exact same tests but it should work + if(strcmp(classNameOfAutoObject(obj), "KServerSession") == 0) session = ((KServerSession *)obj)->parentSession; - else if(strcmp(obj->vtable->GetClassName(obj), "KClientSession") == 0) + else if(strcmp(classNameOfAutoObject(obj), "KClientSession") == 0) session = ((KClientSession *)obj)->parentSession; } diff --git a/k11_extension/source/svc/SendSyncRequest.c b/k11_extension/source/svc/SendSyncRequest.c index 1d3c244..215c5ae 100644 --- a/k11_extension/source/svc/SendSyncRequest.c +++ b/k11_extension/source/svc/SendSyncRequest.c @@ -37,15 +37,8 @@ Result SendSyncRequestHook(Handle handle) bool skip = false; Result res = 0; - bool isValidClientSession = false; - if(clientSession != NULL && kernelVersion >= SYSTEM_VERSION(2, 46, 0)) - { - KClassToken tok; - clientSession->syncObject.autoObject.vtable->GetClassToken(&tok, &clientSession->syncObject.autoObject); - isValidClientSession = tok.flags == 0xA5; - } - else if(clientSession != NULL) // not the exact same test but it should work - isValidClientSession = strcmp(clientSession->syncObject.autoObject.vtable->GetClassName(&clientSession->syncObject.autoObject), "KClientSession") == 0; + // not the exact same test but it should work + bool isValidClientSession = clientSession != NULL && strcmp(classNameOfAutoObject(&clientSession->syncObject.autoObject), "KClientSession") == 0; if(isValidClientSession) { @@ -54,7 +47,7 @@ Result SendSyncRequestHook(Handle handle) case 0x10042: { SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); - if(info != NULL && strcmp(info->name, "srv:pm") == 0) + if(info != NULL && kernelVersion >= SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0) { res = doPublishToProcessHook(handle, cmdbuf); skip = true; @@ -112,7 +105,7 @@ Result SendSyncRequestHook(Handle handle) case 0x50100: { SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); - if(info != NULL && strcmp(info->name, "srv:") == 0) + if(info != NULL && (strcmp(info->name, "srv:") == 0 || (kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0))) { char name[9] = { 0 }; memcpy(name, cmdbuf + 1, 8); @@ -126,7 +119,8 @@ Result SendSyncRequestHook(Handle handle) outClientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, (Handle)cmdbuf[3]); if(outClientSession != NULL) { - SessionInfo_Add(outClientSession->parentSession, name); + if(strcmp(classNameOfAutoObject(&outClientSession->syncObject.autoObject), "KClientSession") == 0) + SessionInfo_Add(outClientSession->parentSession, name); outClientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&outClientSession->syncObject.autoObject); } } @@ -163,7 +157,7 @@ Result SendSyncRequestHook(Handle handle) case 0x4010042: { SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); - if(info != NULL && strcmp(info->name, "srv:pm") == 0) + if(info != NULL && kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0) { res = doPublishToProcessHook(handle, cmdbuf); skip = true; diff --git a/k11_extension/source/svc/TranslateHandle.c b/k11_extension/source/svc/TranslateHandle.c index 62d703c..e0b35be 100644 --- a/k11_extension/source/svc/TranslateHandle.c +++ b/k11_extension/source/svc/TranslateHandle.c @@ -50,14 +50,7 @@ Result TranslateHandle(u32 *outKAddr, char *outClassName, Handle handle) if(obj == NULL) return 0xD8E007F7; // invalid handle - if(kernelVersion >= SYSTEM_VERSION(2, 46, 0)) - { - KClassToken tok; - obj->vtable->GetClassToken(&tok, obj); - name = tok.name; - } - else - name = obj->vtable->GetClassName(obj); + name = classNameOfAutoObject(obj); if(name == NULL) // shouldn't happen name = "KAutoObject"; diff --git a/sysmodules/rosalina/rosalina.rsf b/sysmodules/rosalina/rosalina.rsf index 6600b60..67d62b5 100644 --- a/sysmodules/rosalina/rosalina.rsf +++ b/sysmodules/rosalina/rosalina.rsf @@ -1,7 +1,7 @@ BasicInfo: Title : rosalina CompanyCode : "00" - ProductCode : 0828builder + ProductCode : lennybuilder ContentType : Application Logo : None @@ -47,13 +47,13 @@ AccessControlInfo: # We're using the global custom bit31 mapping SystemCallAccess: - # The kernel extension removes svc perms checks, so... - SendSyncRequest2: 47 # CustomBackdoor - UnmapProcessMemory: 114 + # The kernel extension removes svc perms checks, so below is just to avoid a makerom error + Backdoor: 123 + KernelSetState: 124 InterruptNumbers: ServiceAccessControl: - - srv:pm + - fs:USER # Not strictly needed as rosalina has access to everything, it's rather to avoid a makerom warning FileSystemAccess: - DirectSdmc - CtrNandRw