pelite\wrap/
tls.rs

1use crate::*;
2use super::Wrap;
3
4/// TLS Directory.
5impl<'a, Pe32: pe32::Pe<'a>, Pe64: pe64::Pe<'a>> Wrap<pe32::tls::Tls<'a, Pe32>, pe64::tls::Tls<'a, Pe64>> {
6	/// Gets the PE instance.
7	#[inline]
8	pub fn pe(&self) -> Wrap<Pe32, Pe64> {
9		match self {
10			Wrap::T32(tls) => Wrap::T32(tls.pe()),
11			Wrap::T64(tls) => Wrap::T64(tls.pe()),
12		}
13	}
14	/// Returns the underlying TLS directory image.
15	#[inline]
16	pub fn image(&self) -> Wrap<&'a image::IMAGE_TLS_DIRECTORY32, &'a image::IMAGE_TLS_DIRECTORY64> {
17		match self {
18			Wrap::T32(tls) => Wrap::T32(tls.image()),
19			Wrap::T64(tls) => Wrap::T64(tls.image()),
20		}
21	}
22	/// Gets the raw TLS initialization data.
23	#[inline]
24	pub fn raw_data(&self) -> Result<&'a [u8]> {
25		match self {
26			Wrap::T32(tls) => tls.raw_data(),
27			Wrap::T64(tls) => tls.raw_data(),
28		}
29	}
30	/// Gets the TLS slot location.
31	#[inline]
32	pub fn slot(&self) -> Result<&'a u32> {
33		match self {
34			Wrap::T32(tls) => tls.slot(),
35			Wrap::T64(tls) => tls.slot(),
36		}
37	}
38	/// Gets the TLS initialization callbacks.
39	#[inline]
40	pub fn callbacks(&self) -> Result<Wrap<&'a [u32], &'a [u64]>> {
41		match self {
42			Wrap::T32(tls) => Wrap::T32(tls.callbacks()).transpose(),
43			Wrap::T64(tls) => Wrap::T64(tls.callbacks()).transpose(),
44		}
45	}
46}