Binary to MS COFF object file converter

Started by Vortex, November 04, 2006, 04:40:08 PM

Previous topic - Next topic

Vortex

Here is my new tool binary to MS COFF object file converter, bin2coff

This tiny tool converts any binary file to a linkable MS COFF object file.

Usage :
   
Quotebin2coff srcfile.ext output.obj label

srcfile.ext   :   
            Any kind of binary file

output.obj   :
            The name of the object file to be created

label      :       
            A label name presenting the embedded binary data to the linker
            Notice that the label should be prefixed with an underscore depending
            on the external label naming convention of your development tools.

http://vortex.masmcode.com/files/bin2coff10.zip

Vortex

Here is a simple SFX archive demo using Jeremy Collake's compression library. The compressed data is converted to a linkable COFF object module.

[attachment deleted by admin]

jack

speaking of converting to coff, I am still looking for a utility that converts omf libs to coff  :wink

Vortex

Quote from: jack on November 06, 2006, 08:32:12 PM
speaking of converting to coff, I am still looking for a utility that converts omf libs to coff  :wink

That's easy. Pelle's librarian Polib does the job :

QuoteConvert an OMF import library to COFF [4.00]

You can use POLIB to convert an import library in OMF format (Borland) to COFF (Pelles C, Microsoft). When you do, use the following syntax:

POLIB OMF-library /OUT:library

The argument OMF-library specifies the name of import library in OMF format.

The result will be written to the file named library.


Vortex

Here is the SFX archive demo this time running the child executable.



[attachment deleted by admin]

hfheatherfox07

I think I miss understood the purpose of this tool ....

I used bin2coff to get HelloWorld.obj from "HelloWorld.exe" than I used you obj2asm to get HelloWorld.asm  from HelloWorld.obj

Is that Possible? what is the obj2asm for other wise ?  I get a weird looking .asm all hex

dedndave

it is hex that may be placed in the data segment of an asm source

Vortex

Hi hfheatherfox07,

You could try dumppe if you wish to disassemble an executable :

\masm32\bin\dumppe.exe

hfheatherfox07

Not sure what do you mean by \masm32\bin\dumppe.exe

can you post an example .....

I thought there was a way to get an actual .ASM back out of .exe  ...
I figured if ml.exe makes a coff object out of .asm and link.exe compiles an executable out of that ... that you found a way to go backwards....
not sure how Binary to MS COFF object  would handle the .res if there was a compiled .rc as well


dedndave

there is a program in the masm32\bin folder named dumppe.exe
it is a command line tool

DumpPE /?
will display the switches

DumpPE -disasm MyFile.exe
will disassemble an exe

Vortex

Consider this quick example, dummy.asm :



.386
.model flat,stdcall
option casemap:none

include     \masm32\include\kernel32.inc

includelib  \masm32\lib\kernel32.lib

.code

start:

   xor     eax,eax
   invoke  ExitProcess,eax

END start


Build it as a GUI application.

dumppe.exe -disasm dummy.exe


00401000                    start:
00401000 33C0                   xor     eax,eax
00401002 50                     push    eax
00401003 E800000000             call    fn_00401008
00401008                    fn_00401008:
00401008 FF2500204000           jmp     dword ptr [ExitProcess]


The above code is just only a portion of dumppe's output.

The other option is to use Agner Fog's objconv tool :

objconv.exe -fmasm dummy.exe disasm.asm

Again a portion of the output :


.386
option dotname
.model flat

public Entry_point

extern ExitProcess: near                                ; kernel32.dll


_text   SEGMENT BYTE PUBLIC 'CODE'                      ; section number 1

Entry_point PROC NEAR
       xor     eax, eax                                ; 00401000 _ 33. C0
       push    eax                                     ; 00401002 _ 50
       call    ExitProcess                             ; 00401003 _ E8, 00000000

ExitProcess LABEL NEAR
       jmp     dword ptr [imp_ExitProcess]             ; 00401008 _ FF. 25, 00402000(d)
Entry_point ENDP


You need to modify disasm.asm to produce a source file which can be processed by Masm.