Platform:Microsoft Visual C++ ABI
| Developer | Microsoft |
|---|---|
| Uses | Library:Microsoft C Runtime |
| Platforms | Win32 (x86), Win64 (x64, ARM64) |
| Magic | 63 73 6D E0 (exception code 0xE06D7363), 22 05 93 19 (FuncInfo) |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
The C++ binary conventions of Microsoft's compiler (cl.exe), also followed by clang-cl: decorated (mangled) names starting with '?', RTTI records reachable from slot -1 of every vftable, and the ThrowInfo/FuncInfo tables behind C++ exceptions (exception code 0xE06D7363). On x86 these records hold absolute pointers; on x64 and ARM64 they hold 32-bit image-relative offsets (RVAs).
Overview
The ABI is defined by what cl.exe emits and what the Visual C++ runtime (vcruntime, msvcrt) consumes. Microsoft has not published it as a specification; the open-source references are clang's MSVC-compatible code generator and mangler (llvm-project, Apache-2.0 with LLVM exception) and Wine's reimplementation of the runtime (LGPL-2.1). Everything on these pages was also checked on binaries built with MSVC 19.44 (Visual Studio 2022, toolset 14.44) for x86 and x64.
- Decorated names: Platform:Microsoft Visual C++ ABI/Name decoration:
?name@scope@@<encoding>, e.g.?method@Klass@@QEBAHPEBD@Z. Visible in exports, imports, PDBs, MAP files and inside RTTI strings. - Debug information: the compiler writes Format:CodeView records into
.debug$S/.debug$Tof each object (S_COMPILE3 with the exact cl.exe version is there even without /Z7 or /Zi), and the linker merges them into a Format:PDB (Program Database) named by the PE's RSDS record; even a stripped public PDB lists the (decorated) name of every external function and global as an S_PUB32 record; static functions appear only in the private module streams. - RTTI: Platform:Microsoft Visual C++ ABI/RTTI: TypeDescriptor, CompleteObjectLocator, ClassHierarchyDescriptor, BaseClassArray, BaseClassDescriptor. The name of every polymorphic class compiled with /GR (the default) is in the binary as
.?AV<name>@@(class) or.?AU<name>@@(struct). - C++ exceptions: Platform:Microsoft Visual C++ ABI/C++ exception handling:
throwcalls_CxxThrowException(object, ThrowInfo), which raises SEH exception 0xE06D7363; per-function FuncInfo tables (magic 0x19930522) or, on x64 by default, compressed FuncInfo4 tables describe try blocks, catch handlers and unwinding.
Identification
A module was built from C++ by MSVC (or clang-cl) when it contains:
- the string
.?AVtype_info@@(the TypeDescriptor name oftype_infoitself; exactly one occurrence in every RTTI-enabled module checked: two self-built test programs, a third-party x64 application, msvcp140.dll x86 and x64); - other
.?AV/.?AUstrings (class names); - imports or code of
_CxxThrowException,__CxxFrameHandler3,__CxxFrameHandler4,__RTDynamicCast,__RTtypeid, usually from vcruntime140.dll or linked statically; - the dword 0xE06D7363 (
63 73 6D E0) in exception filters, and FuncInfo records starting22 05 93 19(older compilers also20 05 93 19,21 05 93 19).
Before looking at the code, the PE headers usually name the toolchain: Microsoft link writes a Rich header whose entries give the exact compiler and linker builds (C vs C++, /GL, PGO), the optional header's linker version is 14.x for VS2015-VS2026, and /GL builds carry a POGO debug entry listing .rdata$r (RTTI) and .text$x (exception funclets) ranges; see Format:PE (Portable Executable)/Rich header, Format:PE (Portable Executable)#Compiler and linker identification and Format:PE (Portable Executable)/Debug directory#POGO and VC_FEATURE. clang-cl linked with lld-link has no Rich header.
GCC/MinGW and Itanium-ABI clang builds use _Z names and N3foo3BarE-style type names instead and contain no .?AV strings (checked on MinGW-w64 GCC builds, including libstdc++-6.dll); see Platform:Itanium C++ ABI#Identification.
Conventions
- Pointers inside RTTI and EH data: absolute virtual addresses on x86 (they need base relocations), 32-bit RVAs from the image base on x64 and ARM64. The x64 CompleteObjectLocator also stores its own RVA so the runtime can find the image base. TypeDescriptors are the exception: they are real
type_infoobjects with a vfptr and use full pointers on every architecture. - vftables: the pointer-sized slot just before a vftable (
vftable[-1]) points to the class's CompleteObjectLocator when RTTI is enabled. A class with several vfptrs (multiple inheritance) has one vftable and one locator per vfptr. - Calling conventions: x86 member functions use
__thiscall(thisin ECX, callee pops);_CxxThrowExceptionis__stdcallon x86. x64 has one convention (thisin RCX). - Sections: the linker puts RTTI in
.rdata(subsection.rdata$r), TypeDescriptors in.data(they are written at run time), ThrowInfo/CatchableType and FuncInfo in.rdata(from.xdata). Windows' own DLLs often merge.rdatainto.text, so scanners must not skip executable sections.
Recovery recipes
- Name the classes: search
.?AV/.?AU, step back two pointers to the TypeDescriptor, find the CompleteObjectLocator that references it at offset 0x0C, find the pointer to the locator; the vftable starts right after it. Code:Microsoft Visual C++ ABI/msvc_rtti_scan (Python) does this for x86 and x64 files. - Name virtual functions' owners: a function in the vftable of class X but not in its base's is X's override. With a virtual destructor, one slot (slot 0 when the destructor is the first virtual function) holds the scalar deleting destructor
??_G(virtual void *X::scalar deleting destructor'(unsigned int)`, argument bit 0 = also free the memory). - List what a module throws: every distinct thrown type has a ThrowInfo record pointing to the types it can be caught as (CatchableTypeArray); the scanner's
--throwoption lists them. - Find catch handlers: on x86 each function with try/catch has an
__ehhandler$<function>thunkxor ecx, eax; call __security_check_cookie; mov eax, offset FuncInfo; jmp __CxxFrameHandler3(bytes33 C8 E8 ?? ?? ?? ?? B8 ?? ?? ?? ?? E9); on x64 the handler data of the function's UNWIND_INFO is the RVA of its FuncInfo (FH3) or FuncInfo4 (FH4). - Skip compiler scaffolding: /GS cookies, CFG guard calls, x86 SEH frames, stack probes and magic-number divisions are described on Technique:Recognizing compiler-generated code.
Topics
- RTTI — Layout of MSVC's run-time type information: the TypeDescriptor (type_info object with the decorated name), the CompleteObjectLocator found at vftable[-1], the C
- Name decoration — How MSVC decorates (mangles) C++ names: '?' + name + '@'-terminated scopes + '@' + codes for access, calling convention and types; special names for constructor
- C++ exception handling — How MSVC implements C++ exceptions: throw calls _CxxThrowException, which raises SEH exception 0xE06D7363 with the object and a ThrowInfo record (plus the image
Code & repositories
- {{Repo|url=https://github.com/llvm/llvm-project%7Ccommit=8cdfc2de74ce046bae08f3a423be85694f225f3b%7Clicense=Apache-2.0 WITH LLVM-exception (LICENSE.TXT at the repository root; the detector reports none)|description=LLVM/clang. clang-cl generates MSVC-compatible C++: clang/lib/CodeGen/MicrosoftCXXABI.cpp builds the RTTI records (TypeDescriptor, CompleteObjectLocator, ClassHierarchyDescriptor, BaseClassDescriptor) and the EH records (ThrowInfo, CatchableTypeArray, CatchableType); clang/lib/AST/MicrosoftMangle.cpp decorates names; llvm/lib/Demangle/MicrosoftDemangle.cpp (llvm-undname) decodes them, with test vectors in llvm/test/Demangle/ms-.test; llvm/lib/CodeGen/AsmPrinter/WinException.cpp writes FuncInfo tables (magic 0x19930522).|tested_on=Read at this commit (sparse checkout of the four files and the ms-.test files); every layout used on the wiki was compared with binaries built by MSVC 19.44 (VS 2022) for x86 and x64. Not built.|checked=checked 2026-10-17; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries}}
- {{Repo|url=https://github.com/wine-mirror/wine%7Ccommit=7298a818b79446bae153b8d5aa27235ab3703bf9%7Clicense=LGPL-2.1-or-later (declared: the detector found none; check the repository)|description=Wine's reimplementation of the Visual C++ runtime: dlls/msvcrt/cxx.h (RTTI and exception type structures in pointer and RVA forms, type flags), cpp.c (_CxxThrowException, __RTDynamicCast, type_info), except.c / except_i386.c (__CxxFrameHandler3 and FuncInfo magic checks), handler4.c (__CxxFrameHandler4: the compressed FuncInfo4 format), include/winternl.h (0xE06D7363).|tested_on=Read at this commit (sparse checkout of dlls/msvcrt and include headers); structures and the FH4 header and compressed-integer encoding compared with MSVC 19.44 x86/x64 test binaries. Not built.|checked=checked 2026-10-17; last activity 2026-10-16}}
Pitfalls
UnDecorateSymbolName(dbghelp) andundname.exedecode a TypeDescriptor name only after its leading '.' is removed; with flags 0x2800 (UNDNAME_32_BIT_DECODE | UNDNAME_NO_ARGUMENTS)?AUDuck@zoo@@becomesstruct zoo::Duck.- Identical COMDAT folding and incremental linking: several symbols can share one address (in the test builds
??_Evector and??_Gscalar deleting destructors had the same address), and with /INCREMENTAL the destructor and handler addresses in ThrowInfo and UNWIND_INFO point tojmpthunks, not to the functions. - A vftable's slot count is stored nowhere; counting pointers into executable sections overcounts when vftables are adjacent with no locator pointer between them (modules built with /GR-).
Evidence & references
- llvm-project
clang/lib/CodeGen/MicrosoftCXXABI.cpp,clang/lib/AST/MicrosoftMangle.cpp,llvm/lib/Demangle/MicrosoftDemangle.cpp,llvm/lib/CodeGen/AsmPrinter/WinException.cppat commit 8cdfc2de74ce046bae08f3a423be85694f225f3b. - Wine
dlls/msvcrt/cxx.h,cpp.c,except.c,handler4.c,include/winternl.hat commit 7298a818b79446bae153b8d5aa27235ab3703bf9. - Runtime tests: programs built with cl.exe 19.44 (/EHsc /O2 /GR /MT, x86 and x64, plus x64 /d2FH4-), compared with the linker MAP files and
undname.exe.