1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Allocation-free parser for MSFT-format type library (`.tlb`) files.
//!
//! MSFT is the binary format used by Microsoft COM type libraries since
//! the late 1990s. A type library describes the interfaces, coclasses,
//! enumerations, and constants exposed by a COM component so that tools
//! and languages can use them at compile time or runtime.
//!
//! Record types borrow directly from the input `&[u8]` and carry a
//! lifetime that ties them to the original buffer. Parsing requires no
//! heap allocations beyond what the caller performs to load the file;
//! individual accessor methods return small scalar values by copy.
//!
//! # Quick start
//!
//! ```no_run
//! # fn main() -> Result<(), msft_typelib::Error> {
//! let data = std::fs::read("library.tlb").unwrap();
//! let lib = msft_typelib::TypeLib::parse(&data)?;
//! println!("TypeLib: {} ({} typeinfos)",
//! lib.lib_name().unwrap_or("?"), lib.typeinfo_count());
//! # Ok(())
//! # }
//! ```
//!
//! # Binary format overview
//!
//! An MSFT file begins with a 0x54-byte header (magic `"MSFT"`, version,
//! GUID offset, LCID, flags, etc.), followed by:
//!
//! 1. **Offset table** -- one `i32` per TypeInfo, giving its byte offset
//! inside the TypeInfo segment.
//! 2. **Extra field** (4 bytes) -- help-string-DLL offset when the
//! `HELPDLLFLAG` is set; empirically always present.
//! 3. **Segment directory** -- 15 entries of 16 bytes each
//! (`offset: i32, length: i32, res08, res0c`), pointing to the data
//! segments that follow.
//!
//! The 15 segments are:
//!
//! | Index | Contents |
//! |------:|----------|
//! | 0 | TypeInfo table -- fixed-size (0x64 byte) entries |
//! | 1 | Import-info table -- 12-byte entries referencing external typelibs |
//! | 2 | Import-files table -- variable-length entries with library name, GUID, version |
//! | 3 | Reference table -- 16-byte linked-list entries for coclass impl-types |
//! | 4 | GUID hash table -- bucket array for fast GUID lookup |
//! | 5 | GUID table -- 24-byte entries (16-byte GUID + hreftype + hash chain) |
//! | 6 | Name hash table -- bucket array for fast name lookup |
//! | 7 | Name table -- variable-length entries (12-byte header + name bytes) |
//! | 8 | String table -- variable-length entries (2-byte length + string bytes) |
//! | 9 | Type-descriptor table -- 8-byte entries encoding `TYPEDESC` trees |
//! | 10 | Array-descriptor table -- variable-length `ARRAYDESC` entries |
//! | 11 | Custom-data table -- variant-tagged values (2-byte VT + payload) |
//! | 12 | Custom-data GUID directory -- 12-byte linked-list entries mapping GUIDs to custom data |
//! | 13--14 | Reserved (always empty) |
//!
//! Each TypeInfo has a func/var data block at an absolute file offset.
//! The block starts with a 4-byte size, followed by variable-length
//! function and variable records, then **auxiliary arrays** containing
//! MEMBERIDs and name-table offsets for each member.
//!
//! # Public types
//!
//! | Type | Description |
//! |------|-------------|
//! | [`TypeLib`] | Main entry point and all lookup / iteration methods |
//! | [`TypeInfoEntry`] | One type description (enum, struct, interface, ...) |
//! | [`FuncRecord`] | One function or property accessor |
//! | [`VarRecord`] | One variable or constant |
//! | [`ParameterInfo`] | One function parameter |
//! | [`GuidEntry`] | One GUID-table entry |
//! | [`RefRecord`] | One coclass-implements reference |
//! | [`ImpInfo`] | One imported-typelib reference |
//! | [`ImpFile`] | One imported-library file entry (name, version, GUID) |
//! | [`ArrayDesc`], [`SafeArrayBound`] | Array descriptor with per-dimension bounds |
//! | [`CustDataEntry`] | One entry in the custom data GUID directory |
//! | [`ResolvedHreftype`] | Result of resolving an hreftype (internal or external) |
//! | [`TypeKind`], [`ConstValue`], [`vt_name`] | Shared enumerations and helpers |
//! | [`Guid`] | 16-byte GUID display wrapper |
//! | [`NameEntry`] | A decoded entry from the name table |
//! | [`Error`] | Parse error type |
pub
pub use ;
pub use CustDataEntry;
pub use Error;
pub use FuncRecord;
pub use Guid;
pub use GuidEntry;
pub use ImpFile;
pub use ImpInfo;
pub use ;
pub use NameEntry;
pub use ParameterInfo;
pub use RefRecord;
pub use TypeInfoEntry;
pub use ;
pub use ;
pub use VarRecord;