Skip to content

Commit 8e606d8

Browse files
authored
pe.options: added parse_tls_data option (#457)
* pe.options: added parse_tls_data option
1 parent 9a87a99 commit 8e606d8

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/pe/mod.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,19 @@ impl<'a> PE<'a> {
228228
)?);
229229
}
230230

231-
if let Some(tls_table) = optional_header.data_directories.get_tls_table() {
232-
tls_data = tls::TlsData::parse_with_opts(
233-
bytes,
234-
image_base,
235-
tls_table,
236-
&sections,
237-
file_alignment,
238-
opts,
239-
is_64,
240-
)?;
241-
debug!("tls data: {:#?}", tls_data);
231+
if opts.parse_tls_data {
232+
if let Some(tls_table) = optional_header.data_directories.get_tls_table() {
233+
tls_data = tls::TlsData::parse_with_opts(
234+
bytes,
235+
image_base,
236+
tls_table,
237+
&sections,
238+
file_alignment,
239+
opts,
240+
is_64,
241+
)?;
242+
debug!("tls data: {:#?}", tls_data);
243+
}
242244
}
243245

244246
if header.coff_header.machine == header::COFF_MACHINE_X86_64 {

src/pe/options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct ParseOptions {
99
/// memory](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#other-contents-of-the-file).
1010
/// For on-disk representations, leave as true. Default: true
1111
pub parse_attribute_certificates: bool,
12+
pub parse_tls_data: bool,
1213
/// Whether or not to end with an error in case of incorrect data or continue parsing if able. Default: ParseMode::Strict
1314
pub parse_mode: ParseMode,
1415
}
@@ -27,6 +28,7 @@ impl Default for ParseOptions {
2728
ParseOptions {
2829
resolve_rva: true,
2930
parse_attribute_certificates: true,
31+
parse_tls_data: true,
3032
parse_mode: ParseMode::Strict,
3133
}
3234
}
@@ -37,6 +39,7 @@ impl ParseOptions {
3739
Self {
3840
resolve_rva: false,
3941
parse_attribute_certificates: false,
42+
parse_tls_data: true,
4043
parse_mode: ParseMode::Strict,
4144
}
4245
}

0 commit comments

Comments
 (0)