ns.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <switch.h>
  5. #include "nx/ncm.h"
  6. typedef enum
  7. {
  8. NsApplicationRecordType_Installed = 0x3,
  9. NsApplicationRecordType_GamecardMissing = 0x5,
  10. NsApplicationRecordType_Archived = 0xB,
  11. } NsApplicationRecordType;
  12. /*
  13. * The first value is the number of times the gc has been inserted / removed.
  14. * Inserted is set to true when called with a gc inserted, set to zero otherwise.
  15. * Reboot value is changed on every reboot.
  16. *
  17. * Calling this func more than once results in strange values returned.
  18. *
  19. * The reboot value becomes zero if called again with a gc inserted.
  20. * The value is something different when called again without a gc inserted.
  21. * Sometimes the inserted value is set to one if called again and the gc isn't inserted.
  22. *
  23. * Overall, idk what this func does.
  24. */
  25. typedef struct
  26. {
  27. uint32_t num_gc_state_change;
  28. uint8_t unk1[0x4];
  29. uint8_t inserted;
  30. uint8_t unk2[0x3];
  31. uint8_t reboot_value; //this value is changed every reboot.
  32. uint8_t unk3[0x3];
  33. } gamecard_info_t;
  34. //
  35. bool init_ns(void);
  36. //
  37. void exit_ns(void);
  38. // returns the total size of the sd card.
  39. int64_t ns_get_storage_total_size(NcmStorageId storage_id);
  40. // returns the free space on the sd card.
  41. int64_t ns_get_storage_free_space(NcmStorageId storage_id);
  42. // store data found to out.
  43. // make sure to set the size of the out large enough.
  44. // returns the total stored.
  45. int32_t ns_list_app_record(NsApplicationRecord *out, int32_t count, int32_t offset);
  46. //
  47. int32_t ns_list_app_cnmt_status(NsApplicationContentMetaStatus *out, int32_t count, uint64_t app_id);
  48. // store data to out.
  49. size_t ns_get_app_control_data(NsApplicationControlData *out, uint64_t app_id);
  50. //
  51. int32_t ns_get_app_delivery_info(NsApplicationDeliveryInfo *out, int32_t count, uint64_t app_id, uint32_t attr);
  52. //
  53. bool ns_check_app_delivery_info(const NsApplicationDeliveryInfo *info);
  54. //
  55. int32_t ns_compare_app_delivery_info(const NsApplicationDeliveryInfo *info0, const NsApplicationDeliveryInfo *info1);
  56. //
  57. bool ns_check_if_can_deliver_app_info(NsApplicationDeliveryInfo *info0, int32_t count0, NsApplicationDeliveryInfo *info1);
  58. //
  59. int32_t ns_list_content_meta_key(NcmContentMetaKey *meta, NsApplicationDeliveryInfo *info);
  60. //
  61. int32_t ns_count_application_record(uint64_t app_id);
  62. //
  63. Result ns_delete_application_entity(uint64_t app_id);
  64. //
  65. Result ns_delete_application_completely(uint64_t app_id);
  66. //
  67. bool ns_is_application_moveable(uint64_t app_id, NcmStorageId storage_id);
  68. //
  69. Result ns_move_application(uint64_t app_id, NcmStorageId storage_id);
  70. //
  71. NsApplicationOccupiedSize ns_get_application_occupied_size(uint64_t app_id);
  72. // push an application record.
  73. bool ns_push_application_record(uint64_t app_id, const NcmContentStorageRecord *records, uint32_t count);
  74. // delete an application record using the app_id.
  75. bool ns_delete_application_record(uint64_t app_id);
  76. // count the amount of content already installed.
  77. int32_t ns_count_application_content_meta(uint64_t app_id);
  78. // write all existing content to void *out_buf. Call this after count_out > 1.
  79. bool ns_list_application_record_content_meta(uint64_t offset, uint64_t app_id, NcmContentStorageRecord *records, uint32_t count);
  80. /*
  81. * testing
  82. */
  83. //
  84. bool ns_get_gamecard_info(gamecard_info_t *out);