⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l_tos.s

📁 给程序加密(upx)
💻 S
📖 第 1 页 / 共 2 页
字号:
                dc.b    'u2'            ; moveq.l #xx,d0L(loop2):       move.l  -(a4),-(a3)                dbra    d0,L(loop2)#endif        ; a3 now points to the start of the compressed block; ------------- copy code to stack and setup ASTACK; Copy the final startup code below the stack. This will get; called via "jmp (ASTACK)" after decompression and relocation.copy_to_stack:                lea.l   clear_bss_end(pc),a2                move.l  d4,-(ASTACK)    ; entry point for final jmp                moveq.l #((clear_bss_end-clear_bss)/2-1),d5L(loop):        move.w  -(a2),-(ASTACK)                subq.l  #1,d5                bcc     L(loop)#ifdef FLUSH_CACHE                ; patch code: on the stack, the `rts' becomes a `nop'                move.w #$4e71,flush_cache_rts-clear_bss(ASTACK)#endif        ; note: d5.l is now -1 (needed for decompressor); -------------#ifdef FLUSH_CACHE                bsr     flush_cache#endif; ------------- prepare decompressor        ; a3 still points to the start of the compressed block                move.l  d4,a4           ; dest. for decompressing#define NRV_NO_INIT                ;;moveq.l #-1,d5        ; last_off = -1                moveq.l #-128,d0        ; d0.b = $80#if defined(NRV2B)                moveq.l #-1,d7                moveq.l #-$68,d6        ; 0xffffff98                lsl.w   #5,d6           ; 0xfffff300 == -0xd00#elif defined(NRV2D)                moveq.l #-1,d7                moveq.l #-$50,d6        ; 0xffffffb0                lsl.w   #4,d6           ; 0xfffffb00 == -0x500#elif defined(NRV2E)                moveq.l #0,d7                moveq.l #-$50,d6        ; 0xffffffb0                lsl.w   #4,d6           ; 0xfffffb00 == -0x500#else#  error#endif; ------------- jump to copied decompressor                move.l  d4,a2                add.l   #'up31',a2                jmp     (a2)            ; jmp decompr_start; /*************************************************************************; // this is the final part of the startup code which runs in the stack; **************************************************************************/; ------------- clear dirty bssclear_bss:        ; on entry:        ;   ASTACK      == pc == clear_bss (on stack)        ;   a6          start of dirty bss [long living register]        ;   d6.l        number of clr loops        ;   d3.l        0#if defined(SMALL)L(loop):        move.l  d3,(a6)+                ;;subq.l  #1,d6                dc.b    'u4'            ; subq.l #1,d6 / subq.w #1,d6                bne     L(loop)#else        ; the dirty bss is usually not too large, so we don't        ; bother making movem optimizations hereL(loop):        move.l  d3,(a6)+                move.l  d3,(a6)+                move.l  d3,(a6)+                move.l  d3,(a6)+                ;;subq.l  #1,d6                dc.b    'u4'            ; subq.l #1,d6 / subq.w #1,d6                bne     L(loop)#endif; ------------- flush the cache#ifdef FLUSH_CACHE; info:;  This is also called as a subroutine (before decompression, NOT running;  in the stack). When running in the stack the `rts' is replaced by a `nop'.flush_cache:                FLUSH_CACHEflush_cache_rts:                rts#endif; ------------- restore ASTACK                lea     clear_bss_end-clear_bss+4(ASTACK),sp        ;; assert sp == clear_bss_end(pc)+4; ------------- clear the dirty stack#if 0; better don't do this - we are currently running in the stack; and don't want to make yet another instruction-cache-line dirtyclear_dirty_stack:                ; clear down to clear_bss(pc) + 32 extra longs                moveq.l #((L(loop)-clear_bss+3)/4+32-1),d0                lea     L(loop)(pc),a0L(loop):        move.l  d3,-(a0)                dbra    d0,L(loop)#endif; ------------- start program                movem.l (sp)+,d1-d7/a0-a6                move.l  a0,d0                beq     L(l_app)                sub.l   sp,sp           ; accessory: no stackL(l_app):       dc.w    $4ef9           ; jmp $xxxxxxxx - jmp to text segmentclear_bss_end:; /*************************************************************************; // UPX ident & packheader; **************************************************************************/#if defined(SMALL)#  include "ident_s.ash"#else#  include "ident_n.ash"#endif                align4                ; 32 bytes - #include "header.ash"                dc.b    85,80,88,33     ;     UPX_MAGIC_LE32                dc.b    161,216,208,213 ;     UPX_MAGIC2_LE32                dc.l    0,0,0,0,0                dc.b    0,0,0,45        ; end of text segment - size is a multiple of 4; /*************************************************************************; // This part is appended after the compressed data.; // It runs in the last part of the dirty bss (after the; // relocations and the original fileheader).; **************************************************************************/cutpoint:; ------------- decompress (from a3 to a4)#define a0 A3#define a1 A4#define a3 A2#define d2 D3#if defined(NRV2B)#  include <m68k/n2b_d.ash>#elif defined(NRV2D)#  include <m68k/n2d_d.ash>#elif defined(NRV2E)#  include <m68k/n2e_d.ash>#else#  error#endif#undef a0#undef a1#undef a3#undef d2        ; note: d3.l is 0 from decompressor above; ------------- prepare d6 for clearing the dirty bss#if defined(SMALL)                move.l  #'up41',d6      ; dirty_bss / 4#else                move.l  #'up41',d6      ; dirty_bss / 16#endif; ------------- test if we need to reloc                dc.b    'u3'            ; moveq.l #1,d5 / jmp (ASTACK); ------------- relocreloc:; The decompressed relocations now are just after the decompressed; data segment, i.e. at the beginning of the (dirty) bss.        ; note: d3.l is still 0                move.l  a6,a0           ; a0 = start of relocations                move.l  d4,a1                add.l   (a0)+,a1        ; get initial fixupL(loop1):       add.l   d3,a1           ; increase fixup                add.l   d4,(a1)         ; reloc one addressL(loop2):       move.b  (a0)+,d3                beq     reloc_end                cmp.b   d5,d3           ; note: d5.b is #1 from above                bne     L(loop1)                lea     254(a1),a1      ; d3 == 1 -> add 254, don't reloc                bra     L(loop2)reloc_end:; ------------- clear dirty bss & start program; We are currently running in the dirty bss.; Jump to the code we copied below the stack.        ; note: d3.l is still 0                jmp     (ASTACK)        ; jmp clear_bss (on stack)eof:                dc.w    cutpoint-start  ; size of entry                dc.w    eof-cutpoint    ; size of decompressor                dc.w    decompr_start-cutpoint  ; offset of decompressor start                dc.b    'UPX9'          ; marker for o2bin.pl#if defined(__ASL__)                endsection code#endif                end; vi:ts=8:et:nowrap

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -