2017-09-24 17:08:31 +02:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-09-30 20:15:09 +02:00
|
|
|
#include <map>
|
2017-09-24 17:08:31 +02:00
|
|
|
#include <string>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/file_util.h"
|
2017-09-30 20:15:09 +02:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2017-10-06 05:30:08 +02:00
|
|
|
#include "core/loader/linker.h"
|
2017-09-24 17:08:31 +02:00
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
|
|
|
namespace Loader {
|
|
|
|
|
|
|
|
/// Loads an NSO file
|
2017-10-06 05:30:08 +02:00
|
|
|
class AppLoader_NSO final : public AppLoader, Linker {
|
2017-09-24 17:08:31 +02:00
|
|
|
public:
|
|
|
|
AppLoader_NSO(FileUtil::IOFile&& file, std::string filename, std::string filepath)
|
2017-09-30 20:15:09 +02:00
|
|
|
: AppLoader(std::move(file)), filename(std::move(filename)), filepath(std::move(filepath)) {
|
|
|
|
}
|
2017-09-24 17:08:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the file
|
|
|
|
* @param file FileUtil::IOFile open file
|
|
|
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
|
|
|
*/
|
|
|
|
static FileType IdentifyType(FileUtil::IOFile& file);
|
|
|
|
|
|
|
|
FileType GetFileType() override {
|
|
|
|
return IdentifyType(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
ResultStatus Load() override;
|
|
|
|
|
|
|
|
private:
|
2017-10-04 00:30:02 +02:00
|
|
|
VAddr GetEntryPoint(VAddr load_base) const;
|
2017-09-30 20:15:09 +02:00
|
|
|
bool LoadNso(const std::string& path, VAddr load_base);
|
|
|
|
|
2017-09-24 17:08:31 +02:00
|
|
|
std::string filename;
|
|
|
|
std::string filepath;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Loader
|