flat assembler
Message board for the users of flat assembler.

Index > Windows > win 32-64 combo-exe

Author
Thread Post new topic Reply to topic
Syrasia



Joined: 25 Feb 2010
Posts: 11
Location: Saarland, Germany
Syrasia 29 Apr 2010, 08:32
Today an good friend of me gave me an idea:
As I look int the win32 definition, there was a DOS-specivic code for compability. Is this also in the win64? Because I would then try to combine it: write an normal x64 exe and onyl replacing the "Not runable unter 32 bit" (don't know how exactly it is told) with a jump to an included binary win32 code.
It shold work probertly, I think.
Second question: where can I get the win64 definition?! And maybe also win32 def?
Post 29 Apr 2010, 08:32
View user's profile Send private message Send e-mail Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 29 Apr 2010, 08:41
You can't execute any code located in 64-bit PE file in 32-bit Windows at all because 32-bit PE loader don't find valid PE header (PE signature is different).
Post 29 Apr 2010, 08:41
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 29 Apr 2010, 12:09
Syrasia, keep your creative thinking. Sometimes it is possible to implement things looking impossible. Don't be frustrated after reading my reply to your post further.

You cannot implement your idea about using 16 bit code of exe header under win64 because:

- first reason: win64 abandoned DOS emulation, win64 is not capable to run native 16 bit code, the 16 bit code included in common exe header (PE32+) is useless under win64. No one user is able to pass this limitation.
- second reason: default win64 installation usually turns on noexecute option so header loaded undew win64 is marked as non executable page (it is possible to manually change that and reboot) - so most common users would be unable to run such app. Some win 32 executables packed / protected with packers / protectors using 32 bit win header tricks fail to run under win64 because of non executable header (protectors / packers which used antidebug trick by putting part of their code into win32 executable header)

something out of topic:
when I produce win64 executable I prefer header without 16 bit code which saves few bytes of final executable if your executable has 4 sections (PE signature then starts at offset 40h and last fourth section ends at offset 1E7h

file hdr.asm:
Code:
format MZ    

compile it to produce hdr.exe of size 32 = 20h bytes

64 bit executable sample:
Code:
format PE64 console at 100000000h on 'hdr.exe'
...    
Post 29 Apr 2010, 12:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 29 Apr 2010, 13:06
Continuing offtopic: I've seen a much simpler trick used to do the similar thing:
Code:
format PE on "nul"    

This utilizes the fact that fasm does com2exe conversion when provided with .com file as a stub; and if the input is an empty file, it just converts an empty .com into minimal .exe.
Post 29 Apr 2010, 13:06
View user's profile Send private message Visit poster's website Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 30 Apr 2010, 08:13
great trick with "nul"
it is almost always possible to further improve things looking already improved enough
Post 30 Apr 2010, 08:13
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Syrasia



Joined: 25 Feb 2010
Posts: 11
Location: Saarland, Germany
Syrasia 03 May 2010, 09:46
on topic:
I found a very esayway to get it how I like it:
I didn't wanted to have the resurces and other data double, so it should be an cobo exe. Solution: write a 32 bit exe with a 64 bit exe included and if 64 is suprted, the 32 gives the data from itselve to the 64 bit exe and ends.
also thx for the ansers
PS: I will try to write even an 32 bit exe, witch will use a 64 bit cpu with 32 bit os. It is posible. If anyone has some ideas, wirte them plz.
Very Happy
Post 03 May 2010, 09:46
View user's profile Send private message Send e-mail 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.