In the Folder1 directory, there is a file called test.exe – a Windows desktop application.
It was copied to the Folder2 directory and renamed to test.txt. After that, it was opened in a text editor, and a 32-character text string was added to the beginning (including the newline character before the exe file content, making it 33 characters). Then, the test.com program in the Folder2 directory copied the contents of the test.txt file, starting from the 33rd byte, into the test.exe file.
Here is the test.com program:
.286
.model tiny
.code
org 100h
begin:
mov ax, 3d02h
xor cx, cx;
lea dx, ifilename
int 21h
mov ifiledescriptor, ax;
mov ah, 42h;
mov bx, ifiledescriptor;
mov al, 00h;
mov cx, 0000h
mov dx, 33
int 21h
mov ah, 3ch
xor cx, cx
mov dx, offset ofilename
int 21h
mov ofiledescriptor, ax;
start:
mov ax, 4406h
mov bx, ifiledescriptor
int 21h
or al, al
je exit
mov ah, 3fh
mov bx, ifiledescriptor
mov cx, 0001h
mov dx, offset symbol
int 21h
mov ah, 40h
mov bx, ofiledescriptor
mov cx, 0001h
mov dx, offset symbol
int 21h
jmp start
exit:
mov ax, 4c00h
int 21h
ifilename db "test.txt",0
ofilename db "test.exe",0
ifiledescriptor dw (?)
ofiledescriptor dw (?)
symbol db (?)
end begin
I create the COM file like this:
tasm.exe test.asm
tlink.exe test.obj /t
Now, in the Folder2 directory, we have a test.exe file with exactly the same content as the test.exe file in the Folder1 directory. But here's the problem: the files have the same name and the same content, but they are different files!!! And when I try to run the test.exe file in the Folder2 directory, instead of the Windows desktop application, a DOS text window pops up with the message "Program too big to fit in memory". I think this is because the file was created by a DOS interrupt handler – it's a DOS file.
And now, the big question. How can I copy the contents of the test.txt file into test.exe, starting from the 33rd character, so that it runs as a Windows desktop application?