Struct lde::OcBuilder
[−]
[src]
pub struct OcBuilder { /* fields omitted */ }
Opcode builder.
Conveniently write new opcodes by their byte representation.
Methods
impl OcBuilder
[src]
pub fn new(len: usize) -> OcBuilder
[src]
Create a new opcode of specified length, clamped to 15.
The opcode is initialized to all zeroes.
pub fn write<T: Int>(self, offset: usize, val: T) -> OcBuilder
[src]
Methods from Deref<Target = OpCode>
pub fn read<T: Int>(&self, offset: usize) -> T
[src]
Helps reading immediate and displacement values.
Examples
// mov eax, 0x01010101 let opcode: &lde::OpCode = b"\xB8\x01\x01\x01\x01".into(); // reads the immedate value let result = opcode.read::<u32>(1); assert_eq!(result, 0x01010101);
Panics
Panics if offset..offset + sizeof(T)
is out of bounds.
pub fn write<T: Int>(&mut self, offset: usize, val: T) -> &mut OpCode
[src]
Helps writing immediate and displacement values.
Examples
// mov al, 1 let mut opcode = [0xb0, 0x01]; let opcode: &mut lde::OpCode = (&mut opcode).into(); // change the immediate to 0xff opcode.write(1, 0xff_u8); assert_eq!(opcode, &[0xb0, 0xff]);
Panics
Panics if offset..offset + sizeof(T)
is out of bounds.
Trait Implementations
impl Copy for OcBuilder
[src]
impl Clone for OcBuilder
[src]
fn clone(&self) -> OcBuilder
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for OcBuilder
[src]
impl Eq for OcBuilder
[src]
impl PartialEq for OcBuilder
[src]
fn eq(&self, __arg_0: &OcBuilder) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &OcBuilder) -> bool
[src]
This method tests for !=
.
impl Hash for OcBuilder
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: AsRef<[u8]>> From<T> for OcBuilder
[src]
Converts a template byte slice to an opcode builder.
The input length is clamped to 15 bytes.
impl Deref for OcBuilder
[src]
type Target = OpCode
The resulting type after dereferencing.
fn deref(&self) -> &OpCode
[src]
Dereferences the value.
impl DerefMut for OcBuilder
[src]
impl Debug for OcBuilder
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more