Copying data into an executable by another executable

How can I create a data storage area in a program
that another program can put data into. I'm writing an Install program in C. A simple static BYTE Buf[100000]; does not make the compiled program 100000 bytes larger.

The compiler only stores the initializers and copies them at startup to dynamically allocated memory. So you would need 10000 explicit initialisers. It will not unnecessarily pad the file. Static data not explicitly initialised is initialised to zero, but the compiler does not need to store 10000 zero bytes to do that.

It may be possible to use an assembler directive (with in-line assembly), or a modified linker script to reserve space. Since this would be compiler dependant, you'll need to dig deep in the documentation.

While this is an interesting problem (technically not quite self-modifying code, but close to it), why not simply use an ini file? Writing into an executable is asking for problems unless you know EXACTLY where the compiler is putting everything. If you are trying to hide some data in the exe, all you are doing it raising the bar on hackers, anyone with an ounce of sense will simply open the exe as a text file and look for the data or run a decompiler on it and see what pops out. If you want to keep others from using the extra data, why not encrypt it and have the exe decrypt it as it is being used? Keep in mind you can't make software that can't be re-engineered, only make it more or less difficult.

To write an install program, most of us use an installer. NullSoft's NSIS program is a dream for this.

Otherwise I'd recommend writing a separate installer program using Microsoft's Installation API, then compressing it with an archive program that can build directly to an exe, like PK-Zip. PK-Zip lets you specify a program to run out of it's payload after extraction.

Writing your own installer is re-inventing the wheel though. There are already good, free installers out there written by people who understand how such things are done. Use their tools and save yourself the grief.