pub enum AuxVar<'a> {
Show 34 variants
Null,
Ignore(usize),
ExecFd(usize),
Phdr(*const u8),
Phent(usize),
Phnum(usize),
Pagesz(usize),
Base(*const u8),
Flags(AuxVarFlags),
Entry(*const u8),
NotElf(bool),
Uid(usize),
EUid(usize),
Gid(usize),
EGid(usize),
Platform(&'a str),
HwCap(usize),
Clktck(usize),
Secure(bool),
BasePlatform(&'a str),
Random([u8; 16]),
HwCap2(usize),
ExecFn(&'a str),
Sysinfo(*const u8),
SysinfoEhdr(*const u8),
L1iCacheSize(usize),
L1iCacheGeometry(usize),
L1dCacheSize(usize),
L1dCacheGeometry(usize),
L2CacheSize(usize),
L2CacheGeometry(usize),
L3CacheSize(usize),
L3CacheGeometry(usize),
MinSigStkSz(usize),
}Expand description
High-level version of the serialized form of an auxiliary vector entry. It is used to construct
the auxiliary vector in crate::InitialLinuxLibcStackLayoutBuilder and returned when
a data structure is parsed with crate::InitialLinuxLibcStackLayout.
Variants§
Null
Entry with payload for type AuxVarType::Null.
Ignore(usize)
Entry with payload for type AuxVarType::Ignore.
ExecFd(usize)
Entry with payload for type AuxVarType::ExecFd.
Phdr(*const u8)
Entry with payload for type AuxVarType::Phdr.
Phent(usize)
Entry with payload for type AuxVarType::Phent.
Phnum(usize)
Entry with payload for type AuxVarType::Phnum.
Pagesz(usize)
Entry with payload for type AuxVarType::Pagesz.
Base(*const u8)
Entry with payload for type AuxVarType::Base.
Flags(AuxVarFlags)
Entry with payload for type AuxVarType::Flags.
Entry(*const u8)
Entry with payload for type AuxVarType::Entry.
NotElf(bool)
Entry with payload for type AuxVarType::NotElf.
Uid(usize)
Entry with payload for type AuxVarType::Uid.
EUid(usize)
Entry with payload for type AuxVarType::EUid.
Gid(usize)
Entry with payload for type AuxVarType::Gid.
EGid(usize)
Entry with payload for type AuxVarType::EGid.
Platform(&'a str)
Entry with payload for type AuxVarType::Platform.
HwCap(usize)
Entry with payload for type AuxVarType::HwCap.
Clktck(usize)
Entry with payload for type AuxVarType::Clktck.
Secure(bool)
Entry with payload for type AuxVarType::Secure.
BasePlatform(&'a str)
Entry with payload for type AuxVarType::BasePlatform.
Random([u8; 16])
Entry with payload for type AuxVarType::Random.
This data owns the bytes rather than referencing to it,
because the operation is cheap anyway but it also simplified
parsing. Otherwise, I had to create a &'a [u8; 16] from a
&'a [u8], which is hard without hacky tricks.
HwCap2(usize)
Entry with payload for type AuxVarType::HwCap2.
ExecFn(&'a str)
Entry with payload for type AuxVarType::ExecFn.
Sysinfo(*const u8)
Entry with payload for type AuxVarType::Sysinfo.
SysinfoEhdr(*const u8)
Entry with payload for type AuxVarType::SysinfoEhdr.
L1iCacheSize(usize)
Entry with payload for type AuxVarType::L1iCacheSize.
L1iCacheGeometry(usize)
Entry with payload for type AuxVarType::L1iCacheGeometry.
L1dCacheSize(usize)
Entry with payload for type AuxVarType::L1dCacheSize.
L1dCacheGeometry(usize)
Entry with payload for type AuxVarType::L1dCacheGeometry.
L2CacheSize(usize)
Entry with payload for type AuxVarType::L2CacheSize.
L2CacheGeometry(usize)
Entry with payload for type AuxVarType::L2CacheGeometry.
L3CacheSize(usize)
Entry with payload for type AuxVarType::L3CacheSize.
L3CacheGeometry(usize)
Entry with payload for type AuxVarType::L3CacheGeometry.
MinSigStkSz(usize)
Entry with payload for type AuxVarType::MinSigStkSz.
Implementations§
Source§impl<'a> AuxVar<'a>
impl<'a> AuxVar<'a>
Sourcepub const fn key(&self) -> AuxVarType
pub const fn key(&self) -> AuxVarType
Returns the AuxVarType this aux var corresponds to.
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub fn value_raw(&self) -> usize
pub fn value_raw(&self) -> usize
Transforms any inner value into it’s corresponding usize value. This is similar to the data that is serialized in the data structure on the stack, i.e. the value of the auxiliary vector entry.
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub const fn value_integer(&self) -> Option<usize>
pub const fn value_integer(&self) -> Option<usize>
Returns a value, if the corresponding auxiliary vector entry corresponds to a basic value/integer, and not a pointer, flags, or a boolean.
Sourcepub const fn value_flags(&self) -> Option<AuxVarFlags>
pub const fn value_flags(&self) -> Option<AuxVarFlags>
Returns a value, if the corresponding auxiliary vector entry is of type AuxVarType::Flags.
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub const fn value_boolean(&self) -> Option<bool>
pub const fn value_boolean(&self) -> Option<bool>
Returns a value, if the corresponding auxiliary vector entry corresponds to a boolean, and not a pointer, flags, or a basic value/integer.
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub const fn value_ptr(&self) -> Option<*const u8>
pub const fn value_ptr(&self) -> Option<*const u8>
Returns a value, if the corresponding auxiliary vector entry corresponds to a pointer, and not a boolean, flags, or a basic value/integer. This only affects entries, that point to memory outside of the initial stack layout, i.e. the aux vector data area.
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub fn value_payload_bytes(&'a self) -> Option<&'a [u8]>
pub fn value_payload_bytes(&'a self) -> Option<&'a [u8]>
Returns a value, if the corresponding auxiliary vector entry references data in the
auxiliary vector data area of the data structure.
This returns only something for AuxVarType::Random.
This function is safe, because the creation during parsing already guarantee memory safety (the addresses are accessed).
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}Sourcepub const fn value_payload_cstr(&'a self) -> Option<&'a str>
pub const fn value_payload_cstr(&'a self) -> Option<&'a str>
Returns a value, if the corresponding auxiliary vector entry references data in the
auxiliary vector data area of the data structure.
This returns only something for AuxVarType::Random.
This function is safe, because the creation during parsing already guarantee memory safety (the addresses are accessed).
Examples found in repository?
116unsafe fn parse_memory_unsafe(parsed: &InitialLinuxLibcStackLayout) {
117 println!(" argv");
118 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
119 for (i, arg) in parsed.argv_iter().enumerate() {
120 println!(" [{}] {}", i, arg);
121 }
122
123 println!(" envp");
124 // ptr iter is safe for other address spaces; the other only because here user_addr == write_addr
125 for (i, env) in parsed.envv_iter().enumerate() {
126 println!(" [{}] {}", i, env);
127 }
128
129 println!(" aux");
130 for aux in parsed.aux_var_iter() {
131 // currently: Only AT_RANDOM
132 if let Some(bytes) = aux.value_payload_bytes() {
133 println!(
134 " {:>12?} => @ {:?}: {:?}",
135 aux.key(),
136 aux.value_raw() as *const u8,
137 bytes,
138 );
139 } else if let Some(cstr) = aux.value_payload_cstr() {
140 println!(
141 " {:>12?} => @ {:?}: {:?}",
142 aux.key(),
143 aux.value_raw() as *const u8,
144 cstr,
145 );
146 } else if let Some(flags) = aux.value_flags() {
147 println!(" {:>12?} => {:?}", aux.key(), flags,);
148 } else if let Some(boolean) = aux.value_boolean() {
149 println!(" {:>12?} => {:?}", aux.key(), boolean,);
150 } else if let Some(ptr) = aux.value_ptr() {
151 println!(" {:>12?} => {:?}", aux.key(), ptr,);
152 } else {
153 println!(" {:>12?} => {}", aux.key(), aux.value_raw());
154 }
155 }
156}