comp.lang.ada
 help / color / mirror / Atom feed
* Re: GNAT, Windows, DLLs
  2003-05-28 18:05 GNAT, Windows, DLLs Alfred Hilscher
@ 2003-05-28 17:39 ` Robert A Duff
  2003-05-28 18:14   ` Jano
  0 siblings, 1 reply; 5+ messages in thread
From: Robert A Duff @ 2003-05-28 17:39 UTC (permalink / raw)


Alfred Hilscher <Spam@alfred-hilscher.de> writes:

> I have the follwing problem: In gnat_ug it is said, that the code has to
> call _ada_initialize first and _ada_finalize at last. But - my DLL shall
> replace an existing third party DLL. So the applications using this DLL
> are not Ada-aware, and there is no way to tell them "hey the DLL is
> replaced, you have to call now an initialize-procedure first, and you
> must call this finalize-procedure at the end". So is there a way to make
> this initializing/finalizing transparent?

I don't know.  Surely there's some way to attach initialization code to
a DLL?

>... What can happen, if one/both
> of them are _not_ called?

All of your library-level initialization and finalization code will be
skipped.

- Bob




^ permalink raw reply	[flat|nested] 5+ messages in thread

* GNAT, Windows, DLLs
@ 2003-05-28 18:05 Alfred Hilscher
  2003-05-28 17:39 ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: Alfred Hilscher @ 2003-05-28 18:05 UTC (permalink / raw)


Hi,

does anyone have experience in writing Windows-DLLs with GNAT?

I have the follwing problem: In gnat_ug it is said, that the code has to
call _ada_initialize first and _ada_finalize at last. But - my DLL shall
replace an existing third party DLL. So the applications using this DLL
are not Ada-aware, and there is no way to tell them "hey the DLL is
replaced, you have to call now an initialize-procedure first, and you
must call this finalize-procedure at the end". So is there a way to make
this initializing/finalizing transparent? What can happen, if one/both
of them are _not_ called?

Regards,
Alfred

-----------------------------------------------------
To send me mail, please replace "Spam" by "Jedermann"
-----------------------------------------------------



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT, Windows, DLLs
  2003-05-28 17:39 ` Robert A Duff
@ 2003-05-28 18:14   ` Jano
  2003-05-29  9:17     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 5+ messages in thread
From: Jano @ 2003-05-28 18:14 UTC (permalink / raw)


Robert A Duff dice...
> Alfred Hilscher <Spam@alfred-hilscher.de> writes:
> 
> > I have the follwing problem: In gnat_ug it is said, that the code has to
> > call _ada_initialize first and _ada_finalize at last. But - my DLL shall
> > replace an existing third party DLL. So the applications using this DLL
> > are not Ada-aware, and there is no way to tell them "hey the DLL is
> > replaced, you have to call now an initialize-procedure first, and you
> > must call this finalize-procedure at the end". So is there a way to make
> > this initializing/finalizing transparent?
> 
> I don't know.  Surely there's some way to attach initialization code to
> a DLL?

I don't remember the details, but I've done it in the past. DLLs have 
such initialization/finalization entry points, called if present 
automatically by the OS, and there is the best place to place these 
procedure calls.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT, Windows, DLLs
  2003-05-28 18:14   ` Jano
@ 2003-05-29  9:17     ` Dmitry A. Kazakov
  2003-05-29 13:10       ` Alfred Hilscher
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry A. Kazakov @ 2003-05-29  9:17 UTC (permalink / raw)


Jano wrote:

> Robert A Duff dice...
>> Alfred Hilscher <Spam@alfred-hilscher.de> writes:
>> 
>> > I have the follwing problem: In gnat_ug it is said, that the code has
>> > to call _ada_initialize first and _ada_finalize at last. But - my DLL
>> > shall replace an existing third party DLL. So the applications using
>> > this DLL are not Ada-aware, and there is no way to tell them "hey the
>> > DLL is replaced, you have to call now an initialize-procedure first,
>> > and you must call this finalize-procedure at the end". So is there a
>> > way to make this initializing/finalizing transparent?
>> 
>> I don't know.  Surely there's some way to attach initialization code to
>> a DLL?
> 
> I don't remember the details, but I've done it in the past. DLLs have
> such initialization/finalization entry points, called if present
> automatically by the OS, and there is the best place to place these
> procedure calls.

The word "DLL" lets me suppose that it is about Windows. If so, then DllMain 
procedure is called each time a process loads/unloads DLL. It has a 
parameter to indicate the action (see MSDN DllMain).

But beware:

1. DllMain is called within a critical section. Many system operations will 
hang, no other threads running while you are in.

2. DllMain is not called when process gets aborted. It is one of (many) 
reasons why the button "Reset" is so useful under Windows.

Enjoy Windows programming!

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT, Windows, DLLs
  2003-05-29  9:17     ` Dmitry A. Kazakov
@ 2003-05-29 13:10       ` Alfred Hilscher
  0 siblings, 0 replies; 5+ messages in thread
From: Alfred Hilscher @ 2003-05-29 13:10 UTC (permalink / raw)


Many thanks, this may help me.


"Dmitry A. Kazakov" schrieb:
> 
> Jano wrote:
> 
> > Robert A Duff dice...
> >> Alfred Hilscher <Spam@alfred-hilscher.de> writes:
> >>
> >> > I have the follwing problem: In gnat_ug it is said, that the code has
> >> > to call _ada_initialize first and _ada_finalize at last. But - my DLL
> >> > shall replace an existing third party DLL. So the applications using
> >> > this DLL are not Ada-aware, and there is no way to tell them "hey the
> >> > DLL is replaced, you have to call now an initialize-procedure first,
> >> > and you must call this finalize-procedure at the end". So is there a
> >> > way to make this initializing/finalizing transparent?
> >>
> >> I don't know.  Surely there's some way to attach initialization code to
> >> a DLL?
> >
> > I don't remember the details, but I've done it in the past. DLLs have
> > such initialization/finalization entry points, called if present
> > automatically by the OS, and there is the best place to place these
> > procedure calls.
> 
> The word "DLL" lets me suppose that it is about Windows. If so, then DllMain
> procedure is called each time a process loads/unloads DLL. It has a
> parameter to indicate the action (see MSDN DllMain).
> 
> But beware:
> 
> 1. DllMain is called within a critical section. Many system operations will
> hang, no other threads running while you are in.
> 
> 2. DllMain is not called when process gets aborted. It is one of (many)
> reasons why the button "Reset" is so useful under Windows.
> 
> Enjoy Windows programming!
> 
> --
> Regards,
> Dmitry A. Kazakov
> www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-29 13:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-28 18:05 GNAT, Windows, DLLs Alfred Hilscher
2003-05-28 17:39 ` Robert A Duff
2003-05-28 18:14   ` Jano
2003-05-29  9:17     ` Dmitry A. Kazakov
2003-05-29 13:10       ` Alfred Hilscher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox