Example #1
0
R_API const char *r_anal_data_kind (RAnal *a, ut64 addr, const ut8 *buf, int len) {
	int inv = 0;
	int unk = 0;
	int str = 0;
	int num = 0;
	int i, j;
	RAnalData *data;
	int word = a->bits /8;
	for (i = j = 0; i<len; j++) {
		if (str && !buf[i])
			str ++;
		data = r_anal_data (a, addr+i, buf+i, len-i);
		if (data == NULL) {
			i+= word;
			continue;
		}
		switch (data->type) {
		case R_ANAL_DATA_TYPE_INVALID:
			inv++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_NUMBER:
			if (data->ptr> 1000) num++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_UNKNOWN:
			unk++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_STRING:
			if (data->len>0) {
				i += data->len; //strlen ((const char*)buf+i)+1;
			} else i+=word;
			str++;
			break;
		default:
			i += word;
		}
		r_anal_data_free (data);
        }
//eprintf ("%d %d %d %d\n", inv, unk, num, str);
	if (j<1) return "unknown";
	if ((inv*100/j)>60) return "invalid";
	if ((unk*100/j)>60) return "code";
	if ((num*100/j)>60) return "code";
//return "text";
	if ((str*100/j)>40) return "text";
	return "data";
}
Example #2
0
R_API const char *r_anal_data_kind (RAnal *anal, ut64 addr, const ut8 *buf, int len) {
	int inv = 0;
	int unk = 0;
	int str = 0;
	int num = 0;
	int i, j;
	RAnalData *data;
	int word = anal->bits /8;
	for (i = j = 0; i<len ; j++ ) {
		data = r_anal_data (anal, addr+i, buf+i, len-i);
		switch (data->type) {
		case R_ANAL_DATA_TYPE_INVALID:
			inv++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_NUMBER:
			if (data->ptr> 1000) num++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_UNKNOWN:
			unk++;
			i += word;
			break;
		case R_ANAL_DATA_TYPE_STRING:
			i += data->len; //strlen ((const char*)buf+i)+1;
			str++;
			break;
		default:
			i += word;
		}
		r_anal_data_free (data);
        }
	if (j<1) return "unknown";
	if ((inv*100/j)>60) return "invalid";
	if ((unk*100/j)>60) return "code";
	if ((num*100/j)>60) return "code";
	if ((str*100/j)>40) return "text";
	return "data";
}