Directory UMM :Networking Manual:computer_network_books:
COM
A Slideshow of Epic Proportions
Sean Baxter
http://www.eburg.com/~baxters/
What is COM?
• A standard for interoperable software
• A runtime library providing low-level or
hard-to-implement functionality
• A competitive, capitalist marketplace for
selling functionality to application
developers
• An endless source of healthy obfuscation
That Last Slide Was Pulled From Booboo’s
Rear End. What is COM, Really?
• A sacred covenant held by the world’s best
developers. All software functionality is
encapsulated through a COM class (coclass)
and exposed through COM interfaces
Mooooo
Blah Blah Blah
Blah Blah Blah
Blah Blah Blah
Booboo
Interface and Coclass Fundamentals
• An interface is a group of methods
• A coclass is a group of interfaces
• All coclasses implement the IUnknown
interface
• All other interfaces derive IUnknown
• Lollipop diagrams describe coclasses
IU n k n o w n
IF o o
IB a r
O in k
About Interfaces
• The client communicates with the server through
interface pointers (think base class pointers)
• Methods implemented by the coclass are invoked
through interface pointers
• Interface pointers are acquired through IUnknown
• Because all interfaces derive IUnknown, any
interface pointer on an object can be acquired
through any other interface pointer on the object
• The method to acquire an interface pointer is
IUnknown::QueryInterface (think dynamic_cast)
More About Interfaces
• Interfaces are equivalent to C++ abstract
base classes
• Because there is no standard thunk
mechanism, interfaces do not support
multiple inheritance
• Two IUnknown pointers point to the same
object if their values are equal
• “Dispatch interfaces” are special case
interfaces allowed by the COM
Specification
Interfaces and Virtual Tables
• An interface pointer points to the
corresponding slice of a COM object
• The first 4 bytes of this slice comprise a
pointer to the interface’s virtual table
• Each slot in this virtual table is the address
of an interface method
• A method implementation may be
referenced by more than one vtbl entry
IU n k n o w n
p Q u e ry In te r fa c e
pAddR ef
m _ p U n k V tb l
IF o o
IB a r
Q u e ry In te rfa c e ()
p R e le a s e
A d d R e f()
m _ p F o o V tb l
m _ p B a rV tb l
R e le a s e ( )
p Q u e r y In te r fa c e
pAddR ef
O in k
p R e le a s e
pFooFunc1
pFooFunc2
F o o F u n c 1 ()
pFooFunc3
F o o F u n c 2 ()
p Q u e r y In te r fa c e
F o o F u n c 3 ()
pAddR ef
p R e le a s e
p B a rF u n c 1
B a rF u n c 1 ()
p B a rF u n c 2
p B a rF u n c 3
B a rF u n c 2 ()
B a rF u n c 3 ()
Interface Method Indirection
Reference Counting
• To regulate destruction of objects, COM
requires that all coclasses implement a
reference counter
• COM objects can have their methods
invoked from other threads, processes, and
even machines. Reference Counting
eliminates a number of problems associated
with synchronization
Reference Counting Rules
• Each object is given a reference count of 1 upon
instantiation
• IUnknown::AddRef increments the reference
count
• A successful IUnknown::QueryInterface call
increments the reference count
• IUnknown::Release decrements the reference
count
• When the reference count is decremented to zero,
the object destroys itself
So Why All These Interface and
Reference Counting Formalities?
• One of the most amazing features of COM objects
is location transparency: COM marshals interfaces
between processes and remote computers
• Reference counting guarantees that a client cannot
prematurely destroy a shared object
• COM is language transparent: unsophisticated
languages like Visual Basic, VBA, J-Script, and
VB-Script would not otherwise be able to properly
delete objects
Speaking of Location Transparency...
• COM objects (servers) can be delivered in
two module types: EXEs or DLLs (aka
OCXs)
• EXEs cannot run in-process
• DLLs can only run in-process
• A “surrogate” EXE can load a DLL to make
it an out-of-process server
p Q u e r y In te r fa c e
IU n k n o w n
pAddRef
p R e le a s e
m _ p U n k V tb l
IF o o
Q u e ry In te rfa c e ()
m _ p F o o V tb l
A d d R e f()
R e le a s e ( )
p Q u e r y In te r fa c e
pAddRef
Foo
p R e le a s e
pShake
S h a k e ()
p R a ttle
p R o ll
R a t t le ( )
R o ll( )
An In-process Server
(same apartment)
IU n k n o w n
IU n k n o w n
STA
IF o o
IB a r
IF o o
O in k _ P r o x y
IB a r
IU n k n o w n
O in k _ S t u b
IF o o
C lie n t C o d e
C O M In v is ib le W in d o w
IB a r
STA
In-process Server
(different apartment)
O in k
IU n k n o w n
P ro c e s s
B o u n d a ry
m _ p U n k V tb l
IF o o
m _ p F o o V tb l
F o o _ P ro x y
Q u e ry In te rfa c e _ S tu b ()
Q u e ry In te rfa c e _ P ro x y ()
A d d R e f_ P ro x y ()
IU n k n o w n
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
R e le a s e _ P r o x y ( )
p R e le a s e _ P r o x y
m _ p U n k V tb l
IF o o
S h a k e _ P ro x y ()
S h a k e _ S tu b ()
R a ttle _ P r o x y ( )
R a ttle _ S tu b ( )
R o ll_ P r o x y ( )
R o ll_ S t u b ( )
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
p R e le a s e _ P r o x y
p S h a k e _ P ro x y
p R a ttle _ P ro x y
p R o ll_ P r o x y
IP C
Local Server
m _ p F o o V tb l
Foo
IU n k n o w n
m _ p U n k V tb l
IF o o
m _ p F o o V tb l
F o o _ P ro x y
C lie n t
M a c h in e
Q u e ry In te rfa c e _ P ro x y ()
Q u e ry In te rfa c e _ S tu b ()
A d d R e f_ P ro x y ()
IU n k n o w n
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
R e le a s e _ P r o x y ( )
p R e le a s e _ P r o x y
m _ p U n k V tb l
M S -R P C
IF o o
S h a k e _ P ro x y ()
S h a k e _ S tu b ()
R a ttle _ P r o x y ( )
R a ttle _ S tu b ( )
R o ll_ P r o x y ( )
R o ll_ S t u b ( )
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
p R e le a s e _ P r o x y
p S h a k e _ P ro x y
p R a ttle _ P r o x y
p R o ll_ P r o x y
Remote Server
m _ p F o o V tb l
Foo
S e rv e r
M a c h in e
Things To Note
• All interface method calls are synchronous; a
remote call to a New York server must complete its
round-trip before the client can continue execution
• Asynchronous services are available through
Microsoft Message Queue (MSMQ) and
ICallFactory (Windows 2000)
• Encryption, authentication, and impersonation
services are available with remote server
connections (at least on NT)
Confused?
Where Am I?
The Guy In The Back Row
COM Owns You
So what does all this nonsense about location
transparency and reference counting have to
do with anything?
Ever heard of OLE? Ever heard of ActiveX?
You may suspect that these have something to
do with COM...
WRONG!
They are COM.
All will soon be clear
MS Marketecture:
Common Misperceptions
• OLE is a system of linking and embedding
data into a document (hence the acronym
“Object Link and Embedding”)
• ActiveX, like Java, is a system for building
web page applets
• Microsoft Transaction Server (MTS) processes
business data from the internet
Faery Tales!
The Journey of COM
• Dynamic Data Exchange (DDE) was introduced
while the Earth was still cooling.
• DDE was unsavory. MS unveils OLE 1.0 after the
villagers riot
• OLE 1.0 is a big success but hard to program. MS
unveils OLE 2.0 for Windows 3.1: COM is born
(it’s 16bit)
• Windows NT 3.5 is blessed with OLE (look ma no version number!) and true 32bit COM. OLE is
now “Olè,” which is synonymous with COM
The Journey of COM (II)
• To celebrate Windows 95, MS blesses COM with
the apartment model
• 1996 sees Windows NT 4. DCOM brings network
and multithreading enhancements to COM
• Microsoft Transaction Server (MTS) becomes
available for NT Server. This doesn’t process web
business data. It’s a COM runtime environment
which allows components to run more efficiently
(solving scalability difficulties often faced in
processing business data)
The Journey of COM (III)
• OLE-DB provides consistency when accessing data
from a variety of providers
• MS makes web browsers a priority (IE3) and
simultaneously coins the term “ActiveX,” adding to
the COM marketecture. Like OLE, ActiveX is a
synonym for COM.
• Microsoft Message Queue (MSMQ) delivers
asynchronous (and vastly more reliable) method calls
• Visual C++ 5.0 ships with ATL 2.1. OLE Control
creation has never been so easy!
The Journey of COM (IV)
• Windows 2000 ships in 2004. Microsoft introduces
COM+ acronym: COM+ is simply COM on Win2k
• Win2k includes many COM updates including a
third threading model (the Neutral Threaded
Apartment) and integration of MTS into the COM
runtimes
• COM+ 2.0 delivers legendary COM virtual
machine
• Windows NT 6 device contexts replaced by
DirectDraw surfaces. Classic OLE Control
interfaces deprecated for new, ultra-spiffy interfaces
COMprehension
• COM is a set of many, many technologies.
• COM is really Microsoft’s software
engineering strategy
• Computer people (you) are betting the bank
on Microsoft
• Microsoft is betting the bank on COM
• COM Owns You
COM Defined
A single sentence can’t define COM,
because COM is such a monumental and
omnipresent set of technologies.
So what is a COM technology? Any
software creation that leverages interfaces
and coclasses, as described in the earlier
slides.
COM in Everyday Life
The Month View is from the Microsoft Windows Common
Controls-2 6.0 controls library
Property Pages
How does Visual Basic know which properties to put in the box?
Events
How does Visual Basic know which events the control exposes?
What is a VB Control?
What Functionality Does It Expose?
Properties and Methods
The Secret of Property Pages
Property Page Coclasses
Property Pages Abound!
Standard Interfaces
• Programming sucks. Best to fall back on
platform-provided functionality
• A container/client can interact with any
server/control simply by implementing the
required site interfaces
• Application developers who license your
components are already familiar with the
interfaces
• Standard interfaces can use the Microsoftprovided proxy/stubs
What Are Some COM-Based
Technologies?
•
•
•
•
•
•
•
•
•
OLE Controls
OLE-DB
ADO
DAO
DirectX
TAPI 3.0
Exchange Server
Exchange Client
Active Scripting
•
•
•
•
•
•
•
•
•
CDO 2.0
MAPI
SQL-DMO
SQL-NS
Microsoft Repository
Broadcast Architecture
Still Image API
Microsoft Multimedia
Indexing Service
Still More COM Technologies!
•
•
•
•
•
•
•
•
•
•
Active Desktop
IIS
Microsoft Agent
Microsoft Java SDK
NetMeeting
NetShow
Microsoft Wallet
Active Directory
Active Accessibility
Clustering Service
•
•
•
•
•
•
•
•
•
Fax Services
MSMQ
RAS
Synchronization Manager
Structured Storage
MTS
MMC
Windows Shell API
all OLE Applications
The Glory of COM
• COM eliminates thread synchronization and
IPC/RPC confusion
• COM enables real polymorphism: language
transparency and location transparency
• COM mandates a consistency among
component interfaces to reduce learning curves
• COM allows versionless updates
• COM is the best component standard: it is by
far the most commercially successful
DLL Server Mechanisms
• DllRegisterServer and DllUnregisterServer
manipulate the registry
• DllCanUnloadNow tells COM when the
module is not being used
• DllGetClassObject provides the client with
the class factory of the required COM
object
EXE Server Mechanisms
• A /RegServer argument registers the EXE
• A /UnregServer argument un-registers the
EXE
• CoRegisterClassObject registers a class
factory for clients to connect to
• RegisterActiveObject adds an object to the
Running Object Table (ROT)
COM Object Instantiation
• CoGetClassObject (wrapped by
CoCreateInstance and CoCreateInstanceEx)
launches a module and retrieves its class
factory
• CoGetClassObjectFromURL downloads a
module from an URL, decompresses it,
registers it, and invokes CoGetClassObject on
it
• GetActiveObject loads an object off the ROT
COM Security
• CoInitializeSecurity sets the authentication
requirements for the current process
• The COSERVERINFO structure specifies the
machine name and authentication info for
clients connecting to remote objects
• CoImpersonateClient allows the server to
impersonate the client when accessing other
servers
Books of COMpetency
• The C++ Programming Language (Bjarne
Stroustrup)
• Programming Windows (Charles Petzold)
• Advanced Windows (Jeffrey Richter)
• Design Patterns (Gamma, Helm, Johnson,
Vlissides)
• Essential COM (Don Box)
Hoorah For Reading!
• Effective COM (Box, Brown, Ewald, Sells)
• Inside OLE (Kraig Brockschmidt)
• Professional ATL COM Programming
(Richard Grimes)
• Microsoft Systems Journal
(www.microsoft.com/msj)
• Sean’s Web Page (www.eburg.com/~baxters/)
May the COM Be With You
Thank You
A Slideshow of Epic Proportions
Sean Baxter
http://www.eburg.com/~baxters/
What is COM?
• A standard for interoperable software
• A runtime library providing low-level or
hard-to-implement functionality
• A competitive, capitalist marketplace for
selling functionality to application
developers
• An endless source of healthy obfuscation
That Last Slide Was Pulled From Booboo’s
Rear End. What is COM, Really?
• A sacred covenant held by the world’s best
developers. All software functionality is
encapsulated through a COM class (coclass)
and exposed through COM interfaces
Mooooo
Blah Blah Blah
Blah Blah Blah
Blah Blah Blah
Booboo
Interface and Coclass Fundamentals
• An interface is a group of methods
• A coclass is a group of interfaces
• All coclasses implement the IUnknown
interface
• All other interfaces derive IUnknown
• Lollipop diagrams describe coclasses
IU n k n o w n
IF o o
IB a r
O in k
About Interfaces
• The client communicates with the server through
interface pointers (think base class pointers)
• Methods implemented by the coclass are invoked
through interface pointers
• Interface pointers are acquired through IUnknown
• Because all interfaces derive IUnknown, any
interface pointer on an object can be acquired
through any other interface pointer on the object
• The method to acquire an interface pointer is
IUnknown::QueryInterface (think dynamic_cast)
More About Interfaces
• Interfaces are equivalent to C++ abstract
base classes
• Because there is no standard thunk
mechanism, interfaces do not support
multiple inheritance
• Two IUnknown pointers point to the same
object if their values are equal
• “Dispatch interfaces” are special case
interfaces allowed by the COM
Specification
Interfaces and Virtual Tables
• An interface pointer points to the
corresponding slice of a COM object
• The first 4 bytes of this slice comprise a
pointer to the interface’s virtual table
• Each slot in this virtual table is the address
of an interface method
• A method implementation may be
referenced by more than one vtbl entry
IU n k n o w n
p Q u e ry In te r fa c e
pAddR ef
m _ p U n k V tb l
IF o o
IB a r
Q u e ry In te rfa c e ()
p R e le a s e
A d d R e f()
m _ p F o o V tb l
m _ p B a rV tb l
R e le a s e ( )
p Q u e r y In te r fa c e
pAddR ef
O in k
p R e le a s e
pFooFunc1
pFooFunc2
F o o F u n c 1 ()
pFooFunc3
F o o F u n c 2 ()
p Q u e r y In te r fa c e
F o o F u n c 3 ()
pAddR ef
p R e le a s e
p B a rF u n c 1
B a rF u n c 1 ()
p B a rF u n c 2
p B a rF u n c 3
B a rF u n c 2 ()
B a rF u n c 3 ()
Interface Method Indirection
Reference Counting
• To regulate destruction of objects, COM
requires that all coclasses implement a
reference counter
• COM objects can have their methods
invoked from other threads, processes, and
even machines. Reference Counting
eliminates a number of problems associated
with synchronization
Reference Counting Rules
• Each object is given a reference count of 1 upon
instantiation
• IUnknown::AddRef increments the reference
count
• A successful IUnknown::QueryInterface call
increments the reference count
• IUnknown::Release decrements the reference
count
• When the reference count is decremented to zero,
the object destroys itself
So Why All These Interface and
Reference Counting Formalities?
• One of the most amazing features of COM objects
is location transparency: COM marshals interfaces
between processes and remote computers
• Reference counting guarantees that a client cannot
prematurely destroy a shared object
• COM is language transparent: unsophisticated
languages like Visual Basic, VBA, J-Script, and
VB-Script would not otherwise be able to properly
delete objects
Speaking of Location Transparency...
• COM objects (servers) can be delivered in
two module types: EXEs or DLLs (aka
OCXs)
• EXEs cannot run in-process
• DLLs can only run in-process
• A “surrogate” EXE can load a DLL to make
it an out-of-process server
p Q u e r y In te r fa c e
IU n k n o w n
pAddRef
p R e le a s e
m _ p U n k V tb l
IF o o
Q u e ry In te rfa c e ()
m _ p F o o V tb l
A d d R e f()
R e le a s e ( )
p Q u e r y In te r fa c e
pAddRef
Foo
p R e le a s e
pShake
S h a k e ()
p R a ttle
p R o ll
R a t t le ( )
R o ll( )
An In-process Server
(same apartment)
IU n k n o w n
IU n k n o w n
STA
IF o o
IB a r
IF o o
O in k _ P r o x y
IB a r
IU n k n o w n
O in k _ S t u b
IF o o
C lie n t C o d e
C O M In v is ib le W in d o w
IB a r
STA
In-process Server
(different apartment)
O in k
IU n k n o w n
P ro c e s s
B o u n d a ry
m _ p U n k V tb l
IF o o
m _ p F o o V tb l
F o o _ P ro x y
Q u e ry In te rfa c e _ S tu b ()
Q u e ry In te rfa c e _ P ro x y ()
A d d R e f_ P ro x y ()
IU n k n o w n
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
R e le a s e _ P r o x y ( )
p R e le a s e _ P r o x y
m _ p U n k V tb l
IF o o
S h a k e _ P ro x y ()
S h a k e _ S tu b ()
R a ttle _ P r o x y ( )
R a ttle _ S tu b ( )
R o ll_ P r o x y ( )
R o ll_ S t u b ( )
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
p R e le a s e _ P r o x y
p S h a k e _ P ro x y
p R a ttle _ P ro x y
p R o ll_ P r o x y
IP C
Local Server
m _ p F o o V tb l
Foo
IU n k n o w n
m _ p U n k V tb l
IF o o
m _ p F o o V tb l
F o o _ P ro x y
C lie n t
M a c h in e
Q u e ry In te rfa c e _ P ro x y ()
Q u e ry In te rfa c e _ S tu b ()
A d d R e f_ P ro x y ()
IU n k n o w n
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
R e le a s e _ P r o x y ( )
p R e le a s e _ P r o x y
m _ p U n k V tb l
M S -R P C
IF o o
S h a k e _ P ro x y ()
S h a k e _ S tu b ()
R a ttle _ P r o x y ( )
R a ttle _ S tu b ( )
R o ll_ P r o x y ( )
R o ll_ S t u b ( )
p Q u e r y In te r fa c e _ P r o x y
p A d d R e f_ P ro x y
p R e le a s e _ P r o x y
p S h a k e _ P ro x y
p R a ttle _ P r o x y
p R o ll_ P r o x y
Remote Server
m _ p F o o V tb l
Foo
S e rv e r
M a c h in e
Things To Note
• All interface method calls are synchronous; a
remote call to a New York server must complete its
round-trip before the client can continue execution
• Asynchronous services are available through
Microsoft Message Queue (MSMQ) and
ICallFactory (Windows 2000)
• Encryption, authentication, and impersonation
services are available with remote server
connections (at least on NT)
Confused?
Where Am I?
The Guy In The Back Row
COM Owns You
So what does all this nonsense about location
transparency and reference counting have to
do with anything?
Ever heard of OLE? Ever heard of ActiveX?
You may suspect that these have something to
do with COM...
WRONG!
They are COM.
All will soon be clear
MS Marketecture:
Common Misperceptions
• OLE is a system of linking and embedding
data into a document (hence the acronym
“Object Link and Embedding”)
• ActiveX, like Java, is a system for building
web page applets
• Microsoft Transaction Server (MTS) processes
business data from the internet
Faery Tales!
The Journey of COM
• Dynamic Data Exchange (DDE) was introduced
while the Earth was still cooling.
• DDE was unsavory. MS unveils OLE 1.0 after the
villagers riot
• OLE 1.0 is a big success but hard to program. MS
unveils OLE 2.0 for Windows 3.1: COM is born
(it’s 16bit)
• Windows NT 3.5 is blessed with OLE (look ma no version number!) and true 32bit COM. OLE is
now “Olè,” which is synonymous with COM
The Journey of COM (II)
• To celebrate Windows 95, MS blesses COM with
the apartment model
• 1996 sees Windows NT 4. DCOM brings network
and multithreading enhancements to COM
• Microsoft Transaction Server (MTS) becomes
available for NT Server. This doesn’t process web
business data. It’s a COM runtime environment
which allows components to run more efficiently
(solving scalability difficulties often faced in
processing business data)
The Journey of COM (III)
• OLE-DB provides consistency when accessing data
from a variety of providers
• MS makes web browsers a priority (IE3) and
simultaneously coins the term “ActiveX,” adding to
the COM marketecture. Like OLE, ActiveX is a
synonym for COM.
• Microsoft Message Queue (MSMQ) delivers
asynchronous (and vastly more reliable) method calls
• Visual C++ 5.0 ships with ATL 2.1. OLE Control
creation has never been so easy!
The Journey of COM (IV)
• Windows 2000 ships in 2004. Microsoft introduces
COM+ acronym: COM+ is simply COM on Win2k
• Win2k includes many COM updates including a
third threading model (the Neutral Threaded
Apartment) and integration of MTS into the COM
runtimes
• COM+ 2.0 delivers legendary COM virtual
machine
• Windows NT 6 device contexts replaced by
DirectDraw surfaces. Classic OLE Control
interfaces deprecated for new, ultra-spiffy interfaces
COMprehension
• COM is a set of many, many technologies.
• COM is really Microsoft’s software
engineering strategy
• Computer people (you) are betting the bank
on Microsoft
• Microsoft is betting the bank on COM
• COM Owns You
COM Defined
A single sentence can’t define COM,
because COM is such a monumental and
omnipresent set of technologies.
So what is a COM technology? Any
software creation that leverages interfaces
and coclasses, as described in the earlier
slides.
COM in Everyday Life
The Month View is from the Microsoft Windows Common
Controls-2 6.0 controls library
Property Pages
How does Visual Basic know which properties to put in the box?
Events
How does Visual Basic know which events the control exposes?
What is a VB Control?
What Functionality Does It Expose?
Properties and Methods
The Secret of Property Pages
Property Page Coclasses
Property Pages Abound!
Standard Interfaces
• Programming sucks. Best to fall back on
platform-provided functionality
• A container/client can interact with any
server/control simply by implementing the
required site interfaces
• Application developers who license your
components are already familiar with the
interfaces
• Standard interfaces can use the Microsoftprovided proxy/stubs
What Are Some COM-Based
Technologies?
•
•
•
•
•
•
•
•
•
OLE Controls
OLE-DB
ADO
DAO
DirectX
TAPI 3.0
Exchange Server
Exchange Client
Active Scripting
•
•
•
•
•
•
•
•
•
CDO 2.0
MAPI
SQL-DMO
SQL-NS
Microsoft Repository
Broadcast Architecture
Still Image API
Microsoft Multimedia
Indexing Service
Still More COM Technologies!
•
•
•
•
•
•
•
•
•
•
Active Desktop
IIS
Microsoft Agent
Microsoft Java SDK
NetMeeting
NetShow
Microsoft Wallet
Active Directory
Active Accessibility
Clustering Service
•
•
•
•
•
•
•
•
•
Fax Services
MSMQ
RAS
Synchronization Manager
Structured Storage
MTS
MMC
Windows Shell API
all OLE Applications
The Glory of COM
• COM eliminates thread synchronization and
IPC/RPC confusion
• COM enables real polymorphism: language
transparency and location transparency
• COM mandates a consistency among
component interfaces to reduce learning curves
• COM allows versionless updates
• COM is the best component standard: it is by
far the most commercially successful
DLL Server Mechanisms
• DllRegisterServer and DllUnregisterServer
manipulate the registry
• DllCanUnloadNow tells COM when the
module is not being used
• DllGetClassObject provides the client with
the class factory of the required COM
object
EXE Server Mechanisms
• A /RegServer argument registers the EXE
• A /UnregServer argument un-registers the
EXE
• CoRegisterClassObject registers a class
factory for clients to connect to
• RegisterActiveObject adds an object to the
Running Object Table (ROT)
COM Object Instantiation
• CoGetClassObject (wrapped by
CoCreateInstance and CoCreateInstanceEx)
launches a module and retrieves its class
factory
• CoGetClassObjectFromURL downloads a
module from an URL, decompresses it,
registers it, and invokes CoGetClassObject on
it
• GetActiveObject loads an object off the ROT
COM Security
• CoInitializeSecurity sets the authentication
requirements for the current process
• The COSERVERINFO structure specifies the
machine name and authentication info for
clients connecting to remote objects
• CoImpersonateClient allows the server to
impersonate the client when accessing other
servers
Books of COMpetency
• The C++ Programming Language (Bjarne
Stroustrup)
• Programming Windows (Charles Petzold)
• Advanced Windows (Jeffrey Richter)
• Design Patterns (Gamma, Helm, Johnson,
Vlissides)
• Essential COM (Don Box)
Hoorah For Reading!
• Effective COM (Box, Brown, Ewald, Sells)
• Inside OLE (Kraig Brockschmidt)
• Professional ATL COM Programming
(Richard Grimes)
• Microsoft Systems Journal
(www.microsoft.com/msj)
• Sean’s Web Page (www.eburg.com/~baxters/)
May the COM Be With You
Thank You