sdepackf.nas

来自「Cracker终结者——提供最优秀的软件保护技术」· NAS 代码 · 共 82 行

NAS
82
字号
;;
;; aPLib compression library  -  the smaller the better :)
;;
;; NASM safe assembler wrapper for aP_depack_asm_fast
;;
;; Copyright (c) 1998-2002 by Joergen Ibsen / Jibz
;; All Rights Reserved
;;

; define _ELF_ for ELF32 object files
; define _OBJ_ for OMF object files

bits 32

%include "apnasm.mac"

section aptext

cglobal aPsafe_depack_asm_fast,8

cextern aP_depack_asm_fast,aP_crc32

aplabel aPsafe_depack_asm_fast,8

    pushad

    mov    esi, [esp + 36]    ; esi -> inbuffer
    mov    edi, [esp + 40]    ; edi -> outbuffer

    mov    ebx, [esi]         ; ebx = header.tag

    cmp    ebx, 032335041h    ; check tag == 'AP32'
    jne    short .return_zero

    mov    ebx, [esi + 4]     ; ebx = header.header_size
    cmp    ebx, byte 24       ; check header_size >= 24
    jb     short .return_zero

    add    ebx, esi           ; ebx -> packed data

    push   dword [esi + 8]    ; push header.packed_size
    push   ebx
    call   aP_crc32
    apadjust 8                ; adjust stack (function is cdecl)

    cmp    eax, [esi + 12]    ; check eax == header.packed_crc
    jne    short .return_zero

    push   edi
    push   ebx
    call   aP_depack_asm_fast
    apadjust 8                ; adjust stack (function is cdecl)

    cmp    eax, [esi + 16]    ; check eax == header.orig_size
    jne    short .return_zero

    mov    ebx, eax           ; ebx = unpacked size

    push   eax
    push   edi
    call   aP_crc32
    apadjust 8                ; adjust stack (function is cdecl)

    cmp    eax, [esi + 20]    ; check eax == header.orig_crc

    mov    eax, ebx           ; eax = unpacked size

    je     short .return_eax

.return_zero:
    sub    eax, eax

.return_eax:
    mov    [esp + 28], eax    ; return unpacked length in eax

    popad
    apret 8

%ifdef _OBJ_
  section apdata
%endif

⌨️ 快捷键说明

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