static void Main(string[] args) { Console.WriteLine( @" ################################### # SG Archives Decompiler # ################################### # Made by Daviex # ################################### # Version 2.0 # ################################### # Codename: # ################################### # El Psy Congroo # ################################### Press any key to start... "); Console.ReadLine(); if (args.Length == 0) { Console.WriteLine("You should move the file .npa or .mpk on me to make it works!"); Console.WriteLine("Press a button to close the program."); Console.ReadLine(); Environment.Exit(0); } string originalFile = args[0].Substring(args[0].LastIndexOf('\\') + 1); using (BinaryReader br = new BinaryReader(File.OpenRead(args[0]))) { Console.WriteLine($"Trying to read from file {originalFile}"); //NPA File if (originalFile.ToLower().EndsWith(".npa")) { Console.WriteLine("Your file is a NPA format / JAST USA EDITION"); byte[] header; uint headerLen; headerLen = br.ReadUInt32(); header = br.ReadBytes((int)headerLen); Console.WriteLine("I'm decrypting the header..."); NPA.ScrambleKey(NPA.keyLen); NPA.DecryptBuffer(NPA.keyLen, ref header, (int)headerLen); Console.WriteLine("Gnam Gnam, now i want more data!");; NPA.ParseHeader(br, header, originalFile); } //MPK File else if (originalFile.ToLower().EndsWith(".mpk")) { Console.WriteLine("Your file is a MPK format / STEAM EDITION"); //MPK\0 string magic = Encoding.ASCII.GetString(br.ReadBytes(4)); br.ReadBytes(0x2); ushort headerVersion = br.ReadUInt16(); MPK.fileCount = br.ReadInt32(); //Removing the already readed magic and header length byte[] header = br.ReadBytes(0x38 + (MPK.fileCount * 0x100)); Console.WriteLine("Gnam Gnam, now i want more data!");; MPK.ParseHeader(br, header, originalFile); } else { Console.WriteLine("Unknown file format u passed me"); } } Console.WriteLine(); Console.WriteLine("I ended, but, remember, the Agency still watches you!"); Console.WriteLine("Press a button to close the program."); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine( @" ################################### # SG Archives Compiler # ################################### # Made by Daviex # ################################### # Version 2.0 # ################################### # Codename: # ################################### # El Psy Congroo # ################################### Press any key to start... "); Console.ReadLine(); if (args.Length == 0) { Console.WriteLine("You should move the folder on me to works!"); Console.WriteLine("Press a button to close the program."); Console.ReadLine(); Environment.Exit(0); } int choice = 0; do { Console.WriteLine("In what format you want to compile the archive?"); Console.WriteLine("[1] NPA"); Console.WriteLine("[2] MPK"); }while(!int.TryParse(Console.ReadLine(), out choice) || (choice != (int)Choice.NPA && choice != (int)Choice.MPK)); string originalFolder = args[0]; Console.WriteLine("I'm reading your folder..."); Console.WriteLine(); if (choice == (int)Choice.NPA) { Console.WriteLine("I'm encrypting the header..."); Console.WriteLine(); NPA.ScrambleKey(NPA.keyLen); NPA.ReadDirectory(originalFolder); BinaryWriter bw = new BinaryWriter(File.Create(originalFolder.Substring(originalFolder.LastIndexOf('\\') + 1) + ".npa.new")); NPA.WriteHeader(ref bw); NPA.WriteData(ref bw); bw.Flush(); bw.Close(); } if (choice == (int)Choice.MPK) { MPK.ReadDirectory(originalFolder); BinaryWriter bw = new BinaryWriter(File.Create(originalFolder.Substring(originalFolder.LastIndexOf('\\') + 1).Replace("dir_", "") + ".new")); MPK.WriteHeader(ref bw); MPK.WriteData(ref bw); } Console.WriteLine(); Console.WriteLine("I ended, but remember, the Agency still watches you!"); Console.WriteLine("Press a button to close the program."); Console.ReadLine(); }