public KoiEmulator(RhydonContext ctx, MethodExport export) { _emuCtx = new EmuContext(ctx, export); ctx.Reader.BaseStream.Position = export.Offset; foreach (var h in typeof(KoiEmulator).Assembly.DefinedTypes .Where(t => !t.IsAbstract && typeof(KoiHandler).IsAssignableFrom(t)) .Select(ha => Activator.CreateInstance(ha, _emuCtx)).Cast <KoiHandler>().ToArray()) { _emuCtx.Handlers[h.Handles] = h; } foreach (var v in typeof(KoiEmulator).Assembly.DefinedTypes .Where(t => !t.IsAbstract && typeof(VCallHandler).IsAssignableFrom(t)) .Select(ha => Activator.CreateInstance(ha, _emuCtx)).Cast <VCallHandler>().ToArray()) { _emuCtx.VCallHandlers[v.VCall] = v; } ctx.Logger.Info($"Emulating virtualized method at offset: 0x{export.Offset:X8}"); _emuCtx.Registers[ctx.Constants.REG_K1] = new VMSlot { U4 = export.Key }; _emuCtx.Registers[ctx.Constants.REG_BP] = new VMSlot { U4 = 0 }; _emuCtx.Registers[ctx.Constants.REG_SP] = new VMSlot { U4 = (uint)(export.ArgumentTypes.Length + 1) }; _emuCtx.Registers[ctx.Constants.REG_IP] = new VMSlot { U8 = (ulong)ctx.Reader.BaseStream.Position }; }
public VMSlot GetValue(EmuContext ctx, PointerType type) { object obj = this.instance; bool flag = this.field.DeclaringType.IsValueType && this.instance is IReference; if (flag) { obj = ((IReference)this.instance).GetValue(ctx, PointerType.OBJECT).ToObject(this.field.DeclaringType); } return(VMSlot.FromObject(this.field.GetValue(obj), this.field.FieldType)); }
public unsafe void ToTypedReference(EmuContext ctx, TypedRefPtr typedRef, Type type) { bool flag = this._ptr != null; if (flag) { *(TypedReference *)typedRef = *(TypedReference *)this._ptr.Value; } else { *(TypedRef.PseudoTypedRef *)typedRef = this._typedRef; } }
public unsafe VMSlot GetValue(EmuContext ctx, PointerType type) { bool flag = this._ptr != null; TypedReference typedReference; if (flag) { *(&typedReference) = *(TypedReference *)this._ptr.Value; } else { *(TypedRef.PseudoTypedRef *)(&typedReference) = this._typedRef; } return(VMSlot.FromObject(TypedReference.ToObject(typedReference), __reftype(typedReference))); }
public unsafe void SetValue(EmuContext ctx, VMSlot slot, PointerType type) { bool flag = this.field.DeclaringType.IsValueType && this.instance is IReference; if (flag) { TypedReference obj; ((IReference)this.instance).ToTypedReference(ctx, (void *)(&obj), this.field.DeclaringType); this.field.SetValueDirect(obj, slot.ToObject(this.field.FieldType)); } else { this.field.SetValue(this.instance, slot.ToObject(this.field.FieldType)); } }
public unsafe void SetValue(EmuContext ctx, VMSlot slot, PointerType type) { bool flag = this._ptr != null; TypedReference typedReference; if (flag) { *(&typedReference) = *(TypedReference *)this._ptr.Value; } else { *(TypedRef.PseudoTypedRef *)(&typedReference) = this._typedRef; } Type typeFromHandle = __reftype(typedReference); object value = slot.ToObject(typeFromHandle); Helpers.TypedReferenceHelpers.SetTypedRef(value, (void *)(&typedReference)); }
public void ToTypedReference(EmuContext ctx, TypedRefPtr typedRef, Type type) { throw new NotImplementedException(); }
public void SetValue(EmuContext ctx, VMSlot slot, PointerType type) { throw new NotImplementedException(); }
public VMSlot GetValue(EmuContext ctx, PointerType type) { throw new NotImplementedException(); }
public void ToTypedReference(EmuContext ctx, TypedRefPtr typedRef, Type type) { Rhydon.Emulator.Helpers.TypedReferenceHelpers.GetFieldAddr(ctx, this.instance, this.field, typedRef); }