Kernel Auto Objects

Kernel Auto Objects

KAutoObject

KAutoObject represents a reference counted object that destroys itself when there are no more references to it.

Size : 0x8 bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count

Class Definition #

   class KAutoObject {
    public:
       u32 m_referenceCount;       // 0x4
    protected:
       virtual ~KAutoObject() { }
   };

Category:Kernel auto objects

KCodeSet

class KCodeSet extends KAutoObject;

Size : 0x64 bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count
0x8KCodeSetMemDescriptorMemory section info for .text
0x1CKCodeSetMemDescriptorMemory section info for .rodata
0x30KCodeSetMemDescriptorMemory section info for .data
0x44u32Total .text pages
0x48u32Total .rodata pages
0x4Cu32Total RW pages (.bss + .data)
0x50u64Process name as 8-byte string
0x58u16?
0x5Au16?
0x5Cu64TitleID

KCodeSetMemDescriptor #

Sections too large to fit into any available memory blocks will be split across multiple memory blocks with a KBlockInfo instance for each. This is described by the memory section info struct:

KPort

class KPort extends KAutoObject;

Size : 0x48 bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count
0x8u32Pointer to KServerPort vtable
0xCu32KServerPort Reference count
0x10u32Node count for threads
0x14KLinkedListNode*Pointer to first KLinkedListNode in the list of threads that sync with this object
0x18KLinkedListNode*Pointer to last KLinkedListNode in the list of threads that sync with this object
0x1Cu32Node count for sessions
0x20KLinkedListNode*Pointer to first KLinkedListNode in the list of KServerSessions associated with this port
0x24KLinkedListNode*Pointer to last KLinkedListNode in the list of KServerSessions associated with this port
0x28KPort*Pointer to parent KPort
0x2Cu32Pointer to KClientPort vtable
0x30u32KClientPort Reference count
0x34u32Node count for threads
0x38KLinkedListNode*Pointer to first KLinkedListNode in the list of threads that sync with this object
0x3CKLinkedListNode*Pointer to last KLinkedListNode in the list of threads that sync with this object
0x40s16Current connection count to port
0x42s16Max connection count to port
0x44KPort*Pointer to the parent port object;

Category:Kernel auto objects

KResourceLimit

class KResourceLimit extends KAutoObject;

Size : 0x74 bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count
0x8s32Max Priority
0xCs32Max commit
0x10s32Max thread
0x14s32Max event
0x18s32Max mutex
0x1Cs32Max semaphore
0x20s32Max timer
0x24s32Max shared memory
0x28s32Max address arbiter
0x2Cs32Max CPU time
0x30s32Current Priority
0x34s32Current commit
0x38s32Current thread
0x3Cs32Current event
0x40s32Current mutex
0x44s32Current semaphore
0x48s32Current timer
0x4Cs32Current shared memory
0x50s32Current address arbiter
0x54s32Current CPU time
0x58KObjectMutexMutex
0x60KPreemptionTimerPreemption timer for the current core, see below

There are 4 KResourceLimit objects created on the kernel heap. Each is used for a different category specified by the exheader’s resource limit category specifier in the exheader ARM11 Local System Capabilities.

KSession

class KSession extends KAutoObject;

Size : 0x4C bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count
0x20KThread*X ?
0x24KThread*Y ?
0x2CKThread*Z ?

It seems X=Y=Z. X, Y and Z can be NULL.

Structure for at least 5.0.0-11 NATIVE_FIRM upward:

Size : 0x4C bytes ( KAutoObject, KServerSession, KClientSession, sequentially):

OffsetType
0x0KAutoObjectu32
0x4u32
0x8KServerSessionu32
0xCu32
0x10u32
0x14KLinkedListNode*
0x18KLinkedListNode*
0x1CKSession*
0x20KThread*
0x24KThread*
0x28KThread*
0x2CKClientSessionu32
0x30u32
0x34u32
0x38KLinkedListNode*
0x3CKLinkedListNode*
0x40KSession*
0x44u32
0x48KClientPort*

Session status:

KSharedMemory

class KSharedMemory extends KAutoObject and KLinkedList;

Size : 0x28 bytes

OffsetTypeDescription
0x0u32Pointer to vtable
0x4u32Reference count
0x8u32Node count for KBlockInfo objects
0xCKLinkedListNode*Pointer to first KLinkedListNode in the list of KBlockInfo objects associated with this KSharedMemory object
0x10KLinkedListNode*Pointer to last KLinkedListNode in the list of KBlockInfo objects associated with this KSharedMemory object
0x14KProcess*Owner
0x18u32Owner permissions
0x1Cu32Other processes’ permissions for this block
0x20u8Set after KBlockInfo is generated for the KSharedMemory
0x21s8Set after all KBlockInfo is generated
0x22u8Unknown
0x24u32Address

Category:Kernel auto objects