flat assembler
Message board for the users of flat assembler.

Index > Windows > Report a PE format problem

Author
Thread Post new topic Reply to topic
jiangfasm



Joined: 08 Mar 2015
Posts: 60
jiangfasm
hello.asm
---------------------------------
include 'win32wx.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

.code

start:
invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
invoke ExitProcess,0

.end start


jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ fasm hello.asm
flat assembler version 1.71.39 (1048576 kilobytes memory)
4 passes, 0.1 seconds, 1536 bytes.

jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ ./hello.exe

Everything is normal

----------------------------------------------------------

include 'win32wx.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

.code
.code ;<- problem
start:
invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
invoke ExitProcess,0

.end start

jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ fasm hello.asm
flat assembler version 1.71.39 (1048576 kilobytes memory)
4 passes, 0.1 seconds, 1536 bytes.

jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ ./hello.exe
bash: ./hello.exe: cannot execute binary file: Exec format error

Problem code above, can be run under wine.

Win7 will not run.

Wait, and then send a test results in the wine.


jiang@jiang:~/fasm/examples/hello$ fasm hello.asm
flat assembler version 1.71.39 (2097152 kilobytes memory)
4 passes, 0.4 seconds, 1536 bytes.
jiang@jiang:~/fasm/examples/hello$ wine hello.exe
err:menubuilder:init_xdg error looking up the desktop directory


Description:
Filesize: 170.55 KB
Viewed: 1544 Time(s)

2015-09-09.png


Post 09 Sep 2015, 07:49
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
Yes, the empty PE section generated by the duplicate .code macro will cause a problem with the loader.
Post 09 Sep 2015, 13:41
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 60
jiangfasm
revolution wrote:
Yes, the empty PE section generated by the duplicate .code macro will cause a problem with the loader.

------------------------------------------------------
; example of simplified Windows programming using complex macro features

include 'win32wx.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

section '.text' code readable executable
section '.text' code readable executable
start:
invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
invoke ExitProcess,0

.end start



jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ fasm hello.asm
flat assembler version 1.71.39 (1048576 kilobytes memory)
6 passes, 0.1 seconds, 1536 bytes.

jack@JACK-PC MINGW64 ~/fasm/examples/hello
$ ./hello
bash: ./hello: cannot execute binary file: Exec format error

Cannot run!
Post 09 Sep 2015, 14:31
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
Yes, the empty section is not supported by the loader. It is not disallowed by the PE spec, but the OS loader will still fail to load it.

The solution is to not put empty sections in your PE file.
Post 09 Sep 2015, 17:02
View user's profile Send private message Visit poster's website Reply with quote
jiangfasm



Joined: 08 Mar 2015
Posts: 60
jiangfasm
revolution wrote:
Yes, the empty section is not supported by the loader. It is not disallowed by the PE spec, but the OS loader will still fail to load it.

The solution is to not put empty sections in your PE file.


Thank you for your answer, my Windows improves the programming levels.
Post 10 Sep 2015, 00:58
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 GitHub, YouTube, Twitter.

Website powered by rwasa.