Go: add context api (#668)
This commit is contained in:
committed by
Nguyen Anh Quynh
parent
19028f41f6
commit
64f4692c22
26
bindings/go/unicorn/context_test.go
Normal file
26
bindings/go/unicorn/context_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package unicorn
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestContext(t *testing.T) {
|
||||
u, err := NewUnicorn(ARCH_X86, MODE_32)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
u.RegWrite(X86_REG_EBP, 100)
|
||||
ctx, err := u.ContextSave(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
u.RegWrite(X86_REG_EBP, 200)
|
||||
err = u.ContextRestore(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
val, _ := u.RegRead(X86_REG_EBP)
|
||||
if val != 100 {
|
||||
t.Fatal("context restore failed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user