Example #1
0
        private IsoDetailsResults readXex()
        {
            IsoDetailsResults results = null;

            byte[] bytes    = null;
            string path     = null;
            string pathTemp = null;

            Console.WriteLine("+ Locating default.xex...");
            try
            {
                bytes    = iso.GetFile("default.xex");
                pathTemp = args.PathTemp;
                path     = pathTemp + "default.xex";
                Console.WriteLine("+ Extracting default.xex...");
                if ((bytes == null) || (bytes.Length == 0))
                {
                    throw new Exception("Couldn't locate default.xex. Please check this ISO is valid.");
                }
                File.WriteAllBytes(path, bytes);
            }
            catch (Exception exception)
            {
                throw new Exception("A problem occured when reading the contents of the ISO image.\n\nPlease ensure this is a valid Xbox 360 ISO by running it through ABGX360.\n\n" + exception.Message);
            }
            Console.WriteLine("+ Found! Reading default.xex...");
            using (XexInfo info = new XexInfo(bytes))
            {
                if (!info.IsValid)
                {
                    throw new Exception("Default.xex is not valid.");
                }
                if (info.Header.ContainsKey(XexInfoFields.ExecutionInfo))
                {
                    XexExecutionInfo info2 = (XexExecutionInfo)info.Header[XexInfoFields.ExecutionInfo];
                    results = new IsoDetailsResults("", DataConversion.BytesToHexString(info2.TitleID), DataConversion.BytesToHexString(info2.MediaID), info2.Platform.ToString(), info2.ExecutableType.ToString(), info2.DiscNumber.ToString(), info2.DiscCount.ToString());
                }
            }
            Console.WriteLine("+ Extracting resources...");
            Process process = new Process {
                EnableRaisingEvents = false
            };

            process.StartInfo.FileName = args.PathXexTool;
            if (File.Exists(process.StartInfo.FileName))
            {
                process.StartInfo.WorkingDirectory       = pathTemp;
                process.StartInfo.Arguments              = "-d . default.xex";
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = false;
                process.StartInfo.CreateNoWindow         = true;
                try
                {
                    process.Start();
                    process.WaitForExit();
                    process.Close();
                }
                catch (Win32Exception)
                {
                    throw new Exception("Could not launch XexTool!");
                }
                if (results != null && File.Exists(pathTemp + results.TitleID))
                {
                    Xdbf xdbf = new Xdbf(File.ReadAllBytes(pathTemp + results.TitleID));
                    try
                    {
                        MemoryStream stream3 = new MemoryStream(xdbf.GetResource(1, 3));
                        stream3.Seek(0x11L, SeekOrigin.Begin);
                        int count = stream3.ReadByte();
                        results.Name = Encoding.UTF8.GetString(stream3.ToArray(), 0x12, count);
                        stream3.Close();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            MemoryStream stream4 = new MemoryStream(xdbf.GetResource(1, 0));
                            stream4.Seek(0x11L, SeekOrigin.Begin);
                            int num2 = stream4.ReadByte();
                            results.Name = Encoding.UTF8.GetString(stream4.ToArray(), 0x12, num2);
                            stream4.Close();
                        }
                        catch (Exception)
                        {
                            results.Name = "Unable to read name.";
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("- Couldn't locate XexTool. Expected location was:\n" + process.StartInfo.FileName + "\n\nTry disabling User Access Control if it's enabled.");
            }
            return(results);
        }
Example #2
0
        private void readXex(DoWorkEventArgs e)
        {
            IsoDetailsResults results = null;

            byte[] bytes    = null;
            string path     = null;
            string pathTemp = null;

            base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Progress, "Locating default.xex..."));
            try
            {
                bytes    = this.iso.GetFile("default.xex");
                pathTemp = this.args.PathTemp;
                path     = pathTemp + "default.xex";
                base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Progress, "Extracting default.xex..."));
                if ((bytes == null) || (bytes.Length == 0))
                {
                    base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "Couldn't locate default.xex. Please check this ISO is valid."));
                    return;
                }
                File.WriteAllBytes(path, bytes);
            }
            catch (Exception exception)
            {
                base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "A problem occured when reading the contents of the ISO image.\n\nPlease ensure this is a valid Xbox 360 ISO by running it through ABGX360.\n\n" + exception.Message));
                return;
            }
            base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Progress, "Found! Reading default.xex..."));
            using (XexInfo info = new XexInfo(bytes))
            {
                if (!info.IsValid)
                {
                    base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "Default.xex is not valid."));
                    return;
                }
                if (info.Header.ContainsKey(XexInfoFields.ExecutionInfo))
                {
                    XexExecutionInfo info2 = (XexExecutionInfo)info.Header[XexInfoFields.ExecutionInfo];
                    results = new IsoDetailsResults("", DataConversion.BytesToHexString(info2.TitleID), DataConversion.BytesToHexString(info2.MediaID), info2.Platform.ToString(), info2.ExecutableType.ToString(), info2.DiscNumber.ToString(), info2.DiscCount.ToString(), null);
                }
            }
            base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Progress, "Extracting resources..."));
            Process process = new Process {
                EnableRaisingEvents = false
            };

            process.StartInfo.FileName = this.args.PathXexTool;
            if (File.Exists(process.StartInfo.FileName))
            {
                process.StartInfo.WorkingDirectory       = pathTemp;
                process.StartInfo.Arguments              = "-d . default.xex";
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = false;
                process.StartInfo.CreateNoWindow         = true;
                try
                {
                    process.Start();
                    process.WaitForExit();
                    process.Close();
                }
                catch (Win32Exception)
                {
                    base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "Could not launch XexTool!"));
                    return;
                }
                if (File.Exists(pathTemp + results.TitleID))
                {
                    Chilano.Xbox360.Xdbf.Xdbf xdbf = new Chilano.Xbox360.Xdbf.Xdbf(File.ReadAllBytes(pathTemp + results.TitleID));
                    base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Progress, "Extracting thumbnail..."));
                    try
                    {
                        byte[]       resource = xdbf.GetResource(XdbfResource.Thumb, XdbfResourceType.TitleInfo);
                        MemoryStream stream   = new MemoryStream(resource);
                        Image        image    = Image.FromStream(stream);
                        results.Thumbnail    = (Image)image.Clone();
                        results.RawThumbnail = (byte[])resource.Clone();
                        image.Dispose();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            byte[]       buffer  = xdbf.GetResource(XdbfResource.Thumb, XdbfResourceType.Achievement);
                            MemoryStream stream2 = new MemoryStream(buffer);
                            Image        image2  = Image.FromStream(stream2);
                            results.Thumbnail    = (Image)image2.Clone();
                            results.RawThumbnail = (byte[])buffer.Clone();
                            image2.Dispose();
                        }
                        catch (Exception)
                        {
                            base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "Couldn't find thumbnail in XDBF. Possibly corrupt XDBF?"));
                        }
                    }
                    try
                    {
                        MemoryStream stream3 = new MemoryStream(xdbf.GetResource(1, (ushort)3));
                        stream3.Seek(0x11L, SeekOrigin.Begin);
                        int count = stream3.ReadByte();
                        results.Name = Encoding.UTF8.GetString(stream3.ToArray(), 0x12, count);
                        stream3.Close();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            MemoryStream stream4 = new MemoryStream(xdbf.GetResource(1, (ushort)0));
                            stream4.Seek(0x11L, SeekOrigin.Begin);
                            int num2 = stream4.ReadByte();
                            results.Name = Encoding.UTF8.GetString(stream4.ToArray(), 0x12, num2);
                            stream4.Close();
                        }
                        catch (Exception)
                        {
                            results.Name = "Unable to read name.";
                        }
                    }
                }
                e.Result = results;
            }
            else
            {
                base.ReportProgress(0, new IsoDetailsResults(IsoDetailsResultsType.Error, "Couldn't locate XexTool. Expected location was:\n" + process.StartInfo.FileName + "\n\nTry disabling User Access Control if it's enabled."));
            }
        }