when I load a Windows PE file, IDA auto load 2 til: ntapi64_win7 & mssdk64_win7
and when I use type MACRO_ERROR, I found that it was being defined twice.
so when I set num expr to enum, it’s will be confused, general it’s use ntapi64_win7’s MACRO_ERROR not mssdk64_win7.
static const char error_type[] = "MACRO_ERROR";
[...]
// create a new expression
cexpr_t *num_expr = make_num(HRESULT_CODE(value), nullptr, BADADDR, 0, no_sign, sizeof(int64_t));
num_expr->n->nf.type_name = error_type;
num_expr->n->nf.props |= NF_VALID;
num_expr->n->nf.serial = 0;
num_expr->n->nf.flags = enum_flag();
num_expr->type.get_named_type(nullptr, error_type, BTF_ENUM);
[...]
so I try to use load_til manually:
[...]
qstring errbuf;
til_t *til = load_til("mssdk_win7", &errbuf);
if (til == nullptr)
{
msg("Failed to load til: %s\n", errbuf.c_str());
return;
}
[...]
// create a new expression
cexpr_t *num_expr = make_num(HRESULT_CODE(value), nullptr, BADADDR, 0, no_sign, sizeof(int64_t));
num_expr->n->nf.type_name = error_type;
num_expr->n->nf.props |= NF_VALID;
num_expr->n->nf.serial = 0;
num_expr->n->nf.flags = enum_flag();
num_expr->type.get_named_type(til, error_type, BTF_ENUM);
[...] // maybe we need free til after plugin uninstall
unfortunately, it’s looks like nothing has changed…
BTW, another question is, when I self-modified ctree, expr( op = cot_num
) seems cannot to convert(create) enum / hex / oct / …
it’s my issue or expected behavior?