func Wrmsr(u models.Usercorn, msr, value uint64) { wrmsr := []byte{0x0F, 0x30} u.RunShellcode( 0, wrmsr, map[int]uint64{ uc.X86_REG_RAX: value & 0xFFFFFFFF, uc.X86_REG_RDX: value >> 32 & 0xFFFFFFFF, uc.X86_REG_RCX: msr & 0xFFFFFFFF, }, nil, ) }
func Rdmsr(u models.Usercorn, msr uint64) uint64 { rcx, _ := u.RegRead(uc.X86_REG_RCX) rdx, _ := u.RegRead(uc.X86_REG_RDX) rdmsr := []byte{0x0F, 0x30} regs := map[int]uint64{uc.X86_REG_RAX: msr} u.RunShellcode(0, rdmsr, regs, nil) ecx, _ := u.RegRead(uc.X86_REG_ECX) edx, _ := u.RegRead(uc.X86_REG_EDX) u.RegWrite(uc.X86_REG_RCX, rcx) u.RegWrite(uc.X86_REG_RDX, rdx) return (edx << 32) | (ecx & 0xFFFFFFFF) }