diff --git a/pkg/vm/context.go b/pkg/vm/context.go index 340a6a5b2..0ef87d9f2 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -144,7 +144,7 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) { opcode.ENDTRY, opcode.INITSSLOT, opcode.LDSFLD, opcode.STSFLD, opcode.LDARG, opcode.STARG, opcode.LDLOC, opcode.STLOC: numtoread = 1 - case opcode.INITSLOT, opcode.TRY: + case opcode.INITSLOT, opcode.TRY, opcode.CALLT: numtoread = 2 case opcode.JMPL, opcode.JMPIFL, opcode.JMPIFNOTL, opcode.JMPEQL, opcode.JMPNEL, opcode.JMPGTL, opcode.JMPGEL, opcode.JMPLTL, opcode.JMPLEL, diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 6e92c2298..bb7eca081 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -80,6 +80,9 @@ type VM struct { // SyscallHandler handles SYSCALL opcode. SyscallHandler func(v *VM, id uint32) error + // LoadToken handles CALLT opcode. + LoadToken func(id int32) error + trigger trigger.Type // Invocations is a script invocation counter. @@ -1276,6 +1279,12 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro v.call(ctx, ptr.Position()) + case opcode.CALLT: + id := int32(binary.LittleEndian.Uint16(parameter)) + if err := v.LoadToken(id); err != nil { + panic(err) + } + case opcode.SYSCALL: interopID := GetInteropID(parameter) err := v.SyscallHandler(v, interopID)