Copy Link
Add to Bookmark
Report

Xine - issue #5 - Phile 305

eZine's profile picture
Published in 
Xine
 · 7 months ago

 

Ú-----------------------------¿
| Xine - issue #5 - Phile 305 |
À-----------------------------Ù





Ú-------------¿
| VxD Packer2 |
À-------------Á-------------------------------------------------------------

This utility is basically the same as "VxD Packer". The only difference is
that instead of "cutting", whenever possible, the space between the end of
the "Fixup Record Table" and the beginning of the "Enumerated Data Pages",
it "cuts" the unused space between the end of the MZ header and the start of
the LE header. This space usually contains real-mode code to display a mes-
sage like "This program cannot be run in DOS mode." and never gets executed
unless the file is renamed to an EXE extension and then run. It is only pre-
sent for compatibility.

Ú-----------------------------¿
| 1. Assembling and compiling |
À-----------------------------Ù

Compile it to a COM file, using:
tasm vxdpack2 /ml /m5
tlink vxdpack2 /t

----------------------´ Start of file: VXDPACK2.ASM Ã-----------------------
.Model Tiny
.Code
.386

include DOS.INC
include MZ.INC
include LE.INC

.Radix 16d
org (size PSP)

Max_Size = 0f000h

Start:
mov ah,9
mov dx,offset Intro_Text
int 21 ;Display introductory text
mov bx,PSP_CommandLine
cmp byte ptr ds:[bx.CT_Length],0
jne Valid_File
mov dx,offset Usage_Text
jmp Exit_Disp ;Display syntax
Valid_File:
inc bx ;Same as: add bx,CT_Arguments
cmp byte ptr ds:[bx],' '
je Valid_File
mov dx,bx
Seek_End:
inc bx
cmp byte ptr ds:[bx],0dh
jne Seek_End
mov byte ptr ds:[bx],0
mov ax,3d02h
int 21 ;Open the file (read/write mode)
jnc Proceed1
IO_Error:
mov dx,offset Fail_IO
jmp Exit_Disp ;Report error
Proceed1:
mov word ptr ds:[File_Handle],ax
mov al,2
call Seek_AL
or dx,dx
jz Proceed2
Too_Big:
mov ah,3eh
call File_Int ;Close the file
jmp IO_Error
Proceed2:
cmp ax,Max_Size
ja Too_Big
mov word ptr ds:[File_Size],ax
push ax
call Seek_Begin
pop cx
mov ah,3fh
mov dx,offset Buffer
int 21 ;Read file to buffer
mov bx,dx
cmp word ptr ds:[bx.MZ_magic],IMAGE_DOS_SIGNATURE
jne Too_Big
cmp word ptr ds:[bx.MZ_lfarlc],IMAGE_SIZEOF_DOS_HEADER
jb Too_Big
mov bp,bx
add bx,word ptr ds:[bx.MZ_lfanew]
cmp word ptr ds:[bx.LE_magic],IMAGE_VXD_SIGNATURE
jne Too_Big
cmp word ptr ds:[bx.LE_dircnt],0
jne Too_Big
mov si,bx
mov di,(offset Buffer)+IMAGE_SIZEOF_DOS_HEADER
mov ax,si
sub ax,di
jz Too_Big
mov cx,word ptr ds:[File_Size]
sub cx,word ptr ds:[bp.MZ_lfanew]
mov word ptr ds:[bp.MZ_lfanew],IMAGE_SIZEOF_DOS_HEADER
sub word ptr ds:[File_Size],ax ;Fix file size
sub word ptr ds:[bx.LE_datapage],ax ;Fix "Offset of Enumerated Data Pages"
mov bp,LE_nrestab ;Fix "Offset of Non-resident Names Table"
call Fix_If_Not_Null
mov bp,LE_debuginfo ;Fix "Offset of the debugging information"
call Fix_If_Not_Null
mov bp,LE_winresoff ;Fix "Offset of Windows Resources"
call Fix_If_Not_Null
cld
rep movsb ;Shift data to pack the file
call Seek_Begin
mov ah,40
mov cx,word ptr ds:[File_Size]
mov dx,offset Buffer
int 21 ;Write packed file
mov ah,40
xor cx,cx
int 21 ;Mark end of file
mov ah,3eh
int 21 ;Close it
mov dx,offset Success ;Report success
Exit_Disp:
mov ah,9
int 21
mov ah,4ch
int 21 ;Terminate program

;Routines
Seek_Begin: ;Reset file position
mov al,0
Seek_AL:
mov ah,42
xor cx,cx
cwd
File_Int:
mov bx,word ptr ds:[File_Handle]
int 21
retn

Fix_If_Not_Null:
push bx
add bx,bp
cmp word ptr ds:[bx],0
je Null
sub word ptr ds:[bx],ax
Null:
pop bx
retn

;Messages and data
Intro_Text db "VxD Packer2 by Horned Beast/VADER",0dh,0ah
db "E-mail: hbeast@darkmail.com",0dh,0ah,0dh,0ah,'$'
Usage_Text db "Usage: VXDPACK2.COM (VxDFile)",0dh,0ah,'$'
Fail_IO db "Failure in file I/O!",0dh,0ah,'$'
Success db "File packed!",0dh,0ah,'$'
File_Handle dw ?
File_Size dw ?

Buffer:

end Start
-----------------------´ End of file: VXDPACK2.ASM Ã------------------------

← previous
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT