deconstructed_rom_directory.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <string>
  5. #include "common/common_types.h"
  6. #include "core/file_sys/program_metadata.h"
  7. #include "core/loader/loader.h"
  8. namespace Core {
  9. class System;
  10. }
  11. namespace Loader {
  12. /**
  13. * This class loads a "deconstructed ROM directory", which are the typical format we see for Switch
  14. * game dumps. The path should be a "main" NSO, which must be in a directory that contains the other
  15. * standard ExeFS NSOs (e.g. rtld, sdk, etc.). It will automatically find and load these.
  16. * Furthermore, it will look for the first .romfs file (optionally) and use this for the RomFS.
  17. */
  18. class AppLoader_DeconstructedRomDirectory final : public AppLoader {
  19. public:
  20. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file,
  21. bool override_update_ = false);
  22. // Overload to accept exefs directory. Must contain 'main' and 'main.npdm'
  23. explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory,
  24. bool override_update_ = false);
  25. /**
  26. * Identifies whether or not the given file is a deconstructed ROM directory.
  27. *
  28. * @param dir_file The file to verify.
  29. *
  30. * @return FileType::DeconstructedRomDirectory, or FileType::Error
  31. * if the file is not a deconstructed ROM directory.
  32. */
  33. static FileType IdentifyType(const FileSys::VirtualFile& dir_file);
  34. FileType GetFileType() const override {
  35. return IdentifyType(file);
  36. }
  37. LoadResult Load(Kernel::KProcess& process, Core::System& system) override;
  38. ResultStatus ReadRomFS(FileSys::VirtualFile& out_dir) override;
  39. ResultStatus ReadIcon(std::vector<u8>& out_buffer) override;
  40. ResultStatus ReadProgramId(u64& out_program_id) override;
  41. ResultStatus ReadTitle(std::string& title) override;
  42. bool IsRomFSUpdatable() const override;
  43. ResultStatus ReadNSOModules(Modules& out_modules) override;
  44. private:
  45. FileSys::ProgramMetadata metadata;
  46. FileSys::VirtualFile romfs;
  47. FileSys::VirtualDir dir;
  48. std::vector<u8> icon_data;
  49. std::string name;
  50. u64 title_id{};
  51. bool override_update;
  52. Modules modules;
  53. };
  54. } // namespace Loader