Board index » delphi » How to put(pack) exe(dll) file in exe?

How to put(pack) exe(dll) file in exe?

I assume that what you want to do is to distribute just one file.

It appears that you have a 'favourite' DLL that you want to distribute
with the EXE.

You could look at making a self extracting system - I would check out
the PKZIP and WINZIP sites for that - but I suspect that you are not
really after setup systems.

The easiest thing is NOT to have a DLL - just include the code in your
project.

I assume that you have considered this - and that you do not have the
source for the DLL - yet you talk about the DCU - and if you have the
DCU you should be able to include it in your project.

However if you really must do this :

-  Append the DLL to the end of your EXE
 - Write code for extracting it - ie: the last 16 bytes of the  
   jiggered EXE contains the offset of the DLL and its length
   + of course a signature.
- Dynamically load the DLL
  see: Loadlibrary, GetProcessAdress, FreeLibrary

A sledgehammer to crack a hazelnut - but it'll work.

On Sun, 28 May 2000 14:23:10 +0200, "Mindaugas Ezerskis"

Quote
<me...@takas.lt> wrote:
>Hello friends,

>Will you tell me how to put exe(dll) file in exe. I need to do something
>like self extract file i.e. add some external data to my project. For
>example
>when I run my 'single.exe' file I need that it would extract dll file from
>itself
>and run it. This dll (myfile.dll (dcu)) is just 18kb.

>Please help me.

>I tried TRessourceStore component by Alexandre GUILLIEN, but it doesn't work
>on D5 :(

>Thank you in advance,

>Mezer
>E-mail: me...@takas.lt

 

Re:How to put(pack) exe(dll) file in exe?


Im Artikel <959528836.648...@news.balt.net>, "Mindaugas Ezerskis"
<me...@takas.lt> schreibt:

Quote
>This dll (myfile.dll (dcu)) is just 18kb.

In this case you should add the unit to your project, with *no* overhead to
unpack, and possibly further size reduction due to the omission of unused code
and data.

DoDi

Re:How to put(pack) exe(dll) file in exe?


On 30 May 2000 00:44:28 GMT, vb...@aol.com (VBDis) wrote:

Quote
>In this case you should add the unit to your project, with *no* overhead to
>unpack, and possibly further size reduction due to the omission of unused code
>and data.

>DoDi

True - but I reckon that he does not have the full source.

Re:How to put(pack) exe(dll) file in exe?


 Thank you Jerry. You sollution was pretty good however it do not fit my
needs. My dll(dcu) file cannot be included in exe because it acts as windows
hook so it must be external. Also dll can't be added to the end of exe
because I'll want to comress this exe with exe compression utilities like
NeoLight or similar.

One guy at borland.public.delphi suggested this sollution. I am going to try
this:
What do you think?

Quote
> Use resources.
> Open notepad, make a file in you project dir named bla.rc which contains:

> BLA RCDATA "Blabla.exe"

> Now open a command-prompt, type:

> cd\C:\Progra~1\Borland\Delphi5\Bin\
> BRCC32.EXE -foBla.res Bla.rc

> You now have a Bla.res file...

> In your project, put after {$R *.DFM} this:

> {$R BLA.RES}

> Now, somewhere:

> var x: TResourceStream;
> begin
> x := TResourceStream.Create(HINSTANCE, 'BLA',RT_RCDATA);
> x.SaveToFile('Blabla.exe');
> x.Free;
> end;

> Now you can use your embedded file, using LoadLibrary for DLL's. Make sure
> you delete it after you're done, and save to a windows temp directory. You
> can use an API to get that location.
> You might also want to use an exepacker like UPX.

> --
> WinAmp currently playing Nine Inch Nails - I Want To {*word*30} You Like An
Animal
> Generated by SigAmp plugin by Matthijs Laan

(creepingdeat...@metallica.com)

Quote

Sincerely,
Mezer

Quote
J French <je...@iss.u-net.com> wrote in message

news:39313ff7.84817@news.u-net.com...

- Show quoted text -

Quote
> I assume that what you want to do is to distribute just one file.

> It appears that you have a 'favourite' DLL that you want to distribute
> with the EXE.

> You could look at making a self extracting system - I would check out
> the PKZIP and WINZIP sites for that - but I suspect that you are not
> really after setup systems.

> The easiest thing is NOT to have a DLL - just include the code in your
> project.

> I assume that you have considered this - and that you do not have the
> source for the DLL - yet you talk about the DCU - and if you have the
> DCU you should be able to include it in your project.

> However if you really must do this :

> -  Append the DLL to the end of your EXE
>  - Write code for extracting it - ie: the last 16 bytes of the
>    jiggered EXE contains the offset of the DLL and its length
>    + of course a signature.
> - Dynamically load the DLL
>   see: Loadlibrary, GetProcessAdress, FreeLibrary

> A sledgehammer to crack a hazelnut - but it'll work.

> On Sun, 28 May 2000 14:23:10 +0200, "Mindaugas Ezerskis"
> <me...@takas.lt> wrote:

> >Hello friends,

> >Will you tell me how to put exe(dll) file in exe. I need to do something
> >like self extract file i.e. add some external data to my project. For
> >example
> >when I run my 'single.exe' file I need that it would extract dll file
from
> >itself
> >and run it. This dll (myfile.dll (dcu)) is just 18kb.

> >Please help me.

> >I tried TRessourceStore component by Alexandre GUILLIEN, but it doesn't
work
> >on D5 :(

> >Thank you in advance,

> >Mezer
> >E-mail: me...@takas.lt

Re:How to put(pack) exe(dll) file in exe?


Im Artikel <39339b6a.11435...@news.u-net.com>, je...@iss.u-net.com (J French)
schreibt:

Quote
>True - but I reckon that he does not have the full source.

The DCU file is sufficient, as long as it's compiled for the same Delphi
version.

You also must not have the sources for the system units, in order to use the
units in any of your programs.

DoDi

Other Threads