rpcsx/rpcs3/Loader/PUP.cpp
Cornee Traas 458dbbd15d PS3UPDAT.PUP installer (#2386)
* Add PUP loader

* Add .tar loader and update .pup loader

* Add extract method + offset to TAR loader

Also adds error checking + operator bool overload

* Add firmware decryption keys to key vault

* Initial seperation of SELFDecrypter

This seperates SELFDecrypter into itself and SCEDecrypter.
SCEDecrypter contains the logic to decrypt any file with an SCE Header.
SELFDecrypter inherits from SCEDecrypter and contains the code
specifically to do with ELF. DecryptData could be deduplicated more.

* Add "Install Firmware" option to tools menu

* SCEDecrypter: put each segment in own file

Also, const-correctness, adjusted buffer size and better error handling

* More SELFDecrypter refactoring

* Compile fix

* Add messageboxes to firmware install

* Add progress bar to firmware install
2017-02-16 10:15:00 +08:00

37 lines
755 B
C++

#include "stdafx.h"
#include "PUP.h"
pup_object::pup_object(const fs::file& file): m_file(file)
{
PUPHeader m_header;
m_file.read(m_header);
if (m_header.magic != "SCEUF\0\0\0"_u64)
{
isValid = false;
return;
}
m_file_tbl.resize(m_header.file_count);
m_file.read(m_file_tbl);
m_hash_tbl.resize(m_header.file_count);
m_file.read(m_hash_tbl);
}
fs::file pup_object::get_file(u64 entry_id)
{
if (!isValid) return fs::file();
for (PUPFileEntry file_entry : m_file_tbl)
{
if (file_entry.entry_id == entry_id)
{
std::vector<u8> file_buf(file_entry.data_length);
m_file.seek(file_entry.data_offset);
m_file.read(file_buf, file_entry.data_length);
return fs::make_stream(std::move(file_buf));
}
}
return fs::file();
};