Upload
channing-carlson
View
11
Download
0
Embed Size (px)
DESCRIPTION
Local server process. Client Process. In-process server. In-process object. COM. Local server. Stub. Local object. RPC. COM. Remote Machine. Local object proxy. Remote server process. COM. Remote server. Stub. Remote object. Remote object proxy. RPC. Server Types. - PowerPoint PPT Presentation
Citation preview
Server Types
Client Process
ClientClient
In-processserver
In-processserver
In-processobject
COMCOM
Localobjectproxy
Remoteobjectproxy
Local server process
Local serverLocal server
Localobject
COMCOM
Stub
Remote server process
COMCOM
Stub
Remote MachineRPC
RPCRemote server
Remote server
Remoteobject
The Generic Structure of a Server Module
ObjectObject interfaces
(as many as desired)
Class factory:Creates objects
Registration
Sever module
IClassFactory(2)
Exposure forClass factory
Unloadingmechanism
Implementation differs between DLL and EXE servers.
Implementation can be independent of execution context.
Registry Entries
In-process servers: InprocServer32=<path to DLL>
Object handlers: InprocHandler32=<path to DLL>
Local servers: LocalServer32=<path to EXE>
Self-Registration
DLL Servers– DllRegisterServer– DllUnregisterServer
EXE servers Command arguments– /RegServer – /UnregServer
Exposing the Class Factory In-Process Server
Implement DllGetClassObject
Implement DllCanUnloadNow
STDAPI DllGetClassObject(REFCLSID rclsid,
REFIID riid,
void **ppv);
STDAPI DllGetClassObject(REFCLSID rclsid,
REFIID riid,
void **ppv);
STDAPI DllCanUnloadNow(void);STDAPI DllCanUnloadNow(void);
Exposing the Class Factory Local Server
CoRegisterClassObject
CoRevokeClassObject
HRESULT CoRevokeClassObject(DWORD dwRegister);HRESULT CoRevokeClassObject(DWORD dwRegister);
STDAPI CoRegisterClassObject(
REFCLSID rclsid,
IUnknown * pUnk,
DWORD dwClsContext,
DWORD flags,
LPDWORD lpdwRegister
);
STDAPI CoRegisterClassObject(
REFCLSID rclsid,
IUnknown * pUnk,
DWORD dwClsContext,
DWORD flags,
LPDWORD lpdwRegister
);
In-Process-Server Creation
Local-Server Creation
Marshaling
There are three types of marshaling– Type library marshaling– Standard marshaling– Custom marshaling
Type Library Marshaling
Uses the automation marshaler “oleaut32.dll” provided by COM
You must register the type library for the component
The type of the arguments has to be compatible with C++ Variant structure
Standard Marshaling
The proxy-stub DLL for standard marshaling can be produced by the help of MIDL compiler
Custom Marshaling
Quite involved and needed when the methods in an interface use user defined data types
Need to implement IMarshal
Type Library Marshaling
Standard Marshaling
Exercises
1. Use standard marshaling to implement CalculatorMemory as a local server.