public void TestValidCall() { var module = new RuntimeIshtarModule(AppVault.CurrentVault, _module.Name); var b1 = new RuntimeIshtarClass("tst%global::foo/bar1", VeinTypeCode.TYPE_OBJECT.AsRuntimeClass(), module); var m1 = b1.DefineMethod("soq", VeinTypeCode.TYPE_VOID.AsRuntimeClass(), MethodFlags.Public | MethodFlags.Virtual); m1.PIInfo = PInvokeInfo.New(((delegate * < void >) & Foo1)); var b2 = new RuntimeIshtarClass("tst%global::foo/bar2", b1, module); var m2 = b2.DefineMethod("soq", VeinTypeCode.TYPE_VOID.AsRuntimeClass(), MethodFlags.Public | MethodFlags.Override); m2.PIInfo = PInvokeInfo.New(((delegate * < void >) & Foo2)); b2.init_vtable(); ((delegate * < void >)b2.Method["soq()"].PIInfo.Addr)(); var result = IshtarGC.AllocObject(b2); var pointer = result->vtable[m2.vtable_offset]; var d2 = IshtarUnsafe.AsRef <RuntimeIshtarMethod>(pointer); ((delegate * < void >)d2.PIInfo.Addr)(); }
public static RuntimeIshtarMethod GetEntryPoint(this RuntimeIshtarModule module, string name) { foreach (var method in module.class_table.SelectMany(x => x.Methods)) { if (!method.IsStatic) { continue; } if (method.Name == $"{name}()") { return((RuntimeIshtarMethod)method); } } return(null); }
public void ValidVTableInitialization() { var module = new RuntimeIshtarModule(AppVault.CurrentVault, _module.Name); var IFoo1 = new RuntimeIshtarClass("tst%global::foo/IFoo1", T.OBJECT, module); var IFoo2 = new RuntimeIshtarClass("tst%global::foo/IFoo2", T.OBJECT, module); IFoo1.Flags = ClassFlags.Interface | ClassFlags.Public | ClassFlags.Abstract; IFoo2.Flags = ClassFlags.Interface | ClassFlags.Public | ClassFlags.Abstract; IFoo1.DefineMethod("doodoo", T.VOID, MethodFlags.Abstract | MethodFlags.Public); IFoo2.DefineMethod("moomoo", T.VOID, MethodFlags.Abstract | MethodFlags.Public); var Zoo1 = new RuntimeIshtarClass("tst%global::foo/Zoo1", new [] { T.OBJECT, IFoo1, IFoo2 }, module); var method1 = Zoo1.DefineMethod("doodoo", T.VOID, MethodFlags.Override | MethodFlags.Public); var method2 = Zoo1.DefineMethod("moomoo", T.VOID, MethodFlags.Override | MethodFlags.Public); method1.PIInfo = (delegate * < void >) & Foo1; method2.PIInfo = (delegate * < void >) & Foo2; Assert.DoesNotThrow(() => Zoo1.init_vtable()); Assert.DoesNotThrow(() => ((delegate * < void >)Zoo1.Method["doodoo()"].PIInfo.Addr)()); Assert.DoesNotThrow(() => ((delegate * < void >)Zoo1.Method["moomoo()"].PIInfo.Addr)()); }