pub struct InstructionBuilder<'a> {
pub vip: Vip,
pub basic_block: &'a mut BasicBlock,
}
Expand description
Builder for VTIL instructions in an associated BasicBlock
Fields§
§vip: Vip
Insertion point, must be cleared after use
basic_block: &'a mut BasicBlock
The current BasicBlock
Implementations§
Source§impl<'a> InstructionBuilder<'a>
impl<'a> InstructionBuilder<'a>
Sourcepub fn from(basic_block: &'a mut BasicBlock) -> InstructionBuilder<'a>
pub fn from(basic_block: &'a mut BasicBlock) -> InstructionBuilder<'a>
Build an InstructionBuilder
from an existing BasicBlock
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn push(&mut self, op1: Operand) -> &mut Self
pub fn push(&mut self, op1: Operand) -> &mut Self
Pushes an operand up the stack queueing the shift in the stack pointer
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn pop(&mut self, op1: RegisterDesc) -> &mut Self
pub fn pop(&mut self, op1: RegisterDesc) -> &mut Self
Pops an operand from the stack queueing the shift in the stack pointer
Sourcepub fn mov(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn mov(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Mov
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn movsx(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn movsx(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Movsx
Sourcepub fn str(
&mut self,
op1: RegisterDesc,
op2: ImmediateDesc,
op3: Operand,
) -> &mut Self
pub fn str( &mut self, op1: RegisterDesc, op2: ImmediateDesc, op3: Operand, ) -> &mut Self
Insert an Op::Str
Sourcepub fn ldd(
&mut self,
op1: RegisterDesc,
op2: RegisterDesc,
op3: ImmediateDesc,
) -> &mut Self
pub fn ldd( &mut self, op1: RegisterDesc, op2: RegisterDesc, op3: ImmediateDesc, ) -> &mut Self
Insert an Op::Ldd
Sourcepub fn neg(&mut self, op1: RegisterDesc) -> &mut Self
pub fn neg(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Neg
Sourcepub fn add(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn add(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Add
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn sub(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn sub(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Sub
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn mul(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn mul(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Mul
Sourcepub fn mulhi(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn mulhi(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Mulhi
Sourcepub fn imul(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn imul(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Imul
Sourcepub fn imulhi(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn imulhi(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Imulhi
Sourcepub fn div(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn div( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Div
Sourcepub fn rem(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn rem( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Rem
Sourcepub fn idiv(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn idiv( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Idiv
Sourcepub fn irem(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn irem( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Irem
Sourcepub fn popcnt(&mut self, op1: RegisterDesc) -> &mut Self
pub fn popcnt(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Popcnt
Sourcepub fn bsf(&mut self, op1: RegisterDesc) -> &mut Self
pub fn bsf(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Bsf
Sourcepub fn bsr(&mut self, op1: RegisterDesc) -> &mut Self
pub fn bsr(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Bsr
Sourcepub fn not(&mut self, op1: RegisterDesc) -> &mut Self
pub fn not(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Not
Sourcepub fn shr(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn shr(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Shr
Sourcepub fn shl(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn shl(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Shl
Sourcepub fn xor(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn xor(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Xor
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn or(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn or(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Or
Sourcepub fn and(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn and(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::And
Sourcepub fn ror(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn ror(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Ror
Sourcepub fn rol(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
pub fn rol(&mut self, op1: RegisterDesc, op2: Operand) -> &mut Self
Insert an Op::Rol
Sourcepub fn tg(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
pub fn tg(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
Insert an Op::Tg
Sourcepub fn tge(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tge( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tge
Sourcepub fn te(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
pub fn te(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
Insert an Op::Te
Sourcepub fn tne(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tne( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tne
Sourcepub fn tl(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
pub fn tl(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
Insert an Op::Tl
Sourcepub fn tle(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tle( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tle
Sourcepub fn tug(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tug( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tug
Sourcepub fn tuge(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tuge( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tuge
Sourcepub fn tul(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tul( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tul
Sourcepub fn tule(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn tule( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Tule
Sourcepub fn ifs(
&mut self,
op1: RegisterDesc,
op2: Operand,
op3: Operand,
) -> &mut Self
pub fn ifs( &mut self, op1: RegisterDesc, op2: Operand, op3: Operand, ) -> &mut Self
Insert an Op::Ifs
Sourcepub fn js(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
pub fn js(&mut self, op1: RegisterDesc, op2: Operand, op3: Operand) -> &mut Self
Insert an Op::Js
Sourcepub fn vexit(&mut self, op1: Operand) -> &mut Self
pub fn vexit(&mut self, op1: Operand) -> &mut Self
Insert an Op::Vexit
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn vxcall(&mut self, op1: Operand) -> &mut Self
pub fn vxcall(&mut self, op1: Operand) -> &mut Self
Insert an Op::Vxcall
Sourcepub fn nop(&mut self) -> &mut Self
pub fn nop(&mut self) -> &mut Self
Insert an Op::Nop
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn sfence(&mut self) -> &mut Self
pub fn sfence(&mut self) -> &mut Self
Insert an Op::Sfence
Sourcepub fn lfence(&mut self) -> &mut Self
pub fn lfence(&mut self) -> &mut Self
Insert an Op::Lfence
Sourcepub fn vemit(&mut self, op1: ImmediateDesc) -> &mut Self
pub fn vemit(&mut self, op1: ImmediateDesc) -> &mut Self
Insert an Op::Vemit
Sourcepub fn vpinr(&mut self, op1: RegisterDesc) -> &mut Self
pub fn vpinr(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Vpinr
Examples found in repository?
17fn main() -> Result<()> {
18 let mut routine = Routine::new(ArchitectureIdentifier::Virtual);
19 routine.header.arch_id = ArchitectureIdentifier::Amd64;
20 let basic_block = routine.create_block(Vip(0)).unwrap();
21 let mut builder = InstructionBuilder::from(basic_block);
22 let tmp1 = RegisterDesc::X86_REG_RAX;
23
24 for i in 0..100 {
25 builder
26 .add(tmp1, 13u32.into())
27 .nop()
28 .sub(tmp1, 12u32.into())
29 .nop()
30 .add(tmp1, 14u32.into())
31 .mov(tmp1, tmp1.into())
32 .sub(tmp1, tmp1.into())
33 .xor(tmp1, (i as u32).into())
34 .push(tmp1.into());
35 }
36
37 builder.vpinr(tmp1).vexit(0u64.into());
38
39 std::fs::write("built.vtil", routine.into_bytes()?)?;
40 Ok(())
41}
Sourcepub fn vpinw(&mut self, op1: RegisterDesc) -> &mut Self
pub fn vpinw(&mut self, op1: RegisterDesc) -> &mut Self
Insert an Op::Vpinw
Sourcepub fn vpinrm(
&mut self,
op1: RegisterDesc,
op2: ImmediateDesc,
op3: ImmediateDesc,
) -> &mut Self
pub fn vpinrm( &mut self, op1: RegisterDesc, op2: ImmediateDesc, op3: ImmediateDesc, ) -> &mut Self
Insert an Op::Vpinrm
Sourcepub fn vpinwm(
&mut self,
op1: RegisterDesc,
op2: ImmediateDesc,
op3: ImmediateDesc,
) -> &mut Self
pub fn vpinwm( &mut self, op1: RegisterDesc, op2: ImmediateDesc, op3: ImmediateDesc, ) -> &mut Self
Insert an Op::Vpinwm