Example #1
0
        internal bool xExtract(string OutLocation, bool SubItems)
        {
            if (OutLocation == null || OutLocation == "")
            {
                return(false);
            }
            OutLocation = OutLocation.xExtractLegitPath();
            if (!VariousFunctions.xCheckDirectory(OutLocation))
            {
                return(false);
            }
            GDFContents xConts = xRead();

            foreach (GDFFile x in xConts.Files)
            {
                DJsIO y = new DJsIO(true);
                try
                {
                    if (x.xExtract(y))
                    {
                        y.Close();
                        VariousFunctions.MoveFile(y.FileNameLong, OutLocation + "/" + x.Name);
                    }
                }
                catch { y.Close(); }
                VariousFunctions.DeleteFile(y.FileNameLong);
            }
            foreach (GDFFolder x in xConts.xFolders)
            {
                try { x.xExtract(OutLocation + "/" + x.Name, SubItems); }
                catch { }
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// Extract the file
        /// </summary>
        /// <param name="OutLocation"></param>
        /// <returns></returns>
        public bool Extract(string OutLocation)
        {
            if (xDrive.ActiveCheck())
            {
                return(false);
            }
            bool  xReturn = false;
            DJsIO xIO     = new DJsIO(true);

            try
            {
                xReturn = xExtract(ref xIO);
                xIO.Close();
                if (xReturn)
                {
                    xReturn = VariousFunctions.MoveFile(xIO.FileNameLong, OutLocation);
                }
            }
            catch
            {
                xIO.Close();
                xReturn = false;
            }
            VariousFunctions.DeleteFile(xIO.FileNameLong);
            xDrive.xActive = false;
            return(xReturn);
        }
Example #3
0
        /// <summary>
        /// Makes a copy of an Xbox Live profile into a HDD profile
        /// (Works only for profiles and if not a HDD profile already)
        /// </summary>
        /// <param name="xOutLocation"></param>
        /// <returns></returns>
        public bool MakeHDDAccountCopy(string xOutLocation)
        {
            if (!ParseCheck())
            {
                return(false);
            }
            ProfilePackage xPackage = null;

            try
            {
                if (MakeBackup(xOutLocation))
                {
                    xPackage = (ProfilePackage)(new STFSPackage(xOutLocation, null));
                }
                else
                {
                    return(false);
                }
                if (!xPackage.ParseSuccess)
                {
                    throw new Exception(); // Goes to catch
                }
                xPackage.UserFile.ForceIntoHDDAccount();
                xPackage.xSaveAccount();
                xPackage.xIO.Close();
                return(true);
            }
            catch
            {
                xPackage.xIO.Close();
                VariousFunctions.DeleteFile(xPackage.xIO.FileNameLong);
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// Reads a GPD from the Titles Played index of the User GPD
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="xEntry"></param>
        /// <returns></returns>
        public GameGPD ReadGame(uint ID, out FileEntry xEntry)
        {
            xEntry = null;
            if (!ParseCheck())
            {
                return(null);
            }
            if (UserGPD == null)
            {
                return(null);
            }
            FileEntry x = GetFile(ID.ToString("X") + ".gpd");

            if (x == null)
            {
                return(null);
            }
            DJsIO y = x.GetTempIO(true);

            if (y == null || !y.Accessed)
            {
                y.Close();
                VariousFunctions.DeleteFile(y.FileNameLong);
                return(null);
            }
            y.Close();
            GameGPD z = new GameGPD(y.FileNameLong, ID);

            if (z.IsValid)
            {
                xEntry = x;
                return(z);
            }
            return(null);
        }
Example #5
0
        void xWatch_Created(object sender, FileSystemEventArgs e)
        {
            string droppath = Directory.GetParent(e.FullPath).FullName;

            temp = null;
            menuStrip1.Enabled = menuStrip2.Enabled = listView1.Enabled = false;
            status             = "Extracting items";
            foreach (ListViewItem y in listView1.SelectedItems)
            {
                switch (y.ImageIndex)
                {
                case 1:
                {
                    FATXFolderEntry ent = (FATXFolderEntry)y.Tag;
                    ent.Extract(droppath, true);
                    break;
                }

                case 2:
                {
                    FATXFileEntry ent   = ((FATXFileEntry)y.Tag);
                    string        xfile = droppath + "/" + ent.Name;
                    ent.Extract(xfile);
                    break;
                }

                default: break;
                }
            }
            VariousFunctions.DeleteFile(e.FullPath);
            status             = "Idle";
            isitem             = false;
            menuStrip1.Enabled = menuStrip2.Enabled = listView1.Enabled = true;
        }
Example #6
0
        public MainForm()
        {
            CheckForIllegalCrossThreadCalls = false;
            string proc = Process.GetCurrentProcess().ProcessName;
            int    id   = Process.GetCurrentProcess().Id;

            Process[] lst = Process.GetProcesses();
            foreach (Process p in lst)
            {
                if (p.ProcessName != proc || p.Id == id)
                {
                    continue;
                }
                MessageBox.Show("This program is already open");
                Process.GetCurrentProcess().Kill();
                return;
            }
            InitializeComponent();
            VariousFunctions.DeleteFile(Application.StartupPath + "/LFLiveUpdater.exe");
            bool   devmode = AssemblyFunctions.GrabParentProcessName() == "devenv";
            Thread y       = new Thread(new ParameterizedThreadStart(upd));

            y.Start(devmode);
            Thread x = new Thread(new ParameterizedThreadStart(startss));

            x.Start(devmode);
            VariousFunctions.DeleteTempFiles();
            Thread z = new Thread(new ThreadStart(readrss));

            z.Start();
            PublicKV = new RSAParams(Application.StartupPath + "/KV.bin");
            if (!PublicKV.Valid)
            {
                MessageBox.Show("Cannot load KV");
                Process.GetCurrentProcess().Kill();
                return;
            }
            XAbout.WriteLegalLocally();
            while (x.IsAlive)
            {
                Application.DoEvents();
            }
            Show();
            while (y.IsAlive)
            {
                Application.DoEvents();
            }
            Enabled = true;
            Select();
            Focus();
            if (!devmode)
            {
                updr.Dispose();
                updr = null;
            }
            checkForUpdatesToolStripMenuItem.Enabled = true;
        }
Example #7
0
        /// <summary>
        /// Extract a file
        /// </summary>
        /// <param name="OutLocale"></param>
        /// <returns></returns>
        public bool Extract(string OutLocale)
        {
            if (!xref.ActiveCheck())
            {
                return(false);
            }
            DJsIO xIO = new DJsIO(true);

            if (!xExtract(xIO))
            {
                xIO.Close();
                VariousFunctions.DeleteFile(xIO.FileNameLong);
                return(xref.xActive = false);
            }
            xIO.Close();
            bool xSuccess = VariousFunctions.MoveFile(xIO.FileNameLong, OutLocale);

            VariousFunctions.DeleteFile(xIO.FileNameLong);
            return(xSuccess & !(xref.xActive = false));
        }
Example #8
0
        private void loadInViewerToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            FileEntry xent = xprof.GetFile(xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex].ID.ToString("X") + ".gpd");

            if (xent == null)
            {
                Log("Could not find specified file");
                this.Enabled = true;
                return;
            }
            Log("Extracting " + xent.Name + "...");
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                VariousFunctions.DeleteFile(xOut);
                this.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, ProfileTools.GPDNameToID(xent.Name));

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                this.Enabled = true;
                return;
            }
            GPDViewer x = new GPDViewer(xload);

            x.MdiParent = xMForm;
            x.Show();
            Log("GPD Loaded");
            this.Enabled = true;
        }
Example #9
0
 /// <summary>
 /// Deletes the files associated to this file (used for closing the file)
 /// </summary>
 /// <returns></returns>
 public bool DeleteProfileFiles()
 {
     if (!ParseCheck())
     {
         return(false);
     }
     try
     {
         if (HasDashGPD)
         {
             UserGPD.xIO.Close();
             VariousFunctions.DeleteFile(UserGPD.xIO.FileNameLong);
         }
         if (HasValidAccount)
         {
             UserFile.IO.Close();
             VariousFunctions.DeleteFile(UserFile.IO.FileNameLong);
         }
         return(true);
     }
     catch { return(false); }
 }
Example #10
0
        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            isitem          = true;
            xparent.Enabled = false;
            string folder = VariousFunctions.GetTempFileLocale();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            string[] file;
            byte[]   rand = new byte[10];
            new Random().NextBytes(rand);
            temp = rand.HexString();
            file = new string[1] {
                folder + "/" + temp
            };
            var data = new DataObject(DataFormats.FileDrop, file);

            data.SetData(DataFormats.StringFormat, file[0]);
            File.Create(file[0]).Dispose();
            File.SetAttributes(folder + "/" + temp, FileAttributes.Hidden | FileAttributes.Temporary);
            xWatcher.Filter              = temp;
            xWatcher.NotifyFilter        = NotifyFilters.FileName;
            xWatcher.Created            += new FileSystemEventHandler(xWatch_Created);
            xWatcher.EnableRaisingEvents = xWatcher.IncludeSubdirectories = true;
            DoDragDrop(data, DragDropEffects.Move);
            xparent.Enabled = true;
            Application.DoEvents();
            VariousFunctions.DeleteFile(folder + "/" + temp);
        }
Example #11
0
        private void loadInViewerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }
            FileEntry xent = (FileEntry)listView1.SelectedItems[0].Tag;

            this.Enabled = false;
            Log("Extracting " + xent.Name + "...");
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                this.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, ProfileTools.GPDNameToID(xent.Name));

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                this.Enabled = true;
                return;
            }
            GPDViewer x = new GPDViewer(xload);

            x.MdiParent = xMForm;
            x.Show();
            Log("GPD Loaded");
            this.Enabled = true;
        }
Example #12
0
        private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox3.SelectedIndex < 0)
            {
                return;
            }
            tabControl1.Enabled = false;
            buttonX12.Enabled   = true;
            TitlePlayedEntry x = xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex];

            try { dateTimePicker3.Value = dateTimePicker4.Value = x.LastLoadedDT; }
            catch { dateTimePicker3.Value = dateTimePicker4.Value = DateTime.Now; }
            textBoxX14.Text  = "Unlocked " + x.EarnedCount.ToString() + " of " + x.PossibleCount.ToString();
            textBoxX14.Text += Environment.NewLine + "Total of " + x.EarnedWorth.ToString() + " of " + x.PossibleWorth.ToString();
            string    path = x.TitleID.ToString("X").ToUpper() + ".gpd";
            FileEntry xent = xPackage.GetFile(path);

            if (xent == null)
            {
                Log("Error: could not find GPD");
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, x.TitleID);

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                xload = null;
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            listBox2.Items.Clear();
            for (int i = 0; i < xload.Achievements.Length; i++)
            {
                listBox2.Items.Add(xload.Achievements[i].Title);
            }
            Image xTitleIMGS = xload.GetImageByID(0x8000);

            if (xTitleIMGS != null)
            {
                pictureBox4.Image = xTitleIMGS;
            }
            else
            {
                pictureBox4.Image = PublicResources.NoImage;
            }
            string xTitleStrings = xload.GetStringByID(0x8000);

            if (xTitleStrings != null)
            {
                textBoxX4.Text = xTitleStrings;
            }
            else
            {
                textBoxX4.Text = "Unknown";
            }
            xLoadedGPD   = xload;
            xLoadedEntry = xent;
            if (listBox2.Items.Count > 0)
            {
                listBox2.SelectedIndex = 0;
            }
            listBox2_SelectedIndexChanged(null, null);
            buttonX11.Enabled                =
                buttonX3.Enabled             =
                    buttonX10.Enabled        =
                        tabControl1.Enabled  =
                            buttonX6.Enabled =
                                tabControlPanel10.Enabled = true;
            Log("GPD Loaded");
        }
Example #13
0
        /// <summary>
        /// Loads the profile information from the package
        /// </summary>
        /// <param name="xboth"></param>
        /// <returns></returns>
        bool LoadProfile(bool xboth)
        {
            if (!ParseCheck())
            {
                return(false);
            }
            new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(System.Threading.Thread.CurrentThread);
            bool xreturn = true;

            if (xboth)
            {
                FileEntry xacct = GetFile("Account");
                if (xacct != null && xacct.Size == 404)
                {
                    if (HasValidAccount)
                    {
                        xUserFile.IO.Dispose();
                    }
                    AddToLog("Parsing Account file");
                    DJsIO xAcctIO = xacct.GetTempIO(true);
                    if (xAcctIO == null || !xAcctIO.Accessed)
                    {
                        if (xAcctIO != null)
                        {
                            xAcctIO.Dispose();
                            VariousFunctions.DeleteFile(xAcctIO.FileNameLong);
                        }
                    }
                    else
                    {
                        xUserFile = new UserAccount(xAcctIO, AccountType.Stock, true);
                        xreturn   = xUserFile.Success;
                        if (!xUserFile.Success)
                        {
                            xUserFile = new UserAccount(xAcctIO, AccountType.Kits, true);
                            xreturn   = xUserFile.Success;
                            if (!xUserFile.Success)
                            {
                                xUserFile = null;
                            }
                        }
                    }
                }
            }
            FileEntry xdash = GetFile("FFFE07D1.gpd");

            if (xdash != null)
            {
                AddToLog("Parsing User GPD");
                DJsIO xFFIO = xdash.GetTempIO(true);
                if (xFFIO == null || !xFFIO.Accessed)
                {
                    if (xFFIO != null)
                    {
                        VariousFunctions.DeleteFile(xFFIO.FileNameLong);
                    }
                }
                else
                {
                    try
                    {
                        xFFIO.Close();
                        if (HasDashGPD)
                        {
                            xUserGPD.xIO.Dispose();
                        }
                        xUserGPD = new DashGPD(xFFIO.FileNameLong);
                        xreturn &= xUserGPD.IsValid;
                        if (!xUserGPD.IsValid)
                        {
                            xUserGPD = null;
                            xFFIO.Dispose();
                            VariousFunctions.DeleteFile(xFFIO.FileNameLong);
                        }
                    }
                    catch { xUserGPD = null; }
                }
            }
            return(xreturn);
        }