struct parsed_data *btj;// branch targets for jumptables
struct parsed_proto *pp;// parsed_proto for OP_CALL
void *datap;
+ int asmln;
};
// datap:
static int g_ida_func_attr;
static int g_allow_regfunc;
#define ferr(op_, fmt, ...) do { \
- printf("error:%s:#%zd: '%s': " fmt, g_func, (op_) - ops, \
+ printf("%s:%d: error: [%s] '%s': " fmt, asmfn, (op_)->asmln, g_func, \
dump_op(op_), ##__VA_ARGS__); \
fcloseall(); \
exit(1); \
} while (0)
#define fnote(op_, fmt, ...) \
- printf("error:%s:#%zd: '%s': " fmt, g_func, (op_) - ops, \
+ printf("%s:%d: note: [%s] '%s': " fmt, asmfn, (op_)->asmln, g_func, \
dump_op(op_), ##__VA_ARGS__)
#define MAX_REGS 8
op->pfo = op_table[i].pfo;
op->pfo_inv = op_table[i].pfo_inv;
op->regmask_src = op->regmask_dst = 0;
+ op->asmln = asmln;
for (opr = 0; opr < op_table[i].minopr; opr++) {
regmask = regmask_ind = 0;
fprintf(fout, " {\n");
}
- if (pp->is_fptr && !pp->is_arg)
+ if (pp->is_fptr && !pp->is_arg) {
fprintf(fout, "%s%s = %s;\n", buf3, pp->name,
out_src_opr(buf1, sizeof(buf1), po, &po->operand[0],
"(void *)", 0));
+ if (pp->is_unresolved)
+ fprintf(fout, "%sunresolved_call(\"%s:%d\", %s);\n",
+ buf3, asmfn, po->asmln, pp->name);
+ }
fprintf(fout, "%s", buf3);
if (strstr(pp->ret_type.name, "int64")) {
}
if (pp->is_unresolved) {
- snprintf(buf2, sizeof(buf2), " unresoved %dreg",
+ snprintf(buf2, sizeof(buf2), " unresolved %dreg",
pp->argc_reg);
strcat(g_comment, buf2);
}
parse_op(&ops[pi], words, wordc);
if (sctproto != NULL) {
- if (ops[pi].op == OP_CALL)
+ if (ops[pi].op == OP_CALL || ops[pi].op == OP_JMP)
ops[pi].datap = sctproto;
sctproto = NULL;
}
--- /dev/null
+#define unresolved_call(n, p) \
+ printf("%s: unresolved_call %p %s\n", n, p, addr_to_sym(p))
+
+/* mingw is missing dbghelp stuff.. */
+static const char *addr_to_sym(void *addr)
+{
+ static HMODULE dbgh;
+ static BOOL WINAPI (*pSymFromAddr)(HANDLE hProcess, DWORD64 Address,
+ DWORD64* Displacement, void *Symbol);
+ static BOOL WINAPI (*pSymInitialize)(HANDLE hProcess,
+ PCSTR UserSearchPath, BOOL fInvadeProcess);
+ static char info[88 + 256];
+
+ if (dbgh == NULL)
+ dbgh = LoadLibraryA("dbghelp.dll");
+ if (dbgh == NULL)
+ return "(no dbghelp)";
+ if (pSymFromAddr == NULL)
+ pSymFromAddr = (void *)GetProcAddress(dbgh, "SymFromAddr");
+ if (pSymFromAddr == NULL)
+ return "(no SymFromAddr)";
+ if (pSymInitialize == NULL) {
+ pSymInitialize = (void *)GetProcAddress(dbgh, "SymInitialize");
+ if (pSymInitialize == NULL)
+ return "(no SymInitialize)";
+ pSymInitialize(GetCurrentProcess(), NULL, TRUE);
+ }
+
+ *(ULONG *)&info[0] = 88; // SizeOfStruct
+ *(ULONG *)&info[80] = 256; // MaxNameLen
+ if (!pSymFromAddr(GetCurrentProcess(), (DWORD64)(unsigned int)addr, NULL, info))
+ return "(no sym)";
+
+ return info + 84;
+}
+