deconstructed_rom_directory.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 Core {
  10. class System;
  11. }
  12. namespace Loader {
  13. /**
  14. * This class loads a "deconstructed ROM directory", which are the typical format we see for Switch
  15. * game dumps. The path should be a "main" NSO, which must be in a directory that contains the other
  16. * standard ExeFS NSOs (e.g. rtld, sdk, etc.). It will automatically find and load these.
  17. * Furthermore, it will look for the first .romfs file (optionally) and use this for the RomFS.
  18. */
  19. class AppLoader_DeconstructedRomDirectory final : public AppLoader {
  20. public:
  21. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file,
  22. bool override_update = false);
  23. // Overload to accept exefs directory. Must contain 'main' and 'main.npdm'
  24. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory,
  25. bool override_update = false);
  26. /**
  27. * Returns the type of the file
  28. * @param file open file
  29. * @return FileType found, or FileType::Error if this loader doesn't know it
  30. */
  31. static FileType IdentifyType(const FileSys::VirtualFile& file);
  32. FileType GetFileType() const override {
  33. return IdentifyType(file);
  34. }
  35. LoadResult Load(Kernel::Process& process, Core::System& system) override;
  36. ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
  37. ResultStatus ReadIcon(std::vector<u8>& buffer) override;
  38. ResultStatus ReadProgramId(u64& out_program_id) override;
  39. ResultStatus ReadTitle(std::string& title) override;
  40. bool IsRomFSUpdatable() const override;
  41. ResultStatus ReadNSOModules(Modules& modules) override;
  42. private:
  43. FileSys::ProgramMetadata metadata;
  44. FileSys::VirtualFile romfs;
  45. FileSys::VirtualDir dir;
  46. std::vector<u8> icon_data;
  47. std::string name;
  48. u64 title_id{};
  49. bool override_update;
  50. Modules modules;
  51. };
  52. } // namespace Loader