Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; COM2EXE v0.1 by Strength (316 bytes)
- ;
- ; tasm com2exe.asm
- ; tlink com2exe.obj /t
- ;
- ; C:\>com2exe
- ; COM2EXE v1.0 by Strength
- ; Usage: COM2EXE source target
- ;
- ; C:\>com2exe source.com target.exe
- ; COM2EXE v1.0 by Strength
- ; OK!
- ;
- ; C:\>com2exe source.com c:
- ; COM2EXE v1.0 by Strength
- ; Access denied!
- ;
- ; C:\>com2exe filenotfound.com target.exe
- ; COM2EXE v1.0 by Strength
- ; File not found!
- .model tiny
- .code
- org 100h
- start:
- mov ah, 09h ; Print String
- lea dx, Logo
- int 21h
- mov si, 80h
- lodsb
- test al, al
- jz DisplayUsage
- inc si
- xor bx, bx
- Get1Param:
- lodsb
- cmp al, 0dh
- jz DisplayUsage
- cmp al, 20h
- jz Get2Param
- jmp Get1Param
- Get2Param:
- test bl, bl
- jnz DisplayUsage
- mov byte ptr[si-1], 0
- mov di, si
- inc bx
- jmp Get1Param
- DisplayUsage:
- test bl, bl
- jnz done
- lea dx, Usage
- jmp short PrintAndEnd
- done:
- mov byte ptr[si-1], 0
- mov ax, 3d00h ; Open a File
- mov dx, 82h
- int 21h
- jc error
- mov word ptr[SourceHandle], ax
- xchg ax, bx
- xor cx, cx
- xor dx, dx
- mov ax, 4202h ; Move File Pointer (LSEEK)
- int 21h
- mov word ptr[LengthSource], ax
- add ax, 32
- and ax, 511
- mov word ptr[ExeHeaderByte2and3], ax
- mov ax, 4200h ; Move File Pointer (LSEEK)
- int 21h
- mov ax, word ptr[LengthSource]
- mov cl, 9
- shr ax, cl
- inc ax
- mov word ptr[ExeHeaderByte4and5], ax
- mov ah, 3ch ; Create a File (CREAT)
- xor cx, cx
- mov dx, di
- int 21h
- jc error
- mov si, ax
- xchg ax, bx
- mov ah, 40h ; Write to File or Device, Using a Handle
- mov cx, 20h ; dlugosc naglowka
- lea dx, Header
- int 21h
- mov cx, word ptr[LengthSource]
- lea dx, Logo
- Write:
- push cx
- mov ah, 3fh ; Read from File or Device, Using a Handle
- mov bx, word ptr[SourceHandle]
- xor cx, cx
- inc cx
- int 21h
- mov ah, 40h ; Write to File or Device, Using a Handle
- mov bx, si
- int 21h
- pop cx
- loop Write
- mov ah, 3eh ; Close a File Handle
- int 21h
- mov bx, word ptr[SourceHandle]
- int 21h
- lea dx, OK
- PrintAndEnd:
- mov ah, 09h
- int 21h
- TheEnd:
- int 20h ; mozna tutaj wstawic 'ret', ale
- ; wtedy po przekonwertowaniu proga
- ; na exe by sie nie zamykal
- error:
- lea dx, FileNotFound
- cmp ax, 2
- jz PrintAndEnd
- lea dx, AccessDenied
- jmp PrintAndEnd
- Logo db 'COM2EXE v1.0 by Strength', 13, 10, '$'
- Usage db 'Usage: COM2EXE source target$'
- FileNotFound db 'File not found!$'
- AccessDenied db 'Access denied!$'
- OK db 'OK!$'
- SourceHandle dw ?
- LengthSource dw ?
- Header db 4dh, 5ah
- ExeHeaderByte2and3 dw ?
- ExeHeaderByte4and5 dw ?
- Header2 dw 0
- dw 2
- dw 1000h, 0ffffh
- dw 0fff0h, 0fffeh
- dw 0
- dw 100h, 0fff0h
- dw 1ch
- dw 0, 0, 0
- end start
Advertisement
Add Comment
Please, Sign In to add comment