示例#1
0
        /// <summary>
        /// Get the existence of an anti-modchip string from a PlayStation disc, if possible
        /// </summary>
        /// <param name="path">Path to scan for anti-modchip strings</param>
        /// <returns>Anti-modchip existence if possible, false on error</returns>
        public static async Task <bool> GetPlayStationAntiModchipDetected(string path)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var antiModchip = new PSXAntiModchip();
                    foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
                    {
                        try
                        {
                            byte[] fileContent = File.ReadAllBytes(file);
                            string protection = antiModchip.CheckContents(file, fileContent, false, null, null);
                            if (!string.IsNullOrWhiteSpace(protection))
                            {
                                return true;
                            }
                        }
                        catch { }
                    }
                }
                catch { }

                return false;
            }));
        }
示例#2
0
        /// <summary>
        /// Get the existance of an anti-modchip string from a PlayStation disc, if possible
        /// </summary>
        /// <param name="driveLetter">Drive letter to use to check</param>
        /// <returns>Anti-modchip existance if possible, false on error</returns>
        protected static bool GetPlayStationAntiModchipDetected(char?driveLetter)
        {
            // If there's no drive letter, we can't do this part
            if (driveLetter == null)
            {
                return(false);
            }

            // If the folder no longer exists, we can't do this part
            string drivePath = driveLetter + ":\\";

            if (!Directory.Exists(drivePath))
            {
                return(false);
            }

            // Scan through each file to check for the anti-modchip strings
            var antiModchip = new PSXAntiModchip();

            foreach (string path in Directory.EnumerateFiles(drivePath, "*", SearchOption.AllDirectories))
            {
                try
                {
                    byte[] fileContent = File.ReadAllBytes(path);
                    string protection  = antiModchip.CheckContents(path, fileContent, includePosition: false);
                    if (!string.IsNullOrWhiteSpace(protection))
                    {
                        return(true);
                    }
                }
                catch
                {
                    // No-op, we don't care what the error was
                }
            }

            return(false);
        }