it:windows_ipc
Különbségek
A kiválasztott változat és az aktuális verzió közötti különbségek a következők.
Előző változat mindkét oldalonElőző változatKövetkező változat | Előző változat | ||
it:windows_ipc [2013/07/11 08:55] – [Interfaces] rblst | it:windows_ipc [Unknown date] (aktuális) – külső szerkesztés (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Sor 1: | Sor 1: | ||
+ | ====== Interprocess communication in Windows ====== | ||
+ | ===== History of technologies ====== | ||
+ | ==== DDE ==== | ||
+ | * Dynamic Data Exchange (Microsoft 1987) | ||
+ | * **first IPC method** in Windows | ||
+ | * sending and receiving messages in so-called " | ||
+ | |||
+ | ==== OLE ==== | ||
+ | * Object Linking and Embedding (Microsoft Word and Excel 1991, Windows 1992) | ||
+ | * Microsoft' | ||
+ | * built on top of DDE for compound documents | ||
+ | * e.g. spreadsheet embedded in a Word document: as changes are made to the spreadsheet within Excel, they appear automatically inside the Word document | ||
+ | |||
+ | === VBX === | ||
+ | * Visual Basic Extensions (Visual Basic 1.0, 1992) | ||
+ | * packaged extension in the form of a DLL | ||
+ | * graphical object design | ||
+ | * later adapted by other languages such as Visual C++ | ||
+ | |||
+ | ==== OLE 2 ==== | ||
+ | * Windows 3.1, 1992 | ||
+ | * OLE changed to OLE 2 | ||
+ | * text " | ||
+ | * **COM**: **object model as a new foundation**, | ||
+ | * ABI: COM Application binary interface | ||
+ | * **OCXs**: OLE custom controls, successor to VBX controls (1994) | ||
+ | * **OLE Automation**: | ||
+ | * OLE 2 later became known as **" | ||
+ | |||
+ | ==== COM ==== | ||
+ | * Component Object Model (Microsoft, 1993) | ||
+ | * binary interface standard for software components | ||
+ | * IPC and dynamic object creation: objects can be used in environments different from where they were created, even across machine boundaries (**DCOM**) | ||
+ | * language-neutral | ||
+ | * **basis for Microsoft technologies**: | ||
+ | * similar to other component software interface technologies, | ||
+ | |||
+ | ==== ActiveX ==== | ||
+ | * new use for OCXs, 1996 | ||
+ | * Web browser' | ||
+ | * **Microsoft gradually renamed all OLE technologies to ActiveX** | ||
+ | * except the compound document technology in Microsoft Office, that is stilled called OLE | ||
+ | * OLE Automation became Automation | ||
+ | |||
+ | |||
+ | ==== COM+ ==== | ||
+ | * MTS (Microsoft Transaction Server): COM and DCOM based NT technology; support for distributed transactions, | ||
+ | * MTS later became COM+ | ||
+ | * mostly reimplemented by Microsoft .NET but it still uses COM+ under the '' | ||
+ | ===== Current technologies ====== | ||
+ | **COM** is still the basic model for IPC and the basis for current **[[http:// | ||
+ | |||
+ | * **OLE**: compound documents in Microsoft Office | ||
+ | * **Automation**: | ||
+ | * **COM+**: distributed services for COM | ||
+ | | ||
+ | Microsoft .NET: can interact with COM+ (via COM-interop-assemblies) and provides wrappers to most commonly used COM controls. It hides most detail from component creation and therefore eases development. WCF (Windows Communication Foundation) for web services is part of .NET. | ||
+ | |||
+ | |||
+ | ===== COM ===== | ||
+ | * COM is a language agnostic binary standard | ||
+ | * usable with programming languages capable of understanding and implementing binary defined data types and interfaces | ||
+ | * software with COM-aware components, also called COM objects (an //object// is a // | ||
+ | |||
+ | ==== Interfaces ==== | ||
+ | * each COM object exposes its functionality through one or more interfaces | ||
+ | * the object uses code that implements each **method** (also called function) of the interface | ||
+ | * COM makes these functions available to any client asking for a pointer to the interface (inside or outside of the process) | ||
+ | * **all access to components occurs via the interfaces** | ||
+ | * **IID**: interface ID (GUID), used to distinguished interfaces from each other | ||
+ | * language bindings: C, C++, Visual Basic, Delphi, scripting languages etc. | ||
+ | |||
+ | === IUnknown interface === | ||
+ | * custom interface that all COM components must implement | ||
+ | * **vtable**-based invocation (also called dispatch table, not to be confused with the dispatch interface below) | ||
+ | * methods for lifetime management: type conversion (casting) and reference counting | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * every interface derives (directly or indirectly) from '' | ||
+ | * '' | ||
+ | |||
+ | === IDispatch interface === | ||
+ | * OLE Automation interface | ||
+ | * native access from a wider range of languages (scripting languages: ASP, JavaScript etc.) compared to custom interfaces | ||
+ | * late binding: applications can find out what properties and methods are supported by an object and the way to invoke them at run-time | ||
+ | * properties and methods are identified by a Dispatch ID: **'' | ||
+ | * derives from '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * a single " | ||
+ | * represents a logical " | ||
+ | * flexible, but additional introspection and invocation overhead compared to custom interfaces | ||
+ | * clients don't need to build custom binding code from information in a type library | ||
+ | |||
+ | |||
+ | === IDual interface === | ||
+ | * both '' | ||
+ | ==== Classes ==== | ||
+ | * COM classes ('' | ||
+ | * resembles classes in other object-oriented programming languages | ||
+ | * **CLSID**: class ID that identify a component type, which are Globally Unique Identifiers (GUIDs) | ||
+ | * created based on their '' | ||
+ | * **polymorphism**: | ||
+ | |||
+ | |||
+ | ==== Type library (TLB) ==== | ||
+ | * file that contains binary metadata to represent COM types: classes, interfaces, structures, enumerations | ||
+ | * described using Microsoft Interface Definition Language (IDL) | ||
+ | * TLB files can be processed by compilers and runtime environments (VB, Delphi, .NET etc.) to generate language-specific constructs to represent the COM types | ||
+ | |||
+ | === IDL === | ||
+ | * defines COM types and other user-defined types | ||
+ | * language independent | ||
+ | * similar to C++ declarations, | ||
+ | * bracketed attributes before declarations: | ||
+ | * IDL files are compiled by the MIDL compiler into a type library (or other language-specific files) | ||
+ | |||
+ | ==== Reference counting ==== | ||
+ | * COM objects are responsible for their own creation and destruction through reference-counting | ||
+ | * reference counts are controlled by the clients through the '' | ||
+ | * COM objects must free their own memory when the reference count drops to zero | ||
+ | * certain languages (e.g. Visual Basic) provide automatic reference counting, objects need not explicitly maintain any internal reference counter | ||
+ | |||
+ | ==== Registry usage ==== | ||
+ | |||
+ | * COM classes, interfaces and type libraries are listed by GUIDs in the registry: | ||
+ | * classes: '' | ||
+ | * interfaces: '' | ||
+ | * COM libraries use the registry to locate either the correct local libraries for each COM object or the network location for a remote service | ||
+ | |||
+ | === RegFree COM === | ||
+ | * registration-free COM | ||
+ | * introduced with Windows XP | ||
+ | * allows COM components to store activation metadata and CLSID in an **assembly manifest** | ||
+ | * assembly manifest | ||
+ | * resource in the executable | ||
+ | * separate file (XML) installed with the component | ||
+ | * allows multiple versions of the same component to be installed in different directories described by their own manifests | ||
+ | * application loading: | ||
+ | * Windows loader searches for the manifest and creates activation context | ||
+ | * if no implementation for the CLSID is found in the activation context, the registry is scanned | ||
+ | |||
+ | ==== Client and server ==== | ||
+ | * COM client: any object that gets a pointer to a COM server and uses its services by calling the methods of its interfaces | ||
+ | * COM server: any object that provides services to clients in the form of COM interface implementations (that can be called by any client that is able to get a pointer to one of its interfaces) | ||
+ | |||
+ | === Server types === | ||
+ | * **in-process**: | ||
+ | * implemented in a **DLL** | ||
+ | * **out-of-process**: | ||
+ | * implemented in an executable file (**EXE**) | ||
+ | * can reside either on local or remote computer | ||
+ | * mechanism to allow an in-process server (DLL) to run in a surrogate EXE process | ||
+ | * client applications do not need to be aware of how server objects are packaged (in-process objects or as local or remote objects) | ||
+ | * DCOM allows objects to be packaged as Windows services | ||
+ | |||
+ | === Server responsibilites === | ||
+ | * the client wants a pointer to an object | ||
+ | * the client asks that a server be launched | ||
+ | * an instance of the object provided by the server is created and activated | ||
+ | |||
+ | The server must: | ||
+ | - implement code for a class object through an implementation of either the IClassFactory or IClassFactory2 interface | ||
+ | - register its CLSID in the system registry on the machine on which it resides | ||
+ | - provide security: determine whether it will provide a pointer to one of its objects to a client | ||
+ | ==== Implementation ==== | ||
+ | * COM implementations are responsible for | ||
+ | * entering and leaving the COM environment | ||
+ | * instantiating and reference-counting COM objects | ||
+ | * querying objects for supported interfaces | ||
+ | * handling errors | ||
+ | |||