libmwemu 0.25.1

x86 32/64bits and system internals emulator, for securely emulating malware and other stuff.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::color;
use crate::emu::Emu;
use iced_x86::Instruction;

// BMI2 SARX dest, src, count : shift src by (count & size-1); flags unaffected.
pub fn execute(emu: &mut Emu, ins: &Instruction, _instruction_sz: usize, _rep_step: bool) -> bool {
    emu.show_instruction(color!("Green"), &crate::emu::decoded_instruction::DecodedInstruction::X86(*ins));
    let sz = emu.get_operand_sz(ins, 0) as u64;
    let src = emu.get_operand_value(ins, 1, true).unwrap_or(0);
    let cnt = emu.get_operand_value(ins, 2, true).unwrap_or(0);
    let shift = cnt & (sz - 1);
    let result = match sz { 64 => ((src as i64) >> shift) as u64, 32 => (((src as u32) as i32) >> shift) as u32 as u64, _ => return false };
    emu.set_operand_value(ins, 0, result);
    true
}