News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

exe2bin in 64-bit Windows

Started by kashifrmemon, October 12, 2010, 08:55:49 PM

Previous topic - Next topic

kashifrmemon

I use Masm 6.11 and 16 bit linker to generate a .exe
Then convert it the .exe to .bin using exe2bin

I recently updated my development machine to 64-bit Win 7.

The problem is exe2bin no longer works (error says that is not compatible with 64-bit Windows).
This used to work fine on 32 Windows (tried on Vista and Win7).

Is there a way to convert 16-bit .exe to .bin on 64-bit Windows?

Any help would be appreciated.

dedndave

exe2bin is a fairly simple program
if i wanted to do something similar under a 64-bit environment, i would probably just re-write it in 32-bit

even so, the resultant 16-bit image is not useful in a 64-bit environment, other that creating EPROMS or something
16-bit programs do not appear to run under 64-bit OS's
although, you might try something like DOSBox or some other type of VM

kashifrmemon

The final image does go to a EPROM.

Rewriting exe2bin did come to mind, but I thought maybe there is already a solution out there.
If not then that is probably what I will have to do.

redskull

If you are writing a tiny mode program, you can just make a .COM file (/at) but keep the ORG set as 0 in leui of 0x0100.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

dedndave

Red - thing is - exe2bin is a 16-bit program that will not run under 64-bit OS (not without some work, at least)

exe2bin is not a complicated deal, though

first, the EXE must meet a few requirements:
1) it must be ORG'ed at either 0 or 100h
2) all code and data must fit into a single segment, or at least, 64 K
   (i have seen cases where multiple segments are declared, but are combined - exe2bin should handle that)
3) there must be no run-time relocatable elements

after those requirements are checked, the program basically strips off the MZ EXE header and
places the remaining binary code and data, with offsets calculated according to the ORG offset
it should be a very simple program to write

as i recall, exe2bin is only about 3 K of code - an easy disassembly

redskull

but could you not produce an equivlent file by using ml with /at switch and the old-version linker with the /tiny switch (both 32-bit programs if I recall correctly)?  Is not a COM file with origin 0 just a binary file?

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

dedndave

ya know, Red, that would probably work
although, i have never tried it with ORG=0
so - you are saying: use Link16.exe that is in the masm32 package (aka lnk563.exe)

MichaelW

Exe2bin is not necessary with the later 16-bit linkers. At its simplest, to create a binary you define an appropriate segment, place code and/or data statements in the segment, assemble with ML /c and link with Link16 /TINY. For example, this will assemble and link to a 1-byte binary:

.386
CODE SEGMENT
    nop
CODE ENDS
end


The model directive and simplified segment definitions can also be used for this.
eschew obfuscation

japheth

Quote from: MichaelW on October 13, 2010, 05:28:26 AM
Exe2bin is not necessary with the later 16-bit linkers.

True. Additionally, there's a Win32 version of exe2bin available in the Open Watcom package - to be found at  \Watcom\binnt\exe2bin.exe.


kashifrmemon

Thanks for all the suggestions.
I will check them out and post my results.