flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > DOS MZ Exe header is not correct

Author
Thread Post new topic Reply to topic
LowLevelMahn



Joined: 30 Sep 2008
Posts: 9
Code:
format MZ 

entry main:start
stack 100h

segment main
  start: 
  ret
    


producing an exe with this content

Code:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000  4D 5A 21 00 01 00 00 00 02 00 10 00 FF FF 01 00  MZ!.........ÿÿ..
00000010  00 01 00 00 00 00 00 00 1C 00 00 00 00 00 00 00  ................
00000020  C3                                               Ã
    


exe header (size = 0x1C)
4D 5A 21 00 01 00 00 00 02 00 10 00 FF FF 01 00 00 01 00 00 00 00 00 00 1C
00 00 00

signature: MZ
bytes_in_last_block: 0x0021
blocks_in_file: 0x0001
num_relocs: 0x0000
header_paragraphs: 0x0002
min_extra_paragraphs: 0x0010
max_extra_paragraphs: 0xFFFF
ss:sp: 0x0001:0x0100 (offset32: 0x00000110)
checksum: 0x0000
cs:ip: 0x0000:0x0000 (offset32: 0x00000000)
reloc_table_offset: 0x001C
overlay_number: 0x0000

there are no relocations (num_relocs: 0x0000) in the relocation table but there are four 0 bytes before the ret opcode
00 00 00 00

ret instruction
C3

btw: its not possible to haven an zero-size stack exe (more an academic problem but still possible with other assemblers)

i think: due to this IDA Pro is telling me that the exe is maybe packed
Post 17 Aug 2018, 15:03
View user's profile Send private message Reply with quote
LowLevelMahn



Joined: 30 Sep 2008
Posts: 9
maybe i got it:

image_start = header_paragraphs * 16

so the 4 extra bytes are just padding
Post 17 Aug 2018, 18:22
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6968
Location: Kraków, Poland
Yes, this is padding to the nearest paragraph boundary.

If you need more control over the contents of the headers, please try fasmg with its MZ formatting macros. In the basic form they are fully compatible with fasm 1, but because they are simply macros, you can easily alter anything.
Post 17 Aug 2018, 19:58
View user's profile Send private message Visit poster's website Reply with quote
LowLevelMahn



Joined: 30 Sep 2008
Posts: 9
thanks

other question: is there a real need that i can't have an exe with zero size stack?
Post 18 Aug 2018, 05:18
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6968
Location: Kraków, Poland
LowLevelMahn wrote:
other question: is there a real need that i can't have an exe with zero size stack?
Obviously corrupting your code/data upon a first interrupt that happens is not a good idea. Wink
You can, however, set up the stack completely manually with the other syntax:
Code:
stack segment:offset    
This syntax allows too choose the initial values of SS and SP directly.
Post 18 Aug 2018, 05:28
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.