Other [asm] [x86-64]Pure asm threads

Hi.
I'm trying to make a simple pure asm multi-threading app.
There is a syscall
Code:
430    AUE_THR_CREATE    STD    { int thr_create(ucontext_t *ctx, long *id, int flags); }

But I can't find any example how to use that, especially how to create context?

Of course I can wrap it in C. But that's not the point.

Could someone point me where to look? Or give an example?

Best regards
w.
 
Ok.
I Gave up.

I it is possible.
But, It will take too much time to understand how does it works, make all structs etc.
Maybe some day i will try again ,)

keywords are:
Code:
455 AUE_THR_NEW STD { int thr_new(struct thr_param *param, int param_size); }
477 AUE_MMAP STD { caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos); }
431    AUE_THR_EXIT    STD    { void thr_exit(long *state); }

w.
 
Ok.
I Gave up.

I it is possible.
But, It will take too much time to understand how does it works, make all structs etc.
Maybe some day i will try again ,)

keywords are:
Code:
455 AUE_THR_NEW STD { int thr_new(struct thr_param *param, int param_size); }
477 AUE_MMAP STD { caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos); }
431    AUE_THR_EXIT    STD    { void thr_exit(long *state); }

w.

An old thread ... but when you decide to revisit this:

The needed structures are as follows:
Code:
STRUC rtprio
.type: RESW 1
.prio: RESW 1
ENDSTRUC

STRUC thr_param
.op:         RESQ 1
.arg:        RESQ 1
.stack_base: RESQ 1
.stack_size: RESQ 1
.tls_base:   RESQ 1
.tls_size:   RESQ 1
.child_tid:  RESQ 1
.parent_tid: RESQ 1
.flags:      RESD 1
.rtp:        RESB rtprio_size
.spare:      RESQ 3
ENDSTRUC

You can then initialize the a block of memory that has the thr_param data:

Code:
                ; Zero our thr_param structure
                pxor xmm0, xmm0
                movdqa  [rsp - thr_param_size], xmm0
                movdqa  [rsp - thr_param_size + 16], xmm0
                movdqa  [rsp - thr_param_size + 32], xmm0
                movdqa  [rsp - thr_param_size + 48], xmm0
                movdqa  [rsp - thr_param_size + 64], xmm0
                movdqa  [rsp - thr_param_size + 80], xmm0

                ; Setup thr_param
                mov     qword [rsp - thr_param_size + thr_param.op], thread_start
                mov     [rsp - thr_param_size + thr_param.stack_base], rax
                mov     qword [rsp - thr_param_size + thr_param.stack_size], 3568
                lea     rax, [rax + 3568]
                mov     [rsp - thr_param_size + thr_param.tls_base], rax
                mov     qword [rsp - thr_param_size + thr_param.tls_size], 512
                lea     rax, [rax + 512]
                mov     [rsp - thr_param_size + thr_param.parent_tid], rax
                lea     rax, [rax + 8]
                mov     qword [rsp - thr_param_size + thr_param.child_tid], rax

The decimal constants change to your liking. thread_start would be the entrypoint for your start routine.
From there you can create a thread:

Code:
                mov     eax, 455
                lea     rdi, [rsp - thr_param_size]
                mov     esi, 96
                syscall
 
Back
Top