Is it possible to edit/modify COFF and OMF object files? Are there any tools available
for this purpose?

What I want to do is to remove the data section from an OMF obj. file. The final executable
file contains an empty data section which increases the length of file.
Posted on 2003-05-21 08:03:59 by Vortex
You need a hex editor and good knowledge of PE's. I was making my own but got side tracked with work demands. My last thing I need to do is have the program read the size of the sections because Windows loads a program in 4K pages. So when I treid a continous load of an EXE file I got stopped because the memory inbetween say the executable portion and the next section was not even page boudries. But the COFF is the first section loaded and can certainly be edited.
Posted on 2003-05-21 21:16:17 by mrgone
Vortex, you may want to consider merging sections when linking. Here's
an example of a NMAKE file configuration I use for COFF files...

# NMAKE MAKEFILE TEMPLATE
NAME=prog
VERSION=1.0
BIN=\masm32\bin
SUBSYSTEM=WINDOWS
LIBPATH=\masm32\lib
AFLAGS=/c /coff /Cp /Fl /Sn
OPT=/RELEASE /OPT:NOWIN98 /OPT:REF /MERGE:.rdata=.data /MERGE:.data=.text /SECTION:.text,ERW
LFLAGS=$(OPT) /VERSION:$(VERSION) /SUBSYSTEM:$(SUBSYSTEM) /LIBPATH:$(LIBPATH)

.asm.obj:
$(BIN)\ml $(AFLAGS) $<
.obj.exe:
$(BIN)\link $(LFLAGS) $<
del $<

all: $(NAME).exe

$(NAME).exe: $(NAME).obj
$(NAME).obj: $(NAME).asm

Employing the link optimizations generally results in smaller executables.

However as far as OMF is concerned there seems to be a paucity of editing and alignment tools on the net. Also, according to the following info:

http://rs1.szif.hu/~tomcat/win32/apj2.txt

TASM always adds a .data section. But I don't know whether the OMF
standard requires this.
Posted on 2003-05-21 22:03:01 by Poimander
mrgone,poimander,

Thanks for your help.
The creation of sections depends on the linker I am using.
Posted on 2003-05-22 02:31:11 by Vortex
Windows uses file mapping to load a file. It is an exact image of how it is stored on the hard disk in 4K pages. I still would like to overide that blank memory gap between uneven page boundries. Would be so much simpler. I have seen various discussions on getting to ring zero but most examples don't work. One says somehow you can use call gates and another says to use ntdll.dll and one exampe I got actually worked but pulled up a DOS window to display results. I think it uses IOCTL some kind of way. When I get time I will explore.
Posted on 2003-05-22 04:14:48 by mrgone