Fix naming convention in plist parser
This commit is contained in:
parent
8dc8fdd71f
commit
6b2d6fed9a
4 changed files with 151 additions and 151 deletions
|
|
@ -30,7 +30,7 @@ typedef struct rz_xnu_kernelcache_parsed_pointer_t {
|
|||
typedef struct rz_xnu_kernelcache_obj_t {
|
||||
RzBuffer *cache_buf;
|
||||
RzBuffer *patched_buf;
|
||||
RCFValueDict *prelink_info;
|
||||
RzCFValueDict *prelink_info;
|
||||
ut64 pa2va_exec;
|
||||
ut64 pa2va_data;
|
||||
struct _RKextIndex *kexts;
|
||||
|
|
|
|||
|
|
@ -18,55 +18,55 @@ typedef enum {
|
|||
RZ_CF_STATE_IN_KEY,
|
||||
RZ_CF_STATE_IN_SCALAR,
|
||||
RZ_CF_STATE_IN_IGNORE,
|
||||
} RCFParsePhase;
|
||||
} RzCFParsePhase;
|
||||
|
||||
typedef struct _RCFParseState {
|
||||
RCFParsePhase phase;
|
||||
typedef struct _RzCFParseState {
|
||||
RzCFParsePhase phase;
|
||||
char *key;
|
||||
RCFValueType value_type;
|
||||
RCFValueDict *dict;
|
||||
RCFValueArray *array;
|
||||
} RCFParseState;
|
||||
RzCFValueType value_type;
|
||||
RzCFValueDict *dict;
|
||||
RzCFValueArray *array;
|
||||
} RzCFParseState;
|
||||
|
||||
static RCFParseState *rz_cf_parse_state_new(RCFParsePhase phase);
|
||||
static void rz_cf_parse_state_free(RCFParseState *state);
|
||||
static RzCFParseState *rz_cf_parse_state_new(RzCFParsePhase phase);
|
||||
static void rz_cf_parse_state_free(RzCFParseState *state);
|
||||
|
||||
static RCFKeyValue *rz_cf_key_value_new(char *key, RCFValue *value);
|
||||
static void rz_cf_key_value_free(RCFKeyValue *key_value);
|
||||
static RzCFKeyValue *rz_cf_key_value_new(char *key, RzCFValue *value);
|
||||
static void rz_cf_key_value_free(RzCFKeyValue *key_value);
|
||||
|
||||
static RCFValueDict *rz_cf_value_dict_new(void);
|
||||
static void rz_cf_value_dict_add(RCFValueDict *dict, RCFKeyValue *key_value);
|
||||
static void rz_cf_value_dict_print(RCFValueDict *dict);
|
||||
static RzCFValueDict *rz_cf_value_dict_new(void);
|
||||
static void rz_cf_value_dict_add(RzCFValueDict *dict, RzCFKeyValue *key_value);
|
||||
static void rz_cf_value_dict_print(RzCFValueDict *dict);
|
||||
|
||||
static RCFValueArray *rz_cf_value_array_new(void);
|
||||
static void rz_cf_value_array_free(RCFValueArray *array);
|
||||
static void rz_cf_value_array_add(RCFValueArray *array, RCFValue *value);
|
||||
static void rz_cf_value_array_print(RCFValueArray *dict);
|
||||
static RzCFValueArray *rz_cf_value_array_new(void);
|
||||
static void rz_cf_value_array_free(RzCFValueArray *array);
|
||||
static void rz_cf_value_array_add(RzCFValueArray *array, RzCFValue *value);
|
||||
static void rz_cf_value_array_print(RzCFValueArray *dict);
|
||||
|
||||
static RCFValueString *rz_cf_value_string_new(char *string);
|
||||
static void rz_cf_value_string_free(RCFValueString *string);
|
||||
static void rz_cf_value_string_print(RCFValueString *string);
|
||||
static RzCFValueString *rz_cf_value_string_new(char *string);
|
||||
static void rz_cf_value_string_free(RzCFValueString *string);
|
||||
static void rz_cf_value_string_print(RzCFValueString *string);
|
||||
|
||||
static RCFValueInteger *rz_cf_value_integer_new(char *string);
|
||||
static void rz_cf_value_integer_free(RCFValueInteger *integer);
|
||||
static void rz_cf_value_integer_print(RCFValueInteger *integer);
|
||||
static RzCFValueInteger *rz_cf_value_integer_new(char *string);
|
||||
static void rz_cf_value_integer_free(RzCFValueInteger *integer);
|
||||
static void rz_cf_value_integer_print(RzCFValueInteger *integer);
|
||||
|
||||
static RCFValueData *rz_cf_value_data_new(char *string);
|
||||
static void rz_cf_value_data_free(RCFValueData *data);
|
||||
static void rz_cf_value_data_print(RCFValueData *data);
|
||||
static RzCFValueData *rz_cf_value_data_new(char *string);
|
||||
static void rz_cf_value_data_free(RzCFValueData *data);
|
||||
static void rz_cf_value_data_print(RzCFValueData *data);
|
||||
|
||||
static RCFValueNULL *rz_cf_value_null_new(void);
|
||||
static void rz_cf_value_null_free(RCFValueNULL *null);
|
||||
static void rz_cf_value_null_print(RCFValueNULL *null);
|
||||
static RzCFValueNULL *rz_cf_value_null_new(void);
|
||||
static void rz_cf_value_null_free(RzCFValueNULL *null);
|
||||
static void rz_cf_value_null_print(RzCFValueNULL *null);
|
||||
|
||||
static RCFValueBool *rz_cf_value_bool_new(bool value);
|
||||
static void rz_cf_value_bool_free(RCFValueBool *bool_value);
|
||||
static void rz_cf_value_bool_print(RCFValueBool *bool_value);
|
||||
static RzCFValueBool *rz_cf_value_bool_new(bool value);
|
||||
static void rz_cf_value_bool_free(RzCFValueBool *bool_value);
|
||||
static void rz_cf_value_bool_print(RzCFValueBool *bool_value);
|
||||
|
||||
static void rz_cf_value_free(RCFValue *value);
|
||||
static void rz_cf_value_free(RzCFValue *value);
|
||||
|
||||
RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut64 size, int options) {
|
||||
RCFValueDict *result = NULL;
|
||||
RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut64 size, int options) {
|
||||
RzCFValueDict *result = NULL;
|
||||
yxml_t x;
|
||||
int i;
|
||||
char *content = NULL;
|
||||
|
|
@ -101,8 +101,8 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
|
||||
switch (r) {
|
||||
case YXML_ELEMSTART: {
|
||||
RCFParseState *state = (RCFParseState *)rz_list_get_top(stack);
|
||||
RCFParseState *next_state = NULL;
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_get_top(stack);
|
||||
RzCFParseState *next_state = NULL;
|
||||
|
||||
if (!strcmp(x.elem, "dict")) {
|
||||
next_state = rz_cf_parse_state_new(RZ_CF_STATE_IN_DICT);
|
||||
|
|
@ -167,8 +167,8 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
break;
|
||||
}
|
||||
case YXML_ELEMEND: {
|
||||
RCFParseState *state = (RCFParseState *)rz_list_pop(stack);
|
||||
RCFParseState *next_state = (RCFParseState *)rz_list_get_top(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_pop(stack);
|
||||
RzCFParseState *next_state = (RzCFParseState *)rz_list_get_top(stack);
|
||||
if (!state || !next_state) {
|
||||
goto beach;
|
||||
}
|
||||
|
|
@ -193,36 +193,36 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
}
|
||||
|
||||
if (state->phase != RZ_CF_STATE_IN_KEY) {
|
||||
RCFValue *value = NULL;
|
||||
RzCFValue *value = NULL;
|
||||
|
||||
switch (state->phase) {
|
||||
case RZ_CF_STATE_IN_DICT:
|
||||
value = (RCFValue *)state->dict;
|
||||
value = (RzCFValue *)state->dict;
|
||||
break;
|
||||
case RZ_CF_STATE_IN_ARRAY:
|
||||
value = (RCFValue *)state->array;
|
||||
value = (RzCFValue *)state->array;
|
||||
break;
|
||||
case RZ_CF_STATE_IN_SCALAR:
|
||||
if (!content && state->value_type != RZ_CF_FALSE && state->value_type != RZ_CF_TRUE) {
|
||||
value = (RCFValue *)rz_cf_value_null_new();
|
||||
value = (RzCFValue *)rz_cf_value_null_new();
|
||||
} else {
|
||||
switch (state->value_type) {
|
||||
case RZ_CF_STRING:
|
||||
value = (RCFValue *)rz_cf_value_string_new(content);
|
||||
value = (RzCFValue *)rz_cf_value_string_new(content);
|
||||
break;
|
||||
case RZ_CF_INTEGER:
|
||||
value = (RCFValue *)rz_cf_value_integer_new(content);
|
||||
value = (RzCFValue *)rz_cf_value_integer_new(content);
|
||||
RZ_FREE(content);
|
||||
break;
|
||||
case RZ_CF_DATA:
|
||||
value = (RCFValue *)rz_cf_value_data_new(content);
|
||||
value = (RzCFValue *)rz_cf_value_data_new(content);
|
||||
RZ_FREE(content);
|
||||
break;
|
||||
case RZ_CF_TRUE:
|
||||
value = (RCFValue *)rz_cf_value_bool_new(true);
|
||||
value = (RzCFValue *)rz_cf_value_bool_new(true);
|
||||
break;
|
||||
case RZ_CF_FALSE:
|
||||
value = (RCFValue *)rz_cf_value_bool_new(false);
|
||||
value = (RzCFValue *)rz_cf_value_bool_new(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -235,11 +235,11 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
|
||||
if (next_state->phase == RZ_CF_STATE_IN_DICT) {
|
||||
if (value) {
|
||||
RCFKeyValue *key_value = rz_cf_key_value_new(next_state->key, value);
|
||||
RzCFKeyValue *key_value = rz_cf_key_value_new(next_state->key, value);
|
||||
rz_cf_value_dict_add(next_state->dict, key_value);
|
||||
} else if (state->phase != RZ_CF_STATE_IN_IGNORE) {
|
||||
RZ_LOG_ERROR("Missing value for key %s\n", next_state->key);
|
||||
rz_cf_value_free((RCFValue *)value);
|
||||
rz_cf_value_free((RzCFValue *)value);
|
||||
goto beach;
|
||||
}
|
||||
} else if (next_state->phase == RZ_CF_STATE_IN_ARRAY) {
|
||||
|
|
@ -247,7 +247,7 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
rz_cf_value_array_add(next_state->array, value);
|
||||
} else if (state->phase != RZ_CF_STATE_IN_IGNORE) {
|
||||
RZ_LOG_ERROR("Missing value for array\n");
|
||||
rz_cf_value_free((RCFValue *)value);
|
||||
rz_cf_value_free((RzCFValue *)value);
|
||||
goto beach;
|
||||
}
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut6
|
|||
break;
|
||||
}
|
||||
case YXML_CONTENT: {
|
||||
RCFParseState *state = (RCFParseState *)rz_list_get_top(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_get_top(stack);
|
||||
if (state->phase == RZ_CF_STATE_IN_IGNORE) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -292,22 +292,22 @@ beach:
|
|||
return result;
|
||||
}
|
||||
|
||||
static RCFParseState *rz_cf_parse_state_new(RCFParsePhase phase) {
|
||||
RCFParseState *state = RZ_NEW0(RCFParseState);
|
||||
static RzCFParseState *rz_cf_parse_state_new(RzCFParsePhase phase) {
|
||||
RzCFParseState *state = RZ_NEW0(RzCFParseState);
|
||||
if (state) {
|
||||
state->phase = phase;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
static void rz_cf_parse_state_free(RCFParseState *state) {
|
||||
static void rz_cf_parse_state_free(RzCFParseState *state) {
|
||||
if (state) {
|
||||
RZ_FREE(state);
|
||||
}
|
||||
}
|
||||
|
||||
static RCFKeyValue *rz_cf_key_value_new(char *key, RCFValue *value) {
|
||||
RCFKeyValue *key_value = RZ_NEW0(RCFKeyValue);
|
||||
static RzCFKeyValue *rz_cf_key_value_new(char *key, RzCFValue *value) {
|
||||
RzCFKeyValue *key_value = RZ_NEW0(RzCFKeyValue);
|
||||
if (!key_value) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ static RCFKeyValue *rz_cf_key_value_new(char *key, RCFValue *value) {
|
|||
return key_value;
|
||||
}
|
||||
|
||||
static void rz_cf_key_value_free(RCFKeyValue *key_value) {
|
||||
static void rz_cf_key_value_free(RzCFKeyValue *key_value) {
|
||||
if (!key_value) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -334,8 +334,8 @@ static void rz_cf_key_value_free(RCFKeyValue *key_value) {
|
|||
RZ_FREE(key_value);
|
||||
}
|
||||
|
||||
static RCFValueDict *rz_cf_value_dict_new(void) {
|
||||
RCFValueDict *dict = RZ_NEW0(RCFValueDict);
|
||||
static RzCFValueDict *rz_cf_value_dict_new(void) {
|
||||
RzCFValueDict *dict = RZ_NEW0(RzCFValueDict);
|
||||
if (!dict) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ static RCFValueDict *rz_cf_value_dict_new(void) {
|
|||
return dict;
|
||||
}
|
||||
|
||||
RZ_API void rz_cf_value_dict_free(RCFValueDict *dict) {
|
||||
RZ_API void rz_cf_value_dict_free(RzCFValueDict *dict) {
|
||||
rz_return_if_fail(dict);
|
||||
|
||||
if (dict->pairs) {
|
||||
|
|
@ -357,7 +357,7 @@ RZ_API void rz_cf_value_dict_free(RCFValueDict *dict) {
|
|||
RZ_FREE(dict);
|
||||
}
|
||||
|
||||
static void rz_cf_value_dict_add(RCFValueDict *dict, RCFKeyValue *key_value) {
|
||||
static void rz_cf_value_dict_add(RzCFValueDict *dict, RzCFKeyValue *key_value) {
|
||||
if (!dict || !dict->pairs) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -365,9 +365,9 @@ static void rz_cf_value_dict_add(RCFValueDict *dict, RCFKeyValue *key_value) {
|
|||
rz_list_push(dict->pairs, key_value);
|
||||
}
|
||||
|
||||
static void rz_cf_value_dict_print(RCFValueDict *dict) {
|
||||
static void rz_cf_value_dict_print(RzCFValueDict *dict) {
|
||||
RzListIter *iter;
|
||||
RCFKeyValue *key_value;
|
||||
RzCFKeyValue *key_value;
|
||||
int length = rz_list_length(dict->pairs);
|
||||
int i = 0;
|
||||
printf("{");
|
||||
|
|
@ -381,8 +381,8 @@ static void rz_cf_value_dict_print(RCFValueDict *dict) {
|
|||
printf("}");
|
||||
}
|
||||
|
||||
static RCFValueArray *rz_cf_value_array_new(void) {
|
||||
RCFValueArray *array = RZ_NEW0(RCFValueArray);
|
||||
static RzCFValueArray *rz_cf_value_array_new(void) {
|
||||
RzCFValueArray *array = RZ_NEW0(RzCFValueArray);
|
||||
if (!array) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ static RCFValueArray *rz_cf_value_array_new(void) {
|
|||
return array;
|
||||
}
|
||||
|
||||
static void rz_cf_value_array_free(RCFValueArray *array) {
|
||||
static void rz_cf_value_array_free(RzCFValueArray *array) {
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -407,7 +407,7 @@ static void rz_cf_value_array_free(RCFValueArray *array) {
|
|||
RZ_FREE(array);
|
||||
}
|
||||
|
||||
static void rz_cf_value_array_add(RCFValueArray *array, RCFValue *value) {
|
||||
static void rz_cf_value_array_add(RzCFValueArray *array, RzCFValue *value) {
|
||||
if (!array || !array->values) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -415,9 +415,9 @@ static void rz_cf_value_array_add(RCFValueArray *array, RCFValue *value) {
|
|||
rz_list_push(array->values, value);
|
||||
}
|
||||
|
||||
static void rz_cf_value_array_print(RCFValueArray *array) {
|
||||
static void rz_cf_value_array_print(RzCFValueArray *array) {
|
||||
RzListIter *iter;
|
||||
RCFValue *value;
|
||||
RzCFValue *value;
|
||||
int length = rz_list_length(array->values);
|
||||
int i = 0;
|
||||
printf("[");
|
||||
|
|
@ -430,8 +430,8 @@ static void rz_cf_value_array_print(RCFValueArray *array) {
|
|||
printf("]");
|
||||
}
|
||||
|
||||
static RCFValueString *rz_cf_value_string_new(char *string) {
|
||||
RCFValueString *value_string = RZ_NEW0(RCFValueString);
|
||||
static RzCFValueString *rz_cf_value_string_new(char *string) {
|
||||
RzCFValueString *value_string = RZ_NEW0(RzCFValueString);
|
||||
if (!value_string) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -442,7 +442,7 @@ static RCFValueString *rz_cf_value_string_new(char *string) {
|
|||
return value_string;
|
||||
}
|
||||
|
||||
static void rz_cf_value_string_free(RCFValueString *string) {
|
||||
static void rz_cf_value_string_free(RzCFValueString *string) {
|
||||
if (!string) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -455,15 +455,15 @@ static void rz_cf_value_string_free(RCFValueString *string) {
|
|||
RZ_FREE(string);
|
||||
}
|
||||
|
||||
static void rz_cf_value_string_print(RCFValueString *string) {
|
||||
static void rz_cf_value_string_print(RzCFValueString *string) {
|
||||
char *escaped = strdup(string->value);
|
||||
escaped = rz_str_replace(escaped, "\"", "\\\"", 1);
|
||||
printf("\"%s\"", escaped);
|
||||
RZ_FREE(escaped);
|
||||
}
|
||||
|
||||
static RCFValueInteger *rz_cf_value_integer_new(char *string) {
|
||||
RCFValueInteger *integer = RZ_NEW0(RCFValueInteger);
|
||||
static RzCFValueInteger *rz_cf_value_integer_new(char *string) {
|
||||
RzCFValueInteger *integer = RZ_NEW0(RzCFValueInteger);
|
||||
if (!integer) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ static RCFValueInteger *rz_cf_value_integer_new(char *string) {
|
|||
return integer;
|
||||
}
|
||||
|
||||
static void rz_cf_value_integer_free(RCFValueInteger *integer) {
|
||||
static void rz_cf_value_integer_free(RzCFValueInteger *integer) {
|
||||
if (!integer) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -483,12 +483,12 @@ static void rz_cf_value_integer_free(RCFValueInteger *integer) {
|
|||
RZ_FREE(integer);
|
||||
}
|
||||
|
||||
static void rz_cf_value_integer_print(RCFValueInteger *integer) {
|
||||
static void rz_cf_value_integer_print(RzCFValueInteger *integer) {
|
||||
printf("%llu", integer->value);
|
||||
}
|
||||
|
||||
static RCFValueData *rz_cf_value_data_new(char *string) {
|
||||
RCFValueData *data = RZ_NEW0(RCFValueData);
|
||||
static RzCFValueData *rz_cf_value_data_new(char *string) {
|
||||
RzCFValueData *data = RZ_NEW0(RzCFValueData);
|
||||
if (!data) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -508,7 +508,7 @@ static RCFValueData *rz_cf_value_data_new(char *string) {
|
|||
return data;
|
||||
}
|
||||
|
||||
static void rz_cf_value_data_free(RCFValueData *data) {
|
||||
static void rz_cf_value_data_free(RzCFValueData *data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -522,12 +522,12 @@ static void rz_cf_value_data_free(RCFValueData *data) {
|
|||
RZ_FREE(data);
|
||||
}
|
||||
|
||||
static void rz_cf_value_data_print(RCFValueData *data) {
|
||||
static void rz_cf_value_data_print(RzCFValueData *data) {
|
||||
printf("\"...\"");
|
||||
}
|
||||
|
||||
static RCFValueNULL *rz_cf_value_null_new(void) {
|
||||
RCFValueNULL *null = RZ_NEW0(RCFValueNULL);
|
||||
static RzCFValueNULL *rz_cf_value_null_new(void) {
|
||||
RzCFValueNULL *null = RZ_NEW0(RzCFValueNULL);
|
||||
if (!null) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ static RCFValueNULL *rz_cf_value_null_new(void) {
|
|||
return null;
|
||||
}
|
||||
|
||||
static void rz_cf_value_null_free(RCFValueNULL *null) {
|
||||
static void rz_cf_value_null_free(RzCFValueNULL *null) {
|
||||
if (!null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -546,12 +546,12 @@ static void rz_cf_value_null_free(RCFValueNULL *null) {
|
|||
RZ_FREE(null);
|
||||
}
|
||||
|
||||
static void rz_cf_value_null_print(RCFValueNULL *null) {
|
||||
static void rz_cf_value_null_print(RzCFValueNULL *null) {
|
||||
printf("null");
|
||||
}
|
||||
|
||||
static RCFValueBool *rz_cf_value_bool_new(bool value) {
|
||||
RCFValueBool *bool_value = RZ_NEW0(RCFValueBool);
|
||||
static RzCFValueBool *rz_cf_value_bool_new(bool value) {
|
||||
RzCFValueBool *bool_value = RZ_NEW0(RzCFValueBool);
|
||||
if (!bool_value) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -560,80 +560,80 @@ static RCFValueBool *rz_cf_value_bool_new(bool value) {
|
|||
return bool_value;
|
||||
}
|
||||
|
||||
static void rz_cf_value_bool_free(RCFValueBool *bool_value) {
|
||||
static void rz_cf_value_bool_free(RzCFValueBool *bool_value) {
|
||||
if (bool_value) {
|
||||
bool_value->type = RZ_CF_INVALID;
|
||||
RZ_FREE(bool_value);
|
||||
}
|
||||
}
|
||||
|
||||
static void rz_cf_value_bool_print(RCFValueBool *bool_value) {
|
||||
static void rz_cf_value_bool_print(RzCFValueBool *bool_value) {
|
||||
if (bool_value->type == RZ_CF_TRUE) {
|
||||
printf("true");
|
||||
} else {
|
||||
printf("false");
|
||||
}
|
||||
}
|
||||
static void rz_cf_value_free(RCFValue *value) {
|
||||
static void rz_cf_value_free(RzCFValue *value) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value->type) {
|
||||
case RZ_CF_DICT:
|
||||
rz_cf_value_dict_free((RCFValueDict *)value);
|
||||
rz_cf_value_dict_free((RzCFValueDict *)value);
|
||||
break;
|
||||
case RZ_CF_ARRAY:
|
||||
rz_cf_value_array_free((RCFValueArray *)value);
|
||||
rz_cf_value_array_free((RzCFValueArray *)value);
|
||||
break;
|
||||
case RZ_CF_STRING:
|
||||
rz_cf_value_string_free((RCFValueString *)value);
|
||||
rz_cf_value_string_free((RzCFValueString *)value);
|
||||
break;
|
||||
case RZ_CF_INTEGER:
|
||||
rz_cf_value_integer_free((RCFValueInteger *)value);
|
||||
rz_cf_value_integer_free((RzCFValueInteger *)value);
|
||||
break;
|
||||
case RZ_CF_DATA:
|
||||
rz_cf_value_data_free((RCFValueData *)value);
|
||||
rz_cf_value_data_free((RzCFValueData *)value);
|
||||
break;
|
||||
case RZ_CF_NULL:
|
||||
rz_cf_value_null_free((RCFValueNULL *)value);
|
||||
rz_cf_value_null_free((RzCFValueNULL *)value);
|
||||
break;
|
||||
case RZ_CF_TRUE:
|
||||
case RZ_CF_FALSE:
|
||||
rz_cf_value_bool_free((RCFValueBool *)value);
|
||||
rz_cf_value_bool_free((RzCFValueBool *)value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RZ_API void rz_cf_value_print(RCFValue *value) {
|
||||
RZ_API void rz_cf_value_print(RzCFValue *value) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (value->type) {
|
||||
case RZ_CF_DICT:
|
||||
rz_cf_value_dict_print((RCFValueDict *)value);
|
||||
rz_cf_value_dict_print((RzCFValueDict *)value);
|
||||
break;
|
||||
case RZ_CF_ARRAY:
|
||||
rz_cf_value_array_print((RCFValueArray *)value);
|
||||
rz_cf_value_array_print((RzCFValueArray *)value);
|
||||
break;
|
||||
case RZ_CF_STRING:
|
||||
rz_cf_value_string_print((RCFValueString *)value);
|
||||
rz_cf_value_string_print((RzCFValueString *)value);
|
||||
break;
|
||||
case RZ_CF_INTEGER:
|
||||
rz_cf_value_integer_print((RCFValueInteger *)value);
|
||||
rz_cf_value_integer_print((RzCFValueInteger *)value);
|
||||
break;
|
||||
case RZ_CF_DATA:
|
||||
rz_cf_value_data_print((RCFValueData *)value);
|
||||
rz_cf_value_data_print((RzCFValueData *)value);
|
||||
break;
|
||||
case RZ_CF_NULL:
|
||||
rz_cf_value_null_print((RCFValueNULL *)value);
|
||||
rz_cf_value_null_print((RzCFValueNULL *)value);
|
||||
break;
|
||||
case RZ_CF_TRUE:
|
||||
case RZ_CF_FALSE:
|
||||
rz_cf_value_bool_print((RCFValueBool *)value);
|
||||
rz_cf_value_bool_print((RzCFValueBool *)value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -17,52 +17,52 @@ typedef enum {
|
|||
RZ_CF_NULL,
|
||||
RZ_CF_TRUE,
|
||||
RZ_CF_FALSE
|
||||
} RCFValueType;
|
||||
} RzCFValueType;
|
||||
|
||||
typedef struct _CFValue {
|
||||
RCFValueType type;
|
||||
} RCFValue;
|
||||
typedef struct rz_cf_Value {
|
||||
RzCFValueType type;
|
||||
} RzCFValue;
|
||||
|
||||
typedef struct _CFKeyValue {
|
||||
typedef struct rz_cf_KeyValue {
|
||||
char *key;
|
||||
RCFValue *value;
|
||||
} RCFKeyValue;
|
||||
RzCFValue *value;
|
||||
} RzCFKeyValue;
|
||||
|
||||
typedef struct _CFValueDict {
|
||||
RCFValueType type;
|
||||
RzList /*<RCFKeyValue *>*/ *pairs;
|
||||
} RCFValueDict;
|
||||
typedef struct rz_cf_value_dict {
|
||||
RzCFValueType type;
|
||||
RzList /*<RzCFKeyValue *>*/ *pairs;
|
||||
} RzCFValueDict;
|
||||
|
||||
typedef struct _CFValueArray {
|
||||
RCFValueType type;
|
||||
RzList /*<RCFValue *>*/ *values;
|
||||
} RCFValueArray;
|
||||
typedef struct rz_cf_value_array {
|
||||
RzCFValueType type;
|
||||
RzList /*<RzCFValue *>*/ *values;
|
||||
} RzCFValueArray;
|
||||
|
||||
typedef struct _CFValueString {
|
||||
RCFValueType type;
|
||||
typedef struct rz_cf_value_string {
|
||||
RzCFValueType type;
|
||||
char *value;
|
||||
} RCFValueString;
|
||||
} RzCFValueString;
|
||||
|
||||
typedef struct _CFValueInteger {
|
||||
RCFValueType type;
|
||||
typedef struct rz_cf_value_integer {
|
||||
RzCFValueType type;
|
||||
ut64 value;
|
||||
} RCFValueInteger;
|
||||
} RzCFValueInteger;
|
||||
|
||||
typedef struct _CFValueData {
|
||||
RCFValueType type;
|
||||
typedef struct rz_cf_value_data {
|
||||
RzCFValueType type;
|
||||
RzBuffer *value;
|
||||
} RCFValueData;
|
||||
} RzCFValueData;
|
||||
|
||||
typedef struct _CFValueBool {
|
||||
RCFValueType type;
|
||||
} RCFValueBool;
|
||||
typedef struct rz_cf_value_bool {
|
||||
RzCFValueType type;
|
||||
} RzCFValueBool;
|
||||
|
||||
typedef struct _CFValueNULL {
|
||||
RCFValueType type;
|
||||
} RCFValueNULL;
|
||||
typedef struct rz_cf_value_null {
|
||||
RzCFValueType type;
|
||||
} RzCFValueNULL;
|
||||
|
||||
RZ_API RCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut64 size, int options);
|
||||
RZ_API void rz_cf_value_dict_free(RCFValueDict *dict);
|
||||
RZ_API void rz_cf_value_print(RCFValue *value);
|
||||
RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut64 size, int options);
|
||||
RZ_API void rz_cf_value_dict_free(RzCFValueDict *dict);
|
||||
RZ_API void rz_cf_value_print(RzCFValue *value);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *o, RzBuffer *buf, Sdb *sdb)
|
|||
goto beach;
|
||||
}
|
||||
|
||||
RCFValueDict *prelink_info = NULL;
|
||||
RzCFValueDict *prelink_info = NULL;
|
||||
if (main_mach0->hdr.filetype != MH_FILESET && prelink_range->range.size) {
|
||||
prelink_info = rz_cf_value_dict_parse(fbuf, prelink_range->range.offset,
|
||||
prelink_range->range.size, RZ_CF_OPTION_SKIP_NSDATA);
|
||||
|
|
@ -282,12 +282,12 @@ static RPrelinkRange *get_prelink_info_range_from_mach0(struct MACH0_(obj_t) * m
|
|||
}
|
||||
|
||||
static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
||||
RCFValueArray *kext_array = NULL;
|
||||
RzCFValueArray *kext_array = NULL;
|
||||
RzListIter *iter;
|
||||
RCFKeyValue *item;
|
||||
RzCFKeyValue *item;
|
||||
rz_list_foreach (obj->prelink_info->pairs, iter, item) {
|
||||
if (!strcmp(item->key, "_PrelinkInfoDictionary")) {
|
||||
kext_array = (RCFValueArray *)item->value;
|
||||
kext_array = (RzCFValueArray *)item->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -303,7 +303,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
|
||||
bool is_sorted = true;
|
||||
RKext *prev_kext = NULL;
|
||||
RCFValueDict *kext_item;
|
||||
RzCFValueDict *kext_item;
|
||||
rz_list_foreach (kext_array->values, iter, kext_item) {
|
||||
RKext *kext = RZ_NEW0(RKext);
|
||||
if (!kext) {
|
||||
|
|
@ -318,7 +318,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
if (item->value->type != RZ_CF_STRING) {
|
||||
break;
|
||||
}
|
||||
RCFValueString *type = (RCFValueString *)item->value;
|
||||
RzCFValueString *type = (RzCFValueString *)item->value;
|
||||
if (strcmp(type->value, "KEXT")) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
if (!strcmp(item->key, "_PrelinkExecutableLoadAddr")) {
|
||||
if (item->value->type == RZ_CF_INTEGER) {
|
||||
kext_incomplete--;
|
||||
kext->vaddr = ((RCFValueInteger *)item->value)->value;
|
||||
kext->vaddr = ((RzCFValueInteger *)item->value)->value;
|
||||
kext->range.offset = kext->vaddr - obj->pa2va_exec;
|
||||
}
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
if (!strcmp(item->key, "_PrelinkExecutableSize")) {
|
||||
kext_incomplete--;
|
||||
if (item->value->type == RZ_CF_INTEGER) {
|
||||
kext->range.size = ((RCFValueInteger *)item->value)->value;
|
||||
kext->range.size = ((RzCFValueInteger *)item->value)->value;
|
||||
} else {
|
||||
kext->range.size = 0;
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
if (!strcmp(item->key, "_PrelinkKmodInfo")) {
|
||||
if (item->value->type == RZ_CF_INTEGER) {
|
||||
kext_incomplete--;
|
||||
kext->mod_info = ((RCFValueInteger *)item->value)->value;
|
||||
kext->mod_info = ((RzCFValueInteger *)item->value)->value;
|
||||
kext->mod_info -= obj->pa2va_data;
|
||||
}
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj) {
|
|||
if (!strcmp(item->key, "CFBundleIdentifier")) {
|
||||
if (item->value->type == RZ_CF_STRING) {
|
||||
kext_incomplete--;
|
||||
kext->name = ((RCFValueString *)item->value)->value;
|
||||
kext->name = ((RzCFValueString *)item->value)->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue