TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollard
from: Herbert Rosenau
date: 1998-09-30 13:16:42
subject: How do DLLs load and unload ?

Hi Jonathan,

 JdBP> If you don't know what the problem is here, then I suggest that you read
 JdBP> a bit about x86 programming.  A return instruction cannot transfer from a
 JdBP> lower privilege ring to a higher privilege ring.  Calling ring 3 from
 JdBP> ring 0 necessitates that some magic be performed when the ring 3 code
 JdBP> returns.  Usually this involves some sort of trampoline.

The loader is an process as its own. If you try to load any program or DLL
you'll go though the call gate into ring 0. The process is halted then.
This is done implicit by the sheduler (called from the kernel in ring 0 if
needed).

ring 3			ring 0

startup:
register signalhandler
     call gate  --->    kernel: save address of signal procedure
                                to coninue process if a signal occures
return from call gate <----            
:
:
:
exec..() or
spawn..() or
DosLoadModule()
     call gate  ---->   sheduler: hold the process
                        loader: try to load
                        if no error:
sleeping                   sheduler: continue process
(other processes           sheduler: activate new process (if necessary)
 my run during          else
 idle time of ring 0)      get error code from loader and
                           transfer to process the call cames from
return from call gate  <---- release process
:
:
:

			Child process dies (normal or abnormal)

   call gate   <--------------- call parents signal handler
      save stack address
      set new stack
      call users signal handler
      restore stack address
      return --------->

The kernel has its own transation table to have access to the full 4GB
addressroom. It will load and free real memory on demand, copy data from
one location to another independant of the translation tables of processes
on ring 3.

The memory manager (functions inside the kernel) syncronises the
translation tables of ring 0, ring 2 and all processes on ring 3 to point
to the same physical address - but with different rights - if needed.

All communication between different processes and outside shared memory
goes over the call gate. 


Tschau/Bye

Herbert


--- Sqed/32 1.14/development  1782:
* Origin: Lieber den Magen verrenkt als dem Wirt was geschenkt. (2:2476/493)
SEEN-BY: 396/1 632/0 371 633/210 260 267 270 371 635/506 728 639/252 670/218
@PATH: 2476/493 480 2410/200 2432/200 2433/1200 225 270/101 396/1 633/260
@PATH: 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™.