Library:ATL
| Vendor | Microsoft |
|---|---|
| Platforms | Platform:Windows |
| Versions | ATL 2.x/3.0 (atl.dll), 7.0 to 11.0 |
| On this wiki | Facts · Code · Notes · Topics |
Microsoft's Active Template Library: C++ templates for small COM servers and windows, whose compiled artefacts are the COM object map (_ATL_OBJMAP_ENTRY), the interface map (_ATL_INTMAP_ENTRY) and code-generated message maps instead of tables.
Identification
- Dynamic ATL:
atl.dll(ATL 2/3, VC6, a fewAtl*exports) oratl71/atl80/atl90/atl100/atl110for the redistributable versions; most programs link ATL statically as templates, so look for class names rather than imports: RTTI names such as.?AV?$CComObject@...@ATL@@,.?AV?$CComObjectRootEx@...,.?AVCComModule@ATL@@,.?AVCAtlModule,.?AV?$CWindowImpl@...,.?AV?$CDialogImpl@.... Strings:AtlAxWin(the ActiveX host window class) andATL:followed by a hex number for subclassed windows (Unverified). - Modules export the standard COM entry points:
DllGetClassObject,DllCanUnloadNow,DllRegisterServer,DllUnregisterServer, oftenDllInstall.
COM object map
ATL 3.0 (VC6) objects are listed by BEGIN_OBJECT_MAP/OBJECT_ENTRY, an array of _ATL_OBJMAP_ENTRY in the module's data, terminated by an entry with a NULL pclsid. The layout (Wine's reconstruction in include/atlbase.h; Wine states that its headers are written to handle layout differences between ATL versions): const CLSID* pclsid, HRESULT (*pfnUpdateRegistry)(BOOL), pfnGetClassObject, pfnCreateInstance, IUnknown* pCF (the class factory, filled at run time), DWORD dwRegister, pfnGetObjectDescription, then pfnGetCategoryMap and pfnObjectMain (added in ATL 3.0). That is nine fields, 36 bytes on x86 and 72 on x64. The older ATL 2 layout lacks the last two.
Since ATL 7 (Visual Studio 2002) OBJECT_ENTRY_AUTO(clsid, class) places pointers to the entries in a linker-merged section (ATL$__a to ATL$__z, Unverified) and the module walks m_ppAutoObjMapFirst to m_ppAutoObjMapLast; in ATL 11 (VS2012) the entry replaces pCF and dwRegister by a pointer pCache (_ATL_OBJMAP_ENTRY110, eight fields). The creator functions are CComCreator<CComObject<T>>::CreateInstance thunks: from the clsid you reach the C++ class that implements the COM object.
Interface map (QueryInterface)
Inside each object, BEGIN_COM_MAP/COM_INTERFACE_ENTRY generate _GetEntries(), a static array of _ATL_INTMAP_ENTRY: const IID* piid, DWORD_PTR dw, _ATL_CREATORARGFUNC* pFunc (12 bytes on x86, 24 on x64). For a plain COM_INTERFACE_ENTRY(I) pFunc is the sentinel value 1 and dw is the offset from the object to the interface's vtable pointer (so the table gives the layout of a multiply inheriting class); other macros store a function (aggregation, tear-offs, chained maps). The array ends with a NULL piid. CComObjectRootBase::InternalQueryInterface walks it. The sentinel and special dw values are Unverified (the Wine header defines the struct only).
The IIDs in the array identify the interfaces an object implements; look them up with the IID list of the Windows SDK.
Message maps
ATL window classes (CWindowImpl, CDialogImpl, WTL, see Library:WTL) do not build a data table. BEGIN_MSG_MAP(CMyWnd) generates a member function ProcessWindowMessage(HWND, UINT uMsg, WPARAM, LPARAM, LRESULT& lResult, DWORD dwMsgMapID): a chain of if (uMsg == WM_X) { ... lResult = OnX(...); if (bHandled) return TRUE; } comparisons inside a switch (dwMsgMapID). In disassembly, look for a virtual function with this signature (it is the first virtual of the CMessageMap base) containing a sequence of compares against message constants (WM_COMMAND 0x111, WM_PAINT 0xF, ...) and nested compares of LOWORD(wParam) for COMMAND_ID_HANDLER; each handler is called directly. CHAIN_MSG_MAP calls the base class's ProcessWindowMessage, ALT_MSG_MAP(n) adds another case. The static WndProc thunk (StartWindowProc then a small x86 thunk that rewrites the HWND argument with this, in _stdcallthunk) is the window procedure registered with Windows. Unverified: the thunk bytes differ per ATL version (mov dword ptr [esp+4], this; jmp WindowProc).
Related
Technique:Reading COM and WinRT code (registry layout, IIDs, slots), Format:COM type library (TLB).
Code & repositories
- Wine
include/atlbase.h(struct layouts of_ATL_OBJMAP_ENTRY,_ATL_INTMAP_ENTRY,_ATL_COM_MODULE) anddlls/atl/(an implementation of theatl.dllexports, LGPL). - Microsoft's own ATL source ships with Visual Studio and is not open source here; do not copy it.
- https://github.com/wine-mirror/wine @
7298a818b79446bae153b8d5aa27235ab3703bf9· license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize COPYING.LIB)
Wine (LGPL-2.1+): user32 dialog.c, menu.c, resource.c parse the dialog, menu and accelerator resource formats; include/atlbase.h has the ATL object/interface map structs.
Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-10-16
Evidence & references
- Wine commit 7298a818b7,
include/atlbase.hlines 38-113 and 200-239 (struct fields as quoted above).