Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
mov esi,[tasking_current] ;base of a task table entry
add esi, 0x00000002 ; TSS selector for a task
mov word ax, [es:esi] ; Now the selector is in ax
Now ax holds a selector of a gdt entry which points to a tss of a task. Now, all I have to do is making a far jmp using this selector as segment. Offset can be a random value, because it will be ignored. So I tried this:
push eax ; ax contains your TSS selector
push 0 ; offset is ignored
jmp far ptr [esp+0]
add esp, 8 ; if you switch back to this task, remove the dwords pushed onto the stack
mov esi,[tasking_current] ;base of a task table entry
add esi, 0x00000002 ; TSS selector for a task
jmp far dword [es:esi - 4]
This works because the offset is ignored, so we can pretend that "[es:esi-4]" contains a 4 byte offset (that's ignored) followed by the 2 byte selector.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.