EXE file format info... mind blowing

Blitz3D Forums/Blitz3D Programming/EXE file format info... mind blowing

Nate the Great(Posted 2009) [#1]
Hi

as some people on here have noticed I like to reinvent the wheel for curiosity's sake so here it goes...

I was just curious of how to write an exe via the writefile and writeint commands in blitz... I know it is possible. So after much thought I decided learning the exe file format is a must at this stage and I did a ton of research and experimenting getting manny bsd's along the way. so after going through much strife to get to what I know about the exe file format already (which is relatively nothing) I decided that someone on the blitz blog might know.

all I know now is that the first 4 bytes of every exe are the same

0x4d and 0x5a consecutively

i think these translate to binary accordingly

0000 0000 0100 1101 x 0000 0000 0101 1010

is that right? and if so how would i write that via the writeint command? how does blitz write integers?

I also know that the first 80 to 100 ish bytes of every blitz3d compiled program are the same mostlikely because they have the same icon and information

so is there an expert in the field? does anyone know anything about this format that we use so often yet never have come to understand fully?


skidracer(Posted 2009) [#2]
http://en.wikipedia.org/wiki/Portable_Executable


Gabriel(Posted 2009) [#3]
Your hex to binary conversions look right to me, except that you've filled them out with leading zeros, which won't be correct if the first 4 bytes are 4d and 5a.

You don't need to do anything to convert them. Blitz3D is already quite happy dealing with hex numbers. You just prefix them with a $ to denote that they're hex. You can do binary too, but I'm not positive of the character you need to denote binary. I think you prefix it with % as in %0100110101011010

WriteInt(File,$4d5a)



Nate the Great(Posted 2009) [#4]
Thanks gabriel! that will be helpful! it just goes to show that even after 6 years of programming in blitz, there are still random little things to be learned :)

@skidracer

ill take a look at it later.. have to go to bed right now. thanks


I still cant figure out the commands in hex :p anyone know these?


xlsior(Posted 2009) [#5]
Windows .exe file format:

http://www.wotsit.org/download.asp?f=exe-win&sc=287540417


Ginger Tea(Posted 2009) [#6]
32-bit Portable Executable: Introduced with Windows NT, these are the most complex[citation needed] and can be identified by the "PE" in ASCII. These can be run by all versions of Windows NT, and also Windows 95 and higher, partially also in DOS using HX DOS Extender. They are also used in BeOS R3, however the format used by BeOS somewhat violates the PE specification as it doesn't specify a correct subsystem[citation needed].


although without looking at the ascii chart i doubt PE match those numbers (edit: its MZ which is for DOS apparantly)

other versions of windows/dos prefixed exes with
MZ, NE, LX or LE


Wings(Posted 2009) [#7]
ahh you make an assembler for windows :)


Nate the Great(Posted 2009) [#8]
thanks xlsior the link didnt work but I found the same file somewhere else :) its really complicated but im sure I can understand it eventually...

At wings

exactly


hmmm now to get this off the ground :p


SytzeZ(Posted 2009) [#9]
I one time downloaded a free program: Immunity Debugger
Google it, and I'm sure you'll find it.
I don't know exactly what it does, but it can look into an .exe file in a weird way, and returns some weird code.
Sometimes there are c++ function names in it