Extent for xread(); more args for upx_main()

l_lx_exec.c l_lx_exec86.asm

committer: jreiser <jreiser> 958847261 +0000
This commit is contained in:
John Reiser
2000-05-20 18:27:41 +00:00
parent 1c24a96864
commit 25ade0970b
2 changed files with 100 additions and 117 deletions
+28 -30
View File
@@ -48,6 +48,9 @@
%endif
%include "ident.ash"
; /*************************************************************************
; // program entry point
; // see glibc/sysdeps/i386/elf/start.S
@@ -57,41 +60,12 @@ GLOBAL _start
EXTERN upx_main
_start:
xor ebp, ebp ; Clear the frame pointer
%if 0
; personality(PER_LINUX)
mov eax, 136 ; syscall_personality
xor ebx, ebx ; PER_LINUX
int 0x80
%endif
pop eax ; Pop the argument count
mov ecx, esp ; argv starts just at the current stack top
lea edx, [ecx+eax*4+4] ; envp = &argv[argc + 1]
push eax ; Restore the stack
and esp, byte -8 ; Align the stack
push edx ; Push third argument: envp
push ecx ; Push second argument: argv
;;; push eax ; Push first argument: argc
call upx_main ; Call the UPX main function
hlt ; Crash if somehow upx_main does return
%include "ident.ash"
call main ; push &decompress
; /*************************************************************************
; // C callable decompressor
; **************************************************************************/
%ifdef NRV2B
%define decompress nrv2b_decompress_asm_fast
%elifdef NRV2D
%define decompress nrv2d_decompress_asm_fast
%else
%error
%endif
GLOBAL decompress
%define INP dword [esp+24+4]
%define INS dword [esp+24+8]
%define OUTP dword [esp+24+12]
@@ -144,5 +118,29 @@ decompress:
pop ebp
ret
; /*************************************************************************
; // prepare arguments and call upx_main
; **************************************************************************/
main:
pop ebp ; &decompress
%if 0
; personality(PER_LINUX)
mov eax, 136 ; syscall_personality
xor ebx, ebx ; PER_LINUX
int 0x80
%endif
pop eax ; Pop the argument count
mov ecx, esp ; argv starts just at the current stack top
lea edx, [ecx+eax*4+4] ; envp = &argv[argc + 1]
push eax ; Restore the stack
push ebp ; argument: &decompress
%define PAGE_MASK (~0<<12)
and ebp, PAGE_MASK
push ebp ; argument: &Elf32_Ehdr
push edx ; Push third argument: envp
push ecx ; Push second argument: argv
;;; push eax ; Push first argument: argc
call upx_main ; Call the UPX main function
hlt ; Crash if somehow upx_main does return
; vi:ts=8:et:nowrap