Improved thread creation on Linux

This commit is contained in:
2025-02-16 11:31:31 +01:00
parent d0bcd8cf9f
commit 00be603b8f
5 changed files with 39 additions and 5 deletions

View File

@ -1,9 +1,22 @@
import sys
const clone {
vm 0x100
fs 0x200
files 0x400
sighand 0x800
parent 0x8000
thread 0x10000
io 0x80000000
}
create(func *Any) -> Int {
size := 4096
stack := sys.mmap(0, size, 0x1|0x2, 0x02|0x20|0x100|0x20000)
rip := stack + size - 8
store(rip, 8, func)
return sys.clone(0x100|0x200|0x400|0x800|0x8000|0x10000|0x80000000, rip)
stack += size
stack -= 8
store(stack, 8, _exit)
stack -= 8
store(stack, 8, func)
return sys.clone(clone.vm|clone.fs|clone.files|clone.sighand|clone.parent|clone.thread|clone.io, stack)
}