Some kext refactoring
This commit is contained in:
parent
46e9cb6b23
commit
cfc6cf24bf
@ -1178,6 +1178,20 @@ static inline KDebug *debugOfProcess(KProcess *process)
|
|||||||
return KPROCESS_GET_RVALUE(process, debug);
|
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);
|
extern Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
|
||||||
|
|
||||||
static inline Result createHandleForProcess(Handle *out, KProcess *process, KAutoObject *obj)
|
static inline Result createHandleForProcess(Handle *out, KProcess *process, KAutoObject *obj)
|
||||||
|
@ -42,20 +42,12 @@ Result ControlService(ServiceOp op, u32 varg1, u32 varg2)
|
|||||||
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTable, (Handle)varg2);
|
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTable, (Handle)varg2);
|
||||||
if(obj == NULL)
|
if(obj == NULL)
|
||||||
return 0xD8E007F7; // invalid handle
|
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
|
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;
|
session = ((KServerSession *)obj)->parentSession;
|
||||||
else if(strcmp(obj->vtable->GetClassName(obj), "KClientSession") == 0)
|
else if(strcmp(classNameOfAutoObject(obj), "KClientSession") == 0)
|
||||||
session = ((KClientSession *)obj)->parentSession;
|
session = ((KClientSession *)obj)->parentSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,15 +37,8 @@ Result SendSyncRequestHook(Handle handle)
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
|
|
||||||
bool isValidClientSession = false;
|
// not the exact same test but it should work
|
||||||
if(clientSession != NULL && kernelVersion >= SYSTEM_VERSION(2, 46, 0))
|
bool isValidClientSession = clientSession != NULL && strcmp(classNameOfAutoObject(&clientSession->syncObject.autoObject), "KClientSession") == 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;
|
|
||||||
|
|
||||||
if(isValidClientSession)
|
if(isValidClientSession)
|
||||||
{
|
{
|
||||||
@ -54,7 +47,7 @@ Result SendSyncRequestHook(Handle handle)
|
|||||||
case 0x10042:
|
case 0x10042:
|
||||||
{
|
{
|
||||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
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);
|
res = doPublishToProcessHook(handle, cmdbuf);
|
||||||
skip = true;
|
skip = true;
|
||||||
@ -112,7 +105,7 @@ Result SendSyncRequestHook(Handle handle)
|
|||||||
case 0x50100:
|
case 0x50100:
|
||||||
{
|
{
|
||||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
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 };
|
char name[9] = { 0 };
|
||||||
memcpy(name, cmdbuf + 1, 8);
|
memcpy(name, cmdbuf + 1, 8);
|
||||||
@ -126,6 +119,7 @@ Result SendSyncRequestHook(Handle handle)
|
|||||||
outClientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, (Handle)cmdbuf[3]);
|
outClientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, (Handle)cmdbuf[3]);
|
||||||
if(outClientSession != NULL)
|
if(outClientSession != NULL)
|
||||||
{
|
{
|
||||||
|
if(strcmp(classNameOfAutoObject(&outClientSession->syncObject.autoObject), "KClientSession") == 0)
|
||||||
SessionInfo_Add(outClientSession->parentSession, name);
|
SessionInfo_Add(outClientSession->parentSession, name);
|
||||||
outClientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&outClientSession->syncObject.autoObject);
|
outClientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&outClientSession->syncObject.autoObject);
|
||||||
}
|
}
|
||||||
@ -163,7 +157,7 @@ Result SendSyncRequestHook(Handle handle)
|
|||||||
case 0x4010042:
|
case 0x4010042:
|
||||||
{
|
{
|
||||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
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);
|
res = doPublishToProcessHook(handle, cmdbuf);
|
||||||
skip = true;
|
skip = true;
|
||||||
|
@ -50,14 +50,7 @@ Result TranslateHandle(u32 *outKAddr, char *outClassName, Handle handle)
|
|||||||
if(obj == NULL)
|
if(obj == NULL)
|
||||||
return 0xD8E007F7; // invalid handle
|
return 0xD8E007F7; // invalid handle
|
||||||
|
|
||||||
if(kernelVersion >= SYSTEM_VERSION(2, 46, 0))
|
name = classNameOfAutoObject(obj);
|
||||||
{
|
|
||||||
KClassToken tok;
|
|
||||||
obj->vtable->GetClassToken(&tok, obj);
|
|
||||||
name = tok.name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
name = obj->vtable->GetClassName(obj);
|
|
||||||
|
|
||||||
if(name == NULL) // shouldn't happen
|
if(name == NULL) // shouldn't happen
|
||||||
name = "KAutoObject";
|
name = "KAutoObject";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
BasicInfo:
|
BasicInfo:
|
||||||
Title : rosalina
|
Title : rosalina
|
||||||
CompanyCode : "00"
|
CompanyCode : "00"
|
||||||
ProductCode : 0828builder
|
ProductCode : lennybuilder
|
||||||
ContentType : Application
|
ContentType : Application
|
||||||
Logo : None
|
Logo : None
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ AccessControlInfo:
|
|||||||
# We're using the global custom bit31 mapping
|
# We're using the global custom bit31 mapping
|
||||||
|
|
||||||
SystemCallAccess:
|
SystemCallAccess:
|
||||||
# The kernel extension removes svc perms checks, so...
|
# The kernel extension removes svc perms checks, so below is just to avoid a makerom error
|
||||||
SendSyncRequest2: 47 # CustomBackdoor
|
Backdoor: 123
|
||||||
UnmapProcessMemory: 114
|
KernelSetState: 124
|
||||||
|
|
||||||
InterruptNumbers:
|
InterruptNumbers:
|
||||||
ServiceAccessControl:
|
ServiceAccessControl:
|
||||||
- srv:pm
|
- fs:USER # Not strictly needed as rosalina has access to everything, it's rather to avoid a makerom warning
|
||||||
FileSystemAccess:
|
FileSystemAccess:
|
||||||
- DirectSdmc
|
- DirectSdmc
|
||||||
- CtrNandRw
|
- CtrNandRw
|
||||||
|
Reference in New Issue
Block a user