shadPS4/src/core/file_format/trp.h
raziel1000 0f27e0edf2 - Added trophy decryption when extracting a fpkg. trp icons and xmls are dumped to game_data/<title> (can be restored if deleted by accident by opening the trophy viewer)
- Added a trophy viewer (right click on game ==> trophy viewer)
- Enabled Run button.
- Switched gui settings to toml.
- Added recent files (6 max)
- Applied @raphaelthegreat suggestions and corrections (Thanks a lot).
- Fixed several bugs and crashes.
- Full screen should disabled by default.
- Added region in list mode.
- Added a simple temp elf list widget.
- Added messages when extracting pkg (ex: installing a patch before the game...etc)
2024-06-10 20:42:21 -06:00

46 lines
1.2 KiB
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <vector>
#include "common/endian.h"
#include "common/io_file.h"
#include "common/types.h"
#include "core/crypto/crypto.h"
struct TrpHeader {
u32_be magic; // (0xDCA24D00)
u32_be version;
u64_be file_size; // size of full trp file
u32_be entry_num; // num entries
u32_be entry_size; // size of entry
u32_be dev_flag; // 1: dev
unsigned char digest[20]; // sha1 hash
u32_be key_index; // 3031300?
unsigned char padding[44];
};
struct TrpEntry {
char entry_name[32];
u64_be entry_pos;
u64_be entry_len;
u32_be flag; // 3 = CONFIG/ESFM , 0 = PNG
unsigned char padding[12];
};
class TRP {
public:
TRP();
~TRP();
bool Extract(std::filesystem::path trophyPath);
void GetNPcommID(std::filesystem::path trophyPath, int index);
private:
Crypto crypto;
std::vector<u8> NPcommID = std::vector<u8>(12);
std::array<u8, 16> np_comm_id{};
std::array<u8, 16> esfmIv{};
std::filesystem::path trpFilesPath;
static constexpr int iv_len = 16;
};