[comp.os.msdos.programmer] Linking binary data into MSC/MASM programs

jls@hsv3.UUCP (James Seidman) (02/28/91)

I'm writing a program which needs access to some large (8K-32K) chunks of
data.  These data are produced by other programs and wind up in data files.
I'm currently just reading the data in from these files at run time, but
would really like to able to link them into my main program.

I could theoretically write a program (call it BIN2DB) which would take my
binary file and make a huge masm file with a bunch of DB directives in it,
but this seems like a real pain.  What would be really perfect would be to
have a utility (say BIN2OBJ) which would turn my file into a Microsoft OBJ
with a public symbol at location 0.  Then I could very easily access the
data from inside my program.

Has anyone tried anything like this?  Or does someone have alternate
suggestions?  Thanks in advance!

-- 
Jim Seidman (Drax), the accidental engineer.
"It doesn't have to work... they'll be paralyzed just from laughing at me."
							- Dr. Who, _Shada_
UUCP: ames!vsi1!hsv3!jls	         INTERNET: hsv3.UUCP!jls@apple.com

raymond@math.berkeley.edu (Raymond Chen) (02/28/91)

In article <7431@hsv3.UUCP>, jls@hsv3 (James Seidman) writes:
>What would be really perfect would be to
>have a utility (say BIN2OBJ) which would turn my file into a Microsoft OBJ
>with a public symbol at location 0.  

Like, say, this program that I found by sending the message

	lookup /OBJ/

to rjc@math.princeton.edu, as per the instructions in the
comp.sys.ibm.pc.misc Frequently Asked Questions file?

Programs on wsmr-SIMTEL20.army.mil as of 91-02-27 matching your search criterion: 
 
Directory PD1:<MSDOS.PGMUTL> 
IDTAG.ARC     B   18189  900116  Cvt text file to OBJ for linking to executable 
MAKEOBJ.ARC   B   11008  900102  Cvt data file to OBJ for linking to executable 

hollen@megatek.UUCP (Dion Hollenbeck) (03/05/91)

In article <7431@hsv3.UUCP> jls@hsv3.UUCP (James Seidman) writes:
> I'm writing a program which needs access to some large (8K-32K) chunks of
> data.  These data are produced by other programs and wind up in data files.
> I'm currently just reading the data in from these files at run time, but
> would really like to able to link them into my main program.
> 

If nothing else works, here is a kludge which might.  I used it in
a previous life to stitch a p-SYSTEM binary into an MS-DOS loader
program, but that is another story.

In your executable, define a 32mb data area (global static data)
initialized to a pattern you can easily find.
Link so you get a map!!!.  Rename .exe to .bin, read into debug.
Using the offset from the map, look just before the 32 meg area
for some lenght for the pattern.  When you have found the address
at which the block of data lives, just read in the file to that
location from disk.  Write the file back and change .bin to .exe.

Hope you do not have to resort to this, but it worked for me in a
past life.
--
-----
	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121
        uunet!megatek!hollen       or  hollen@megatek.uucp