Example #1
0
        private static InfoEntry ReadInfo(BinaryReader infosReader)
        {
            InfoEntry infoEntry = new InfoEntry();

            infoEntry.Address           = infosReader.ReadUInt64();
            infoEntry.GuestSize         = infosReader.ReadUInt64();
            infoEntry.HighCq            = infosReader.ReadBoolean();
            infoEntry.Stubbed           = infosReader.ReadBoolean();
            infoEntry.CodeLen           = infosReader.ReadInt32();
            infoEntry.RelocEntriesCount = infosReader.ReadInt32();

            return(infoEntry);
        }
Example #2
0
        private static void UpdateInfo(InfoEntry infoEntry)
        {
            _infosStream.Seek(-InfoEntry.Stride, SeekOrigin.Current);

            // WriteInfo.
            _infosWriter.Write((ulong)infoEntry.Address);
            _infosWriter.Write((ulong)infoEntry.GuestSize);
            _infosWriter.Write((ulong)infoEntry.Hash.Low);
            _infosWriter.Write((ulong)infoEntry.Hash.High);
            _infosWriter.Write((bool)infoEntry.HighCq);
            _infosWriter.Write((bool)infoEntry.Stubbed);
            _infosWriter.Write((int)infoEntry.CodeLen);
            _infosWriter.Write((int)infoEntry.RelocEntriesCount);
        }
        /// <summary>
        /// Gets subtitle file matching to video
        /// </summary>
        /// <param name="ieVideo">InfoEntry of a video to find matching subtitle file for</param>
        /// <returns>Matching subtitle file</returns>
        public InfoEntry GetSubtitle(InfoEntry ieVideo)
        {
            List <string> subext = new List <string>(Helper.ReadProperties(Config.SubtitleExtensions));

            foreach (InfoEntry ie in this.episodes)
            {
                if (Path.GetFileNameWithoutExtension(ieVideo.Filename) == Path.GetFileNameWithoutExtension(ie.Filename))
                {
                    if (subext.Contains(ie.Extension))
                    {
                        return(ie);
                    }
                }
            }
            return(null);
        }
        public void Add(InfoEntry info, string category = "Default")
        {
            IList <InfoEntry> list;

            if (!_info.TryGetValue(category, out list))
            {
                list = new List <InfoEntry>();
                _info.Add(category, list);
            }

            if (list.Any(p => p.Title == info.Title))
            {
                throw new ArgumentException("An InfoEntry object with the same title already exists in that category.", "info");
            }

            list.Add(info);
        }
Example #5
0
 /// <summary>
 /// Figures out if this is a movie file by looking at the destination path. Right now this only works
 /// if season subdirectories are used, as this check looks for the season directory folder in the destination
 /// path. Future versions might also check for similarity between the name of the file and the destination folder,
 /// since movie files are to be put in the same folder as their name (minus part identifiers, i.e. "CD1").
 /// </summary>
 /// <param name="ie">the file which is checked</param>
 /// <returns>true if ie is a movie file, false otherwise</returns>
 public static bool IsMovie(InfoEntry ie)
 {
     if (ie.Destination == "")
     {
         return(false);
     }
     string[] patterns = Helper.ReadProperties(Config.Extract);
     for (int i = patterns.Length - 1; i >= 0; i--)
     {
         string seasondir = patterns[i].Replace("%E", "\\d*");
         seasondir = seasondir.Replace("%S", "\\d*");
         if (Regex.Match(ie.Destination, seasondir).Success)
         {
             return(false);
         }
     }
     return(true);
 }
Example #6
0
        void AttachRow(int row, InfoEntry entry)
        {
            if (!entry.TwoColumns)
            {
                info_table.Attach(entry.LabelWidget, 0, 1, (uint)row, (uint)row + 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
            }

            info_table.Attach(entry.InfoWidget, entry.TwoColumns ? 0u : 1u, 2, (uint)row, (uint)row + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            if (entry.InfoWidget is Label infoLabel)
            {
                infoLabel.PopulatePopup += HandlePopulatePopup;
            }

            if (entry.InfoWidget is Entry infoEntry)
            {
                infoEntry.PopulatePopup += HandlePopulatePopup;
            }
        }
        protected override void DoPaintEvent(BaseScreen screen)
        {
            base.DoPaintEvent(screen);

            screen.SetTextColor(Colors.Gold, true);

            ExtRect crt = ClientRect;
            ExtRect cr  = new ExtRect();

            cr.Left   = crt.Left + 10;
            cr.Right  = crt.Right - 10;
            cr.Top    = crt.Top + 10;
            cr.Bottom = cr.Top + 36 - 1;
            CtlCommon.DrawCtlBorder(screen, cr);

            //int ww = (32 * 3) + (10 * 2);
            //cr.inflate(-2, -2);
            int offset = (cr.Width) / 3; //- ww

            int sy = cr.Top + (cr.Height - screen.GetTextHeight("A")) / 2;

            for (int i = 0; i < 3; i++)
            {
                int     runeId = fRunes[i];
                RuneRec rune   = StaticData.dbRunes[runeId];
                //GlobalVars.nwrWin.Resources.drawImage(screen, cr.Left + offset + (i * (32 + 10)), cr.Top + 3, rune.ImageIndex, 255);
                InfoEntry inf = (InfoEntry)GlobalVars.nwrDB.FindEntryBySign(rune.Sign);

                int sx = cr.Left + (offset * i);
                GlobalVars.nwrWin.Resources.DrawImage(screen, sx, cr.Top + 3, rune.ImageIndex, 255);

                sx = sx + 32 + 3;
                screen.DrawText(sx, sy, inf.Name, 0);
            }

            /*rt = new TRect(cr.Left + 2, cr.Top + 2, cr.Left + 2 + 32 - 1, cr.Top + 2 + 32 - 1);
             * screen.fillRect(rt, Colors.White);
             *
             * screen.drawText(rt.Right + 10, cr.Top + (36 - screen.getTextHeight("A")) / 2, this.fCollocutor.getName(), 0);*/
        }
Example #8
0
        void AttachRow(int row, InfoEntry entry)
        {
            if (!entry.TwoColumns)
            {
                info_table.Attach(entry.LabelWidget, 0, 1, (uint)row, (uint)row + 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
            }

            info_table.Attach(entry.InfoWidget, entry.TwoColumns ? 0u : 1u, 2, (uint)row, (uint)row + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            var info_label = entry.InfoWidget as Label;

            if (info_label != null)
            {
                info_label.PopulatePopup += HandlePopulatePopup;
            }

            var info_entry = entry.InfoWidget as Entry;

            if (info_entry != null)
            {
                info_entry.PopulatePopup += HandlePopulatePopup;
            }
        }
        private void CreateDefaultSet()
        {
            _info.Add("System", new[]
            {
                InfoEntry.Create("Operating System", UnityEngine.SystemInfo.operatingSystem),
                InfoEntry.Create("Device Name", UnityEngine.SystemInfo.deviceName, true),
                InfoEntry.Create("Device Type", UnityEngine.SystemInfo.deviceType),
                InfoEntry.Create("Device Model", UnityEngine.SystemInfo.deviceModel),
                InfoEntry.Create("CPU Type", UnityEngine.SystemInfo.processorType),
                InfoEntry.Create("CPU Count", UnityEngine.SystemInfo.processorCount),
                InfoEntry.Create("System Memory", SRFileUtil.GetBytesReadable(((long)UnityEngine.SystemInfo.systemMemorySize) * 1024 * 1024))
                //Info.Create("Process Name", () => Process.GetCurrentProcess().ProcessName)
            });


#if ENABLE_IL2CPP
            const string IL2CPP = "Yes";
#else
            const string IL2CPP = "No";
#endif

            _info.Add("Unity", new[]
            {
                InfoEntry.Create("Version", Application.unityVersion),
                InfoEntry.Create("Debug", Debug.isDebugBuild),
                InfoEntry.Create("Unity Pro", Application.HasProLicense()),
                InfoEntry.Create("Genuine",
                                 "{0} ({1})".Fmt(Application.genuine ? "Yes" : "No",
                                                 Application.genuineCheckAvailable ? "Trusted" : "Untrusted")),
                InfoEntry.Create("System Language", Application.systemLanguage),
                InfoEntry.Create("Platform", Application.platform),
                InfoEntry.Create("IL2CPP", IL2CPP),
                InfoEntry.Create("Application Version", Application.version),
                InfoEntry.Create("SRDebugger Version", SRDebug.Version),
            });

            _info.Add("Display", new[]
            {
                InfoEntry.Create("Resolution", () => Screen.width + "x" + Screen.height),
                InfoEntry.Create("DPI", () => Screen.dpi),
                InfoEntry.Create("Fullscreen", () => Screen.fullScreen),
                InfoEntry.Create("Orientation", () => Screen.orientation)
            });

            _info.Add("Runtime", new[]
            {
                InfoEntry.Create("Play Time", () => Time.unscaledTime),
                InfoEntry.Create("Level Play Time", () => Time.timeSinceLevelLoad),
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
                InfoEntry.Create("Current Level", () => Application.loadedLevelName),
#else
                InfoEntry.Create("Current Level", () =>
                {
                    var activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
                    return("{0} (Index: {1})".Fmt(activeScene.name, activeScene.buildIndex));
                }),
#endif
                InfoEntry.Create("Quality Level",
                                 () =>
                                 QualitySettings.names[QualitySettings.GetQualityLevel()] + " (" +
                                 QualitySettings.GetQualityLevel() + ")")
            });

            // Check for cloud build manifest
            var cloudBuildManifest = (TextAsset)Resources.Load("UnityCloudBuildManifest.json");
            var manifestDict       = cloudBuildManifest != null
                ? Json.Deserialize(cloudBuildManifest.text) as Dictionary <string, object>
                : null;

            if (manifestDict != null)
            {
                var manifestList = new List <InfoEntry>(manifestDict.Count);

                foreach (var kvp in manifestDict)
                {
                    if (kvp.Value == null)
                    {
                        continue;
                    }

                    var value = kvp.Value.ToString();
                    manifestList.Add(InfoEntry.Create(GetCloudManifestPrettyName(kvp.Key), value));
                }

                _info.Add("Build", manifestList);
            }

            _info.Add("Features", new[]
            {
                InfoEntry.Create("Location", UnityEngine.SystemInfo.supportsLocationService),
                InfoEntry.Create("Accelerometer", UnityEngine.SystemInfo.supportsAccelerometer),
                InfoEntry.Create("Gyroscope", UnityEngine.SystemInfo.supportsGyroscope),
                InfoEntry.Create("Vibration", UnityEngine.SystemInfo.supportsVibration)
            });

#if UNITY_IOS
            _info.Add("iOS", new[] {
#if UNITY_5 || UNITY_5_3_OR_NEWER
                InfoEntry.Create("Generation", UnityEngine.iOS.Device.generation),
                InfoEntry.Create("Ad Tracking", UnityEngine.iOS.Device.advertisingTrackingEnabled),
#else
                InfoEntry.Create("Generation", iPhone.generation),
                InfoEntry.Create("Ad Tracking", iPhone.advertisingTrackingEnabled),
#endif
            });
#endif
#pragma warning disable 618
            _info.Add("Graphics", new[]
            {
                InfoEntry.Create("Device Name", UnityEngine.SystemInfo.graphicsDeviceName),
                InfoEntry.Create("Device Vendor", UnityEngine.SystemInfo.graphicsDeviceVendor),
                InfoEntry.Create("Device Version", UnityEngine.SystemInfo.graphicsDeviceVersion),
                InfoEntry.Create("Max Tex Size", UnityEngine.SystemInfo.maxTextureSize),
#if !UNITY_5 && !UNITY_5_3_OR_NEWER
                InfoEntry.Create("Fill Rate",
                                 SystemInfo.graphicsPixelFillrate > 0 ? "{0}mpix/s".Fmt(SystemInfo.graphicsPixelFillrate) : "Unknown"),
#endif
                InfoEntry.Create("NPOT Support", UnityEngine.SystemInfo.npotSupport),
                InfoEntry.Create("Render Textures",
                                 "{0} ({1})".Fmt(UnityEngine.SystemInfo.supportsRenderTextures ? "Yes" : "No",
                                                 UnityEngine.SystemInfo.supportedRenderTargetCount)),
                InfoEntry.Create("3D Textures", UnityEngine.SystemInfo.supports3DTextures),
                InfoEntry.Create("Compute Shaders", UnityEngine.SystemInfo.supportsComputeShaders),
#if !UNITY_5 && !UNITY_5_3_OR_NEWER
                InfoEntry.Create("Vertex Programs", SystemInfo.supportsVertexPrograms),
#endif
                InfoEntry.Create("Image Effects", UnityEngine.SystemInfo.supportsImageEffects),
                InfoEntry.Create("Cubemaps", UnityEngine.SystemInfo.supportsRenderToCubemap),
                InfoEntry.Create("Shadows", UnityEngine.SystemInfo.supportsShadows),
                InfoEntry.Create("Stencil", UnityEngine.SystemInfo.supportsStencil),
                InfoEntry.Create("Sparse Textures", UnityEngine.SystemInfo.supportsSparseTextures)
            });
#pragma warning restore 618
        }
Example #10
0
 public void AddSystemInfo(InfoEntry entry, string category = "Default")
 {
     _informationService.Add(entry, category);
 }
Example #11
0
        /// <summary>
        /// Returns the cache entry for the given member info. If the cache entry doesn't exist,
        /// the entry for the info is populated on demand.
        /// </summary>
        private static InfoEntry GetCacheEntry(MemberInfo info)
        {
            InfoEntry cachedInfo = new InfoEntry();

            lock (infoCache) {
                if (infoCache.TryGetValue(info, out cachedInfo))
                {
                    return(cachedInfo);
                }
            }

            //
            // SdfVariability
            //
            var attrs = (UsdVariabilityAttribute[])info.GetCustomAttributes(
                typeof(UsdVariabilityAttribute), true);

            cachedInfo.sdfVariability = attrs.Length == 0
                                ? pxr.SdfVariability.SdfVariabilityVarying
                                : attrs[0].SdfVariability;

            //
            // IsPrimvar
            //
            var attrs2 = (VertexDataAttribute[])info.
                         GetCustomAttributes(typeof(VertexDataAttribute), true);

            cachedInfo.isPrimvar = attrs2.Length > 0;

            //
            // IsFusedDisplayColor
            //
            var attrs7 = (FusedDisplayColorAttribute[])info.
                         GetCustomAttributes(typeof(FusedDisplayColorAttribute), true);

            cachedInfo.isFusedDisplayColor = attrs7.Length > 0;

            //
            // IsFusedTransform
            //
            var attrs8 = (FusedTransformAttribute[])info.
                         GetCustomAttributes(typeof(FusedTransformAttribute), true);

            cachedInfo.isFusedTransform = attrs8.Length > 0;

            //
            // IsCustomData
            //
            var attrs6 = (CustomDataAttribute[])info.
                         GetCustomAttributes(typeof(CustomDataAttribute), true);

            cachedInfo.isCustomData = attrs6.Length > 0;

            //
            // IsNonSerialized
            //
            var attrs3 = (NonSerializedAttribute[])info.
                         GetCustomAttributes(typeof(NonSerializedAttribute), true);

            cachedInfo.isNonSerialized = attrs3.Length > 0;

            //
            // UsdNamespace
            //
            var attrs4 = (UsdNamespaceAttribute[])info.
                         GetCustomAttributes(typeof(UsdNamespaceAttribute), true);

            cachedInfo.usdNamespace = attrs4.Length == 0 ? "" : attrs4[0].Name;

            //
            // IsRelationship
            //
            var attrs9 = (UsdRelationshipAttribute[])info.
                         GetCustomAttributes(typeof(UsdRelationshipAttribute), true);

            cachedInfo.isRelationship = attrs9.Length > 0;

            //
            // IsAssetPath
            //
            var attrs10 = (UsdAssetPathAttribute[])info.
                          GetCustomAttributes(typeof(UsdAssetPathAttribute), true);

            cachedInfo.isAssetPath = attrs10.Length > 0;

            //
            // Cache & return.
            //
            lock (infoCache) {
                infoCache[info] = cachedInfo;
            }
            return(cachedInfo);
        }
Example #12
0
 internal void Add(InfoEntry ie)
 {
     this.episodes.Add(ie);
 }
Example #13
0
        internal static void LoadTranslations(ConcurrentDictionary <ulong, TranslatedFunction> funcs, IMemoryManager memory, JumpTable jumpTable)
        {
            if ((int)_infosStream.Length == 0 ||
                (int)_codesStream.Length == 0 ||
                (int)_relocsStream.Length == 0 ||
                (int)_unwindInfosStream.Length == 0)
            {
                return;
            }

            Debug.Assert(funcs.Count == 0);

            _infosStream.Seek(0L, SeekOrigin.Begin);
            _codesStream.Seek(0L, SeekOrigin.Begin);
            _relocsStream.Seek(0L, SeekOrigin.Begin);
            _unwindInfosStream.Seek(0L, SeekOrigin.Begin);

            using (BinaryReader infosReader = new BinaryReader(_infosStream, EncodingCache.UTF8NoBOM, true))
                using (BinaryReader codesReader = new BinaryReader(_codesStream, EncodingCache.UTF8NoBOM, true))
                    using (BinaryReader relocsReader = new BinaryReader(_relocsStream, EncodingCache.UTF8NoBOM, true))
                        using (BinaryReader unwindInfosReader = new BinaryReader(_unwindInfosStream, EncodingCache.UTF8NoBOM, true))
                        {
                            for (int i = 0; i < GetInfosEntriesCount(); i++)
                            {
                                InfoEntry infoEntry = ReadInfo(infosReader);

                                if (infoEntry.Stubbed)
                                {
                                    SkipCode(infoEntry.CodeLen);
                                    SkipReloc(infoEntry.RelocEntriesCount);
                                    SkipUnwindInfo(unwindInfosReader);
                                }
                                else if (infoEntry.HighCq || !PtcProfiler.ProfiledFuncs.TryGetValue(infoEntry.Address, out var value) || !value.highCq)
                                {
                                    byte[] code = ReadCode(codesReader, infoEntry.CodeLen);

                                    if (infoEntry.RelocEntriesCount != 0)
                                    {
                                        RelocEntry[] relocEntries = GetRelocEntries(relocsReader, infoEntry.RelocEntriesCount);

                                        PatchCode(code, relocEntries, memory.PageTablePointer, jumpTable);
                                    }

                                    UnwindInfo unwindInfo = ReadUnwindInfo(unwindInfosReader);

                                    TranslatedFunction func = FastTranslate(code, infoEntry.GuestSize, unwindInfo, infoEntry.HighCq);

                                    bool isAddressUnique = funcs.TryAdd(infoEntry.Address, func);

                                    Debug.Assert(isAddressUnique, $"The address 0x{infoEntry.Address:X16} is not unique.");
                                }
                                else
                                {
                                    infoEntry.Stubbed = true;
                                    UpdateInfo(infoEntry);

                                    StubCode(infoEntry.CodeLen);
                                    StubReloc(infoEntry.RelocEntriesCount);
                                    StubUnwindInfo(unwindInfosReader);
                                }
                            }
                        }

            if (_infosStream.Position < _infosStream.Length ||
                _codesStream.Position < _codesStream.Length ||
                _relocsStream.Position < _relocsStream.Length ||
                _unwindInfosStream.Position < _unwindInfosStream.Length)
            {
                throw new Exception("Could not reach the end of one or more memory streams.");
            }

            jumpTable.Initialize(PtcJumpTable, funcs);

            PtcJumpTable.WriteJumpTable(jumpTable, funcs);
            PtcJumpTable.WriteDynamicTable(jumpTable);

            Logger.Info?.Print(LogClass.Ptc, $"{funcs.Count} translated functions loaded");
        }
 private void SetEntryWidgetVisibility(InfoEntry entry, bool def)
 {
     entry.InfoWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
     entry.LabelWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
 }
        private void AttachRow(int row, InfoEntry entry)
        {
            if (!entry.TwoColumns) {
                info_table.Attach (entry.LabelWidget, 0, 1, (uint)row, (uint)row + 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
            }

            info_table.Attach (entry.InfoWidget, entry.TwoColumns ? 0u : 1u, 2, (uint)row, (uint)row + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            var info_label = entry.InfoWidget as Label;
            if (info_label != null)
                info_label.PopulatePopup += HandlePopulatePopup;

            var info_entry = entry.InfoWidget as Entry;
            if (info_entry != null)
                info_entry.PopulatePopup += HandlePopulatePopup;
            ;
        }
Example #16
0
        /// <summary>
        /// Main Rename function
        /// </summary>
        public void Rename(BackgroundWorker worker, DoWorkEventArgs e)
        {
            this.worker = worker;
            this.dwea   = e;

            long TotalBytes = 0;
            long Bytes      = 0;

            foreach (InfoEntry ie in episodes)
            {
                if (ie.ProcessingRequested && ie.Destination != "" && ie.FilePath.Fullfilename.ToLower()[0] != ie.Destination.ToLower()[0])
                {
                    FileInfo info = new FileInfo(ie.FilePath.Fullfilename);
                    TotalBytes += info.Length;
                }
            }
            //Go through all files and do stuff
            for (int i = 0; i < this.episodes.Count; i++)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    Logger.Instance.LogMessage("Renaming Cancelled.", LogLevel.INFO);
                    return;
                }

                InfoEntry ie = InfoEntryManager.Instance[i];
                if (ie.MarkedForDeletion && ie.ProcessingRequested)
                {
                    try
                    {
                        File.Delete(ie.FilePath.Fullfilename);
                        episodes.Remove(ie);
                        //Go back so no entry is skipped after removal of current entry
                        i--;
                        continue;
                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.LogMessage("Couldn't delete " + ie.FilePath.Fullfilename + ": " + ex.Message, LogLevel.ERROR);
                    }
                }

                //need to set before ie.Rename because it resets some conditions
                bool copyfile = ie.ProcessingRequested && ie.Destination != "" && ie.FilePath.Fullfilename.ToLower()[0] != ie.Destination.ToLower()[0];

                //if there are files which actually need to be copied since they're on a different drive, only count those for the progress bar status since they take much longer
                if (TotalBytes > 0)
                {
                    ProgressAtCopyStart = ((double)Bytes / (double)TotalBytes * 100);
                    if (copyfile)
                    {
                        ProgressAtCopyEnd = Math.Min(ProgressAtCopyStart + (long)(((double)new FileInfo(ie.FilePath.Fullfilename).Length) / (double)TotalBytes * 100), 100);
                    }
                    else
                    {
                        ProgressAtCopyEnd = ProgressAtCopyStart;
                    }
                }
                else
                {
                    ProgressAtCopyStart = i;
                    ProgressAtCopyEnd   = i;
                }

                worker.ReportProgress((int)ProgressAtCopyStart);

                //if a InfoEntry is moved to a different destination directory that isn't visible in the current basedir, remove it
                int  subdirlevel = Filepath.GetSubdirectoryLevel(Helper.ReadProperty(Config.LastDirectory), ie.Destination);
                bool remove      = subdirlevel > Helper.ReadInt(Config.MaxDepth) || subdirlevel == -1;
                //this call will also report progress more detailed by calling ReportSingleFileProgress()
                ie.Rename(worker, e);
                if (remove)
                {
                    episodes.Remove(ie);
                    //Go back so no entry is skipped after removal of current entry
                    i--;
                }
                //after file is (really) copied, add its size
                if (copyfile)
                {
                    Bytes += new FileInfo(ie.FilePath.Fullfilename).Length;
                }
            }
            if (Helper.ReadBool(Config.DeleteEmptyFolders))
            {
                //Delete all empty folders code
                Helper.DeleteAllEmptyFolders(Helper.ReadProperty(Config.LastDirectory), new List <string>(Helper.ReadProperties(Config.IgnoreFiles)), worker, e);
            }
            if (!e.Cancel)
            {
                Logger.Instance.LogMessage("Renaming (and possibly moving and deleting) finished!", LogLevel.INFO);
            }
            else
            {
                Logger.Instance.LogMessage("Renaming Cancelled.", LogLevel.INFO);
            }
        }
Example #17
0
        internal static void LoadTranslations(
            ConcurrentDictionary <ulong, TranslatedFunction> funcs,
            IMemoryManager memory,
            JumpTable jumpTable,
            EntryTable <uint> countTable)
        {
            if (AreCarriersEmpty())
            {
                return;
            }

            long infosStreamLength       = _infosStream.Length;
            long relocsStreamLength      = _relocsStream.Length;
            long unwindInfosStreamLength = _unwindInfosStream.Length;

            _infosStream.Seek(0L, SeekOrigin.Begin);
            _relocsStream.Seek(0L, SeekOrigin.Begin);
            _unwindInfosStream.Seek(0L, SeekOrigin.Begin);

            using (BinaryReader relocsReader = new(_relocsStream, EncodingCache.UTF8NoBOM, true))
                using (BinaryReader unwindInfosReader = new(_unwindInfosStream, EncodingCache.UTF8NoBOM, true))
                {
                    for (int index = 0; index < GetEntriesCount(); index++)
                    {
                        InfoEntry infoEntry = DeserializeStructure <InfoEntry>(_infosStream);

                        if (infoEntry.Stubbed)
                        {
                            SkipCode(index, infoEntry.CodeLength);
                            SkipReloc(infoEntry.RelocEntriesCount);
                            SkipUnwindInfo(unwindInfosReader);

                            continue;
                        }

                        bool isEntryChanged = infoEntry.Hash != ComputeHash(memory, infoEntry.Address, infoEntry.GuestSize);

                        if (isEntryChanged || (!infoEntry.HighCq && PtcProfiler.ProfiledFuncs.TryGetValue(infoEntry.Address, out var value) && value.HighCq))
                        {
                            infoEntry.Stubbed    = true;
                            infoEntry.CodeLength = 0;
                            UpdateInfo(infoEntry);

                            StubCode(index);
                            StubReloc(infoEntry.RelocEntriesCount);
                            StubUnwindInfo(unwindInfosReader);

                            if (isEntryChanged)
                            {
                                PtcJumpTable.Clean(infoEntry.Address);

                                Logger.Info?.Print(LogClass.Ptc, $"Invalidated translated function (address: 0x{infoEntry.Address:X16})");
                            }

                            continue;
                        }

                        byte[] code = ReadCode(index, infoEntry.CodeLength);

                        Counter <uint> callCounter = null;

                        if (infoEntry.RelocEntriesCount != 0)
                        {
                            RelocEntry[] relocEntries = GetRelocEntries(relocsReader, infoEntry.RelocEntriesCount);

                            PatchCode(code, relocEntries, memory.PageTablePointer, jumpTable, countTable, out callCounter);
                        }

                        UnwindInfo unwindInfo = ReadUnwindInfo(unwindInfosReader);

                        TranslatedFunction func = FastTranslate(code, callCounter, infoEntry.GuestSize, unwindInfo, infoEntry.HighCq);

                        bool isAddressUnique = funcs.TryAdd(infoEntry.Address, func);

                        Debug.Assert(isAddressUnique, $"The address 0x{infoEntry.Address:X16} is not unique.");
                    }
                }

            if (_infosStream.Length != infosStreamLength || _infosStream.Position != infosStreamLength ||
                _relocsStream.Length != relocsStreamLength || _relocsStream.Position != relocsStreamLength ||
                _unwindInfosStream.Length != unwindInfosStreamLength || _unwindInfosStream.Position != unwindInfosStreamLength)
            {
                throw new Exception("The length of a memory stream has changed, or its position has not reached or has exceeded its end.");
            }

            jumpTable.Initialize(PtcJumpTable, funcs);

            PtcJumpTable.WriteJumpTable(jumpTable, funcs);
            PtcJumpTable.WriteDynamicTable(jumpTable);

            Logger.Info?.Print(LogClass.Ptc, $"{funcs.Count} translated functions loaded");
        }
Example #18
0
 public void Remove(InfoEntry ie)
 {
     this.episodes.Remove(ie);
 }
Example #19
0
        private static void UpdateInfo(InfoEntry infoEntry)
        {
            _infosStream.Seek(-Unsafe.SizeOf <InfoEntry>(), SeekOrigin.Current);

            SerializeStructure(_infosStream, infoEntry);
        }
Example #20
0
 void SetEntryWidgetVisibility(InfoEntry entry, bool def)
 {
     entry.InfoWidget.Visible  = ContextSwitchStrategy.InfoEntryVisible(Context, entry) && def;
     entry.LabelWidget.Visible = ContextSwitchStrategy.InfoEntryVisible(Context, entry) && def;
 }