Re: Critical section shared betwen dll and main program
- From: "Volodymyr Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx>
- Date: Tue, 8 Jan 2008 09:35:28 +0100
"Ben Voigt [C++ MVP]" wrote:
Or have you a way to call
InitializeCriticalSection/EnterCriticalSection/LeaveCriticalSection
without
passing a pointer to the kernel32.dll?
In this case, usually the executable is statically linked against
kernel32.lib. I am discussing the case of dynamic (user specific) DLL
loading and passing PCRITICAL_SECTION between (possibly) old version of DLL
and an executable which was build in newer environment. The key factor here
is that old DLL was not rebuilt.
"Ben Voigt [C++ MVP]" wrote:
Not a problem, because CRITICAL_SECTION in each module must match the
Win32 API definition, in which case they are certainly compatible with
each other.
Agree. But if structure values change, both modules should be recompiled in
a newer environment (in case if pointers to structures are exposed for
external usage), if this is not done, the bug case appears.
--
Volodymyr
NG tips:
http://msmvps.com/blogs/v_scherbina/pages/microsoft-newsgroups-tips.aspx
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:uYYkCSYUIHA.5132@xxxxxxxxxxxxxxxxxxxxxxx
"Volodymyr Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx> wrote in message
news:eunYTAUUIHA.5496@xxxxxxxxxxxxxxxxxxxxxxx
Actually, I would not suggest to pass pointer to any structure between
different components like EXE and DLL.
I guess you aren't using Win32 then. Or have you a way to call
InitializeCriticalSection/EnterCriticalSection/LeaveCriticalSection
without passing a pointer to the kernel32.dll?
Because there is a theoretical chance of incompatible ABE (Application
Binary Environment) bug. Even taking into account, that CRITICAL_SECTION
was not changed since 9x, there always exists a possibility that it might
change, and the code will have a very hidden and weird bug, when DLL uses
old version of CRITICAL_SECTION and passes a pointer to it which is used
in EXE, which was compiled in a newer environment, with another
CRITICAL_SECTION. This of course is a weird situation, but one should
keep in mind such kind of possibility.
Not a problem, because CRITICAL_SECTION in each module must match the
Win32 API definition, in which case they are certainly compatible with
each other.
--
VolodymyrNG tips:
http://msmvps.com/blogs/v_scherbina/pages/microsoft-newsgroups-tips.aspx
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:uSXppnyTIHA.5264@xxxxxxxxxxxxxxxxxxxxxxx
"Mandi" <mandi@xxxxxxxxxxxx> wrote in message
news:%23nauFfyTIHA.4476@xxxxxxxxxxxxxxxxxxxxxxx
I use critical section in my dll. Now I want to refer to it in my Main
executable?
Is there a way to do it?
There is no problem with passing its address between exe and DLL.
--
Scott McPhillips [VC++ MVP]
.
- Follow-Ups:
- Re: Critical section shared betwen dll and main program
- From: Ben Voigt [C++ MVP]
- Re: Critical section shared betwen dll and main program
- References:
- Critical section shared betwen dll and main program
- From: Mandi
- Re: Critical section shared betwen dll and main program
- From: Scott McPhillips [MVP]
- Re: Critical section shared betwen dll and main program
- From: Volodymyr Shcherbyna
- Re: Critical section shared betwen dll and main program
- From: Ben Voigt [C++ MVP]
- Critical section shared betwen dll and main program
- Prev by Date: Re: How to troubleshoot bugchecks on my own?
- Next by Date: Re: How to format disk by application
- Previous by thread: Re: Critical section shared betwen dll and main program
- Next by thread: Re: Critical section shared betwen dll and main program
- Index(es):
Relevant Pages
|