troubleshooting Question

Sharing a pointer in a DLL

Avatar of divyaveda
divyaveda asked on
9 Comments1 Solution381 ViewsLast Modified:

This problem is a bit similar to the Shared memory problem under C Programming topic. But I could not use the solution suggested there in this problem. The problem is as follows:

I have a DLL(DLL1) that is used by an application and another DLL (DLL2). There are certain variables in
the DLL1 that are shared by the other 2. This shared segment is placed under pragma directive as

#pragma data_seg("APP_Shared")
BOOL gbLinkUp = FALSE;
APP_Handle ghAppHandle = NULL;
DWORD gdwEventId = 0;  and so on
#pragma data_seg()

One of these shared variables happens to be a pointer(AppHandle) that is allocated by a proprietary library accessed by the DLL. This obviously is
causing the problem when one application updates this variable and the other tries to use it as the contents of the pointer are messed up. My query is "How do we share a pointer between 2 applications using a common

Is there some other alternative that I should be opting given that I cannot change the Proprietary library allocating the pointer. For eg: store the pointer separately in App and DLL2 and pass it to DLL1 wherever it's used instead of storing in DLL1 as shared global. Please Suggest

- Divya


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros