Usermode/ld-acess - Fixed crash when arguments are passed to user apps
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / arch / x86.asm.h
index 9e45273..2d2c36a 100644 (file)
 _errno:        dw      0
 
 [section .text]
+[global _start]
+[extern SoMain]
+_start:
+       call SoMain
+       add esp, 4      ; // Base address
+       jmp eax
+
 ; DEST
 ; SRC
 _memcpy:
@@ -150,6 +157,7 @@ clone:
        push ebp
        mov ebp, esp
        push ebx
+       push edx
        
        mov ebx, [ebp+12]       ; Get new stack pointer
        
@@ -181,11 +189,20 @@ clone:
        sub ebx, 12
        %endif
 .doCall:
+       mov edx, ebx    ; Save new stack
        mov eax, SYS_CLONE
        mov ecx, ebx    ; Stack
        mov ebx, [ebp+8]        ; Flags
        SYSCALL_OP
        mov [_errno], ebx
+       
+       test eax, eax
+       jnz .ret
+       test edx, edx
+       jz .ret
+       mov esp, edx
+.ret:
+       pop edx
        pop ebx
        pop ebp
        ret

UCC git Repository :: git.ucc.asn.au