nso.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 <optional>
  6. #include "common/common_types.h"
  7. #include "common/swap.h"
  8. #include "core/file_sys/patch_manager.h"
  9. #include "core/loader/loader.h"
  10. namespace Kernel {
  11. class Process;
  12. }
  13. namespace Loader {
  14. constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000;
  15. struct NSOArgumentHeader {
  16. u32_le allocated_size;
  17. u32_le actual_size;
  18. INSERT_PADDING_BYTES(0x18);
  19. };
  20. static_assert(sizeof(NSOArgumentHeader) == 0x20, "NSOArgumentHeader has incorrect size.");
  21. /// Loads an NSO file
  22. class AppLoader_NSO final : public AppLoader {
  23. public:
  24. explicit AppLoader_NSO(FileSys::VirtualFile file);
  25. /**
  26. * Returns the type of the file
  27. * @param file std::shared_ptr<VfsFile> open file
  28. * @return FileType found, or FileType::Error if this loader doesn't know it
  29. */
  30. static FileType IdentifyType(const FileSys::VirtualFile& file);
  31. FileType GetFileType() const override {
  32. return IdentifyType(file);
  33. }
  34. static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file,
  35. VAddr load_base, bool should_pass_arguments,
  36. std::optional<FileSys::PatchManager> pm = {});
  37. ResultStatus Load(Kernel::Process& process) override;
  38. };
  39. } // namespace Loader