I'm not sure how clear the title of the question is. Here's what I'm trying to do:
I have a process, which uses DLL libraries as plugins. Those libraries use functions, synchronized with a critical section object . I want all DLL functions to be synchronized with the same critical section object. I thought about the following: the first DLL will initialize a critical section object, and other DLLs will use it too, instead of initializing a new one. But how can I get the pointer to the critical section object of the first DLL?
One solution I thought of is using a Named Shared Memory, and placing the pointer to the critical section object there. It will work, but it feels like shooting a fly with a bazooka. Is there a simpler and more idiomatic way to create a named object with a retrievable pointer?
(Create/Open)Mutex()specifying the same name, and they will each get their own local handle to the same mutex object in the kernel, and thus can sync with each other. You can't do that with a critical section, you have to pass a pointer around instead.