mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 09:39:55 +00:00
PKG: Implement SDATA decryption
This commit is contained in:
parent
77c252a4c0
commit
3e84a2acc0
@ -667,6 +667,8 @@ package_error package_reader::check_target_app_version() const
|
||||
return package_error::app_version;
|
||||
}
|
||||
|
||||
fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose = false);
|
||||
|
||||
bool package_reader::extract_data(atomic_t<double>& sync)
|
||||
{
|
||||
if (!m_is_valid)
|
||||
@ -745,7 +747,7 @@ bool package_reader::extract_data(atomic_t<double>& sync)
|
||||
const bool log_error = entry.pad || (entry.type & ~PKG_FILE_ENTRY_KNOWN_BITS);
|
||||
(log_error ? pkg_log.error : pkg_log.notice)("Entry 0x%08x: %s (pad=0x%x)", entry.type, name, entry.pad);
|
||||
|
||||
switch (entry.type & 0xff)
|
||||
switch (const u8 entry_type = entry.type & 0xff)
|
||||
{
|
||||
case PKG_FILE_ENTRY_NPDRM:
|
||||
case PKG_FILE_ENTRY_NPDRMEDAT:
|
||||
@ -771,7 +773,14 @@ bool package_reader::extract_data(atomic_t<double>& sync)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fs::file out{ path, fs::rewrite })
|
||||
const bool is_buffered = entry_type == PKG_FILE_ENTRY_SDAT;
|
||||
|
||||
if (entry_type == PKG_FILE_ENTRY_NPDRMEDAT)
|
||||
{
|
||||
pkg_log.todo("NPDRM EDAT!");
|
||||
}
|
||||
|
||||
if (fs::file out = is_buffered ? fs::make_stream<std::vector<u8>>() : fs::file{ path, fs::rewrite })
|
||||
{
|
||||
bool extract_success = true;
|
||||
for (u64 pos = 0; pos < entry.file_size; pos += BUF_SIZE)
|
||||
@ -807,6 +816,17 @@ bool package_reader::extract_data(atomic_t<double>& sync)
|
||||
}
|
||||
}
|
||||
|
||||
if (is_buffered)
|
||||
{
|
||||
out = DecryptEDAT(out, name, 1, "", reinterpret_cast<u8*>(&m_header.klicensee), true);
|
||||
if (!out || !fs::write_file(path, fs::rewrite, static_cast<fs::container_stream<std::vector<u8>>*>(out.release().get())->obj))
|
||||
{
|
||||
num_failures++;
|
||||
pkg_log.error("Failed to create file %s", path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_success)
|
||||
{
|
||||
if (did_overwrite)
|
||||
|
Loading…
x
Reference in New Issue
Block a user