File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -222,18 +222,23 @@ impl<'a> PE<'a> {
222
222
}
223
223
}
224
224
225
- let certtable = if let Some ( certificate_table) =
226
- * optional_header. data_directories . get_certificate_table ( )
227
- {
228
- certificates = certificate_table:: enumerate_certificates (
229
- bytes,
230
- certificate_table. virtual_address ,
231
- certificate_table. size ,
232
- ) ?;
225
+ // Parse attribute certificates unless opted out of
226
+ let certtable = if opts. parse_attribute_certificates {
227
+ if let Some ( certificate_table) =
228
+ * optional_header. data_directories . get_certificate_table ( )
229
+ {
230
+ certificates = certificate_table:: enumerate_certificates (
231
+ bytes,
232
+ certificate_table. virtual_address ,
233
+ certificate_table. size ,
234
+ ) ?;
233
235
234
- let start = certificate_table. virtual_address as usize ;
235
- let end = start + certificate_table. size as usize ;
236
- Some ( start..end)
236
+ let start = certificate_table. virtual_address as usize ;
237
+ let end = start + certificate_table. size as usize ;
238
+ Some ( start..end)
239
+ } else {
240
+ None
241
+ }
237
242
} else {
238
243
None
239
244
} ;
Original file line number Diff line number Diff line change 3
3
pub struct ParseOptions {
4
4
/// Wether the parser should resolve rvas or not. Default: true
5
5
pub resolve_rva : bool ,
6
+ /// Whether or not to parse attribute certificates.
7
+ /// Set to false for in-memory representation, as the [loader does not map this info into
8
+ /// memory](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#other-contents-of-the-file).
9
+ /// For on-disk representations, leave as true. Default: true
10
+ pub parse_attribute_certificates : bool ,
6
11
}
7
12
8
13
impl ParseOptions {
9
14
/// Returns a parse options structure with default values
10
15
pub fn default ( ) -> Self {
11
- ParseOptions { resolve_rva : true }
16
+ ParseOptions {
17
+ resolve_rva : true ,
18
+ parse_attribute_certificates : true ,
19
+ }
12
20
}
13
21
}
You can’t perform that action at this time.
0 commit comments