15
Server Types Client Process Client In-process server In-process object COM Local object proxy Remote object proxy Local server process Local server Local object COM Stub Remote server process COM Stub Remote Machine RPC RPC Remote server Remote object

Server Types

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

Page 1: Server Types

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

Page 2: Server Types

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.

Page 3: Server Types

Registry Entries

In-process servers: InprocServer32=<path to DLL>

Object handlers: InprocHandler32=<path to DLL>

Local servers: LocalServer32=<path to EXE>

Page 4: Server Types

Self-Registration

DLL Servers– DllRegisterServer– DllUnregisterServer

EXE servers Command arguments– /RegServer – /UnregServer

Page 5: Server Types

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);

Page 6: Server Types

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

);

Page 7: Server Types

In-Process-Server Creation

Page 8: Server Types

Local-Server Creation

Page 9: Server Types

Marshaling

There are three types of marshaling– Type library marshaling– Standard marshaling– Custom marshaling

Page 10: Server Types

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

Page 11: Server Types

Standard Marshaling

The proxy-stub DLL for standard marshaling can be produced by the help of MIDL compiler

Page 12: Server Types

Custom Marshaling

Quite involved and needed when the methods in an interface use user defined data types

Need to implement IMarshal

Page 13: Server Types

Type Library Marshaling

Page 14: Server Types

Standard Marshaling

Page 15: Server Types

Exercises

1. Use standard marshaling to implement CalculatorMemory as a local server.