123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #ifndef _MANAGE_METADATA_H_
- #define _MANAGE_METADATA_H_
- #include "metadata.h"
- #include "uncopyable.h"
- #include "loader.h"
- #include "binparser.h"
- #define MAX_BUFFER_SIZE 4096
- #define TCS_TEMPLATE_SIZE 72
- #define STRCMP strcmp
- #define STRNCMP strncmp
- #define SSA_NUM 2
- #define SSA_FRAME_SIZE 1
- typedef enum _para_type_t
- {
- PRODID = 0,
- ISVSVN,
- RELEASETYPE,
- INTELSIGNED,
- PROVISIONKEY,
- LAUNCHKEY,
- DISABLEDEBUG,
- HW,
- TCSNUM,
- TCSPOLICY,
- STACKMAXSIZE,
- HEAPMAXSIZE,
- MISCSELECT,
- MISCMASK
- } para_type_t;
- typedef struct _xml_parameter_t
- {
- const char* name;
- uint64_t max_value;
- uint64_t min_value;
- uint64_t value;
- uint32_t flag;
- } xml_parameter_t;
- bool parse_metadata_file(const char *xmlpath, xml_parameter_t *parameter, int parameter_count);
- bool update_metadata(const char *path, const metadata_t *metadata, uint64_t meta_offset);
- class CMetadata: private Uncopyable
- {
- public:
- CMetadata(metadata_t *metadata, BinParser *parser);
- ~CMetadata();
- bool build_metadata(const xml_parameter_t *parameter);
- private:
- bool modify_metadata(const xml_parameter_t *parameter);
- void *alloc_buffer_from_metadata(uint32_t size);
- bool build_layout_table();
- bool build_patch_table();
- bool build_layout_entries(vector<layout_t> &layouts);
- bool build_patch_entries(vector<patch_entry_t> &patches);
- layout_entry_t *get_entry_by_id(uint16_t id);
- bool build_tcs_template(tcs_t *tcs);
- bool build_gd_template(uint8_t *data, uint32_t *data_size);
- uint64_t calculate_sections_size();
- uint64_t calculate_enclave_size(uint64_t size);
- void* get_rawdata_by_rva(uint64_t rva);
- metadata_t *m_metadata;
- BinParser *m_parser;
- create_param_t m_create_param;
- };
- #endif
|