public static ExecutionState Load(DarksVMContext ctx) { ExecutionState state = ExecutionState.Next; bool isAbnormal = true; do { try { state = DarkInternal(ctx); switch (state) { case ExecutionState.Throw: { uint sp = ctx.Registers[DarksVMConstants.REG_SP].U4; DarksVMSlot ex = ctx.Stack[sp--]; ctx.Registers[DarksVMConstants.REG_SP].U4 = sp; DoThrow(ctx, ex.O); break; } case ExecutionState.Rethrow: { uint sp = ctx.Registers[DarksVMConstants.REG_SP].U4; DarksVMSlot ex = ctx.Stack[sp--]; ctx.Registers[DarksVMConstants.REG_SP].U4 = sp; HandleRethrow(ctx, ex.O); return(state); } } isAbnormal = false; } catch (Exception ex) { // Patched to catch object SetupEHState(ctx, ex); isAbnormal = false; } finally { if (isAbnormal) { HandleAbnormalExit(ctx); state = ExecutionState.Exit; } else if (ctx.EHStates.Count > 0) { do { HandleEH(ctx, ref state); } while(state == ExecutionState.Rethrow); } } } while(state != ExecutionState.Exit); return(state); }
public DarksVMSlot GetValue(DarksVMContext ctx, PointerType type) { object inst = this.instance; if (this.field.DeclaringType.IsValueType && this.instance is IReference) { inst = ((IReference)this.instance).GetValue(ctx, PointerType.OBJECT).ToObject(this.field.DeclaringType); } return(DarksVMSlot.FromObject(this.field.GetValue(inst), this.field.FieldType)); }
public unsafe void SetValue(DarksVMContext ctx, DarksVMSlot slot, PointerType type) { if (this.field.DeclaringType.IsValueType && this.instance is IReference) { TypedReference typedRef; ((IReference)this.instance).ToTypedReference(ctx, &typedRef, this.field.DeclaringType); this.field.SetValueDirect(typedRef, slot.ToObject(this.field.FieldType)); } else { this.field.SetValue(this.instance, slot.ToObject(this.field.FieldType)); } }
public DarksVMSlot GetValue(DarksVMContext ctx, PointerType type) { TypedReference typedRef; if (this._ptr != null) { *&typedRef = *(TypedReference *)this._ptr.Value; } else { *(PseudoTypedRef *)&typedRef = this._typedRef; } return(DarksVMSlot.FromObject(TypedReference.ToObject(typedRef), __reftype(typedRef))); }
public void SetValue(DarksVMContext ctx, DarksVMSlot slot, PointerType type) { if (type == PointerType.BYTE) { slot.U8 = slot.U1; } else if (type == PointerType.WORD) { slot.U8 = slot.U2; } else if (type == PointerType.DWORD) { slot.U8 = slot.U4; } ctx.Stack[StackPos] = slot; }
private static void HandleAbnormalExit(DarksVMContext ctx) { DarksVMSlot oldBP = ctx.Registers[DarksVMConstants.REG_BP]; DarksVMSlot oldSP = ctx.Registers[DarksVMConstants.REG_SP]; for (int i = ctx.EHStack.Count - 1; i >= 0; i--) { EHFrame frame = ctx.EHStack[i]; if (frame.EHType == DarksVMConstants.EH_FAULT || frame.EHType == DarksVMConstants.EH_FINALLY) { SetupFinallyFrame(ctx, frame); Load(ctx); } } ctx.EHStack.Clear(); }
public void SetValue(DarksVMContext ctx, DarksVMSlot slot, PointerType type) { TypedReference typedRef; if (this._ptr != null) { *&typedRef = *(TypedReference *)this._ptr.Value; } else { *(PseudoTypedRef *)&typedRef = this._typedRef; } Type refType = __reftype(typedRef); object value = slot.ToObject(refType); TypedReferenceHelpers.SetTypedRef(value, &typedRef); }
public DarksVMSlot GetValue(DarksVMContext ctx, PointerType type) { DarksVMSlot slot = ctx.Stack[this.StackPos]; if (type == PointerType.BYTE) { slot.U8 = slot.U1; } else if (type == PointerType.WORD) { slot.U8 = slot.U2; } else if (type == PointerType.DWORD) { slot.U8 = slot.U4; } else if (slot.O is IValueTypeBox) { slot.O = ((IValueTypeBox)slot.O).Clone(); } return(slot); }
public void SetValue(DarksVMContext ctx, DarksVMSlot slot, PointerType type) { throw new NotSupportedException(); }