flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > bug in 1.7X: format pe dll - ERROR_BAD_EXE_FORMAT

Author
Thread Post new topic Reply to topic
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank
When I trying to use(through LoadLibrary) library assembled from that code:
Code:
format pe dll gui
entry start

include 'win32ax.inc'

section '.edata' export readable writable
export 'testdll.dll',\
  start, 'test'
section '.text' code readable executable
start:
 mov eax,1
   ret
section '.reloc' fixups data discardable
    


I get NULL and GetLastError returns ERROR_BAD_EXE_FORMAT(193)

In older versions weren't such problem.

in 1.70.03 and 1.71.00 the same thing.
Post 21 Sep 2012, 20:05
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Blank
This has been discussed so many times... A section should not be empty. But your relocations section becomes empty because there are no relocations to apply. Besides the relocations section should have the attribute readable.

Code:
format pe dll gui 
entry start 

include 'win32ax.inc' 

section '.edata' export readable writable 
export 'testdll.dll',\ 
        start, 'test'

section '.text' code readable executable 
start: 
        mov eax,1 
        ret

section '.reloc' data readable discardable
data fixups
end data
dd ?    


P.S. And there's no bug now. There was a bug in fasm versions, which created a loadable library by putting invalid data into the relocations directory.
Post 21 Sep 2012, 20:46
View user's profile Send private message Reply with quote
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank
Thank you for help.
"There was a bug in fasm versions, which created a loadable library by putting invalid data into the relocations directory." - I'll would miss for it - that bug was so useful.
Post 21 Sep 2012, 21:14
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
Blank
Quote:
that bug was so useful

If you don't like the solution I provided in the previous post, you can always force creation of a dummy fixup by putting dd $ somewhere in you source code. But the binary will become 512 bytes larger, if there are no other fixups.
Post 21 Sep 2012, 21:20
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
You may use this code so you can be sure it will work on both, Win9x and NT line:
Code:
section '.reloc' data discardable fixups
if ~ $-$$ 
        dd      0,8 ;empty fixups section iff no other fixups 
end if    
If you use "dd $" then the first line of the code will be enough, but I think it is better to not force Windows to relocate if not really needed as that will cause the affected code page to get dirty and not shareable with other processes (unless it happens to be mapped to the same address AND Windows is smart to take advantage of that).
Post 21 Sep 2012, 22:01
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
LocoDelAssembly
Quote:
but I think it is better to not force Windows to relocate if not really needed as that will cause the affected code page to get dirty and not shareable with other processes

Nobody said, that dd $ must be put into the code section.

Btw. I don't think someone still cares about Win9x. Forgetting it would allow to save 512 bytes.
Post 21 Sep 2012, 22:06
View user's profile Send private message Reply with quote
Blank



Joined: 28 Feb 2012
Posts: 13
Location: Ukraine
Blank
l_inc wrote:
Blank
Quote:
that bug was so useful

If you don't like the solution


No, I mean before was enough one 'section' directive, now also required data block and dword - more routine code to write.

Would be nice if more sections(.code and .data exist) were wrapped(out of the box) into macros such as: .import .export .reloc .tls

or separate fasm base and includes(and make it available from download page).
create several fasm include packages: for each OS or group of users who would be responsible(actualize it, add features, etc.) for package.
Post 22 Sep 2012, 07:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Blank wrote:
... or separate fasm base and includes(and make it available from download page).
create several fasm include packages: for each OS or group of users who would be responsible(actualize it, add features, etc.) for package.
There is already a thread for that:

http://board.flatassembler.net/topic.php?t=7882
Post 22 Sep 2012, 07:55
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
related to windoze, madmatt's stuff works is very accurated.
i have made some update for my needs, but i dont want to bore madmatt every time, sending him those little updates.
also it's difficoult to find update, because it is zipped on "volatile" websites,
or referenced from a couple of links somewhere on board (find FASMW64).
a repo, i propose Hg, would be 100% suitable for it.
madmatt, are you there ?
Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 22 Sep 2012, 18:39
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Yep, still here, and your right. It would be better if someone would host the package so that many people could contribute to the project (includes/examples) and have a single place to download the latest in a .rar or .zip file. I'd do this myself, but I'm a complete caveman when it comes to setting up websites or sourceforge.

hopcode:
Got your private message, so if your hosting offer still stands then I can email you my latest update.
Post 26 Sep 2012, 14:53
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
hi madmatt,
sorry for late response. just uploaded the last zipped release (28 März 2012)
i found on esnip some times ago, at

[EDIT] repo link to be determined[/EDIT]

i used the name "madmatt" for the repo, "the madmatt toolkit"

i like the nick Very Happy . you can always retain the "FASMW64" original name,
if you decide eventually to push yourself updates on google or where you like
(then we will clone from your repo to local, so that i delete that of mine
currently online).

i send you my email, and some details about the text files.

_________________
⠓⠕⠏⠉⠕⠙⠑


Last edited by hopcode on 27 Sep 2012, 16:08; edited 1 time in total
Post 27 Sep 2012, 06:18
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Ok, that looks better (and simpler) than all the file sharing sites I've been using. Thanks! I'll have a new update shortly, so how would I log in to upload updates?
Post 27 Sep 2012, 14:05
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
a pm in box,
Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 27 Sep 2012, 16:09
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.