Pelles C forum

C language => Beginner questions => Topic started by: sp00n on May 01, 2007, 10:01:56 AM

Title: How can I paste any data in the <project>.exe file?
Post by: sp00n on May 01, 2007, 10:01:56 AM
I need to keep a binary data(near 3Mb) inside my exe-file. How can I do it in Pelles C?
P.S. data is just binary file, no bitmap, no text, no any known format:)
Title: Re: How can I paste any data in the <project>.exe file?
Post by: JohnF on May 01, 2007, 10:08:55 AM
Try using RCDATA in the .RC file

2  RCDATA "data.dat"

John
Title: Re: How can I paste any data in the <project>.exe file?
Post by: sp00n on May 01, 2007, 10:26:57 AM
Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?
Title: Re: How can I paste any data in the <project>.exe file?
Post by: TimoVJL on May 01, 2007, 11:01:54 AM
Or put it into object.

http://www.smorgasbordet.com/forum/index.php?topic=1121.0 (http://www.smorgasbordet.com/forum/index.php?topic=1121.0)
Title: Re: How can I paste any data in the <project>.exe file?
Post by: JohnF on May 01, 2007, 01:10:21 PM
Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?

I expect you could use WizWriteFileFromResource() but if not look at these API's

HRSRC hRes = FindResource(hInst, name, RT_RCDATA);
DWORD dwResSize = SizeofResource(hInst, hRes);
HGLOBAL hResGlobal = LoadResource(hInst, hRes);
LPVOID lpResMem = LockResource(hResGlobal);

You should check the return values of course.

John
Title: Re: How can I paste any data in the <project>.exe file?
Post by: sp00n on May 01, 2007, 01:20:26 PM
Or put it into object.

http://www.smorgasbordet.com/forum/index.php?topic=1121.0 (http://www.smorgasbordet.com/forum/index.php?topic=1121.0)

Is it work on PocketPC? Cause I have a linker error about Invalid machine type  ;)
Title: Re: How can I paste any data in the <project>.exe file?
Post by: sp00n on May 01, 2007, 01:41:33 PM
Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?

I expect you could use WizWriteFileFromResource() but if not look at these API's

HRSRC hRes = FindResource(hInst, name, RT_RCDATA);
DWORD dwResSize = SizeofResource(hInst, hRes);
HGLOBAL hResGlobal = LoadResource(hInst, hRes);
LPVOID lpResMem = LockResource(hResGlobal);
Thanks John. It working well.
Title: Re: How can I paste any data in the <project>.exe file?
Post by: TimoVJL on May 01, 2007, 03:48:55 PM
Quote
Is it work on PocketPC? Cause I have a linker error about Invalid machine type
No, there was machine type IMAGE_FILE_MACHINE_I386 .
In File2Obj1.zip have changed ifh.Machine = IMAGE_FILE_MACHINE_UNKNOWN .
Perhaps this works with PocketPC.
Title: Re: How can I paste any data in the <project>.exe file?
Post by: Vortex on May 01, 2007, 06:26:37 PM
I need to keep a binary data(near 3Mb) inside my exe-file. How can I do it in Pelles C?
P.S. data is just binary file, no bitmap, no text, no any known format:)

sp00n,

You can use a binary to MS COFF object module converter to embed binary data in your executable.
Title: Re: How can I paste any data in the <project>.exe file?
Post by: TimoVJL on May 02, 2007, 07:28:16 AM
Google 'bin2coff tool'
Nice command line tool.
Title: Re: How can I paste any data in the <project>.exe file?
Post by: sp00n on May 04, 2007, 09:33:55 AM
Thanks to all.
Topic closed:)