示例#1
0
        private void RestoreOriginalGlobalAToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (GameFolderSelectDialog.ShowDialog() == DialogResult.OK)
            {
                String GameFolder = GameFolderSelectDialog.SelectedPath.ToString();
                if (GameFolder != "")
                {
                    Log("SATEditor : Starting FNG Injector...");

                    String GlobalAPath = Path.Combine(GameFolder, "GLOBAL", "GlobalA.bun");

                    try
                    {
                        if (File.Exists(GlobalAPath))
                        {
                            File.Delete(GlobalAPath);
                        }
                        File.Copy(GlobalAPath + ".bak", GlobalAPath, true);

                        MessageBox.Show("File restored successfully.", "SATEditor", MessageBoxButtons.OK);
                        Log("FNG Injector : " + GlobalAPath + " " + "is restored successfully from a backup file.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("File could not be restored.", "SATEditor", MessageBoxButtons.OK);
                        Log("FNG Injector : File could not be restored." + " " + "Exception: " + ex.ToString());
                        return;
                    }
                }
            }
        }
示例#2
0
        private void ImportFNGToGlobalAToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (OpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                String FNGAFileName = OpenFileDialog.FileName.ToString();
                if (FNGAFileName != "")
                {
                    if (GameFolderSelectDialog.ShowDialog() == DialogResult.OK)
                    {
                        Log("SATEditor : Starting FNG Injector...");

                        String GameFolder = GameFolderSelectDialog.SelectedPath.ToString();
                        if (GameFolder != "")
                        {
                            FileStream   FNGAFileStream, GlobalAFileStream;
                            BinaryReader FNGAFile, GlobalAFile;
                            BinaryWriter NewGlobalAFile;

                            String GlobalAPath = Path.Combine(GameFolder, "GLOBAL", "GlobalA.bun");

                            try
                            {
                                if (!File.Exists(GlobalAPath + ".bak")) // Create a backup of GlobalA if there isn't any
                                {
                                    File.Copy(GlobalAPath, GlobalAPath + ".bak", true);
                                }

                                FNGAFileStream    = File.Open(FNGAFileName, FileMode.Open);
                                GlobalAFileStream = File.Open(GlobalAPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                                FNGAFile          = new BinaryReader(FNGAFileStream);
                                GlobalAFile       = new BinaryReader(GlobalAFileStream);

                                NewGlobalAFile = new BinaryWriter(GlobalAFileStream);
                                // Add FNG at the end of GlobalA
                                NewGlobalAFile.BaseStream.Position = NewGlobalAFile.BaseStream.Length;
                                NewGlobalAFile.Write(FNGAFile.ReadBytes((int)FNGAFileStream.Length));

                                MessageBox.Show("File injected successfully.", "SATEditor", MessageBoxButtons.OK);
                                Log("FNG Injector : " + FNGAFile + " " + "is injected at the end of" + " " + GlobalAPath);

                                FNGAFile.Close();
                                GlobalAFile.Close();
                                NewGlobalAFile.Close();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("File could not be injected.", "SATEditor", MessageBoxButtons.OK);
                                Log("FNG Injector : File could not be injected." + " " + "Exception: " + ex.ToString());
                                return;
                            }
                        }
                    }
                }
            }
        }