cnmt.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <stdint.h>
  3. #include <switch/services/ncm.h>
  4. #include <switch/services/ncm_types.h>
  5. typedef struct
  6. {
  7. uint64_t title_id;
  8. uint32_t title_version;
  9. uint8_t meta_type;
  10. uint8_t _0xD;
  11. uint16_t extended_header_size;
  12. uint16_t content_count;
  13. uint16_t content_meta_count;
  14. uint8_t attributes;
  15. uint8_t _0x15[0x3];
  16. uint32_t required_sys_version;
  17. uint8_t _0x1C[0x4];
  18. } CnmtFullHeader_t;
  19. typedef struct
  20. {
  21. NcmContentMetaHeader header;
  22. NcmContentMetaKey key;
  23. uint8_t *extended_header; // variable size;
  24. NcmContentInfo *content_infos;
  25. } Cnmt_t; // i don't have a good name for this yet.
  26. //
  27. bool cnmt_push_record(const NcmContentMetaKey *key, NcmStorageId storage_id);
  28. //
  29. bool cnmt_set_db(const NcmContentMetaKey *key, const NcmContentMetaHeader *header, const void *extended_header, const NcmContentInfo *info, NcmStorageId storage_id);
  30. // this will set required app version and required system version to 0.
  31. void cnmt_set_extended_header(void *extended_header, NcmContentMetaType type);
  32. //
  33. bool cnmt_get_header_and_key(const uint8_t *cnmt_data, NcmContentMetaHeader *header_out, NcmContentMetaKey *key_out, int64_t offset);
  34. // parse the cnmt.
  35. // cnmt_data: the data to parse.
  36. // offset: starting offset of the data.
  37. // cnmt_info: the cnmt.nca info.
  38. // cnmt_out: the output.
  39. bool cnmt_parse(const uint8_t *cnmt_data, uint64_t offset, const NcmContentInfo *cnmt_info, Cnmt_t *cnmt_out);
  40. // open the installed cnmt.nca.
  41. bool cnmt_open_installed_file(const NcmContentId *content_id, const NcmContentInfo *cnmt_info, Cnmt_t *cnmt_out, NcmStorageId storage_id);
  42. /*
  43. * Debug
  44. */
  45. //
  46. void cnmt_print_header(const NcmContentMetaHeader *header, const NcmContentMetaKey *key);
  47. //
  48. void cnmt_print_extended_header(const void *extended_header, NcmContentMetaType type);
  49. //
  50. void cnmt_print_content_info(const NcmContentInfo *info);
  51. //
  52. void cnmt_print_content_infos(const NcmContentInfo *info, uint16_t total);