a program to do this exist?


0x89,0xD0, // MOV EAX,EDX
0xD1,0xC8, // ROR EAX,1
0xC3      // RET
Posted on 2006-09-02 18:52:25 by hermano
Sure there is. In your masm folder there is an utility named "bin2db" or attached I got one of F0dder's command line tools giving output in either asm, c, or c-string. Use it like :

bin2h filename.asm a > outputfile.txt for an output like:
db 023h, 064h, 065h, 066h, 069h, 06Eh, 065h, 020h

bin2h filename.asm c > outputfile.txt for an output like:
unsigned char data[2534] = {
0x23, 0x64, 0x65, 0x66, 0x69, 0x6E, 0x65, 0x20, 0x57, 0x49,

bin2h filename.asm s > outputfile.txt for an output like:
unsigned char data[2534] =

To achieve your wanted 0x89, 0xD0 kind of Text use the second one and cut out the beginning and end brackets.
Posted on 2006-09-02 19:54:40 by JimmyClif
If you want to compile assembly source into binary data you should look at fasm, I believe it has that functionality.
Posted on 2006-09-02 19:57:53 by Eóin
i just want to convert some code to bytes, so that i can use them in program im writing...

so, if i have the code in asm, using the bin2db masm tool i can do this? with code (text) or i need the compiled assembly code?
Posted on 2006-09-02 20:02:27 by hermano
Oh, you mean you'd like to quickly get a certain command (like MOV EAX,EDX) translated to it's opcode (0x89,0xD0) without compiling etc...

Look into Hiew or RTA. Both have straight asm to opcode translation capabilities.
Posted on 2006-09-02 20:09:16 by JimmyClif
i cant put hiew to translate opcodes... any help on that?

i have the demo version..
Posted on 2006-09-02 20:22:36 by hermano
Sure easy.

Open a file. (any)
Hit F4 then F2. (F4 is for display changes)
Hit F3 then F2. (F3 is for editing)
Now you can enter Asm commands and it will translate it to opcodes after hitting return.
Posted on 2006-09-02 20:26:54 by JimmyClif
f4 - f2 -> open the file in hex mode
f3 - f2 -> when you press f3, there is no f2 option avaliable...

isnt f4-f3 then f3-f2?
Posted on 2006-09-02 20:34:00 by hermano
Alright, try again.

Open a file.
Hit F4 - When you hit now F2 it will choose Decode as Mode.
Now Hit F3 - Cursor is flashing to edit - When you hit now F2 a dialog will pop up enabling you to enter assembly commands.
Posted on 2006-09-02 21:42:39 by JimmyClif
Now, upper posts are a good reason why I'm not a tutorial writer :P
Posted on 2006-09-02 23:10:34 by JimmyClif
nop.. this hiew program doesnt seem to work...

i open a text file with asm code in it and even going trhu te steps you told me i cant manage to convert asm code to the equivalent in bytes....
Posted on 2006-09-03 21:57:52 by hermano
Just make an asm app, in which you have your function, then another function writes the data to bin or text:

Tester proc arg1:DWORD
xor eax,eax
Tester endp

invoke WriteBytes,Tester,_end_Tester - Tester ; WriteBytes(address,size)

I guess you're trying to include MASM-assembled code into a GCC C++ project? Some .obj -> .o converter (COFF -> ELF) must exist, I think.
Posted on 2006-09-04 01:21:00 by Ultrano
If all else fails, check out FASM or NASM binary format output modes.
Posted on 2006-09-04 06:02:59 by f0dder
You might also be interested in SoftWire. It was designed specifically to generate executable binary code at run-time. There's also a version that can compile from text, if you're interested.
Posted on 2006-09-10 12:19:34 by C0D1F1ED
Oh, I thought you pulled the plug on free SoftWire after you joined (or sold it to?) transgaming - at least that's the impression http://softwire.sourceforge.net/ gives :)
Posted on 2006-09-10 14:48:54 by f0dder