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
//! The raw ECMA-335 metadata, as stored in the file: the metadata root, its
//! streams, and the tables and heaps inside them.
//!
//! Most code wants [`Module`](crate::Module) and the entries in
//! [`crate::dotnet::entries`] instead, which are loaded from this layer and
//! link everything up: a type's methods, a method's signature, and so on. Here,
//! rows point at other rows and heaps by plain indexes that you follow yourself.
//! Use it to look at a file as stored (row counts, heap offsets, coded indexes),
//! or for the flag types the entries share, such as
//! [`TypeAttributes`](streams::tables_stream::TypeAttributes).
//!
//! - [`metadata_header`]: the metadata root and the headers locating each stream.
//! - [`streams`]: the heaps (`#Strings`, `#Blob`, `#GUID`, `#US`) and, in
//! [`streams::tables_stream`], the tables.
//!
//! [`Metadata`](crate::dotnet::Metadata) parses an image down to this level:
//!
//! ```no_run
//! use hao::dotnet::Metadata;
//!
//! let bytes = std::fs::read("Example.dll").unwrap();
//! let metadata = Metadata::parse(&bytes).unwrap();
//! let streams = &metadata.metadata_streams;
//! let tables = &streams.tables_stream;
//!
//! // The Module table has one row. Its name is an offset into #Strings.
//! let module = tables.modules().unwrap().next().unwrap().unwrap();
//! let name = streams.strings_stream.read_string(module.name.0).unwrap();
//! println!("{name}: {} types", tables.header.table_locations.type_def.rows.0);
//! ```
use bitflags;
/// A raw metadata token: table number in the high byte, 1-based row in the low
/// 24 bits. Nothing in hao produces or consumes it yet; resolved tokens are
/// [`MemberToken`](crate::dotnet::il::MemberToken).
;
bitflags!