deconstructed_rom_directory.h 1.9 KB

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