Path: blob/master/external/source/osx/x86/include/_read_exec.s
19516 views
_read_exec:1;; Save some stack space2mov ebp, esp3sub esp, byte 845.loop:6xor ecx, ecx ; clear ecx7mul ecx ; clear eax and edx89;; Read a 4-byte size of code fragment to execute10push ecx11mov esi, esp12mov al, 413push eax ; nbyte14push esi ; buf15push edi ; s16push eax17dec eax18int 0x8019jb end20mov esi, [esp+16] ; code buffer length2122;; mmap memory23xor eax, eax24push eax ; alignment spacer25push eax ; 026dec eax27push eax ; -128inc eax29mov ax, 0x100230push eax ; (MAP_ANON | MAP_PRIVATE)31xor eax, eax32mov al, 733push eax ; (PROT_READ | PROT_WRITE | PROT_EXEC)34push esi ; len35push edx ; addr36push edx ; spacer37mov al, 19738int 0x8039jb end4041;; read fragment from file descriptor into mmap buffer42mov ebx, eax43add ebx, esi44.read_fragment:45push esi ; nbytes46mov eax, ebx47sub eax, esi48push eax ; buf49push edi ; s50push edx ; spacer51xor eax, eax52mov al, 353int 0x80 ; read(edi, eax, esi)54jb end5556sub ebx, eax ; Subtract bytes read to buf end pointer57sub esi, eax ; Subtract bytes read from total58jnz .read_fragment5960jmp ebx616263