View source: Task Queue System (revision 467)
Jump to navigation
Jump to search
2019-05-01T12:16:42Z · PhilYeahz · Download source
=Task memory structure=
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x08 || uint64_t* || Callback function pointer
|-
| 0x08 || 0x04 || char* || Task type/name token
|-
| 0x0C || 0x01 || uint8_t || Unknown value
|-
| 0x0D || 0x01 || uint8_t || Unknown value
|-
| 0x10 || 0x08 || uint64_t* || Next task pointer
|-
| 0x18 || 0x08 || uint64_t* || Some task pointer
|-
| 0x20 || 0x08 || uint64_t* || Current task pointer (at the moment of creation)
|-
| 0x28 || 0x08 || uint64_t* || Some task pointer
|-
| 0x30 || 0x08 || uint64_t* || Some task pointer
|-
| 0x38 || 0x08 || uint64_t* || Some task pointer
|-
| 0x40 || 0x08 || uint64_t* || Some task pointer
|-
| 0x48 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x50 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x58 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x60 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x68 || 0x08 || uint64_t* || Callback function parameter struct pointer
|}
=Task queue=
Task Queue Pointer Offset: 0x1481FFA50 (v1.07)<br>
At the start an ROOT task is created.<br>
When the ROOT task was created the Queue gets filled with NONE task's which do nothing.<br>
At initialization each task has the next task in order as their next task specified inside 0x18.<br>
The last task however points to 0x142A88530 (v1.07) as their next task.<br>
The ROOT task points to the first task as it's next task.<br>
=Enqueue task=
==Enqueue task without TASK data allocation==
To enqueue an task without TASK data allocation the subroutine 0x14049D890 (v1.07) needs to be called.
<sub>
EnqueueTask(void* callbackFunction, uint8_t nextFunctionIndex, uint8_t a3, uint32_t taskToken)
</sub>
==Enqueue task with TASK data allocation==
To enqueue an task with TASK data allocation the subroutine 0x14049DA10 (v1.07) needs to be called.<br>
<sub>
EnqueueTaskWithParameter(void* callbackFunction, uint8_t nextFunctionIndex, uint8_t a3, uint32_t parameterSize, uint32_t taskToken, char* debugTaskName)
</sub>
=Task creation=
During the enqueue process the task will be created with the given callback function.<br>
The callback function parameter, which is optional, is an pointer to an struct than can have any shape or size the callback function needs.<br>
This parameter struct will be allocated inside the USE/fREe storage.
=Task execution=
The main loop iterates through the task queue and calls the callback function with the optional parameter.<br>
When the callback function returns the next task pointer is read from the current task and moved into the task queue address pointer.
=Task cleanup (Destruction)=
A task controls how long it lives in its own callback function.<br>
When a task wants to be destroyed it calls the subroutine 0x14049D660 (v1.07) during its own callback.<br>
=Task parameter=
When a task gets enqueued with a parameter it will need to find some "fREe" storage in the USE/fREe storage.<br>
==Storage entry==
{| class="wikitable"
|-
! Position !! Length !! Type !! Description
|-
| 0x00 || 0x04 || string || Task token (TASK)
|-
| 0x10 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x18 || 0x08 || uint64_t* || Unknown pointer
|-
| 0x20 || 0x04 || string || USE/fREe token
|-
| 0x40 || 0x?? || ? || Storage data
|}