deconstructed_rom_directory.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include "common/common_types.h"
  7. #include "core/file_sys/program_metadata.h"
  8. #include "core/loader/loader.h"
  9. namespace Loader {
  10. /**
  11. * This class loads a "deconstructed ROM directory", which are the typical format we see for Switch
  12. * game dumps. The path should be a "main" NSO, which must be in a directory that contains the other
  13. * standard ExeFS NSOs (e.g. rtld, sdk, etc.). It will automatically find and load these.
  14. * Furthermore, it will look for the first .romfs file (optionally) and use this for the RomFS.
  15. */
  16. class AppLoader_DeconstructedRomDirectory final : public AppLoader {
  17. public:
  18. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file,
  19. bool override_update = false);
  20. // Overload to accept exefs directory. Must contain 'main' and 'main.npdm'
  21. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory,
  22. bool override_update = false);
  23. /**
  24. * Returns the type of the file
  25. * @param file std::shared_ptr<VfsFile> open file
  26. * @return FileType found, or FileType::Error if this loader doesn't know it
  27. */
  28. static FileType IdentifyType(const FileSys::VirtualFile& file);
  29. FileType GetFileType() const override {
  30. return IdentifyType(file);
  31. }
  32. LoadResult Load(Kernel::Process& process) override;
  33. ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
  34. ResultStatus ReadIcon(std::vector<u8>& buffer) override;
  35. ResultStatus ReadProgramId(u64& out_program_id) override;
  36. ResultStatus ReadTitle(std::string& title) override;
  37. bool IsRomFSUpdatable() const override;
  38. ResultStatus ReadNSOModules(Modules& modules) override;
  39. private:
  40. FileSys::ProgramMetadata metadata;
  41. FileSys::VirtualFile romfs;
  42. FileSys::VirtualDir dir;
  43. std::vector<u8> icon_data;
  44. std::string name;
  45. u64 title_id{};
  46. bool override_update;
  47. Modules modules;
  48. };
  49. } // namespace Loader