public static void Call() { IntPtr classAddress = NativeReflection.GetClass("/Script/UnrealEngine_Runtime.MyClass"); StringTest_FunctionAddress = NativeReflection.GetFunction(classAddress, "MyTestFunc2"); StringTest_ParamsSize = NativeReflection.GetFunctionParamsSize(StringTest_FunctionAddress); StringTest_inVal_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "inVal"); StringTest_stringTest_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "stringTest"); StringTest_ParamResult_Offset = NativeReflection.GetPropertyOffset(StringTest_FunctionAddress, "__return"); UMyClass myClass = UObject.NewObject <UMyClass>(); string refVal = "inref"; string arg = "hello world"; unsafe { byte * ParamsBufferAllocation = stackalloc byte[StringTest_ParamsSize]; IntPtr ParamsBuffer = new IntPtr(ParamsBufferAllocation); FStringMarshaler.ToNative(IntPtr.Add(ParamsBuffer, StringTest_inVal_Offset), refVal); //FStringMarshaler.ToNative(IntPtr.Add(ParamsBuffer, StringTest_stringTest_Offset), arg); NativeReflection.InvokeFunction(myClass.Address, StringTest_FunctionAddress, ParamsBuffer, StringTest_ParamsSize); refVal = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_inVal_Offset)); arg = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_stringTest_Offset)); string toReturn = FStringMarshaler.FromNative(IntPtr.Add(ParamsBuffer, StringTest_ParamResult_Offset)); NativeReflection.InvokeFunction_DestroyAll(StringTest_FunctionAddress, ParamsBuffer); } }
static void LoadNativeType() { //if (NativeReflection.CachedTypeInfo.Enabled) //{ // NativeReflection.CachedTypeInfo typeInfo = NativeReflection.CachedTypeInfo.BuildFunction("/Script/USharp.SomeDelegate__DelegateSignature"); // SomeDelegate__DelegateSignature_FunctionAddress = typeInfo.Address; // SomeDelegate__DelegateSignature_ParamsSize = typeInfo.Size; // SomeDelegate__DelegateSignature_IsValid = typeInfo.Exists; // typeInfo.LogIsValid(SomeDelegate__DelegateSignature_IsValid); //} //else { SomeDelegate__DelegateSignature_FunctionAddress = NativeReflection.GetFunction("/Script/USharp.SomeDelegate__DelegateSignature"); SomeDelegate__DelegateSignature_ParamsSize = NativeReflection.GetFunctionParamsSize(SomeDelegate__DelegateSignature_FunctionAddress); SomeDelegate__DelegateSignature_IsValid = SomeDelegate__DelegateSignature_FunctionAddress != IntPtr.Zero; NativeReflection.LogFunctionIsValid("/Script/USharp.SomeDelegate__DelegateSignature", SomeDelegate__DelegateSignature_IsValid); } }
static void LoadNativeType() { //if (NativeReflection.CachedTypeInfo.Enabled) //{ // NativeReflection.CachedTypeInfo typeInfo = NativeReflection.CachedTypeInfo.BuildFunction("/Script/USharp.DelegateRefTest__DelegateSignature"); // DelegateRefTest__DelegateSignature_FunctionAddress = typeInfo.Address; // DelegateRefTest__DelegateSignature_ParamsSize = typeInfo.Size; // DelegateRefTest__DelegateSignature_SomeArgument_IsValid = typeInfo.GetPropertyRefOffsetAndValidate("SomeArgument", ref DelegateRefTest__DelegateSignature_SomeArgument_PropertyAddress, out DelegateRefTest__DelegateSignature_SomeArgument_Offset, Classes.UIntProperty); // DelegateRefTest__DelegateSignature_IsValid = typeInfo.Exists && DelegateRefTest__DelegateSignature_SomeArgument_IsValid; // typeInfo.LogIsValid(DelegateRefTest__DelegateSignature_IsValid); //} //else { DelegateRefTest__DelegateSignature_FunctionAddress = NativeReflection.GetFunction("/Script/USharp.DelegateRefTest__DelegateSignature"); DelegateRefTest__DelegateSignature_ParamsSize = NativeReflection.GetFunctionParamsSize(DelegateRefTest__DelegateSignature_FunctionAddress); NativeReflectionCached.GetPropertyRef(ref DelegateRefTest__DelegateSignature_SomeArgument_PropertyAddress, DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument"); DelegateRefTest__DelegateSignature_SomeArgument_Offset = NativeReflectionCached.GetPropertyOffset(DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument"); DelegateRefTest__DelegateSignature_SomeArgument_IsValid = NativeReflectionCached.ValidatePropertyClass(DelegateRefTest__DelegateSignature_FunctionAddress, "SomeArgument", Classes.UIntProperty); DelegateRefTest__DelegateSignature_IsValid = DelegateRefTest__DelegateSignature_FunctionAddress != IntPtr.Zero && DelegateRefTest__DelegateSignature_SomeArgument_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.DelegateRefTest__DelegateSignature", DelegateRefTest__DelegateSignature_IsValid); } }
public static void Call2() { IntPtr classAddress = NativeReflection.GetClass("/Script/UnrealEngine_Runtime.MyClass"); Test2_FunctionAddress = NativeReflection.GetFunction(classAddress, "MyTestFunc3"); Test2_ParamsSize = NativeReflection.GetFunctionParamsSize(Test2_FunctionAddress); Test2_Param1_Offset = NativeReflection.GetPropertyOffset(Test2_FunctionAddress, "myStruct"); UMyClass myClass = UObject.NewObject <UMyClass>(); FMyStructCustomCtor val = StructDefault <FMyStructCustomCtor> .Value; unsafe { byte * ParamsBufferAllocation = stackalloc byte[Test2_ParamsSize]; IntPtr ParamsBuffer = new IntPtr(ParamsBufferAllocation); FMyStructCustomCtor.ToNative(IntPtr.Add(ParamsBuffer, Test2_Param1_Offset), val); NativeReflection.InvokeFunction(myClass.Address, Test2_FunctionAddress, ParamsBuffer, Test2_ParamsSize); NativeReflection.InvokeFunction_DestroyAll(Test2_FunctionAddress, ParamsBuffer); } }
static void LoadNativeType() { //if (NativeReflection.CachedTypeInfo.Enabled) //{ // NativeReflection.CachedTypeInfo typeInfo = NativeReflection.CachedTypeInfo.BuildClass("/Script/USharp.BPTest1"); // MyMap_IsValid = typeInfo.GetPropertyRefOffsetAndValidate("MyMap", ref MyMap_PropertyAddress, out MyMap_Offset, Classes.UMapProperty); // MySet_IsValid = typeInfo.GetPropertyRefOffsetAndValidate("MySet", ref MySet_PropertyAddress, out MySet_Offset, Classes.USetProperty); // NativeReflection.CachedTypeInfo CallMe6_FunctionInfo = typeInfo.GetFunction("CallMe6"); // CallMe6_FunctionAddress = CallMe6_FunctionInfo.Address; // CallMe6_ParamsSize = CallMe6_FunctionInfo.Size; // CallMe6_test_IsValid = CallMe6_FunctionInfo.GetPropertyOffsetAndValidate("test", out CallMe6_test_Offset, Classes.UStructProperty); // CallMe6_test2_IsValid = CallMe6_FunctionInfo.GetPropertyOffsetAndValidate("test2", out CallMe6_test2_Offset, Classes.UStructProperty); // CallMe6_IsValid = CallMe6_FunctionInfo.Exists && CallMe6_test_IsValid && CallMe6_test2_IsValid; // CallMe6_FunctionInfo.LogIsValid(CallMe6_IsValid); // NativeReflection.CachedTypeInfo CallMe5_FunctionInfo = typeInfo.GetFunction("CallMe5"); // CallMe5_FunctionAddress = CallMe5_FunctionInfo.Address; // CallMe5_ParamsSize = CallMe5_FunctionInfo.Size; // CallMe5_a1_IsValid = CallMe5_FunctionInfo.GetPropertyRefOffsetAndValidate("a1", ref CallMe5_a1_PropertyAddress, out CallMe5_a1_Offset, Classes.UArrayProperty); // CallMe5_a2_IsValid = CallMe5_FunctionInfo.GetPropertyRefOffsetAndValidate("a2", ref CallMe5_a2_PropertyAddress, out CallMe5_a2_Offset, Classes.UArrayProperty); // CallMe5_IsValid = CallMe5_FunctionInfo.Exists && CallMe5_a1_IsValid && CallMe5_a2_IsValid; // CallMe5_FunctionInfo.LogIsValid(CallMe5_IsValid); // NativeReflection.CachedTypeInfo CallMe4_FunctionInfo = typeInfo.GetFunction("CallMe4"); // CallMe4_FunctionAddress = CallMe4_FunctionInfo.Address; // CallMe4_ParamsSize = CallMe4_FunctionInfo.Size; // CallMe4_ReturnValue_IsValid = CallMe4_FunctionInfo.GetPropertyRefOffsetAndValidate("ReturnValue", ref CallMe4_ReturnValue_PropertyAddress, out CallMe4_ReturnValue_Offset, Classes.UArrayProperty); // CallMe4_IsValid = CallMe4_FunctionInfo.Exists && CallMe4_ReturnValue_IsValid; // CallMe4_FunctionInfo.LogIsValid(CallMe4_IsValid); // NativeReflection.CachedTypeInfo CallMe3_FunctionInfo = typeInfo.GetFunction("CallMe3"); // CallMe3_FunctionAddress = CallMe3_FunctionInfo.Address; // CallMe3_ParamsSize = CallMe3_FunctionInfo.Size; // CallMe3_ReturnValue_IsValid = CallMe3_FunctionInfo.GetPropertyRefOffsetAndValidate("ReturnValue", ref CallMe3_ReturnValue_PropertyAddress, out CallMe3_ReturnValue_Offset, Classes.UArrayProperty); // CallMe3_IsValid = CallMe3_FunctionInfo.Exists && CallMe3_ReturnValue_IsValid; // CallMe3_FunctionInfo.LogIsValid(CallMe3_IsValid); // NativeReflection.CachedTypeInfo CallMe2_FunctionInfo = typeInfo.GetFunction("CallMe2"); // CallMe2_FunctionAddress = CallMe2_FunctionInfo.Address; // CallMe2_ParamsSize = CallMe2_FunctionInfo.Size; // CallMe2_IsValid = CallMe2_FunctionInfo.Exists; // CallMe2_FunctionInfo.LogIsValid(CallMe2_IsValid); // NativeReflection.CachedTypeInfo CallMe_FunctionInfo = typeInfo.GetFunction("CallMe"); // CallMe_FunctionAddress = CallMe_FunctionInfo.Address; // CallMe_ParamsSize = CallMe_FunctionInfo.Size; // CallMe_IsValid = CallMe_FunctionInfo.Exists; // CallMe_FunctionInfo.LogIsValid(CallMe_IsValid); //} //else { IntPtr classAddress = NativeReflection.GetClass("/Script/USharp.BPTest1"); NativeReflectionCached.GetPropertyRef(ref MyMap_PropertyAddress, classAddress, "MyMap"); MyMap_Offset = NativeReflectionCached.GetPropertyOffset(classAddress, "MyMap"); MyMap_IsValid = NativeReflectionCached.ValidatePropertyClass(classAddress, "MyMap", Classes.UMapProperty); NativeReflectionCached.GetPropertyRef(ref MySet_PropertyAddress, classAddress, "MySet"); MySet_Offset = NativeReflectionCached.GetPropertyOffset(classAddress, "MySet"); MySet_IsValid = NativeReflectionCached.ValidatePropertyClass(classAddress, "MySet", Classes.USetProperty); CallMe6_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe6"); CallMe6_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe6_FunctionAddress); CallMe6_test_Offset = NativeReflectionCached.GetPropertyOffset(CallMe6_FunctionAddress, "test"); CallMe6_test_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe6_FunctionAddress, "test", Classes.UStructProperty); CallMe6_test2_Offset = NativeReflectionCached.GetPropertyOffset(CallMe6_FunctionAddress, "test2"); CallMe6_test2_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe6_FunctionAddress, "test2", Classes.UStructProperty); CallMe6_IsValid = CallMe6_FunctionAddress != IntPtr.Zero && CallMe6_test_IsValid && CallMe6_test2_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe6", CallMe6_IsValid); CallMe5_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe5"); CallMe5_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe5_FunctionAddress); NativeReflectionCached.GetPropertyRef(ref CallMe5_a1_PropertyAddress, CallMe5_FunctionAddress, "a1"); CallMe5_a1_Offset = NativeReflectionCached.GetPropertyOffset(CallMe5_FunctionAddress, "a1"); CallMe5_a1_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe5_FunctionAddress, "a1", Classes.UArrayProperty); NativeReflectionCached.GetPropertyRef(ref CallMe5_a2_PropertyAddress, CallMe5_FunctionAddress, "a2"); CallMe5_a2_Offset = NativeReflectionCached.GetPropertyOffset(CallMe5_FunctionAddress, "a2"); CallMe5_a2_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe5_FunctionAddress, "a2", Classes.UArrayProperty); CallMe5_IsValid = CallMe5_FunctionAddress != IntPtr.Zero && CallMe5_a1_IsValid && CallMe5_a2_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe5", CallMe5_IsValid); CallMe4_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe4"); CallMe4_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe4_FunctionAddress); NativeReflectionCached.GetPropertyRef(ref CallMe4_ReturnValue_PropertyAddress, CallMe4_FunctionAddress, "ReturnValue"); CallMe4_ReturnValue_Offset = NativeReflectionCached.GetPropertyOffset(CallMe4_FunctionAddress, "ReturnValue"); CallMe4_ReturnValue_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe4_FunctionAddress, "ReturnValue", Classes.UArrayProperty); CallMe4_IsValid = CallMe4_FunctionAddress != IntPtr.Zero && CallMe4_ReturnValue_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe4", CallMe4_IsValid); CallMe3_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe3"); CallMe3_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe3_FunctionAddress); NativeReflectionCached.GetPropertyRef(ref CallMe3_ReturnValue_PropertyAddress, CallMe3_FunctionAddress, "ReturnValue"); CallMe3_ReturnValue_Offset = NativeReflectionCached.GetPropertyOffset(CallMe3_FunctionAddress, "ReturnValue"); CallMe3_ReturnValue_IsValid = NativeReflectionCached.ValidatePropertyClass(CallMe3_FunctionAddress, "ReturnValue", Classes.UArrayProperty); CallMe3_IsValid = CallMe3_FunctionAddress != IntPtr.Zero && CallMe3_ReturnValue_IsValid; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe3", CallMe3_IsValid); CallMe2_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe2"); CallMe2_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe2_FunctionAddress); CallMe2_IsValid = CallMe2_FunctionAddress != IntPtr.Zero; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe2", CallMe2_IsValid); CallMe_FunctionAddress = NativeReflectionCached.GetFunction(classAddress, "CallMe"); CallMe_ParamsSize = NativeReflection.GetFunctionParamsSize(CallMe_FunctionAddress); CallMe_IsValid = CallMe_FunctionAddress != IntPtr.Zero; NativeReflection.LogFunctionIsValid("/Script/USharp.BPTest1:CallMe", CallMe_IsValid); } }