Example #1
0
 public bool Process(InfoReader instance, CommandParser parser)
 {
     if (!_msgLoopStarted)
     {
         if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
         {
             IO.CurrentIO.Write("Message loop on window MemFileMapFormat started.");
         }
         Thread th = new Thread(() =>
         {
             System.Windows.Forms.Application.Run(_formatWindow);
         });
         th.Start();
         if (th.ThreadState == ThreadState.Running)
         {
             _msgLoopStarted = true;
         }
         return(true);
     }
     if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
     {
         IO.CurrentIO.Write("Message loop on window MemFileMapFormat is running. Showing window...");
     }
     _formatWindow.Show();
     return(true);
 }
Example #2
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected BlockRef(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     idea      = InfoReader.Read(info, "Idea", typeof(Block)) as Block;
     insertion = (ModOp)InfoReader.Read(info, "Insertion", typeof(ModOp));
     colorDef  = ColorDef.Read(info, context);
 }
Example #3
0
        void GetOsz(InfoReader instance)
        {
            var ortdpWrapper = instance.GetOrtdp();

            Win32Class.SevenZip zip = new Win32Class.SevenZip {
                SevenZipDirectory = "..\\pg\\7-zip\\7za.exe"
            };
            StringBuilder tmp       = new StringBuilder(ortdpWrapper.FullPath);
            string        basicinfo = $"{ortdpWrapper.Artist} - {ortdpWrapper.Title}";
            string        pattern   = "[" + new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars()) + ":*]";

            System.Text.RegularExpressions.Regex    reg = new System.Text.RegularExpressions.Regex(pattern);
            Win32Class.SevenZip.Native.SevenZipArgs arg = new Win32Class.SevenZip.Native.SevenZipArgs
            {
                FileType = Win32Class.SevenZip.Native.ArchieveType.Zip
            };
            string newdir = reg.Replace($"{ortdpWrapper.Artist} - {ortdpWrapper.Title}", " ");

            arg.ArchieveFileName = "\"" + instance.Setting.OszDir + "\\" + ortdpWrapper.Beatmap.BeatmapSetId + " " + newdir + ".osz\"";
            if (File.Exists(arg.ArchieveFileName.Trim('\"')))
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_OSZEXISTED"));
                File.Delete(arg.ArchieveFileName.Trim('\"'));
            }
            arg.OperationType = Win32Class.SevenZip.Native.Operation.Add;
            if (!instance.Setting.OszDir.ToString().EndsWith("\\"))
            {
                arg.Files = "\"" + ortdpWrapper.Beatmap.BeatmapFolder + "\\*.*" + "\"";
            }
            else
            {
                arg.Files = "\"" + ortdpWrapper.Beatmap.BeatmapFolder + "\"";
            }
            var sta = Win32Class.SevenZip.Native.Run7zCmd(zip.SevenZipDirectory, arg);

            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Success)
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COMPRESSED"));
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.FaltalError)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_FATALERR"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.OutOfMemory)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_OUTOFMEMORY"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Canceled)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_OPERATIONCANCELED"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.CommandLineError)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_COMMANDLINEERR"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Warning)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_WARNINGS"), ConsoleColor.Yellow);
            }
        }
Example #4
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            var or = instance.GetOrtdp();

            if (parser.MainCommand == "open")
            {
                if (parser.Arguments[0] == "beatmappage")
                {
                    Open(instance.GetOrtdp().Beatmap.DownloadLink);
                }
                else if (parser.Arguments[0] == "beatmapfolder")
                {
                    Open(or.Beatmap.BeatmapFolder);
                }
                else if (parser.Arguments[0] == "musicfolder")
                {
                    Open(instance.Setting.DefaultMusicCopyingDirectory);
                }
                else if (parser.Arguments[0] == "videofolder")
                {
                    Open(instance.Setting.DefaultVideoCopyingDirectory);
                }

                else if (parser.Arguments[0] == "bgfolder")
                {
                    Open(instance.Setting.DefaultBackgroundCopyingDirectory);
                }
                else if (parser.Arguments[0] == "oszfolder")
                {
                    Open(instance.Setting.OszDir);
                }

                else if (parser.Arguments[0] == "userpage")
                {
                    string username;
                    if (parser.Arguments.Count < 1)
                    {
                        OsuInfo info = new OsuInfo();
                        username = info.UserName;
                        if (string.IsNullOrEmpty(username))
                        {
                            IO.CurrentIO.WriteColor("无法检测用户名,请在最后填入用户名", ConsoleColor.Red);
                        }
                    }
                    else
                    {
                        username = CombineString(parser.Arguments.Skip(1).ToArray());
                    }
                    Open($"https://osu.ppy.sh/users/{username}");
                }
                else
                {
                    IO.CurrentIO.Write(GetHelp());
                }
            }
            return(true);
        }
Example #5
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            Beatmap currentBeatmap = instance.GetOrtdp().Beatmap;

            if (parser.Arguments[0] == "au")
            {
                if (currentBeatmap is null || string.IsNullOrEmpty(currentBeatmap.AudioFileName) || !File.Exists(currentBeatmap.FullAudioFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.FullAudioFileName);
                string targetPath = GetName(instance.Setting.DefaultMusicCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullAudioFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "vi")
            {
                if (currentBeatmap is null || !currentBeatmap.HasVideo || string.IsNullOrEmpty(currentBeatmap.VideoFileName) || !File.Exists(currentBeatmap.FullVideoFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.VideoFileName);
                string targetPath = GetName(instance.Setting.DefaultMusicCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullVideoFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "bg")
            {
                if (currentBeatmap is null || string.IsNullOrEmpty(currentBeatmap.BackgroundFileName) || !File.Exists(currentBeatmap.FullBackgroundFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.BackgroundFileName);
                string targetPath = GetName(instance.Setting.DefaultBackgroundCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullBackgroundFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "osz")
            {
                GetOsz(instance);
            }
            else
            {
                IO.CurrentIO.Write(GetHelp());
            }
            return(true);
        }
Example #6
0
        public ICreationInfo Read(BinaryReader br, Type type, InfoReader infoReader)
        {
            var prefix = br.ReadString();

            if (prefix == "!R")
            {
                return(new ReferenceInfo(br.ReadInt32()));
            }
            return(Read(prefix, br, infoReader));
        }
Example #7
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected GeoObjectList(SerializationInfo info, StreamingContext context)
 {
     alist = (ArrayList)info.GetValue("List", typeof(ArrayList));
     list  = new List <IGeoObject>(alist.Count);
     for (int i = 0; i < alist.Count; i++)
     {
         list.Add(alist[i] as IGeoObject);
     }
     userData = InfoReader.ReadOrCreate(info, "UserData", typeof(UserData), new object[] { }) as UserData;
 }
Example #8
0
        private ObjectInfo Read(string prefix, BinaryReader br, InfoReader infoReader)
        {
            Type type = Type.GetType(prefix, true);
            var  info = new ObjectInfo
            {
                ObjectType = type,
                Fields     = ReadFields(type, br, infoReader),
            };

            return(info);
        }
Example #9
0
        public ICreationInfo Read(BinaryReader br, Type type, InfoReader infoReader)
        {
            var array = ReadArray(br, type, infoReader);

            return(new ArrayInfo
            {
                ElementType = type.GetElementType(),

                Array = array
            });
        }
Example #10
0
        private ICreationInfo[] ReadArray(BinaryReader br, Type arrayType, InfoReader infoReader)
        {
            var elementType = arrayType.GetElementType();
            var length      = br.ReadInt32();
            var arr         = new ICreationInfo[length];

            for (int i = 0; i < length; i++)
            {
                arr[i] = infoReader.Read(br, elementType);
            }
            return(arr);
        }
Example #11
0
        public bool Process(InfoReader infoReader, CommandParser parser)
        {
            Type t = infoReader.GetOrtdp().GetType();

            PropertyInfo[] properties = t.GetProperties();
            StringBuilder  b          = new StringBuilder();

            foreach (var property in properties)
            {
                if (property.GetCustomAttribute <AvailableVariableAttribute>() is AvailableVariableAttribute attr)
                {
                    b.AppendLine($"{attr.VariableName}   {NI18n.GetLanguageElement(attr.LanguageElementName)}");
                }
                if (property.PropertyType.IsClass)
                {
                    var currentObject = property.GetValue(infoReader.GetOrtdp());
                    if (!(currentObject is null))
                    {
                        var currentProperties = currentObject.GetType().GetProperties();
                        foreach (var i in currentProperties)
                        {
                            if (i.GetCustomAttribute <AvailableVariableAttribute>() is AvailableVariableAttribute attra)
                            {
                                b.AppendLine($"{attra.VariableName}   {NI18n.GetLanguageElement(attra.LanguageElementName)}");
                            }
                        }
                    }
                }
            }
            if (File.Exists("vars.txt"))
            {
                MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
                provider.ComputeHash(File.ReadAllBytes("vars.txt"));
                string md5NewFile = MD5String.GetString(provider);
                provider.ComputeHash(b.ToString().ToBytes());
                string md5Target = MD5String.GetString(provider);
                if (md5NewFile != md5Target)
                {
                    IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_WRITINGHELP"));
                    File.WriteAllText("vars.txt", b.ToString());
                }
            }
            else
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_WRITINGHELP"));
                File.WriteAllText("vars.txt", b.ToString());
            }
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
                FileName = "notepad.exe", Arguments = "vars.txt"
            });
            return(true);
        }
Example #12
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected LayerList(SerializationInfo info, StreamingContext context)
     : this()
 {
     try
     {
         unsortedEntries = info.GetValue("UnsortedEntries", typeof(Layer[])) as Layer[];
     }
     catch (SerializationException)
     {   // alte Dateien beinhalten entries direkt
         entries = (SortedList)info.GetValue("Entries", typeof(SortedList));
     }
     current = (Layer)InfoReader.Read(info, "Current", typeof(Layer));
 }
Example #13
0
 /// <summary>
 /// Constructor required by deserialization
 /// </summary>
 /// <param name="info">SerializationInfo</param>
 /// <param name="context">StreamingContext</param>
 protected HatchStyleList(SerializationInfo info, StreamingContext context)
 {
     try
     {
         unsortedEntries = info.GetValue("UnsortedEntries", typeof(HatchStyle[])) as HatchStyle[];
     }
     catch (SerializationException)
     {   // alte Dateien beinhalten entries direkt
         entries = (SortedList)info.GetValue("Entries", typeof(SortedList));
     }
     current    = (HatchStyle)InfoReader.Read(info, "Current", typeof(HatchStyle));
     resourceId = "HatchStyleList";
 }
        public void ReadObjectTypefromStream()
        {
            InfoReader ir = new InfoReader();

            using (Stream stream = new MemoryStream())
                using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream)))
                    using (BinaryReader br = new BinaryReader(stream))
                    {
                        wr.Write(new SampleClass());
                        stream.Seek(0, SeekOrigin.Begin);
                        var info = ir.Read <SampleClass>(br);
                        Assert.AreSame(typeof(SampleClass), ((ObjectInfo)info).ObjectType);
                    }
        }
        public void ReadPublicFieldNamefromStream()
        {
            InfoReader ir = new InfoReader();

            using (Stream stream = new MemoryStream())
                using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream)))
                    using (BinaryReader br = new BinaryReader(stream))
                    {
                        wr.Write(new SampleClass());
                        stream.Seek(0, SeekOrigin.Begin);
                        var    info         = ir.Read <SampleClass>(br) as ObjectInfo;
                        string expectedName = "simpleMember";
                        Assert.IsTrue(info.Fields.ContainsKey(expectedName));
                    }
        }
        private static ICreationInfo WriteObjectAndReadInfo <T>(T objectToWrite)
        {
            ICreationInfo info;

            using (Stream stream = new MemoryStream())
                using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream)))
                    using (BinaryReader br = new BinaryReader(stream))
                    {
                        wr.Write(objectToWrite);
                        stream.Seek(0, SeekOrigin.Begin);
                        InfoReader ir = new InfoReader();
                        info = ir.Read <T>(br);
                    }
            return(info);
        }
Example #17
0
        public static object GetVariableValue(InfoReader infoReader, string varName, ref bool exist)
        {
            Type t          = infoReader.GetOrtdp().GetType();
            var  properties = t.GetProperties();

            foreach (var p in properties)
            {
                if (p.Name == varName)
                {
                    exist = true;
                    return(p.GetValue(infoReader.GetOrtdp()));
                }
            }
            return(null);
        }
Example #18
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            _infoReader = instance;
            if (parser.Arguments.Count <= 0)
            {
                IO.CurrentIO.Write(GetHelp());
                return(true);
            }

            var commands = instance.CommandProcessors[parser.Arguments[0]];

            if (!(commands is null))
            {
                IO.CurrentIO.Write(commands.GetHelp());
            }
            return(true);
        }
Example #19
0
        void Search(InfoReader infoReader, string varName)
        {
            var p = infoReader.GetOrtdp().GetType().GetProperties();

            Sync.Tools.IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_VARSEARCHRESULT"));
            foreach (System.Reflection.PropertyInfo info in p)
            {
                string argupper = varName.ToUpper();
                string perupper = info.Name.ToUpper();
                if (perupper.Contains(argupper))
                {
                    Sync.Tools.IO.CurrentIO.Write(info.Name, false, false);
                    Sync.Tools.IO.CurrentIO.Write(" ", false, false);
                }
            }
            Sync.Tools.IO.CurrentIO.Write("\n", true, false);
        }
        public void ReadPublicIntFieldValuefromStream()
        {
            InfoReader ir = new InfoReader();

            using (Stream stream = new MemoryStream())
                using (ObjectWriter wr = new ObjectWriter(new BinaryWriter(stream)))
                    using (BinaryReader br = new BinaryReader(stream))
                    {
                        const int five         = 5;
                        var       simpleObject = new SampleClass {
                            simpleMember = five
                        };
                        wr.Write(simpleObject);
                        stream.Seek(0, SeekOrigin.Begin);
                        var info = ir.Read <SampleClass>(br) as ObjectInfo;
                        Assert.AreEqual(five, info.Fields["simpleMember"].GetInstance(null));
                    }
        }
Example #21
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            string apiKey = instance.Setting.ApiKey;

            if (parser.MainCommand == "user")
            {
                if (parser.Arguments[0] == "show")
                {
                    if (IsModeString(parser.Arguments.Last(), out int mode))
                    {
                        OnlineUserQuery query = new OnlineUserQuery
                        {
                            Mode      = (OsuGameMode)mode,
                            UserName  = CombineString(parser.Arguments.GetRange(1, parser.Arguments.Count - 2).ToArray()),
                            OsuApiKey = apiKey
                        };
                        try
                        {
                            if (query.UserInfo.UserId == 0)
                            {
                                string format = NI18n.GetLanguageElement("LANG_ERR_FAILTOQUERYUSERINFO");
                                throw new osuTools.Exceptions.OnlineQueryFailedException(string.Format(format,
                                                                                                       string.IsNullOrEmpty(query.UserName) ? query.UserId.ToString() : query.UserName));
                            }
                            IO.CurrentIO.Write(query.UserInfo.ToString());
                        }
                        catch (Exception e)
                        {
                            IO.CurrentIO.WriteColor(e.Message, ConsoleColor.Red);
                        }
                    }
                    else
                    {
                        IO.CurrentIO.WriteColor("模式必须在最后一个参数的位置被指定。",
                                                ConsoleColor.Red);
                        return(true);
                    }
                }
            }

            return(true);
        }
Example #22
0
        private void addbuton_Click(object sender, RoutedEventArgs e)
        {
            Readers     addReaders     = new Readers();
            Books       addBooks       = new Books();
            InfoReader  addInfoReader  = new InfoReader();
            Return      addReturn      = new Return();
            Extradition addExtradition = new Extradition();

            addReaders.Name    = tbName.Text;
            addReaders.Surname = tbSurname.Text;

            addReturn.ReturnDate = tbReturnDate.SelectedDate;

            addExtradition.DateOfIssue = tbDateOfIssue.SelectedDate;

            addBooks.Title  = tbTitle.Text;
            addBooks.Author = tbAuthor.Text;

            addInfoReader.HomeAddress = tbHomeAddress.Text;
            addInfoReader.Telephone   = tbTelephone.Text;

            addReaders.ID = addBooks.ID;
            addReaders.ID = addInfoReader.ID;
            addReaders.ID = addReturn.ID;
            addReaders.ID = addExtradition.ID;

            dbcontext.db.Readers.Add(addReaders);
            dbcontext.db.Books.Add(addBooks);
            dbcontext.db.InfoReader.Add(addInfoReader);
            dbcontext.db.Return.Add(addReturn);
            dbcontext.db.Extradition.Add(addExtradition);

            dbcontext.db.SaveChanges();

            MessageBox.Show("Вы добавили данные", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Example #23
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            if (_viewer is null)
            {
                _viewer = new VariableViewer(instance.GetOrtdp());
            }

            if (parser.MainCommand == "var")
            {
                if (parser.Arguments[0] == "gui")
                {
                    if (!_msgLoopStarted)
                    {
                        if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
                        {
                            IO.CurrentIO.Write($"Message loop on window VariableViewer started.");
                        }

                        Thread th = new Thread(() =>
                        {
                            System.Windows.Forms.Application.Run(_viewer);
                        });
                        th.Start();
                        if (th.ThreadState == ThreadState.Running)
                        {
                            _msgLoopStarted = true;
                        }
                        return(true);
                    }
                    if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
                    {
                        IO.CurrentIO.Write($"Message loop on VariableViewer is running. Showing window...");
                    }
                    _viewer.Show();
                    return(true);
                }
                int      match             = 0;
                var      s                 = parser.Arguments[0];
                Type     t                 = instance.GetOrtdp().GetType();
                var      ps                = t.GetProperties();
                string[] gets              = s.Split('.');
                object   currentObject     = instance.GetOrtdp();
                var      currentProperties = ps;
                foreach (var name in gets)
                {
                    foreach (var property in currentProperties)
                    {
                        if (property.Name == name)
                        {
                            currentObject     = property.GetValue(currentObject);
                            currentProperties = currentObject.GetType().GetProperties();
                            match++;
                        }
                    }
                }

                IO.CurrentIO.Write(match == gets.Length
                    ? $"{s}:{currentObject}"
                    : NI18n.GetLanguageElement("LANG_ERR_VARNOTFOUND"));
                return(true);
            }


            return(true);
        }
Example #24
0
 public void ReadXml(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     InfoReader reader2 = null;
     try
     {
         reader2 = new InfoReader(reader);
         this.ReadXml(reader2);
     }
     finally
     {
         if (reader2 != null)
         {
             try
             {
                 reader2.Close();
             }
             catch
             {
             }
             reader2 = null;
         }
     }
 }
Example #25
0
 public bool Process(InfoReader infoReader, CommandParser parser)
 {
     Search(infoReader, parser.Arguments[0]);
     return(true);
 }
Example #26
0
 public bool OnUnhandledException(InfoReader instance, Exception exception)
 {
     return(false);
 }
Example #27
0
 public bool Process(InfoReader instance, CommandParser parser)
 {
     try
     {
         var osuprocesses = System.Diagnostics.Process.GetProcessesByName("osu!");
         if (osuprocesses.Length == 0)
         {
             if (string.IsNullOrEmpty(instance.Setting.GameDir))
             {
                 IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_WAITINGFOROSU"), ConsoleColor.Red);
                 while (osuprocesses.Length == 0)
                 {
                     System.Threading.Thread.Sleep(3000);
                 }
             }
             else
             {
                 IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_STARTOSU"), ConsoleColor.Red);
                 System.Diagnostics.Process.Start(instance.Setting.GameDir);
             }
         }
         osuprocesses = System.Diagnostics.Process.GetProcessesByName("osu!");
         var osuprocess = osuprocesses[0];
         var osu        = new HandleTypes.ProcessHandle(osuprocess);
         foreach (ProcessModule module in osuprocess.Modules)
         {
             if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
             {
                 IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_HASINJECTED"));
                 return(true);
             }
         }
         Injector  injector = new Injector(osu.PID, $"{Environment.CurrentDirectory}\\..\\overlay.dll");
         var       res      = injector.Inject();
         Stopwatch s        = new Stopwatch();
         if (res)
         {
             var modules = osuprocess.Modules;
             s.Start();
             while (s.Elapsed.TotalSeconds < 0.5)
             {
                 foreach (ProcessModule module in modules)
                 {
                     if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
                     {
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
                         System.Threading.Thread.Sleep(3000);
                         Sync.SyncHost.Instance.RestartSync();
                         return(true);
                     }
                 }
             }
             if (!File.Exists("injector.exe"))
             {
                 File.WriteAllBytes("injector.exe", Resource1.FallbackInjector);
             }
             var cinjector = System.Diagnostics.Process.Start(
                 new ProcessStartInfo
             {
                 FileName        = "injector",
                 Arguments       = $"\"{Environment.CurrentDirectory}\\..\\overlay.dll\" {osuprocess.Id}",
                 CreateNoWindow  = true,
                 UseShellExecute = false
             });
             while (s.Elapsed.TotalSeconds < 0.5)
             {
                 foreach (ProcessModule module in modules)
                 {
                     if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
                     {
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
                         System.Threading.Thread.Sleep(3000);
                         Sync.SyncHost.Instance.RestartSync();
                         return(true);
                     }
                 }
             }
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
             System.Threading.Thread.Sleep(3000);
             Sync.SyncHost.Instance.RestartSync();
             return(true);
         }
         else
         {
             string msg = NI18n.GetLanguageElement("LANG_INJECTIONFAILED");
             msg += $"({WinAPI.ErrorHandle.GetLastError()}),{WinAPI.ErrorHandle.GetErrorString(WinAPI.ErrorHandle.FormatMessageFlags.FromSystem)}";
             IO.CurrentIO.WriteColor(msg, ConsoleColor.Red);
             return(true);
         }
     }
     catch (InvalidOperationException)
     {
         if (instance.Setting.GameDir == "")
         {
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_ERR_NOOSUDIR"), ConsoleColor.Red);
         }
         return(true);
     }
     catch (System.ComponentModel.Win32Exception)
     {
         if (!File.Exists(instance.Setting.GameDir))
         {
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_ERR_NOOSU"), ConsoleColor.Red);
         }
         return(true);
     }
 }
Example #28
0
        private ICreationInfo Read(FieldInfo fieldInfo, BinaryReader br, InfoReader infoReader)
        {
            var type = fieldInfo.FieldType;

            return(infoReader.Read(br, type));
        }
Example #29
0
        private ICreationInfo ReadField(Type type, BinaryReader br, string fieldName, InfoReader infoReader)
        {
            BindingFlags allInstanceFields = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
            var          fieldInfo         = type.GetField(fieldName, allInstanceFields);

            return(Read(fieldInfo, br, infoReader));
        }
Example #30
0
        private IDictionary <string, ICreationInfo> ReadFields(Type type, BinaryReader br, InfoReader infoReader)
        {
            var dic = new Dictionary <string, ICreationInfo>();

            for (string fieldName = br.ReadString(); fieldName != "!!!END!!!"; fieldName = br.ReadString())
            {
                dic[fieldName] = ReadField(type, br, fieldName, infoReader);
            }

            return(dic);
        }
        public ICreationInfo Read(BinaryReader br, Type type, InfoReader infoReader)
        {
            var value = Read(br, type);

            return(new SimpleTypeInfo(value));
        }