the shared segment is removed from the QuickView.
Is there any differences between C or C++?
Is there any possible project setting/command line directive which will
override
this pragma directive?
References KnowledgeBase :
"How to Share Data Between Different Mappings of a DLL" (Q125677).
"Specifying Shared and Nonshared Data in a DLL" (Q100634).
"How to Specify Shared and Nonshared Data in a DLL" (Q89817).
"Sharing All Data in a DLL" (Q109619).
Any help would be appreciated,
John
"John C. Liss" wrote:
>
> I'm trying to share a variable located in a shared DLL but when
> accessing
> from two different processes they both appear to maintain there own
> memory locations. [snip]
Do you mean that the addresses are different or that the values of the
variables are different?
The addresses may well be different in different processes.
Looking at the KnowledgeBase articles I listed, it appears that sharing
variables in a DLL is very straight forward simply declaring the desired
shared variables within the shared data segment. And as I mentioned
the data segment does show up as shared, I guess for some reason the
variables I declared don't get included in this segment.
As a workaround I could use a file mapping solution but this shared
data segment would prove beneficial in this project and I'm sure others
in the future. And again, any thought are still appreciated!!
Thanks again,
John
"John C. Liss" wrote:
>
> The actual values are different after incrementing in one process or the
> other.
> And yes the addresses are also different, this is why the values are
> different
> after either processes updates it. They do start at the same value
> "int nNumInQueue = 4".
>
> Looking at the KnowledgeBase articles I listed, it appears that sharing
> variables in a DLL is very straight forward simply declaring the desired
> shared variables within the shared data segment. And as I mentioned
> the data segment does show up as shared, I guess for some reason the
> variables I declared don't get included in this segment.
>
> As a workaround I could use a file mapping solution but this shared
> data segment would prove beneficial in this project and I'm sure others
> in the future. And again, any thought are still appreciated!!
One suggestion is to base your dll at some odd address to avoid
relocations. Neither softice or VC6 debugger is easy to use on dlls that
have different addresses in different process spaces
DLL's are mapped in arbitrary order into the address space of a process.
This means the logical address of variables and functions can be
different
between two processes loading the same DLL.
The mapping of shared sections is done through the paging mechanism,
i.e.
on the layer of physical addresses.