📄 sdepack.nas
字号:
;;
;; aPLib compression library - the smaller the better :)
;;
;; NASM safe assembler wrapper for aP_depack_asm
;;
;; 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,8
cextern aP_depack_asm,aP_crc32
aplabel aPsafe_depack_asm,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
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -