G
Gary
Hi all,
I have a situation where I need to generate a new binary file which
just changes a couple of bytes in a couple of places in a pre-existing
master template file.
I can open and read the original file byte by byte and spew it out to
a new file, just changing the appropriate bytes. However since these
files are only about 1k bytes long, I'd like to include those bytes
directly into my code, e.g. as a static array. This would create a
cleaner situation in that I wouldn't have to know where the original
file was, worry about it getting deleted/moved/modified etc. And the
code generation would be a little easier (not that it is hard).
However I am unclear how you would go about attaching a label to the
top of it, making sure that the compiler didn't rearrange any bytes,
and of course, how to make the compiler treat this as just a block of
literal bytes to be considered static data rather than inline assembly
or whatever.
Let's say the file contains 4 bytes, FF FD 45 34
I want something that creates the equivalent of:
char template_file[] = {0xFF, 0xFD, 0X45, 0x34 };
I am using Visual C++ version 6.
Thanks for any hints.
I have a situation where I need to generate a new binary file which
just changes a couple of bytes in a couple of places in a pre-existing
master template file.
I can open and read the original file byte by byte and spew it out to
a new file, just changing the appropriate bytes. However since these
files are only about 1k bytes long, I'd like to include those bytes
directly into my code, e.g. as a static array. This would create a
cleaner situation in that I wouldn't have to know where the original
file was, worry about it getting deleted/moved/modified etc. And the
code generation would be a little easier (not that it is hard).
However I am unclear how you would go about attaching a label to the
top of it, making sure that the compiler didn't rearrange any bytes,
and of course, how to make the compiler treat this as just a block of
literal bytes to be considered static data rather than inline assembly
or whatever.
Let's say the file contains 4 bytes, FF FD 45 34
I want something that creates the equivalent of:
char template_file[] = {0xFF, 0xFD, 0X45, 0x34 };
I am using Visual C++ version 6.
Thanks for any hints.