TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollar
from: Denis Tonn
date: 1998-09-30 11:17:02
subject: How do DLLs load and unl

Original from  Jonathan de Boyne Pollard  to Denis Tonn on 09-27-1998
Original Subject: How do DLLs load and unlo

                         ---------------------------------------

  DT> The loader will automaticly do a DosLoadModule (and fixup) for any 
  DT> modules referenced in the header of the executable. I call this "load
  DT> time" linking vs "run time" linking done with an explicit
  DT> DosLoadModule and DosQueryProcAddr from within the app.  I don't like
  DT> to use the terms "static" or "dynamic" linking
here, they can have
  DT> slightly different connotations in the context of a  compiler and
  DT> it's run time libraries.. 
 
JP> Me neither.
JP> 
JP> From what I can gather, by the way, only the module for the 
JP> main EXE and for DOSCALL1 are loaded by the parent process. 
JP>  All other referenced DLLs are loaded by a special user-
JP> mode function in DOSCALL1 that is where the first thread in 
JP> the process first starts executing.  

 That's pretty close to my understanding too.. 

JP> But this brings up a further question: What happens when a DLL cannot be 
JP> found ?  This should be, and *is*, reported in the pObjName 
JP> buffer for DosExecPgm.  I can see how this would be easy to 
JP> implement if it were the *parent* process that resolved all 
JP> of the import module references and built the initial user 
JP> address space of the child.  But how does this happen if 
JP> the loading is occurring as part of the execution of user-
JP> mode code in the child process ?  Don't tell me that 
JP> there's a back door in OS/2 Warp for user-mode code in one 
JP> process to write to the user address space of another 
JP> process!

 The loader is part of the kernel code, even though it operates in the
context of the process (and is called on a thread of the process). 
Being part of the kernel code, it can switch contexts if required to 
access the parent address space...

 Keep in mind that DosExecPgm is a kernel API, it does enter ring 0 
(through Doscall1) and can access all processes. The information is 
returned the same way.. 
 Until the loader has resolved all the "load time" linking, the parent
process is in a kind of "childwait", regardless of what is coded on 
DosExecPgm.. Once the child is loaded, the parent does not receive 
notifications for explicit DosLoadModule call done in the child. 

 


   Denis       

 All opinions are my very own, IBM has no claim upon them
. 
. 
.
 

 



--- Maximus/2 3.01
* Origin: T-Board - (604) 277-4574 (1:153/908)
SEEN-BY: 396/1 632/0 371 633/210 260 267 270 371 635/506 728 639/252 670/218
@PATH: 153/908 8086 800 140/1 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.