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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//! Raw File structures for the File metadata table.
//!
//! This module provides the [`FileRaw`] struct for reading file data directly
//! from metadata tables before index resolution. The File table lists files
//! that make up multi-file assemblies including modules, resources, and libraries.
//!
//! # Table Structure
//! The File table (`TableId` = 0x26) contains these columns:
//! - `Flags`: 4-byte `FileAttributes` bitmask indicating file type
//! - `Name`: Index into String heap containing filename
//! - `HashValue`: Index into Blob heap containing cryptographic hash
//!
//! # File Types
//! File entries can represent various file types:
//! - **Executable modules**: .netmodule files with .NET code
//! - **Resource files**: .resources files with binary data
//! - **Native libraries**: .dll files with unmanaged code
//! - **Documentation**: .xml files with API documentation
//! - **Configuration**: Data files with application settings
//!
//! # ECMA-335 Reference
//! See ECMA-335, Partition II, §22.19 for the File table specification.
//!
//! # Thread Safety
//! [`FileRaw`] implements [`Clone`] and is safe to share between threads.
use Arc;
use crate::;
/// Raw file data read directly from the File metadata table.
///
/// This structure represents a file entry before index resolution and string/blob
/// dereferencing. File entries describe components of multi-file assemblies including
/// modules, resources, and native libraries.
///
/// # Binary Format
/// Each row in the File table has this layout:
/// ```text
/// Offset | Size | Field | Description
/// -------|------|-----------|----------------------------------
/// 0 | 4 | Flags | FileAttributes bitmask
/// 4 | 2/4 | Name | String heap index
/// 6/8 | 2/4 | HashValue | Blob heap index
/// ```
///
/// String and blob index sizes depend on heap sizes.
///
/// # File Context
/// File entries are used for:
/// - **Multi-module assemblies**: Additional .netmodule files with executable code
/// - **Resource files**: Binary data files (.resources, images, configuration)
/// - **Native libraries**: Unmanaged DLLs for P/Invoke operations
/// - **Documentation**: XML documentation and help files
/// - **Satellite assemblies**: Localization and culture-specific content
///
/// # File Attributes
/// The Flags field contains `FileAttributes` values:
/// - **`CONTAINS_META_DATA` (0x0000)**: File contains .NET metadata
/// - **`CONTAINS_NO_META_DATA` (0x0001)**: Resource file without metadata
///
/// # Hash Security
/// The `HashValue` provides integrity verification:
/// - **SHA-1 or SHA-256**: Algorithm depends on assembly version
/// - **Tamper detection**: Verifies file hasn't been modified
/// - **Loading validation**: Runtime can verify file authenticity
/// - **Security assurance**: Prevents malicious file substitution
///
///
/// # ECMA-335 Reference
/// See ECMA-335, Partition II, §22.19 for the complete File table specification.