KeyLocation.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2018 shchmue
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "Key.hpp"
  18. #include <vector>
  19. #include <switch/types.h>
  20. #define FS_TID 0x0100000000000000
  21. #define SSL_TID 0x0100000000000024
  22. #define SPL_TID 0x0100000000000028
  23. #define ES_TID 0x0100000000000033
  24. #define FIRMA_TID 0x0100000000000819
  25. #define ES_COMMON_SAVE_ID 0x80000000000000E1
  26. #define ES_PERSONALIZED_SAVE_ID 0x80000000000000E2
  27. #define SEG_TEXT BIT(0)
  28. #define SEG_RODATA BIT(1)
  29. #define SEG_DATA BIT(2)
  30. #define KNOWN_KEYBLOBS 6
  31. #define KNOWN_MASTER_KEYS 7
  32. #define KEYBLOB_OFFSET 0x180000
  33. typedef std::vector<u8> byte_vector;
  34. class KeyLocation {
  35. public:
  36. // get memory in requested segments from running title
  37. void get_from_memory(u64 tid, u8 seg_mask);
  38. // get keyblobs from BOOT0
  39. void get_keyblobs();
  40. // locate keys in data
  41. void find_keys(std::vector<Key *> &keys);
  42. // data found by get functions
  43. byte_vector data;
  44. };