flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Feature request: make 0's uninitialized in PE section

Author
Thread Post new topic Reply to topic
SFeLi



Joined: 03 Nov 2004
Posts: 140
Location: Severodvinsk, Russia
SFeLi
What do you think about automatically converting to uninitialized data all data definitions at the end of the section, which produce zero bytes? It wouldn’t break anything in PE.
Code:
        format  pe gui 4.1
        entry   start
        include 'win32a.inc'

start:
        retn

section '.data' data readable writeable
foo dd 12345678
bar dd 0 ; Automatically make it bar dd ?
baz dd 0 ; This too.
    


Last edited by SFeLi on 21 May 2009, 17:03; edited 1 time in total
Post 21 May 2009, 16:59
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17281
Location: In your JS exploiting you and your system
revolution
Why would we need to do this?
Post 21 May 2009, 17:01
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
Location: Severodvinsk, Russia
SFeLi
Yesterday I saw a source that defined a huge list of data via macros and file directives. Resulting EXE had about 600 (!) kb of trailing zeroes in the .flat section. Why not to make PE formatter think about this?
Post 21 May 2009, 17:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

at the end of the section, which produce zero bytes? It wouldn’t break anything in PE.

Sure about this? I remember that some of my MASM programs were not working correctly when placed on ".data?" section variables and assumed them to be zero at start on Win98.
Post 21 May 2009, 17:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17281
Location: In your JS exploiting you and your system
revolution
There are times where putting zeros is needed. With post-processing of files data may be inserted after the .exe is generated.

For the above file, just change your code to correctly generate the uninitialised data.

I don't think it is a good idea to make the assembler guess at what you wanted. What happens when the guess is wrong and you have to find a workaround to fix the assembler's "error".
Post 21 May 2009, 17:15
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
Location: Severodvinsk, Russia
SFeLi
LocoDelAssembly, I’m using 98, almost always try to dd ? everything that needs to be 0 and never encountered such problems…
revolution, do you know a way to store dword ? at addr?
But ok, I was wrong.
Post 21 May 2009, 17:24
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Microsoft Portable Executable and Common Object File Format Specification - Revision 8.1 – February 15, 2008 wrote:
VirtualSize: The total size of the section when loaded into memory. If this value is greater than SizeOfRawData, the section is zero-padded. This field is valid only for executable images and should be set to zero for object files.


This don't back my experience very much... I suppose the specs haven't changed over the time about this so probably my memory is failing me.
Post 21 May 2009, 17:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17281
Location: In your JS exploiting you and your system
revolution
SFeLi wrote:
do you know a way to store dword ? at addr?
Maybe not exactly what you are asking but this a way of finding a length of some non-zero data and then reserving it in the PE
Code:
virtual
  ...
  ; do your 'file' and whatever other stuff
  ...
  MyDataSize = $-$$
end virtual
rb MyDataSize    
Post 21 May 2009, 18:01
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.