2014-04-09 04:45:46 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2013-09-20 08:51:22 +05:30
|
|
|
|
2014-04-09 04:45:46 +05:30
|
|
|
#pragma once
|
2013-09-20 08:51:22 +05:30
|
|
|
|
2014-06-19 04:28:09 +05:30
|
|
|
#include <vector>
|
|
|
|
|
2014-04-09 05:45:08 +05:30
|
|
|
#include "common/common.h"
|
2013-09-20 08:51:22 +05:30
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-06-17 08:48:10 +05:30
|
|
|
// Loader namespace
|
2013-09-20 08:51:22 +05:30
|
|
|
|
|
|
|
namespace Loader {
|
|
|
|
|
2014-06-19 04:28:09 +05:30
|
|
|
/// File types supported by CTR
|
|
|
|
enum class FileType {
|
|
|
|
Error,
|
|
|
|
Unknown,
|
|
|
|
CCI,
|
|
|
|
CXI,
|
|
|
|
CIA,
|
|
|
|
ELF,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Return type for functions in Loader namespace
|
|
|
|
enum class ResultStatus {
|
|
|
|
Success,
|
|
|
|
Error,
|
|
|
|
ErrorInvalidFormat,
|
|
|
|
ErrorNotImplemented,
|
|
|
|
ErrorNotLoaded,
|
2014-06-19 09:23:22 +05:30
|
|
|
ErrorNotUsed,
|
2014-06-19 04:28:09 +05:30
|
|
|
ErrorAlreadyLoaded,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Interface for loading an application
|
|
|
|
class AppLoader : NonCopyable {
|
|
|
|
public:
|
|
|
|
AppLoader() { }
|
|
|
|
virtual ~AppLoader() { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the application
|
|
|
|
* @return ResultStatus result of function
|
|
|
|
*/
|
2014-06-20 03:16:05 +05:30
|
|
|
virtual ResultStatus Load() = 0;
|
2014-06-19 04:28:09 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the code (typically .code section) of the application
|
2014-06-28 01:03:23 +05:30
|
|
|
* @param buffer Reference to buffer to store data
|
|
|
|
* @return ResultStatus result of function
|
2014-06-19 04:28:09 +05:30
|
|
|
*/
|
2014-06-28 01:03:23 +05:30
|
|
|
virtual ResultStatus ReadCode(std::vector<u8>& buffer) {
|
|
|
|
return ResultStatus::ErrorNotImplemented;
|
2014-06-19 04:28:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-23 01:10:21 +05:30
|
|
|
* Get the icon (typically icon section) of the application
|
2014-06-28 01:03:23 +05:30
|
|
|
* @param buffer Reference to buffer to store data
|
|
|
|
* @return ResultStatus result of function
|
2014-06-19 04:28:09 +05:30
|
|
|
*/
|
2014-06-28 01:03:23 +05:30
|
|
|
virtual ResultStatus ReadIcon(std::vector<u8>& buffer) {
|
|
|
|
return ResultStatus::ErrorNotImplemented;
|
2014-06-19 04:28:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-23 01:10:21 +05:30
|
|
|
* Get the banner (typically banner section) of the application
|
2014-06-28 01:03:23 +05:30
|
|
|
* @param buffer Reference to buffer to store data
|
|
|
|
* @return ResultStatus result of function
|
2014-06-19 04:28:09 +05:30
|
|
|
*/
|
2014-06-28 01:03:23 +05:30
|
|
|
virtual ResultStatus ReadBanner(std::vector<u8>& buffer) {
|
|
|
|
return ResultStatus::ErrorNotImplemented;
|
2014-06-19 04:28:09 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-23 01:10:21 +05:30
|
|
|
* Get the logo (typically logo section) of the application
|
2014-06-28 01:03:23 +05:30
|
|
|
* @param buffer Reference to buffer to store data
|
|
|
|
* @return ResultStatus result of function
|
2014-06-19 04:28:09 +05:30
|
|
|
*/
|
2014-06-28 01:03:23 +05:30
|
|
|
virtual ResultStatus ReadLogo(std::vector<u8>& buffer) {
|
|
|
|
return ResultStatus::ErrorNotImplemented;
|
2014-06-19 04:28:09 +05:30
|
|
|
}
|
2013-09-20 08:51:22 +05:30
|
|
|
|
2014-06-19 04:28:09 +05:30
|
|
|
/**
|
2014-06-28 01:03:23 +05:30
|
|
|
* Get the RomFS of the application
|
|
|
|
* @param buffer Reference to buffer to store data
|
|
|
|
* @return ResultStatus result of function
|
2014-06-19 04:28:09 +05:30
|
|
|
*/
|
2014-06-28 01:03:23 +05:30
|
|
|
virtual ResultStatus ReadRomFS(std::vector<u8>& buffer) {
|
|
|
|
return ResultStatus::ErrorNotImplemented;
|
2014-06-19 04:28:09 +05:30
|
|
|
}
|
2013-09-20 08:51:22 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Identifies the type of a bootable file
|
|
|
|
* @param filename String filename of bootable file
|
|
|
|
* @return FileType of file
|
|
|
|
*/
|
2014-06-20 03:16:05 +05:30
|
|
|
FileType IdentifyFile(const std::string &filename);
|
2013-09-20 08:51:22 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Identifies and loads a bootable file
|
|
|
|
* @param filename String filename of bootable file
|
2014-06-19 04:28:09 +05:30
|
|
|
* @return ResultStatus result of function
|
2013-09-20 08:51:22 +05:30
|
|
|
*/
|
2014-06-20 03:16:05 +05:30
|
|
|
ResultStatus LoadFile(const std::string& filename);
|
2013-09-20 08:51:22 +05:30
|
|
|
|
|
|
|
} // namespace
|