Hi guys ...
dose any body know how can we creat a binary file like file1.bin
using masm32 and link or any other linker.
Thanx.
masm 32bit and binary files
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
MASM != NASM
Microsoft Assembler reference: http://msdn2.microsoft.com/en-us/librar ... S.80).aspx (copy+paste, phpbb doesnt like to [url] this)
I couldnt find a binary output format in ml or link though - you should probably use binutils for that, as Candy suggested
Microsoft Assembler reference: http://msdn2.microsoft.com/en-us/librar ... S.80).aspx (copy+paste, phpbb doesnt like to [url] this)
I couldnt find a binary output format in ml or link though - you should probably use binutils for that, as Candy suggested
-
- Member
- Posts: 134
- Joined: Thu Aug 18, 2005 11:00 pm
- Location: Sol. Earth. Europe. Romania. Bucuresti
- Contact:
JLOC has a help file... is not simple ... please read it.
You can also find a sample linker control file in SolarOS.
For your conveninece I post a sample here... however it must be adapted to suit your specific needs... this example is from SOL:
This statements will link sytem32.obj (compiled with TASM) to run at absolute memory location 0xB000
You can also find a sample linker control file in SolarOS.
For your conveninece I post a sample here... however it must be adapted to suit your specific needs... this example is from SOL:
Code: Select all
ALL:
SYSTEM32.obj
SYS32: 0,0B000,0
*,*,*,code32,system32.obj
*
-
- Member
- Posts: 33
- Joined: Wed Apr 26, 2006 11:00 pm
Re: masm 32bit and binary files
You cant, i also had this problem since my os is also completely written in masm32... but you can simply compile the exe-file, then open the exe-file and look up where in the file your code seg is located, and then copy that binairy code to another file, or do whit it what you like to do whit it.abuashraf wrote:Hi guys ...
dose any body know how can we creat a binary file like file1.bin
using masm32 and link or any other linker.
Thanx.
you could use something like this, to find the base of your code:
Code: Select all
mov bx,offset PE_EXE_FILE ; base in mem of the PE-EXE file
add bx,dword [ds:bx+3ch]
; now at "PE" base
add bx,0F8h ; Go to table for segments, so
; .DATA/.CODE
looping:
test dword [ds:bx+36],020000000h ; should be Flag for code segment
jnz GotIt
add bx,40
jmp looping
GotIt:
mov dx,offset PE_EXE_FILE
add dx,dword [bx+20] ; DX + Base in file, for the code seg.
; now DX points to the base in mem, of your code..
offset PE_EXE_FILE + 200h. since that should always be the base of
your code, but depens on the linker.. the above code is cleaner.
(look it up whit a hex edit).
if you also would like to be able to use .Data and .Data? seg's you need to expend the code above a bit, look on the internet for the "PE-header file format".
http://www.madchat.org/vxdevl/papers/wi ... pefile.htm that should cover most of it.
Regards
PyroMathic