mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 07:28:13 +00:00
Added x86Msr functions for the go bindings (#986)
Backports commit d6d413187324e8d9dc852f62016863a44b240a7e from unicorn.
This commit is contained in:
parent
7cad644235
commit
d27ad4df1b
2 changed files with 18 additions and 0 deletions
|
@ -60,6 +60,8 @@ type Unicorn interface {
|
||||||
ContextSave(reuse Context) (Context, error)
|
ContextSave(reuse Context) (Context, error)
|
||||||
ContextRestore(Context) error
|
ContextRestore(Context) error
|
||||||
Handle() *C.uc_engine
|
Handle() *C.uc_engine
|
||||||
|
RegWriteX86Msr(reg uint64, val uint64) error
|
||||||
|
RegReadX86Msr(reg uint64) (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type uc struct {
|
type uc struct {
|
||||||
|
|
|
@ -36,3 +36,19 @@ func (u *uc) RegReadMmr(reg int) (*X86Mmr, error) {
|
||||||
}
|
}
|
||||||
return ret, errReturn(ucerr)
|
return ret, errReturn(ucerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *uc) RegWriteX86Msr(reg uint64, val uint64) error {
|
||||||
|
msr := C.uc_x86_msr{
|
||||||
|
rid: C.uint32_t(reg),
|
||||||
|
value: C.uint64_t(val),
|
||||||
|
}
|
||||||
|
return errReturn(C.uc_reg_write(u.handle, X86_REG_MSR, unsafe.Pointer(&msr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *uc) RegReadX86Msr(reg uint64) (uint64, error) {
|
||||||
|
msr := C.uc_x86_msr{
|
||||||
|
rid: C.uint32_t(reg),
|
||||||
|
}
|
||||||
|
ucerr := C.uc_reg_read(u.handle, X86_REG_MSR, unsafe.Pointer(&msr))
|
||||||
|
return uint64(msr.value), errReturn(ucerr)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue