[comp.windows.ms.programmer] Can DLLs be used as shared libraries?

wcb@gradient.gradient.com (Bill Blackwell) (05/07/91)

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."

barryf@aix01.aix.rpi.edu (Barry B. Floyd) (05/07/91)

Can someone post a list of references to books and articles on DLLs
and their value. Petzold's book was recently mentioned, any others?
 
In general, DLLs seem to be an invaluable tool for developing large
applications (re)using routines. Apparently, given the routine's
calling conventions, one could use DLLs from third-party developers.
Is this the case? What are the restrictions and "gotcha's"?
 
barry


-- 
+--------------------------------------------------------------------+ 
| Barry B. Floyd                   \\\       barry_floyd@mts.rpi.edu |
| Manager Information Systems - HR    \\\          usere9w9@rpitsmts |
+-Rensselaer Polytechnic Institute--------------------troy, ny 12180-+