PRB: Problem with Shared Data Sections in DLLs.

Article translations Article translations
Article ID: 147136 - View products that this article applies to.
This article was previously published under Q147136
Expand all | Collapse all


Because Win32 uses path and file names to identify loaded modules, running an application that uses a DLL with a shared data section may not work correctly if the DLL will be loaded using different paths.


A memory-mapped file should be used to share data between processes.


This behavior is by design.


In Win32, module names include the path and file name, unlike 16-bit Windows where all modules are identified with up to eight character names.

When you use a DLL with a shared data section, the path\file name convention of identifying module names can cause shared sections to not be shared. When the DLL is loaded a second time using a different path, the operating system treats each instance of the DLL as a separate DLL. Because the DLL is loaded twice as separate DLLs, no sections are shared, not even code sections.

For example, when you map network drives E: and F: to the same share and from each drive run an instance of an application that shares data by using a shared data section in a DLL, the DLL is loaded separately with module names like E:\path\filename and F:\path\filename. Each DLL will have its own shared data section and therefore the processes will each see a different copy of the data. In fact, shared data sections are implemented as memory mapped files, so in this case, each instance of the DLL sets up its own memory mapped file for a shared data section.

This problem can be diagnosed by putting a call to GetModuleFileName in the DLL and examining the library names of each instance of the DLL. If the names are different, shared sections will not work for the processes calling them. The reason a file mapping is immune to the different path names is because each process accesses a file mapping by name. File mapping names are constant and independent of file paths.


Article ID: 147136 - Last Review: July 11, 2005 - Revision: 2.1
  • Microsoft Platform Software Development Kit-January 2000 Edition, when used with:
    • Microsoft Windows NT Server 3.5
    • Microsoft Windows NT Server 3.51
    • Microsoft Windows NT Workstation 3.5
    • Microsoft Windows NT Workstation 3.51
    • Microsoft Windows 95

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from