Skip to content

Commit

Permalink
make TLS directory optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaza committed Oct 20, 2024
1 parent aa385fa commit 5fd5a4f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/pe/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ pub struct TlsCallbacks {
impl TlsCallbacks {
pub fn parse(pe: &VecPE) -> Result<TlsCallbacks> {
let callbacks = match pe.get_arch()? {
exe::Arch::X86 => {
let tls = ImageTLSDirectory32::parse(pe)?;
tls.get_callbacks(pe)?
exe::Arch::X86 => match ImageTLSDirectory32::parse(pe) {
Ok(tls) => tls
.get_callbacks(pe)?
.iter()
.map(|x| x.0.into())
.collect::<Vec<u64>>()
}
exe::Arch::X64 => ImageTLSDirectory64::parse(pe)?
.get_callbacks(pe)?
.iter()
.map(|x| x.0)
.collect::<Vec<u64>>(),
.collect::<Vec<u64>>(),
_ => vec![],
},
exe::Arch::X64 => match ImageTLSDirectory64::parse(pe) {
Ok(tls) => tls
.get_callbacks(pe)?
.iter()
.map(|x| x.0)
.collect::<Vec<u64>>(),
_ => vec![],
},
};
Ok(TlsCallbacks { callbacks })
}
Expand Down

0 comments on commit 5fd5a4f

Please sign in to comment.