using Api.Framework; using Api.Framework.Cps; using Api.Framework.Tools; using CsharpHttpHelper; using DevExpress.XtraEditors; using FLSystem.Forms; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Threading; using System.Xml; using UI.Framework.Forms; namespace FLSystem { static class Program { [DllImport("User32.dll")] public static extern int PrivateExtractIcons( string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp int nIconIndex, //从第几个图标开始获取 int cxIcon, //获取图标的尺寸x int cyIcon, //获取图标的尺寸y IntPtr[] phicon, //获取到的图标指针数组 int[] piconid, //图标对应的资源编号 int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用 int flags //标志,默认0就可以,具体可以看LoadImage函数 ); [DllImport("User32.dll")] public static extern bool DestroyIcon( IntPtr hIcon //A handle to the icon to be destroyed. The icon must not be in use. ); private static System.Drawing.Icon _ico; public static System.Drawing.Icon ReadICO() { if (_ico != null) return _ico; try { bool is_next = false; NEXT: DirectoryInfo info = new DirectoryInfo(Util.MapPath()); var files = info.GetFiles("*.exe"); foreach (var data in files) { var file = data.FullName; if (file.EndsWith("FLSystem.exe")) continue; if (file.EndsWith("ZipExtract.exe")) continue; if (file.EndsWith("FLSystemMonitor.exe")) continue; if (file.EndsWith("LevelUpdate.exe")) continue; if (file.EndsWith("OnlineUpdate.exe")) continue; if (file.EndsWith("VersionUpdate.exe")) continue; //if (file.EndsWith("软件异常点我修复.exe")) continue; if (file.EndsWith("检查更新.exe")) continue; if (data.Name.Replace(".exe", "").ToLower().Contains("net")) continue; //选中文件中的图标总数 var iconTotalCount = PrivateExtractIcons(file, 0, 0, 0, null, null, 0, 0); //用于接收获取到的图标指针 IntPtr[] hIcons = new IntPtr[iconTotalCount]; //对应的图标id int[] ids = new int[iconTotalCount]; //成功获取到的图标个数 var successCount = PrivateExtractIcons(file, 0, 256, 256, hIcons, ids, iconTotalCount, 0); //遍历并保存图标 for (var i = 0; i < successCount; i++) { //指针为空,跳过 if (hIcons[i] == IntPtr.Zero) continue; _ico = System.Drawing.Icon.FromHandle(hIcons[i]); return _ico; //内存回收 //DestroyIcon(hIcons[i]); } } if (!is_next) { var exe = Util.MapFile("返利机器人.exe"); if (!File.Exists(exe)) { File.WriteAllBytes(exe, FLSystem.Properties.Resources.返利机器人); goto NEXT; } } } catch (Exception) { } _ico = Properties.Resources.exe; return _ico; } /// /// 过滤特殊字符,保留中文,字母,数字,和- /// /// 输入字符串 /// 发件和收件详细地址有这种情况:“仓场路40-73号迎园新村四坊69号202室”,这种带有-的特殊字符不需要过滤掉 /// public static string FilterChar(string inputValue) { // return Regex.Replace(inputValue, "[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()—|{}【】;‘’,。/*-+]+", "", RegexOptions.IgnoreCase); if (Regex.IsMatch(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+")) { return Regex.Match(inputValue, "[A-Za-z0-9\u4e00-\u9fa5-]+").Value; } return ""; } /// /// The main entry point for the application. /// [STAThread] static void Main() { //var sign = HttpExtend.GetMD5String("Cc"+ "_*54R56@%"); //var ss = Util.DecryptDES("lKMvY5Nw0DjddL2gR2Fhu6GFlMehR0ej70MzzGKOi17O/Lp6r5yD288MdztyYPWBkyA4bkKntMpOgsJ3cWZXau/X3U0aHK06"); //return; //new Form1().ShowDialog(); //return; //string src = string.Format("Data Source={0};Version=3;password={1};Journal Mode=WAL;", Util.MapFile("数据库.db", "Config"), ""); //var tempConfig = new ConnectionConfig() { ConnectionString = src, DatabaseType = DatabaseType.SQLITE }; //var session = ApiClient.GetSession(tempConfig); //var db_order = session.FindSingle("select * from fl_order_alimama where trade_id = @trade_id and trade_parent_id = @trade_parent_id", new { trade_id = "271259596907722923", trade_parent_id = "271259596907722923" }); //return; // ApiClient.SendDingdingMessageNewApi("TEST", "https://oapi.dingtalk.com/robot/send?access_token=24dbd211f807d4651d22d685c788c9df8548f23c09104646d88372d24b7549ef", "SECbb1f0d66c2ba8f71ff4e1620d99e2dd12191ab884d1567e2f949987b4187e59f"); try { EO.WebBrowser.Runtime.AddLicense( "N4SOscufWbPw+g7kp+rp9um7aOPt9BDtrNzpz7iJWZeksefgpePzCOmMQ5ek" + "scufWZekzQzjnZf4ChvkdpnJ4NnCoenz/hChWe3pAx7oqOXBs92wZ6emsdq9" + "RoGkscufdabl/RfusLWRm8ufWZfAAB3jnunN/xHuWdvlBRC8W6i2wNywaKm0" + "w9uhWer58/D3qeD29h7ArbSmwt2uaqizw9uxapmkBxDxrODz/+iha6emsdq9" + "RoGkscufdert+Bngrez29unLn9D7BR7Wb8T66/nCm6y40hu2b8zFzui7aOrt" + "+Bngrez29umMQ7Oz/RTinuX39umMQ3Xj7fQQ7azcwp61n1mXpM0X6Jzc8gQQ" + "yJ21uur5sXGqusrz0XCwtMTis4+zs/0U4p7l9/b043c="); } catch (Exception) { } try { Robot.Framework.Utils.Util.SetWebBrowserFeatures(11); Robot.Framework.RobotServer.Servers.Add("robotsign.api.52cmg.cn"); DevExpressCrack.Crack.Init(); List files = new List(); files.Add(Util.MapFile(@"QQPlus.Framework.dll", @"Assembly\apifile")); files.Add(Util.MapFile(@"FLSystem.dubug", @"Assembly\apifile")); files.Add(Util.MapFile(@"MaxQQ.db", @"Assembly\apifile")); files.Add(Util.MapFile(@"Activity.dll", @"Plugin")); files.Add(Util.MapFile(@"Runtime.dll", @"Plugin")); files.Add(Util.MapFile(@"FLSystem.exe.se")); files.Add(Util.MapFile(@"LevelUpdate.exe")); files.Add(Util.MapFile(@"OnlineUpdate.exe")); files.Add(Util.MapFile(@"version.txt")); files.Add(Util.MapFile(@"Update.zip")); files.Add(Util.MapFile(@"VersionUpdate.exe")); files.Add(Util.MapFile(@"OnlineUpdate.exe")); files.Add(Util.MapFile("软件异常点我修复.exe")); foreach (var item in files) { try { File.Delete(item); } catch (Exception ex) { } } } catch (Exception ex) { } if (!Tools.GetDotNetRelease(393297))//.net版本 参数(393297)在这里面看 https://docs.microsoft.com/zh-tw/dotnet/framework/migration-guide/versions-and-dependencies { XtraMessageBox.Show(@"检测到系统可能未安装.Net FrameWork 4.6.1", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //获取本机调试码 //Computer cx = Computer.Instance(); //var md5 = HttpHelper.ToMD5(cx.ComputerName + cx.CpuID + cx.LoginUserName); ////获取开发调试 //var debug = EncDebugAcc(md5); //var tb_data = "{'pageNum' : '0','activityName' : 'orderCommon'}"; //var tb_api = "mtop.taobao.chatting.group.recommend"; //var tb_version = "1.0"; // GetSign("WGggVwxCetYDAJSz3rev6wHz", "365052383", "21646297", tb_data, tb_api,tb_version, "70047844f777bb980e529af7a40c3ab3", "10000878@tdvideo_android_4.2.2", "AvMoMBLo1CCz-eMOUfuejUazQmEyetOX8RDVE6g", "39.916295", "116.410344","27"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ThreadPool.SetMaxThreads(int.MaxValue, int.MaxValue); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); ReadICO(); // GetXsign("mtop.taobao.rate.detaillist.get",""); CheckMoreopen(); //定时输出日志 Task.Run(() => { string log = Util.MapFile("Runtime.log"); while (true) { try { File.WriteAllText(log, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } catch { } Thread.Sleep(1000 * 10); } }); //检查监控是否启动 try { var location = AppDomain.CurrentDomain.BaseDirectory; var list = Process.GetProcessesByName("FLSystemMonitor").ToList(); bool is_start = false; foreach (var item in list) { try { var fileName = item.MainModule.FileName; var path = fileName.Substring(0, fileName.Length - 19); if (location == path) { is_start = true; break; } } catch { } } if (!is_start) { var jk_file = Util.MapFile("FLSystemMonitor.exe"); if (!File.Exists(jk_file)) { var jk_old_file = Util.MapFile("FLSystemMonitor.exe", "Assembly\\apifile"); if (File.Exists(jk_old_file)) { //File.Copy(jk_old_file,jk_file); ////使用File的静态方法删除路径下的一个文件 //File.Delete(jk_old_file); //使用File的静态方法移动路径下的一个文件 File.Move(jk_old_file, jk_file); } } Process.Start("FLSystemMonitor.exe", "check"); } } catch (Exception) { } DeleteFile(Util.MapFile("Grant.Framework.dll", @"Assembly\library")); DeleteFile(Util.MapFile("Easy4net.dll", @"Assembly\apifile")); SetAllowUnsafeHeaderParsing20(true); //CheckUpdate(); if (CheckUpdate()) return; Application.Run(new main()); } private static string EncDebugAcc(string md5) { string rsakey = "nz1sjqJbDn58VvAs+vUZtOZY4fgSQP2DvmagOEXsx/v0ZJ6ykDi71jtnU01ZD40xBt0fooUiC6VEobUJqdLqoAnqUZGqkD9IPZaVDPDYg6aXowhKZJP4Ipxq0eaXBWfROOBAVF/uFkZ27sjcuCfCpzDafOoRLRQCLQ2TKRgfYd0=AQAB

2WfOYWp6o8EZm14a/K0iFGrKq4QQ9q719GKw2CSNZbmSsN0azhLHKG1iYQn0M/qEzRbc1R79vLTJIF3VwbieDw==

u4I6+v5RANurQV6YH7kGAmsoAHZhx8hbBUnRFKQyCK3LJbzq8gXeVU7mzzOkSzVMoeGEIVUYXb4zL87txkytUw==qwh1XkIMdWNmp8oi5QG3u+Q/ySs+xTLjn/08Lu6ippKVirqHafNv5qgXK0xPZ80ASPBhjvCwoZKAYAwyLBL3lQ==SQP9U5+Ui3D+zwW21yOFY4u2l/eBO/qY9wY3lIIbuaVzZc6a7oO6gB2pYyYI5ABtRtw6R4CLbHWUGRnLHVzeYQ==M1zD3kKgwgQcgWqilmE9/jsAfDTWBaf/2sZDusfS4zhNQtPbZuYtAQOJ5lymvUKkl5BIHrPiQ7LydG47dMiO5w==P6IfGFx+wKsA6wjtIJgDXsvR5vLn8HqeQ97k1bfzp/LiNbdJKeLSBQkWAC7fkRxd5B1G//3tnfO8Glaq9ucnBI1CwJgvoO4h6YtyjmscC8TFpMEu3TfxU1SScokjyciiaXpQsAilFX3RQE1eARuvGaZxwbO3KbAubU6ydZGBK00=
"; RSACryption rsa = new RSACryption(); var text = rsa.RsaEncrypt(md5, rsakey); //Console.WriteLine($"请在根目录建立文件debug.txt,并存放值:\r\n{text}"); return rsa.RsaEncrypt(md5, rsakey); } private static void DeleteFile(string fileName) { try { if (File.Exists(fileName)) File.Delete(fileName); } catch { } } // // 初始化Cef配置,此方法代码不能放于Main方法中,否则Cef无法正常运行,别问为什么,我也不清楚 // #region 系统异常捕获 static bool SetAllowUnsafeHeaderParsing20(bool useUnsafe) { try { //Get the assembly that contains the internal class System.Reflection.Assembly aNetAssembly = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection)); if (aNetAssembly != null) { //Use the assembly in order to get the internal type for the internal class Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal"); if (aSettingsType != null) { //Use the internal static property to get an instance of the internal settings class. //If the static instance isn't created allready the property will create it for us. object anInstance = aSettingsType.InvokeMember("Section", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic, null, null, new object[] { }); if (anInstance != null) { //Locate the private bool field that tells the framework is unsafe header parsing should be allowed or not System.Reflection.FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (aUseUnsafeHeaderParsing != null) { aUseUnsafeHeaderParsing.SetValue(anInstance, useUnsafe); return true; } } } } return false; } catch (Exception ex) { BaseForm.ShowError(ex, "系统.异常"); } return false; } static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { string str = GetExceptionMsg(e.Exception, e.ToString(), "线程"); //MessageBox.Show(str, "子线程错误", MessageBoxButtons.OK, MessageBoxIcon.Error); BaseForm.ShowError(str); } catch (Exception ex) { BaseForm.ShowError(ex, "系统线程异常"); } } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString(), "未知"); // MessageBox.Show(str, "主线程错误", MessageBoxButtons.OK, MessageBoxIcon.Error); BaseForm.ShowError(str); } catch (Exception ex) { BaseForm.ShowError(ex, "系统未知异常"); } } static string GetExceptionMsg(Exception ex, string backStr, string r) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"****************************异常文本_{r}****************************"); sb.AppendLine("【出现时间】:" + DateTime.Now.ToString()); if (ex != null) { if (ex.Message == "This version of Windows is not supported.") { return "Windows版本不支持"; } sb.AppendLine("【异常类型】:" + ex.GetType().Name); sb.AppendLine("【异常信息】:" + (ex.Message == "This version of Windows is not supported." ? "Windows版本不支持" : ex.Message)); sb.AppendLine("【堆栈调用】:" + ex.StackTrace); } else { sb.AppendLine("【未处理异常】:" + backStr); } sb.AppendLine("***************************************************************"); return sb.ToString(); } #endregion #region 自定义一些操作 public static bool CheckUpdate() { try { var LatestData = UpdateClient.GetCloudFileHist(); if (!string.IsNullOrWhiteSpace(LatestData)) { if (new UpdateForm(LatestData).ShowDialog() == DialogResult.OK) { Process.Start("检查更新.exe", "FLSystem.exe"); //Thread.Sleep(100); return true; } } //Thread.Sleep(100); } catch (Exception ex) { } return false; } /// /// 防多开限制 /// public static void CheckMoreopen() { string strFullPath = Application.ExecutablePath; string strFileName = System.IO.Path.GetFileName(strFullPath); string curPath = Util.MapFile(strFileName).ToLower(); int count = 0; foreach (Process p in Process.GetProcessesByName(strFileName.Replace(".exe", ""))) { string path = p.MainModule.FileName.ToLower(); if (path == curPath) count++; } #region 是否允许重启软件 var reset_program = Util.MapFile("reset", "File");//用于导入导出插件重启用,文件存在允许重启 var reset = !File.Exists(reset_program);//保存至变量 try { File.Delete(reset_program);//删除文件 } catch (Exception) { } #endregion if (count > 1) { if (reset) { BaseForm.ShowError("对不起,您不能在同一个目录重复启动该软件!"); // BaseForm.ShowError(str); // MessageBox.Show("对不起,您不能在同一个目录重复启动该软件!", "防多开提醒", MessageBoxButtons.OK, MessageBoxIcon.Error); Exit(); } } } /// /// 退出 /// public static void Exit(bool start = false) { try { if (start) { //程序位置 string strAppFileName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; System.Diagnostics.Process myNewProcess = new System.Diagnostics.Process(); //要启动的应用程序 myNewProcess.StartInfo.FileName = strAppFileName; // 设置要启动的进程的初始目录 myNewProcess.StartInfo.WorkingDirectory = Application.ExecutablePath; //启动程序 myNewProcess.Start(); } //结束该程序 // Application.Exit(); //结束该所有线程 //Environment.Exit(0); Process.GetCurrentProcess().Kill(); } catch (Exception) { } } #endregion } }