Пример #1
0
 public static void SaveStringToFile(string s, string filter = null)
 {
     try
     {
         SaveFileDialog f = new SaveFileDialog();
         if (filter == null)
         {
             f.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";
         }
         else
         {
             f.Filter = filter;
         }
         if (f.ShowDialog().Value)
         {
             using (var tw = File.CreateText(f.FileName))
                 tw.Write(s);
         }
     }
     catch (Exception ex)
     {
         LogSupport.Error(ex);
         throw ex;
     }
 }
Пример #2
0
        public static string LoadStringFromFile(string filter = null)
        {
            OpenFileDialog f = new OpenFileDialog();

            if (filter == null)
            {
                f.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";
            }
            else
            {
                f.Filter = filter;
            }
            try
            {
                if (f.ShowDialog().Value)
                {
                    var s = File.ReadAllText(f.FileName);
                    return(s);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("load fail");
                LogSupport.Error(e);
            }
            return(null);
        }
Пример #3
0
        public static T LoadFromFile <T>(string filter = null)
        {
            OpenFileDialog f = new OpenFileDialog();

            if (filter == null)
            {
                f.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";
            }
            else
            {
                f.Filter = filter;
            }
            try
            {
                if (f.ShowDialog().Value)
                {
                    return(CommonProc.LoadObjFromFile <T>(f.FileName));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("load fail");
                LogSupport.Error(e);
            }
            return(default(T));
        }
Пример #4
0
        async void CopyFiltToResourceFolder(StorageFile f)
        {
            var folder = await GetResourceFolder();

            if (folder != null)
            {
                try
                {
                    var item = await folder.GetItemAsync(f.Name);

                    CommonProc.ShowMessage("Error", "File named " + f.Name + " have already exist in folder");
                    return;
                }
                catch (FileNotFoundException)
                {
                }
                await f.CopyAsync(folder);
            }
            else
            {
                try
                {
                    CommonProc.ShowMessage("Error", "no valid folder for copy");
                }
                catch (Exception e)
                {
                    LogSupport.Error(e);
                }
            }
        }
Пример #5
0
 private static ISupportModule_To Initialize(ISupportModule_From interface_from)
 {
     Interface = interface_from;
     LogSupport.RemoveAllHandlers();
     if (MelonDebug.IsEnabled())
     {
         LogSupport.InfoHandler += MelonLogger.Msg;
     }
     LogSupport.WarningHandler += MelonLogger.Warning;
     LogSupport.ErrorHandler   += MelonLogger.Error;
     if (MelonDebug.IsEnabled())
     {
         LogSupport.TraceHandler += MelonLogger.Msg;
     }
     ClassInjector.DoHook = MelonUtils.NativeHookAttach;
     InitializeUnityVersion();
     ConsoleCleaner();
     SceneManager.sceneLoaded = (
         (SceneManager.sceneLoaded == null)
            ? new Action <Scene, LoadSceneMode>(OnSceneLoad)
            : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >()
         );
     Camera.onPostRender = (
         (Camera.onPostRender == null)
         ? new Action <Camera>(OnPostRender)
         : Il2CppSystem.Delegate.Combine(Camera.onPostRender, (Camera.CameraCallback) new Action <Camera>(OnPostRender)).Cast <Camera.CameraCallback>()
         );
     ClassInjector.RegisterTypeInIl2Cpp <Component>();
     Component.Create();
     return(new SupportModule_To());
 }
        void MarketSurface()
        {
            if (!CanStart())
            {
                return;
            }
            var control = new DistributeSurfaceControl();
            var vm      = new DistributeSurfaceViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("Trend Market(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try {
                    Save();
                    var ml = TargetObject.GetMarketDataList();
                    var tl = TargetObject.GetDistributeTrendByMarket(ml);
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(tl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
        void Surface()
        {
            var control = new SurfaceControl();
            var vm      = new SurfaceControlViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("3 Matrix Analyse(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Save();
                    Dictionary <string, List <Tuple <double, double, double> > > rl = TargetObject.Get3DCurve();


                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(rl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
        void DimentionAnalyse()
        {
            var control = new DimentionAnalyseControl();
            var vm      = new DimentionAnalyseControlViewModel()
            {
                IsBusy = true
            };

            control.DataContext = vm;
            OpenView("Dimention Analyse(" + ProcessMode.ToString() + "):" + GetHeader(), control);
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Save();
                    var rl = TargetObject.GetDimentionAnalyse();


                    App.Current.Dispatcher.Invoke(() =>
                    {
                        vm.LoadData(rl);
                    });
                }
                catch (Exception ex)
                {
                    LogSupport.Error(ex);
                }
            }).ContinueWith((t) =>
            {
                vm.IsBusy = false;
            });
        }
Пример #9
0
        public static void DoPass(RewriteGlobalContext context)
        {
            var typesUnstripped = 0;

            foreach (var unityAssembly in context.UnityAssemblies.Assemblies)
            {
                var processedAssembly = context.TryGetAssemblyByName(unityAssembly.Name.Name);
                if (processedAssembly == null)
                {
                    var newAssembly = new AssemblyRewriteContext(context, unityAssembly,
                                                                 AssemblyDefinition.CreateAssembly(unityAssembly.Name, unityAssembly.MainModule.Name,
                                                                                                   ModuleKind.Dll));
                    context.AddAssemblyContext(unityAssembly.Name.Name, newAssembly);
                    processedAssembly = newAssembly;
                }
                var imports = processedAssembly.Imports;

                foreach (var unityType in unityAssembly.MainModule.Types)
                {
                    ProcessType(processedAssembly, unityType, null, imports, ref typesUnstripped);
                }
            }

            LogSupport.Trace(""); // end the progress message
            LogSupport.Trace($"{typesUnstripped} types restored");
        }
Пример #10
0
        public static void RefreshAllInstrument()
        {
            var connectionStr = ConfigurationManager.ConnectionStrings["MarketDataConnectionString"];

            try
            {
                using (var conn = new SqlConnection(connectionStr.ConnectionString))
                {
                    conn.Open();
                    var rl = conn.Query <Instrument>("Select * from Table_Instruments", new { }, null, true, 60000).ToList();
                    foreach (var r in rl)
                    {
                        r.Ticker    = r.Ticker.Trim();
                        r.Currency  = r.Currency.Trim();
                        r.Industory = r.Industory.Trim();
                        r.Name      = r.Name.Trim();
                        r.Region    = r.Region.Trim();
                        if (r.Memo != null)
                        {
                            r.Memo = r.Memo.Trim();
                        }

                        _AllInstrumentList.Add(r);
                    }
                }
            }catch (Exception ex)
            {
                LogSupport.Error(ex);
            }
        }
Пример #11
0
        private static void HookClassFromType()
        {
            LogSupport.Info("xref scanning type to class");
            var lib = LoadLibrary("GameAssembly.dll");

            LogSupport.Info($"lib: {lib}");
            var classFromTypeEntryPoint = GetProcAddress(lib, nameof(IL2CPP.il2cpp_class_from_il2cpp_type));

            LogSupport.Info($"hook_method: {classFromTypeEntryPoint}");


            var scanner      = new XrefScanner(classFromTypeEntryPoint);
            var targetMethod = scanner.JumpTargets().Single();

            LogSupport.Info($"target_method: {targetMethod}");

            if (targetMethod == IntPtr.Zero)
            {
                return;
            }

            IntPtr *targetVarPointer = &targetMethod;

            DoHook((IntPtr)targetVarPointer,
                   Marshal.GetFunctionPointerForDelegate(new TypeToClassDelegate(ClassFromTypePatch)));
            ourOriginalTypeToClassMethod = Marshal.GetDelegateForFunctionPointer <TypeToClassDelegate>(targetMethod);

            LogSupport.Info("patched");
        }
Пример #12
0
        public static void Setup()
        {
#if DEBUG
            Console.WriteLine(Environment.Version);
            Console.WriteLine(Application.unityVersion);
            Console.WriteLine(Directory.GetCurrentDirectory());

            LogSupport.RemoveAllHandlers();
            LogSupport.TraceHandler   += LogSupport_TraceHandler;
            LogSupport.ErrorHandler   += LogSupport_TraceHandler;
            LogSupport.InfoHandler    += LogSupport_TraceHandler;
            LogSupport.WarningHandler += LogSupport_TraceHandler;
#endif

            ClassInjector.DoHook?.GetInvocationList().ToList().ForEach(d => ClassInjector.DoHook -= (Action <IntPtr, IntPtr>)d);
            ClassInjector.DoHook += JmpPatch;
            UnityVersionHandler.Initialize(2019, 3, 14);
            ClassInjector.RegisterTypeInIl2Cpp <ModManager>();

            while (BaseObject = GameObject.Find("ModManager"))
            {
                GameObject.DestroyImmediate(BaseObject);
            }
            BaseObject = new GameObject("ModManager");
            GameObject.DontDestroyOnLoad(BaseObject);
            var modMgr = BaseObject.AddComponent <ModManager>();
            var types  = Assembly.GetExecutingAssembly().GetTypes().ToList().Where(t => t.BaseType == typeof(ModBase) && !t.IsNested);
            foreach (var type in types)
            {
                modMgr.Mods.Add((ModBase)Activator.CreateInstance(type));
            }
        }
Пример #13
0
        private static bool IsMethodEligible(MethodInfo method)
        {
            if (method.IsGenericMethod || method.IsGenericMethodDefinition)
            {
                return(false);
            }
            if (method.Name == "Finalize")
            {
                return(false);
            }
            if (method.IsStatic || method.IsAbstract)
            {
                return(false);
            }
            if (!IsTypeSupported(method.ReturnType))
            {
                LogSupport.Warning($"Method {method} on type {method.DeclaringType} has unsupported return type {method.ReturnType}");
                return(false);
            }

            foreach (var parameter in method.GetParameters())
            {
                var parameterType = parameter.ParameterType;
                if (!IsTypeSupported(parameterType))
                {
                    LogSupport.Warning($"Method {method} on type {method.DeclaringType} has unsupported parameter {parameter} of type {parameterType}");
                    return(false);
                }
            }

            return(true);
        }
Пример #14
0
 void RefreshOperation()
 {
     while (_IsRunning)
     {
         Thread.Sleep(RefreshFrequency);
         App.Current.Dispatcher.Invoke(() =>
         {
             try {
                 ObersverObject.Refresh();
             }
             catch (Exception ex)
             {
                 LogSupport.Error(ex);
             }
             if (!ObersverObject.NeedRefresh())
             {
                 _IsRunning = false;
             }
             //lock (ObersverObjectList)
             //{
             //    ObersverObjectList.ForEach(v => v.Refresh());
             //    ObersverObjectList.RemoveAll(v => !v.NeedRefresh());
             //    if (ObersverObjectList.Count == 0)
             //        _IsRunning = false;
             //}
         });
     }
 }
Пример #15
0
        public void ExportToHtml(string filePath, int sheetIndex, string path)
        {
            Microsoft.Office.Interop.Excel.Application xlApp = null;
            Workbook xlWorkBook = null;

            try
            {
                xlApp      = new Microsoft.Office.Interop.Excel.Application();
                xlWorkBook = xlApp.Application.Workbooks.Open(filePath);
                var    sheet  = xlWorkBook.Worksheets[sheetIndex];
                object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
                sheet.SaveAs(path, format);
            }
            catch (Exception ex)
            {
                LogSupport.Error(ex);
            }
            finally
            {
                if (xlWorkBook != null)
                {
                    xlWorkBook.Close(true, null, null);
                }
                Thread.Sleep(5000);
                if (xlApp != null)
                {
                    xlApp.Quit();
                }
                Thread.Sleep(5000);
            }
        }
Пример #16
0
        public static void Setup()
        {
            IL2CPP.il2cpp_thread_attach(IL2CPP.il2cpp_domain_get());
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Console.WriteLine(Environment.Version);
            Console.WriteLine(Application.unityVersion);
            Console.WriteLine(Directory.GetCurrentDirectory());
            UnhollowerBaseLib.Runtime.UnityVersionHandler.Initialize(2018, 4, 20);
            LogSupport.RemoveAllHandlers();
            LogSupport.TraceHandler   += LogSupport_TraceHandler;
            LogSupport.ErrorHandler   += LogSupport_TraceHandler;
            LogSupport.InfoHandler    += LogSupport_TraceHandler;
            LogSupport.WarningHandler += LogSupport_TraceHandler;

            ClassInjector.Detour = new DoHookDetour();
            //ClassInjector.DoHook?.GetInvocationList().ToList().ForEach(d => ClassInjector.DoHook -= (Action<IntPtr, IntPtr>)d);
            //ClassInjector.DoHook += JmpPatch;
            ClassInjector.RegisterTypeInIl2Cpp <ModManager>();
            while (BaseObject = GameObject.Find("ModManager"))
            {
                GameObject.DestroyImmediate(BaseObject);
            }
            BaseObject = new GameObject("ModManager");
            GameObject.DontDestroyOnLoad(BaseObject);
            var modMgr = BaseObject.AddComponent <ModManager>();
            var types  = Assembly.GetExecutingAssembly().GetTypes().ToList().Where(t => t.BaseType == typeof(ModBase) && !t.IsNested);

            foreach (var type in types)
            {
                modMgr.Mods.Add((ModBase)Activator.CreateInstance(type));
            }
        }
Пример #17
0
        List <double> GetMA(List <IMarketData> marketDataList, int n)
        {
            try
            {
                var      valueList = new List <double>();
                int      begin     = 0;
                int      rlength   = 0;
                int      rbegin    = 0;
                double[] values    = new double[marketDataList.Count];
                var      dataList  = marketDataList.Select(v => v.Close).ToArray();
                Core.Sma(begin, marketDataList.Count - 1, dataList, n, out rbegin, out rlength, values);
                valueList = values.ToList();
                CommonProc.TrimDoubleList(valueList);
                if (IsAnalyse)
                {
                    if (valueList.Count > 0)
                    {
                        var o = new TimeValueObject()
                        {
                            Name = Name, Value = valueList.LastOrDefault()
                        };
                        o.Time = marketDataList.LastOrDefault().Time;
                        AddReference(n.ToString(), o);
                    }
                }

                return(valueList);
            }
            catch (Exception ex)
            {
                LogSupport.Error(ex);
                throw ex;
            }
        }
        public IEnumerable <IntPtr> JumpTargets()
        {
            var formatter = new IntelFormatter();
            var builder   = new StringBuilder();

            while (true)
            {
                myDecoder.Decode(out var instruction);
                builder.Clear();
                formatter.Format(in instruction, new StringOutput(builder));
                LogSupport.Trace($"Decoded instruction: {builder}");
                if (myDecoder.InvalidNoMoreBytes)
                {
                    yield break;
                }
                if (instruction.FlowControl == FlowControl.Return)
                {
                    yield break;
                }

                if (instruction.FlowControl == FlowControl.UnconditionalBranch || instruction.FlowControl == FlowControl.Call)
                {
                    yield return((IntPtr)ExtractTargetAddress(in instruction));

                    if (instruction.FlowControl == FlowControl.UnconditionalBranch)
                    {
                        yield break;
                    }
                }
            }
        }
Пример #19
0
        public static void DoPass(RewriteGlobalContext context)
        {
            var unityAssemblyFiles = Directory.EnumerateFiles(context.Options.UnityBaseLibsDir, "*.dll");
            var loadedAssemblies   = unityAssemblyFiles.Select(it =>
                                                               AssemblyDefinition.ReadAssembly(it, new ReaderParameters(ReadingMode.Deferred))).ToList();

            var typesUnstripped = 0;

            foreach (var unityAssembly in loadedAssemblies)
            {
                var processedAssembly = context.TryGetAssemblyByName(unityAssembly.Name.Name);
                if (processedAssembly == null)
                {
                    continue;
                }
                var imports = processedAssembly.Imports;

                foreach (var unityType in unityAssembly.MainModule.Types)
                {
                    ProcessType(processedAssembly, unityType, null, imports, ref typesUnstripped);
                }
            }

            LogSupport.Trace(""); // end the progress message
            LogSupport.Trace($"{typesUnstripped} types restored");
        }
Пример #20
0
        public static void DoPass(RewriteGlobalContext context)
        {
            var targetAssembly = context.TryGetAssemblyByName("UnityEngine");

            if (targetAssembly == null)
            {
                LogSupport.Info("No UnityEngine.dll, will not generate forwarders");
                return;
            }

            var targetModule = targetAssembly.NewAssembly.MainModule;

            foreach (var assemblyRewriteContext in context.Assemblies)
            {
                if (!assemblyRewriteContext.NewAssembly.Name.Name.StartsWith("UnityEngine."))
                {
                    continue;
                }
                foreach (var mainModuleType in assemblyRewriteContext.NewAssembly.MainModule.Types)
                {
                    var importedType = targetModule.ImportReference(mainModuleType);
                    var exportedType = new ExportedType(mainModuleType.Namespace, mainModuleType.Name, importedType.Module, importedType.Scope)
                    {
                        Attributes = TypeAttributes.Forwarder
                    };
                    targetModule.ExportedTypes.Add(exportedType);

                    AddNestedTypes(mainModuleType, exportedType, targetModule);
                }
            }
        }
Пример #21
0
        private static ISupportModule Initialize()
        {
            LogSupport.RemoveAllHandlers();
            if (true)
            {
                LogSupport.InfoHandler += MelonLogger.Log;
            }
            LogSupport.WarningHandler += MelonLogger.LogWarning;
            LogSupport.ErrorHandler   += MelonLogger.LogError;
            if (true)
            {
                LogSupport.TraceHandler += MelonLogger.Log;
            }

            ClassInjector.DoHook += Imports.Hook;
            GetUnityVersionNumbers(out var major, out var minor, out var patch);
            UnityVersionHandler.Initialize(major, minor, patch);

            // Il2CppSystem.Console.SetOut(new Il2CppSystem.IO.StreamWriter(Il2CppSystem.IO.Stream.Null));
            try
            {
                var il2CppSystemAssembly = Assembly.Load("Il2Cppmscorlib");

                var consoleType      = il2CppSystemAssembly.GetType("Il2CppSystem.Console");
                var streamWriterType = il2CppSystemAssembly.GetType("Il2CppSystem.IO.StreamWriter");
                var streamType       = il2CppSystemAssembly.GetType("Il2CppSystem.IO.Stream");

                var setOutMethod     = consoleType.GetMethod("SetOut", BindingFlags.Static | BindingFlags.Public);
                var nullStreamField  = streamType.GetProperty("Null", BindingFlags.Static | BindingFlags.Public).GetGetMethod();
                var streamWriterCtor = streamWriterType.GetConstructor(new[] { streamType });

                var nullStream  = nullStreamField.Invoke(null, new object[0]);
                var steamWriter = streamWriterCtor.Invoke(new[] { nullStream });
                setOutMethod.Invoke(null, new[] { steamWriter });
            }
            catch (Exception ex)
            {
                MelonLogger.LogError($"Console cleaning failed: {ex}");
            }

            SetAsLastSiblingDelegateField = IL2CPP.ResolveICall <SetAsLastSiblingDelegate>("UnityEngine.Transform::SetAsLastSibling");

            ClassInjector.RegisterTypeInIl2Cpp <MelonLoaderComponent>();
            //MelonLogger.Log("ClassInjector.RegisterTypeInIl2Cpp<MelonLoaderComponent> done");
            MelonLoaderComponent.Create();
            //MelonLogger.Log("MelonLoaderComponent.Create() done");
            SceneManager.sceneLoaded = (
                (SceneManager.sceneLoaded == null)
                ? new Action <Scene, LoadSceneMode>(OnSceneLoad)
                : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >()
                );
            Camera.onPostRender = (
                (Camera.onPostRender == null)
                ? new Action <Camera>(OnPostRender)
                : Il2CppSystem.Delegate.Combine(Camera.onPostRender, (Camera.CameraCallback) new Action <Camera>(OnPostRender)).Cast <Camera.CameraCallback>()
                );

            return(new Module());
        }
Пример #22
0
        protected override ISignal Calculate(IInstrument instrument, DateTime startTime, DateTime endTime, MarketDataGrade?grade)
        {
            isSignalBiggerMeansBetter = true;
            if (grade == null)
            {
                grade = Grade;
            }
            try
            {
                var dl  = AnalyseDataSource.GetDataList(instrument, startTime, endTime, grade.Value);
                var RSI = new double[dl.Count];

                int bindex;
                int element;

                Core.Rsi(0, dl.Count - 1, dl.Select(p => p.Close).ToArray(),
                         Period, out bindex, out element, RSI);
                var valueList = RSI.ToList();
                CommonProc.TrimDoubleList(valueList);
                if (IsAnalyse)
                {
                    //if (!AnalyseValueList.ContainsKey("RSI"))
                    //{
                    //    AnalyseValueList.Add("RSI", new List<TimeValueObject>());
                    //}


                    if (valueList.Count > 0)
                    {
                        //AddSignal(instrument, dl.Max(v => v.Time), valueList.LastOrDefault(), dl.LastOrDefault().Close, "RSI", SignalType.Analyse);
                        var obj = new TimeValueObject()
                        {
                            Name = Name, Value = valueList.LastOrDefault()
                        };
                        obj.Time = dl.Max(v => v.Time);
                        AddReference("RSI", obj);
                        //AnalyseValueList["RSI"].Add(obj);
                        //var dif = dl.Count - valueList.Count;
                        //for (int i = valueList.Count - 1; i >= 0; i--)
                        //{

                        //    var o = new TimeValueObject() { Name = Name, Value = valueList[i] };
                        //    o.Time = dl[dif + i].Time;
                        //    AddReference("RSI", o);
                        //}
                    }
                }
                //var o = new TimeValueObject() { Name = Name, Time = endTime, Value = null };
                //o.Time = dl.Max(v => v.Time);
                //o.Value = RSI.ToArray().LastOrDefault();
                return(CreateSignal(instrument, dl.Max(v => v.Time), RSI.ToArray().LastOrDefault(), dl.LastOrDefault().Close));
            }
            catch (Exception e)
            {
                LogSupport.Error(e);
            }
            return(null);
        }
Пример #23
0
        private static ISupportModule_To Initialize(ISupportModule_From interface_from)
        {
            Interface = interface_from;
            UnityMappers.RegisterMappers();

            LogSupport.RemoveAllHandlers();
            if (MelonDebug.IsEnabled())
            {
                LogSupport.InfoHandler += MelonLogger.Msg;
            }
            LogSupport.WarningHandler += MelonLogger.Warning;
            LogSupport.ErrorHandler   += MelonLogger.Error;
            if (MelonDebug.IsEnabled())
            {
                LogSupport.TraceHandler += MelonLogger.Msg;
            }

            ClassInjector.Detour = new UnhollowerDetour();
            UnityVersionHandler.Initialize(
                InternalUtils.UnityInformationHandler.EngineVersion.Major,
                InternalUtils.UnityInformationHandler.EngineVersion.Minor,
                InternalUtils.UnityInformationHandler.EngineVersion.Build);

            if (MelonLaunchOptions.Console.CleanUnityLogs)
            {
                ConsoleCleaner();
            }

            try
            {
                SceneManager.sceneLoaded = (
                    (ReferenceEquals(SceneManager.sceneLoaded, null))
                    ? new Action <Scene, LoadSceneMode>(OnSceneLoad)
                    : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >()
                    );
            }
            catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); }

            try
            {
                SceneManager.sceneUnloaded = (
                    (ReferenceEquals(SceneManager.sceneUnloaded, null))
                    ? new Action <Scene>(OnSceneUnload)
                    : Il2CppSystem.Delegate.Combine(SceneManager.sceneUnloaded, (UnityAction <Scene>) new Action <Scene>(OnSceneUnload)).Cast <UnityAction <Scene> >()
                    );
            }
            catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); }

            MonoEnumeratorWrapper.Register();

            ClassInjector.RegisterTypeInIl2Cpp <SM_Component>();
            SM_Component.Create();
            unhollower = new UnhollowerInterface();
            Interface.SetUnhollowerSupportInterface(unhollower);
            HarmonyLib.Public.Patching.PatchManager.ResolvePatcher += HarmonyMethodPatcher.TryResolve;

            return(new SupportModule_To());
        }
Пример #24
0
        internal static ISupportModule_To Initialize(ISupportModule_From interface_from)
        {
            Interface = interface_from;
            UnityMappers.RegisterMappers();

            LogSupport.RemoveAllHandlers();
            if (MelonDebug.IsEnabled())
            {
                LogSupport.InfoHandler += MelonLogger.Msg;
            }
            LogSupport.WarningHandler += MelonLogger.Warning;
            LogSupport.ErrorHandler   += MelonLogger.Error;
            if (MelonDebug.IsEnabled())
            {
                LogSupport.TraceHandler += MelonLogger.Msg;
            }

            ClassInjector.Detour = new UnhollowerDetour();
            InitializeUnityVersion();
            ConsoleCleaner();

            try
            {
                SceneManager.sceneLoaded = (
                    (SceneManager.sceneLoaded == null)
                    ? new Action <Scene, LoadSceneMode>(OnSceneLoad)
                    : Il2CppSystem.Delegate.Combine(SceneManager.sceneLoaded, (UnityAction <Scene, LoadSceneMode>) new Action <Scene, LoadSceneMode>(OnSceneLoad)).Cast <UnityAction <Scene, LoadSceneMode> >()
                    );
            }
            catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneLoaded override failed: {ex}"); }

            try
            {
                SceneManager.sceneUnloaded = (
                    (SceneManager.sceneUnloaded == null)
                    ? new Action <Scene>(OnSceneUnload)
                    : Il2CppSystem.Delegate.Combine(SceneManager.sceneUnloaded, (UnityAction <Scene>) new Action <Scene>(OnSceneUnload)).Cast <UnityAction <Scene> >()
                    );
            }
            catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); }

            try
            {
                Camera.onPostRender = (
                    (Camera.onPostRender == null)
                    ? new Action <Camera>(OnPostRender)
                    : Il2CppSystem.Delegate.Combine(Camera.onPostRender, (Camera.CameraCallback) new Action <Camera>(OnPostRender)).Cast <Camera.CameraCallback>()
                    );
            }
            catch (Exception ex) { MelonLogger.Error($"Camera.onPostRender override failed: {ex}"); }

            ClassInjector.RegisterTypeInIl2Cpp <SM_Component>();
            SM_Component.Create();
            return(new SupportModule_To());
        }
Пример #25
0
        List <double> GetMA(List <IMarketData> marketDataList, int n)
        {
            try
            {
                var valueList = new List <double>();
                int begin     = 0;
                int rlength   = 0;
                int rbegin    = 0;
                //if (MarketDataList.Count > n) { begin = MarketDataList.Count - n; }
                double[] values   = new double[marketDataList.Count];
                var      dataList = marketDataList.Select(v => v.Close).ToArray();
                Core.Sma(begin, marketDataList.Count - 1, dataList, n, out rbegin, out rlength, values);
                valueList = values.ToList();
                CommonProc.TrimDoubleList(valueList);
                if (IsAnalyse)
                {
                    //if (!AnalyseValueList.ContainsKey(n.ToString()))
                    //{
                    //    AnalyseValueList.Add(n.ToString(), new List<TimeValueObject>());
                    //}


                    if (valueList.Count > 0)
                    {
                        //var data = marketDataList.FirstOrDefault();
                        //AddSignal(data.InstrumentTicker, marketDataList.Max(v => v.Time), valueList.LastOrDefault(), marketDataList.LastOrDefault().Close, n.ToString(), SignalType.Analyse);
                        //var dif = marketDataList.Count - valueList.Count;
                        //for (int i =  valueList.Count-1 ;i>=0; i--)
                        //{

                        var o = new TimeValueObject()
                        {
                            Name = Name, Value = valueList.LastOrDefault()
                        };
                        o.Time = marketDataList.LastOrDefault().Time;
                        AddReference(n.ToString(), o);
                        //}
                    }
                }

                //for (int i = 0; i < values.Length - n + 1; i++)
                //{

                //    valueList.Add(values[i]);
                //}
                return(valueList);
            }
            catch (Exception ex)
            {
                LogSupport.Error(ex);
                throw ex;
            }
        }
        public static void DoPass(RewriteGlobalContext context)
        {
            foreach (var assemblyContext in context.Assemblies)
            {
                foreach (var typeContext in assemblyContext.Types)
                {
                    GenerateStaticProxy(assemblyContext, typeContext);
                }
            }

            LogSupport.Trace($"\nTokenless method count: {ourTokenlessMethods}");
        }
Пример #27
0
        public void LoadFromFile()
        {
            var dlg = new OpenFileDialog()
            {
                Filter = "back testing project|*." + BacktestingResource.BacktestingProjectFileExt + "|analyse project|*." + BacktestingResource.AnalyseProjectFileExt + "| (*.*)|*.*"
            };

            if (dlg.ShowDialog() == true)
            {
                if (!dlg.FileName.EndsWith(BacktestingResource.AnalyseProjectFileExt))
                {
                    try {
                        var bp = CommonLib.CommonProc.LoadObjFromFile <BacktestingProject>(dlg.FileName);
                        if (bp != null)
                        {
                            bp.RecoverySerialObject();
                            var svm = new BacktestingProjectSummaryViewModel()
                            {
                                TargetProject = bp, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                            };
                            ProjectList.Add(svm);
                            OpenBacktestingProject(svm);
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        LogSupport.Error(ex);
                    }
                }
                if (!dlg.FileName.EndsWith(BacktestingResource.BacktestingProjectFileExt))
                {
                    try {
                        var ap = CommonLib.CommonProc.LoadObjFromFile <AnalyseProject>(dlg.FileName);
                        if (ap != null)
                        {
                            ap.RecoverySerialObject();
                            var svm = new AnalyseProjectSummaryViewModel()
                            {
                                TargetProject = ap, Open = Open, Delete = Delete, Start = Start, Pause = Pause, Stop = Stop
                            };
                            ProjectList.Add(svm);
                            OpenAnalyseProject(svm);
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        LogSupport.Error(ex);
                    }
                }
            }
        }
Пример #28
0
        public void SetPivotCollapse(string filePath, int sheetIndex)
        {
            Microsoft.Office.Interop.Excel.Application xlApp = null;
            Workbook xlWorkBook = null;

            try
            {
                xlApp      = new Microsoft.Office.Interop.Excel.Application();
                xlWorkBook = xlApp.Application.Workbooks.Open(filePath);
                Thread.Sleep(5000);
                var sheet = xlWorkBook.Worksheets[sheetIndex];
                foreach (var pivot in sheet.PivotTables)
                {
                    foreach (var f in pivot.PivotFields)
                    {
                        var pf = (f as PivotField);
                        if (pf != null)
                        {
                            try
                            {
                                pf.ShowDetail = false;
                            }
                            catch
                            {
                            }
                        }
                    }
                }

                xlWorkBook.Save();
            }
            catch (Exception ex)
            {
                LogSupport.Error(ex);
            }
            finally
            {
                if (xlWorkBook != null)
                {
                    xlWorkBook.Close(true, null, null);
                }
                Thread.Sleep(5000);
                if (xlApp != null)
                {
                    xlApp.Quit();
                }
                Thread.Sleep(5000);
            }
        }
        public unsafe Unity2018_0NativeClassStructHandler()
        {
            Il2CppClassU2018_0 ex = new Il2CppClassU2018_0();
            byte *addr            = (byte *)&ex;

            LogSupport.Trace($"Size:                         {sizeof(Il2CppClassU2018_0)}");
            LogSupport.Trace($"typeHierarchyDepth Offset:    {&ex.typeHierarchyDepth - addr}");
            LogSupport.Trace($"genericRecursionDepth Offset: {&ex.genericRecursionDepth - addr}");
            LogSupport.Trace($"rank Offset:                  {&ex.rank - addr}");
            LogSupport.Trace($"minimumAlignment Offset:      {&ex.minimumAlignment - addr}");
            //LogSupport.Trace($"naturalAligment Offset:       {&ex.Part2.naturalAligment - addr}");
            LogSupport.Trace($"packingSize Offset:           {&ex.packingSize - addr}");
            LogSupport.Trace($"bitfield_1 Offset:            {(byte*)&ex.bitfield_1 - addr}");
            LogSupport.Trace($"bitfield_2 Offset:            {(byte*)&ex.bitfield_2 - addr}");
        }
Пример #30
0
        public void RefreshRadius()
        {
            List <DesignLink> linkList = new List <DesignLink>();

            LinkList.ForEach(l =>
            {
                try
                {
                    RefreshRadius(l, linkList);
                }
                catch (Exception e)
                {
                    LogSupport.Error(e.Message);
                }
            });
        }