Re: Critical section shared betwen dll and main program




"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]




.



Relevant Pages

  • Re: Critical section shared betwen dll and main program
    ... I am discussing the case of dynamic DLL ... loading and passing PCRITICAL_SECTION between old version of DLL ... and an executable which was build in newer environment. ... without passing a pointer to the kernel32.dll? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to pass object from dll to exe? error <98>
    ... But you didn't say you were passing an object, ... std exe maininjects dll into AutoCad process space (for speed reasons ... When an EXE launches, the Windows loader, loads the program into its ... Set MyDll = oAcadApp.GetInterfaceObject ...
    (microsoft.public.vb.general.discussion)
  • Re: new - delete issue
    ... EXE calls a DLL exported function that return a struct pointer. ... The EXE call another exported function that delete all pointers in that list. ...
    (microsoft.public.vc.mfc)
  • Re: Notify multiple instances of my COM dll to take an action
    ... my dll default interface is derived from IUnknown and the exe ... passing the pointer into the exe but the method call on that pointer ...
    (microsoft.public.vc.atl)
  • Re: Structure containing string across DLL boundary
    ... Exe and DLL both built with static RTL. ... Debug build has no issues. ... The DLL allocates the structure with the embedded string. ... The function in the exe is invoked with a pointer to the structure and then ...
    (microsoft.public.vc.stl)