/// <summary> /// Ecc Creation /// </summary> /// <param name="filename"></param> /// <param name="outputfolder"></param> /// <param name="pb"></param> /// <returns></returns> #region ecc creation private void creatergh2eccinit(ref eccs dt) { /// /// Paths /// string pathforit = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string xellfile = Path.Combine(pathforit, @"common/xell/xell-gggggg.bin"); string cdfile = Path.Combine(pathforit, @"common/cdxell/CD"); long size = 0; // cd file { dt.CD_plain = Oper.openfile(cdfile, ref size, 1 * 1024 * 1024); Console.WriteLine("* found decrypted CD"); } // xell file { byte[] data = Oper.openfile(xellfile, ref size, 1 * 1024 * 1024); Console.WriteLine("* found XeLL binary, must be linked to {0}", CODE_BASE); dt.Xell = Oper.padto(data, 0x00, 256 * 1024); } }
private void createrghheader(ref eccs dt, string c) { int base_size = 0x8000 + dt.CB_A.Length + dt.CD.Length + dt.CE.Length; if (dt.CB_B != null) { base_size += dt.CB_B.Length; } base_size += 16383; base_size &= ~16383; int patch_offset = base_size; Console.WriteLine(" * base size: {0}", base_size.ToString("X")); byte[] cbyt = ascii.GetBytes(c); byte[] base_size_array = Oper.StringToByteArray(base_size.ToString("X")); byte[] patch_offset_array = Oper.StringToByteArray(patch_offset.ToString("X")); byte[] smc_offset_array = Oper.StringToByteArray_v2((0x4000 - dt.SMC.Length).ToString("X"), 4); byte[] smc_size_array = Oper.StringToByteArray_v2(dt.SMC.Length.ToString("X"), 4); byte[] header = new byte[0x1000]; /// /// F*****g Header /// header[0x00] = 0xFF; header[0x01] = 0x4F; header[0x02] = 0x07; header[0x03] = 0x60; for (int bytes = 0x04; bytes < 0x08; bytes++) { header[bytes] = 0x00; } header[0x08] = 0x00; header[0x09] = 0x00; header[0x0A] = 0x80; header[0x0B] = 0x00; for (int bytes = 0x0C; bytes < 0x10; bytes++) { header[bytes] = base_size_array[bytes - 0x0c]; } for (int bytes = 0x10; bytes < 0x50; bytes++) { if (bytes - 0x10 >= cbyt.Length) { header[bytes] = 0x00; } else { header[bytes] = cbyt[bytes - 0x10]; } } for (int bytes = 0x50; bytes < 0x62; bytes++) { header[bytes] = 0x00; } header[0x62] = 0x40; header[0x63] = 0x00; for (int bytes = 0x64; bytes < 0x68; bytes++) { header[bytes] = patch_offset_array[bytes - 0x64]; } header[0x68] = 0x00; header[0x69] = 0x02; header[0x6A] = 0x07; header[0x6B] = 0x12; header[0x6C] = 0x00; header[0x6D] = 0x00; header[0x6E] = 0x40; header[0x6F] = 0x00; for (int bytes = 0x70; bytes < 0x78; bytes++) { header[bytes] = 0x00; } for (int bytes = 0x78; bytes < 0x7C; bytes++) { header[bytes] = smc_size_array[bytes - 0x78]; } for (int bytes = 0x7C; bytes < 0x80; bytes++) { header[bytes] = smc_offset_array[bytes - 0x7C]; } header = Oper.padto(header, 0x00, 0x1000); dt.Header = header; /// /// cbyt = null; base_size_array = null; patch_offset_array = null; }