flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > another flaw in fasm?

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 09 Nov 2010, 19:05
why fasm always produce 16 entries in optional header (PE)?
when i have only iat, all following should be cut off. When i dont have any section, it should not create this table. Always 16, why?
Post 09 Nov 2010, 19:05
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 09 Nov 2010, 19:38
I've tried doing that manually getting errors: set IMAGE_OPTIONAL_HEADER.NumberOfDataDirectories to 2, and remove times 14 dq 0.
Post 09 Nov 2010, 19:38
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 Nov 2010, 22:40
Are you sure all loaders support NumberOfDataDirectories properly? I'd doubt that and better leave it at 16.
Post 09 Nov 2010, 22:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20342
Location: In your JS exploiting you and your system
revolution 09 Nov 2010, 23:57
Using less than 16 Data Directories causes the loader to do stupid things. Just don't do it unless you like to see your programs fail.
Post 09 Nov 2010, 23:57
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 10 Nov 2010, 00:22
9x doesn't seem to like less than 16 directories, but XP+ is fine with less.
Post 10 Nov 2010, 00:22
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 10 Nov 2010, 14:58
so 9x doesnt handle it correctly...
ok i belive i have an answer. always set to 16. then whats the point of special entry in optional header, when it cant be != 16? why also bother with optional header size, when its fixed.
Post 10 Nov 2010, 14:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20342
Location: In your JS exploiting you and your system
revolution 10 Nov 2010, 15:02
In MS speak: "optional" == "mandatory for compatibility reasons".
Post 10 Nov 2010, 15:02
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 10 Nov 2010, 15:08
"optional" = "options applied" too
Post 10 Nov 2010, 15:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20342
Location: In your JS exploiting you and your system
revolution 10 Nov 2010, 15:15
Perhaps it is worth pointing out that the Windows loaders do not support the full PE spec. All current and past versions of the exe loaders in Windows only support a subset of the available "options". You can't simply take the PE spec and make a file and expect Windows to properly load it. You still have to make sure that Windows will support the set of "options" that you choose to implement in the file.

Let's not even mention those pesky panicky AVs. Anything out of the ordinary and they will have a full-on panic attack.
Post 10 Nov 2010, 15:15
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 10 Nov 2010, 15:21
see, we are not hllS Smile
Post 10 Nov 2010, 15:21
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 11 Nov 2010, 09:16
revolution wrote:
In MS speak: "optional" == "mandatory for compatibility reasons".
Microsoft Portable Executable and Common Object File Format Specification wrote:
This header is optional in the sense that some files (specifically, object files) do not have it. For image files, this header is required. An object file may have an optional header, but generally this header has no function in an object file except to increase size.
Post 11 Nov 2010, 09:16
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.