🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2455

Can DLLs be used as shared libraries?

#2455
From: Bill Blackwell
Date: Mon, 06 May 1991 17:38
42 lines
2396 bytes
I have a question about using DLLs that I hope someone on the net can 
answer.  Here goes. 
 
I am porting a large Unix-based application library to Windows 3.0.  
My first plan was to build this library as a DLL, to take advantage of 
the ability of DLLs to share code segments among multiple clients.  
However, I soon realized that DLLs are not like Unix shared libraries 
which assume a separate data address space for each client; instead, 
DLLs provide their own data segment which is shared among clients.  
The DLL uses the client stack but its own data segment.  [This struck 
me as strange.]
 
After reading Petzold, I learned that there is some prolog code ahead 
of each exported far library function compiled with -Gw, which causes 
DS to be set to the value of the DLL's data segment upon entry to the 
function.  I thought, Aha - I will compile without -Gw, causing no 
prolog code to be generated, and DS will continue to address the 
client's data segment when it enters the DLL. 
 
My question(s) are: If this even works, what will it break?  Does 
Windows overwrite the DLL function prolog code even when there is no 
prolog code compiled?  Would putting the code in fixed segments remove 
the possibility of Windows modifying the prolog?  Is the "inc bp ... 
dec bp" part of the prolog/epilog code important to Windows?  Does 
Windows itself munge DS between the call to the DLL function and 
execution of the prolog code? 
 
Does specifying DATA NONE in the DLL .def file do the trick?

Has anybody out there tried this or another way of getting more 
traditional shared library behavior out of DLLs? 
 
Any help would be greatly appreciated. 
 
---------------------------------------------------------------
Bill Blackwell				email: wcb@gradient.com
Gradient Technologies, Inc.		voice: (508) 562-2882
577 Main St., Suite 4			  FAX: (508) 562-3549
Hudson, MA 01749

  "Although the Moon is smaller than the Earth, it is farther away."
Technical Details
Message-ID: <288@gradient.gradient.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!gradient!wcb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!gradient!wcb
From: wcb@gradient.gradient.com (Bill Blackwell)
Newsgroups: comp.windows.ms.programmer
Subject: Can DLLs be used as shared libraries?
Keywords: DLL
Message-ID: <288@gradient.gradient.com>
Date: 6 May 91 17:38:58 GMT
Organization: Gradient Technologies Inc., Hudson MA
Lines: 42