NO

Author Topic: How can I paste any data in the <project>.exe file?  (Read 7559 times)

sp00n

  • Guest
How can I paste any data in the <project>.exe file?
« 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:)

JohnF

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #1 on: May 01, 2007, 10:08:55 AM »
Try using RCDATA in the .RC file

2  RCDATA "data.dat"

John

sp00n

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #2 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?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
May the source be with you

JohnF

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #4 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

sp00n

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #5 on: May 01, 2007, 01:20:26 PM »
Or put it into object.

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  ;)

sp00n

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #6 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.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: How can I paste any data in the <project>.exe file?
« Reply #7 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.
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Re: How can I paste any data in the <project>.exe file?
« Reply #8 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.
Code it... That's all...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: How can I paste any data in the <project>.exe file?
« Reply #9 on: May 02, 2007, 07:28:16 AM »
Google 'bin2coff tool'
Nice command line tool.
May the source be with you

sp00n

  • Guest
Re: How can I paste any data in the <project>.exe file?
« Reply #10 on: May 04, 2007, 09:33:55 AM »
Thanks to all.
Topic closed:)