2019-07-24 22:19:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include "loader.h"
|
|
|
|
|
2019-09-24 22:54:27 +02:00
|
|
|
namespace skyline::loader {
|
2019-07-24 22:19:43 +02:00
|
|
|
class NroLoader : public Loader {
|
2019-09-14 14:41:00 +02:00
|
|
|
private:
|
2019-09-24 22:54:27 +02:00
|
|
|
/**
|
|
|
|
* @brief The structure of a single Segment descriptor in the NRO's header
|
|
|
|
*/
|
2019-07-24 22:19:43 +02:00
|
|
|
struct NroSegmentHeader {
|
2019-09-14 14:41:00 +02:00
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
2019-09-24 22:54:27 +02:00
|
|
|
};
|
2019-07-24 22:19:43 +02:00
|
|
|
|
2019-09-24 22:54:27 +02:00
|
|
|
/**
|
|
|
|
* @brief A bit-field struct to read the header of an NRO directly
|
|
|
|
*/
|
2019-07-24 22:19:43 +02:00
|
|
|
struct NroHeader {
|
2019-09-14 14:41:00 +02:00
|
|
|
u32 : 32;
|
|
|
|
u32 mod_offset;
|
|
|
|
u64 : 64;
|
2019-07-24 22:19:43 +02:00
|
|
|
|
2019-09-14 14:41:00 +02:00
|
|
|
u32 magic;
|
|
|
|
u32 version;
|
|
|
|
u32 size;
|
|
|
|
u32 flags;
|
2019-07-24 22:19:43 +02:00
|
|
|
|
|
|
|
NroSegmentHeader text;
|
|
|
|
NroSegmentHeader ro;
|
|
|
|
NroSegmentHeader data;
|
|
|
|
|
2019-09-14 14:41:00 +02:00
|
|
|
u32 bssSize;
|
|
|
|
u32 : 32;
|
|
|
|
u64 build_id[4];
|
|
|
|
u64 : 64;
|
2019-07-24 22:19:43 +02:00
|
|
|
|
|
|
|
NroSegmentHeader api_info;
|
|
|
|
NroSegmentHeader dynstr;
|
|
|
|
NroSegmentHeader dynsym;
|
2019-10-13 10:04:47 +02:00
|
|
|
} header {};
|
2019-07-24 22:19:43 +02:00
|
|
|
|
2019-09-14 14:41:00 +02:00
|
|
|
public:
|
2019-09-05 14:42:19 +02:00
|
|
|
/**
|
2019-09-24 22:54:27 +02:00
|
|
|
* @param filePath The path to the ROM file
|
2019-10-13 10:04:47 +02:00
|
|
|
*/
|
|
|
|
NroLoader(std::string filePath);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This loads in the data of the main process
|
|
|
|
* @param process The process to load in the data
|
2019-09-05 14:42:19 +02:00
|
|
|
* @param state The state of the device
|
|
|
|
*/
|
2019-10-13 10:04:47 +02:00
|
|
|
void LoadProcessData(const std::shared_ptr<kernel::type::KProcess> process, const DeviceState &state);
|
2019-07-24 22:19:43 +02:00
|
|
|
};
|
2019-09-05 14:42:19 +02:00
|
|
|
}
|