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; }); }
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 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); } }
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); } } }
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); } }
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 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 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; //} }); } }
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); }
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; } }
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)); }
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); }
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); } } } }
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 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 void RefreshRadius() { List <DesignLink> linkList = new List <DesignLink>(); LinkList.ForEach(l => { try { RefreshRadius(l, linkList); } catch (Exception e) { LogSupport.Error(e.Message); } }); }
public bool DeleteBatch(string connectionStr, string tableName, string uidName, List <object> objectList, object parameterArray = null, bool useTransaction = false) { var sql = CreateDeleteSql(tableName, objectList, uidName); IDbTransaction tran = null; var result = false; int flag = 0; using (var conn = GetConnection(connectionStr)) { conn.Open(); if (useTransaction) { tran = conn.BeginTransaction(); } try { flag = conn.Execute(sql, parameterArray, tran, TimeoutMs); } catch (Exception ex) { LogSupport.Error(ex); if (tran != null) { tran.Rollback(); } return(false); } if (tran != null) { try { tran.Commit(); result = true; } catch { tran.Rollback(); } } else if (flag > 0) { result = true; } return(result); } }
public virtual List <IMarketData> GetDataList(List <IInstrument> instrumentList, DateTime startTime, DateTime endTime, MarketDataGrade grade) { var ml = new List <IMarketData>(); try { instrumentList.ForEach(v => { ml.AddRange(GetDataList(v, startTime, endTime, grade)); }); } catch (Exception ex) { LogSupport.Error(ex); } return(ml); }
public void InitPrototype <T>(List <T> list, string path, string nameKey) { LogSupport.Info("start init " + typeof(T).Name); try { list.Clear(); if (Directory.Exists(path)) { var subDir = Directory.GetDirectories(path); foreach (var dir in subDir) { var folder = new DirectoryInfo(dir); foreach (FileInfo tFile in folder.GetFiles()) { if ((tFile.Name.EndsWith("dll") || tFile.Name.EndsWith("exe")) && tFile.Name.Contains(nameKey)) { Assembly ass = Assembly.LoadFile(tFile.DirectoryName + "\\" + tFile.Name); var tl = ass.GetTypes().ToList(); tl.ForEach(v => { if (v.GetInterface(typeof(T).Name) != null) { object obj = Activator.CreateInstance(v); var dp = (T)obj; if (dp != null) { LogSupport.Info("loading:" + tFile.Name); //dp.Initialize(); list.Add(dp); } } }); } } } } } catch (Exception ex) { LogSupport.Error(ex); } LogSupport.Info("Loaded count:" + list.Count.ToString()); }
public override IMarketData GetFirstData(IInstrument instrument, DateTime startTime, DateTime endTime, MarketDataGrade grade) { if (instrument == null || string.IsNullOrEmpty(instrument.Ticker)) { return(null); } if (grade == MarketDataGrade.FiveMinutes) { try { string sqlconnection = "Data Source=LYNX-NOTEBOOK\\SQLEXPRESS;Initial Catalog=MarketData;Integrated Security=True"; var connection = new SqlConnection(sqlconnection); var cs = ConfigurationManager.ConnectionStrings["MarketDataConnectionString"].ConnectionString; var sql = "select top 1 * from Table_TradePrice where Time >'" + startTime.ToString() + "' and Time<='" + endTime.ToString() + "' and Ticker='" + instrument.Ticker + "' order by Time"; connection.Open(); var t = connection.Query(sql); connection.Close(); var v = t.FirstOrDefault(); if (v != null) { var md = new MarketData(); md.Time = v.Time; md.InstrumentTicker = instrument.Ticker; md.Low = v.Low; md.Open = v.Open; md.High = v.High; md.Close = v.Close; md.Volume = v.Volume; md.Shares = v.Shares; md.Grade = MarketDataGrade.FiveMinutes; return(md); } return(null); } catch (Exception e) { LogSupport.Error(e); throw e; } } return(base.GetFirstData(instrument, startTime, endTime, grade)); }
void ProcessOrder(IOrder order) { try { if (order == null) { return; } var inst = GetInstrumentList().FirstOrDefault(v => v.Ticker == order.Ticker); if (inst == null) { return; } var p = PositionList.FirstOrDefault(v => v.InstrumentTicker == order.Ticker); if (p == null) { var pos = new Position(); pos.InstrumentName = inst.Name; pos.InstrumentTicker = inst.Ticker; pos.CurrentPrice = order.Price; pos.ProcessOrder(order); pos.CreateTime = order.OrderTime; pos.DataTime = order.OrderTime; if (ProcessMoney(order.CashFlow)) { PositionList.Add(pos); } } else { if (ProcessMoney(order.CashFlow)) { p.ProcessOrder(order); } } } catch (Exception ex) { LogSupport.Error(ex); } }
public override List <IMarketData> GetSourceDataList(IInstrument instrument, DateTime startTime, DateTime endTime) { if (instrument == null || string.IsNullOrEmpty(instrument.Ticker)) { return(null); } var dl = new List <IMarketData>(); try { string sqlconnection = "Data Source=LYNX-NOTEBOOK\\SQLEXPRESS;Initial Catalog=MarketData;Integrated Security=True"; var connection = new SqlConnection(sqlconnection); var cs = ConfigurationManager.ConnectionStrings["MarketDataConnectionString"].ConnectionString; var sql = "select * from Table_TradePrice where Time >='" + startTime.ToString() + "' and Time<='" + endTime.ToString() + "' and Ticker='" + instrument.Ticker + "'"; connection.Open(); var t = connection.Query(sql, new { }, null, true, TimeoutMs); connection.Close(); t.ToList().ForEach(v => { var md = new MarketData(); md.Time = v.Time; md.InstrumentTicker = instrument.Ticker; md.Low = v.Low; md.Open = v.Open; md.High = v.High; md.Close = v.Close; md.Volume = v.Volume; md.Shares = v.Shares; md.Grade = MarketDataGrade.FiveMinutes; dl.Add(md); }); return(dl.OrderBy(v => v.Time).ToList());; } catch (Exception e) { LogSupport.Error(e); throw e; } }
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.Volume).ToArray(); Core.Sma(begin, marketDataList.Count - 1, dataList, n, out rbegin, out rlength, values); var l = values.ToList <double>(); CommonProc.TrimDoubleList(l); return(l); } catch (Exception ex) { LogSupport.Error(ex); throw ex; } }
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 slowK = new double[dl.Count]; var slowD = new double[dl.Count]; int bindex; int element; Core.Stoch(0, dl.Count - 1, dl.Select(p => p.High).ToArray(), dl.Select(p => p.Low).ToArray(), dl.Select(p => p.Close).ToArray(), FastKPeriod, SlowKPeriod, SlowKType, SlowDPeriod, SlowDType, out bindex, out element, slowK, slowD); var skl = slowK.ToList <double>(); var sdl = slowD.ToList <double>(); CommonProc.TrimDoubleList(skl); CommonProc.TrimDoubleList(sdl); if (IsAnalyse) { //if (!AnalyseValueList.ContainsKey("K")) //{ // AnalyseValueList.Add("K", new List<TimeValueObject>()); //} //if (!AnalyseValueList.ContainsKey("D")) //{ // AnalyseValueList.Add("D", new List<TimeValueObject>()); //} if (skl.Count > 0) { //var dif = dl.Count - skl.Count; //for (int i = skl.Count - 1; i >= 0; i--) //{ // var o = new TimeValueObject() { Name = Name, Value = skl[i] }; // o.Time = dl[dif + i].Time; // AddReference("K", o); //} var o = new TimeValueObject() { Name = Name, Value = skl.LastOrDefault() }; o.Time = dl.Max(v => v.Time); AddReference("K", o); //AddSignal(instrument, dl.Max(v => v.Time), skl.LastOrDefault(), dl.LastOrDefault().Close, "K", SignalType.Analyse); //AnalyseValueList["K"].Add(o); } if (sdl.Count > 0) { //var dif = dl.Count - sdl.Count; //for (int i = skl.Count - 1; i >= 0; i--) //{ // var o = new TimeValueObject() { Name = Name, Value = sdl[i] }; // o.Time = dl[dif + i].Time; // AddReference("D", o); //} var o = new TimeValueObject() { Name = Name, Value = sdl.LastOrDefault() }; o.Time = dl.Max(v => v.Time); AddReference("D", o); //AnalyseValueList["D"].Add(o); //AddSignal(instrument, dl.Max(v => v.Time), sdl.LastOrDefault(), dl.LastOrDefault().Close, "D", SignalType.Analyse); } } if (skl[skl.Count - 2] < skl[skl.Count - 1] && sdl[sdl.Count - 2] < sdl[sdl.Count - 1])//current K,D increase { return(CreateSignal(instrument, dl.Max(v => v.Time), ((skl[skl.Count - 1] - skl[skl.Count - 2]) + (sdl[sdl.Count - 1] - sdl[sdl.Count - 2])) / 2d, dl.LastOrDefault().Close)); //var o = new TimeValueObject() { Name = Name, Time = endTime, Value = null }; //o.Time = dl.Max(v => v.Time); //o.Value= ((skl[skl.Count - 1] - skl[skl.Count - 2]) + (sdl[sdl.Count - 1] - sdl[sdl.Count - 2])) / 2d; //return o; } } catch (Exception e) { LogSupport.Error(e); } return(null); }
internal static IEnumerable <XrefInstance> XrefScanImpl(Decoder decoder, bool skipClassCheck = false) { while (true) { decoder.Decode(out var instruction); if (decoder.LastError == DecoderError.NoMoreBytes) { yield break; } if (instruction.FlowControl == FlowControl.Return) { yield break; } if (instruction.Mnemonic == Mnemonic.Int || instruction.Mnemonic == Mnemonic.Int1) { yield break; } if (instruction.Mnemonic == Mnemonic.Call || instruction.Mnemonic == Mnemonic.Jmp) { var targetAddress = ExtractTargetAddress(instruction); if (targetAddress != 0) { yield return(new XrefInstance(XrefType.Method, (IntPtr)targetAddress, (IntPtr)instruction.IP)); } continue; } if (instruction.FlowControl == FlowControl.UnconditionalBranch) { continue; } if (IsMoveMnemonic(instruction.Mnemonic)) { XrefInstance?result = null; try { if (instruction.Op1Kind == OpKind.Memory && instruction.IsIPRelativeMemoryOperand) { var movTarget = (IntPtr)instruction.IPRelativeMemoryAddress; if (instruction.MemorySize != MemorySize.UInt64) { continue; } if (skipClassCheck || XrefGlobalClassFilter(movTarget)) { result = new XrefInstance(XrefType.Global, movTarget, (IntPtr)instruction.IP); } } } catch (Exception ex) { LogSupport.Error(ex.ToString()); } if (result != null) { yield return(result.Value); } } } }
public static void Main(string[] args) { LogSupport.InstallConsoleHandlers(); var options = new UnhollowerOptions(); var analyze = false; var generateMap = false; foreach (var s in args) { if (s == ParamAnalyze) { analyze = true; } else if (s == ParamGenerateDeobMap) { generateMap = true; } else if (s == ParamHelp || s == ParamHelpShort || s == ParamHelpShortSlash) { PrintUsage(); return; } else if (s == ParamVerbose) { LogSupport.TraceHandler += Console.WriteLine; options.Verbose = true; } else if (s == ParamNoXrefCache) { options.NoXrefCache = true; } else if (s == ParamNoCopyUnhollowerLibs) { options.NoCopyUnhollowerLibs = true; } else if (s.StartsWith(ParamInputDir)) { options.SourceDir = s.Substring(ParamInputDir.Length); } else if (s.StartsWith(ParamOutputDir)) { options.OutputDir = s.Substring(ParamOutputDir.Length); } else if (s.StartsWith(ParamMscorlibPath)) { options.MscorlibPath = s.Substring(ParamMscorlibPath.Length); } else if (s.StartsWith(ParamUnityDir)) { options.UnityBaseLibsDir = s.Substring(ParamUnityDir.Length); } else if (s.StartsWith(ParamGameAssemblyPath)) { options.GameAssemblyPath = s.Substring(ParamGameAssemblyPath.Length); } else if (s.StartsWith(ParamUniqChars)) { options.TypeDeobfuscationCharsPerUniquifier = Int32.Parse(s.Substring(ParamUniqChars.Length)); } else if (s.StartsWith(ParamUniqMax)) { options.TypeDeobfuscationMaxUniquifiers = Int32.Parse(s.Substring(ParamUniqMax.Length)); } else if (s.StartsWith(ParamBlacklistAssembly)) { options.AdditionalAssembliesBlacklist.Add(s.Substring(ParamBlacklistAssembly.Length)); } else if (s.StartsWith(ParamObfRegex)) { options.ObfuscatedNamesRegex = new Regex(s.Substring(ParamObfRegex.Length), RegexOptions.Compiled); } else if (s.StartsWith(ParamRenameMap)) { ReadRenameMap(s.Substring(ParamRenameMap.Length), options); } else if (s.StartsWith(ParamGenerateDeobMapAssembly)) { options.DeobfuscationGenerationAssemblies.Add(s.Substring(ParamGenerateDeobMapAssembly.Length)); } else if (s.StartsWith(ParamGenerateDeobMapNew)) { options.DeobfuscationNewAssembliesPath = s.Substring(ParamGenerateDeobMapNew.Length); } else { LogSupport.Error($"Unrecognized option {s}; use -h for help"); return; } } if (analyze && generateMap) { LogSupport.Error($"Can't use {ParamAnalyze} and {ParamGenerateDeobMap} at the same time"); return; } if (analyze) { AnalyzeDeobfuscationParams(options); } else if (generateMap) { DeobfuscationMapGenerator.GenerateDeobfuscationMap(options); } else { Main(options); } }
public string CreateInertSql(string tbName, List <object> ObjectList) { if (ObjectList == null || ObjectList.Count == 0) { return(null); } var o = ObjectList.FirstOrDefault(); var objType = o.GetType(); StringBuilder sql = new StringBuilder(); sql.Append(string.Format("INSERT INTO {0}(", tbName)); var sl = ObjectListHelper.GetValidTypePropertyList(objType, typeof(ReportOutputIgnore)); var hs = ""; sl.ForEach(v => hs += (v + ",")); hs = FixKeyWordColumn(hs); sql.Append(hs); sql.Append(")"); sql.Append(" VALUES "); var vs = ""; ObjectList.ForEach(v => { try { vs += "("; for (int i = 0; i < sl.Count; i++) { var valueString = ""; var value = v.GetType().GetProperty(sl[i]).GetValue(v); if (value == null) { valueString = GetDefaultValue(v.GetType().GetProperty(sl[i])); } else { valueString = value.ToString(); } if (IsNeedQuotation(v.GetType().GetProperty(sl[i]))) { valueString = "'" + valueString + "'"; } if (i != sl.Count - 1) { valueString += ","; } vs += valueString; } vs += "),"; } catch (Exception ex) { LogSupport.Error(ex); } }); sql.Append(vs.Substring(0, vs.Length - 1)); return(sql.ToString()); }
internal static IEnumerable <XrefInstance> XrefScanImpl(Decoder decoder) { while (true) { decoder.Decode(out var instruction); if (decoder.InvalidNoMoreBytes) { yield break; } if (instruction.FlowControl == FlowControl.Return) { yield break; } if (instruction.Mnemonic == Mnemonic.Int || instruction.Mnemonic == Mnemonic.Int1) { yield break; } if (instruction.Mnemonic == Mnemonic.Call || instruction.Mnemonic == Mnemonic.Jmp) { var targetAddress = ExtractTargetAddress(instruction); if (targetAddress != 0) { yield return(new XrefInstance(XrefType.Method, (IntPtr)targetAddress)); } continue; } if (instruction.FlowControl == FlowControl.UnconditionalBranch) { continue; } if (instruction.Mnemonic == Mnemonic.Mov) { XrefInstance?result = null; try { if (instruction.Op1Kind == OpKind.Memory && instruction.IsIPRelativeMemoryOperand) { var movTarget = (IntPtr)instruction.IPRelativeMemoryAddress; if (instruction.MemorySize != MemorySize.UInt64) { continue; } var valueAtMov = (IntPtr)Marshal.ReadInt64(movTarget); if (valueAtMov != IntPtr.Zero) { var targetClass = (IntPtr)Marshal.ReadInt64(valueAtMov); if (targetClass == Il2CppClassPointerStore <string> .NativeClassPtr || targetClass == Il2CppClassPointerStore <Type> .NativeClassPtr) { result = new XrefInstance(XrefType.Global, movTarget); } } } } catch (Exception ex) { LogSupport.Error(ex.ToString()); } if (result != null) { yield return(result.Value); } } } }