KProcess
class KProcess extends KSynchronizationObject;
Size : 0x260 bytes
Offset | Type | Description |
---|---|---|
0x0 | u32 | Pointer to vtable |
0x4 | u32 | Reference count |
0x8 | u32 | Count of KThreads that sync with this object - number of nodes in the linked list below |
0xC | KLinkedListNode* | Pointer to first KLinkedListNode in node list of KThreads that sync with this object |
0x10 | KLinkedListNode* | Pointer to last KLinkedListNode in node list of KThreads that sync with this object |
0x1C | volatile KThread* | 0 or pointer to the thread the currently does something with the process object. |
0x20 | s16 | ? |
0x30 | KLinkedListNode* | Pointer to first KLinkedListNode in list of KMemoryBlocks used by the process |
0x34 | KLinkedListNode* | Pointer to last KLinkedListNode in list of KMemoryBlocks used by the process |
0x40 | u32 | Translation table base |
0x44 | u8 | Context ID |
0x50 | u32 | Size of the MMU table |
0x54 | u32 | Virtual address of the MMU table for this process |
0x58 | u32 | Total size of all thread context pages (0xFF4xxxxx) owned by threads that belong to this process |
0x5C | u32 | Number of KThreadLocalPages used by this KProcess |
0x60 | KLinkedListNode* | Pointer to first KLinkedListNode in the list of KThreadLocalPages |
0x64 | KLinkedListNode* | Pointer to last KLinkedListNode in the list of KThreadLocalPages |
0x6C | s32 | Ideal processor |
0x74 | u32 | Pointer to resource limits for process. |
0x79 | u8 | Proc affinity mask |
0x7C | u32 | Number of threads which belong to this process. |
0x80 | 0x10-bytes | SVC access control mask from the exheader kernel descriptors. |
0x90 | 0x10-bytes | Interrupt flags- 32 interrupts per word, 4 words, 0x80 interrupts total divided evenly across 4 words |
0xA0 | u32 | Kernel flags from the exheader kernel descriptors. |
0xA4 | u16 | Handle table size from the exheader kernel descriptors. When this is 0, handle table is stored in WRAM. |
0xA6 | u16 | Kernel release version field, from the exheader kernel descriptors. |
0xA8 | u32 | Pointer to KCodeSet instance |
0xAC | u32 | Process id, this always begins at 0x0 for the first process. |
0xB0 | u32 | Kernel flags from the exheader kernel descriptors. |
0xB8 | KThread* | Pointer to the process's main (?) thread. |
0xCC | KProcessHandleTable | Pointer to the process's handle table. until 0x1C4 or longer |
0x224 | u32 | ? |
Structure starting with 8.0.0-18 NATIVE_FIRM:
Size : 0x268 bytes
Offset | Type | Description |
---|---|---|
0x0 | u32 | Pointer to vtable |
0x4 | u32 | Reference count |
0x8 | u32 | Count of KThreads that sync with this object - number of nodes in the linked list below |
0xC | KLinkedListNode* | Pointer to first KLinkedListNode in node list of KThreads that sync with this object |
0x10 | KLinkedListNode* | Pointer to last KLinkedListNode in node list of KThreads that sync with this object |
0x2C | u32 | Count of KMemoryBlocks owned by the process |
0x30 | KLinkedListNode* | Pointer to first KLinkedListNode in list of KMemoryBlocks used by the process |
0x34 | KLinkedListNode* | Pointer to last KLinkedListNode in list of KMemoryBlocks used by the process |
0x40 | u32 | Translation table base |
0x44 | u8 | Context ID |
0x4C | u32 | End of userland virtual memory for the process |
0x50 | u32* | LINEAR memory virtual address(userland) base for this process. |
0x58 | u32 | Size of the MMU table |
0x5C | u32 | Virtual address of the MMU table for this process |
0x60 | u32 | Total size of all thread context pages (0xFF4xxxxx) owned by threads that belong to this process |
0x64 | u32 | Number of KThreadLocalPages used by this KProcess |
0x68 | KLinkedListNode* | Pointer to first KLinkedListNode in the list of KThreadLocalPages |
0x6C | KLinkedListNode* | Pointer to last KLinkedListNode in the list of KThreadLocalPages |
0x74 | s32 | Ideal processor for this process |
0x7C | KResourceLimit* | Pointer to resource limits for process. |
0x84 | u32 | Number of threads which belong to this process. |
0x88 | 0x10-bytes | SVC access control mask from the exheader kernel descriptors. |
0x98 | u32[4] | Interrupt flags- 32 interrupts per word, 4 words, 0x80 interrupts total divided evenly across 4 words |
0xA8 | u32 | Kernel flags from the exheader kernel descriptors. |
0xAC | u16 | Handle table size from the exheader kernel descriptors. When this is 0, handle table is stored in WRAM. |
0xAE | u16 | Kernel release version field, from the exheader kernel descriptors. |
0xB0 | u32 | Pointer to KCodeSet instance |
0xB4 | u32 | Process id, this always begins at 0x0 for the first process. |
0xC0 | KThread* | Pointer to the process's main thread. |
0xD4 | KProcessHandleTable | This is the data for tracking and using all of the KProcess's handles. |
0xEC | HandleData[0x28] | These internal HandleData entries are only used if the exheader's handle table size is 0 |
0x22C | ? | Unknown |
Structure starting with 8.1.0-0 New3DS NATIVE_FIRM:
Size : 0x270 bytes
Offset | Type | Description |
---|---|---|
0x0 | u32 | Pointer to vtable |
0x4 | u32 | Reference count |
0x8 | u32 | Count of KThreads that sync with this object - number of nodes in the linked list below |
0xC | KLinkedListNode* | Pointer to first KLinkedListNode in node list of KThreads that sync with this object |
0x10 | KLinkedListNode* | Pointer to last KLinkedListNode in node list of KThreads that sync with this object |
0x64 | u32 | Virtual address of the MMU table for this process |
0x7C | s32 | Ideal processor for this process |
0x84 | KResourceLimit* | Pointer to resource limits for process. |
0xB0 | u32 | Kernel flags from the exheader kernel descriptors. |
0xBC | u32 | Process id, this always begins at 0x0 for the first process. |
0xC8 | KThread* | Pointer to the process's main thread. |
0xDC | KProcessHandleTable | This is the data for tracking and using all of the KProcess's handles. |
0xF4 | HandleData[0x28] | These internal HandleData entries are only used if the exheader's handle table size is 0 |
KProcessHandleTable info struct:
Offset | Type | Description |
---|---|---|
0x0 | HandleData* | Pointer to the process's handle table. |
0x4 | u16 | The max number of handles that can be open at once - usually 0x200. |
0x6 | u16 | Unknown |
0x8 | HandleData* | Pointer to the next open HandleData entry in the handle table. |
0xC | u16 | Total handles used by this KProcess. |
0xE | u16 | The current number of handles in use. |
0x10 | u32 | Unknown |
0x14 | u32 | Unknown |
0x16 | u32 | Unknown |
0x18 | HandleData[28] | This small handle data table, internal to the KProcess, is only used in certain processes that don't have an external handle data table in FCRAM. It is all zeros in most processes. |
HandleData struct:
Offset | Type | Description |
---|---|---|
0x0 | u32 | Handle info |
0x4 | u32 | Pointer to the kernel object that the handle references. |
The handle info u32 works as such:
The high byte is a remainder from the pointer to the next entry that originally occupied the handle table entry. It is unused. Byte 2 is either the class type token starting with firmware version 9.0 or the lowest byte of the char* that points to the class type name in firmware versions below 9.0. The lower halfword is the handle number of the current handle taken from the total handle count for the KProcess that owns the table.
On table creation, each entry in the handle data table is populated with a pointer to the next entry in the table. When a new handle is created, that pointer is moved into offset 0x8 of the KProcessHandleTable info struct to use for generation of the next handle.
The final handle that gets returned when a handle is created is (handle_index | (handle_total << 15)), basically they take the index into the handle data table and OR that with the total handle count << 15. This returned value is the one that gets passed back to the running application and is used to look up the HandleData entry in the table.