220 likes | 440 Views
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.
E N D
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 Client
Implementation can be independent of execution context. Object Class factory: Creates objects Implementation differs between DLL and EXE servers. The Generic Structure of a Server Module Object interfaces (as many as desired) IClassFactory(2) Registration Exposure for Class factory Unloading mechanism Sever module
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 DllCanUnloadNow(void);
Exposing the Class Factory Local Server • CoRegisterClassObject • CoRevokeClassObject STDAPI CoRegisterClassObject( REFCLSID rclsid, IUnknown * pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister ); HRESULT CoRevokeClassObject(DWORDdwRegister);
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
Exercises • Use standard marshaling to implement CalculatorMemory as a local server.