static void event_post_syscall(void *drcontext, int sysnum) { drsys_syscall_t *syscall; drsys_sysnum_t sysnum_full; bool success = false; const char *name; if (drsys_cur_syscall(drcontext, &syscall) != DRMF_SUCCESS) ASSERT(false, "drsys_cur_syscall failed"); if (drsys_syscall_number(syscall, &sysnum_full) != DRMF_SUCCESS) ASSERT(false, "drsys_get_sysnum failed"); ASSERT(sysnum == sysnum_full.number, "primary should match DR's num"); if (drsys_syscall_name(syscall, &name) != DRMF_SUCCESS) ASSERT(false, "drsys_syscall_name failed"); check_mcontext(drcontext); if (drsys_iterate_args(drcontext, drsys_iter_arg_cb, NULL) != DRMF_SUCCESS) ASSERT(false, "drsys_iterate_args failed"); if (drsys_cur_syscall_result(drcontext, &success, NULL, NULL) != DRMF_SUCCESS || !success) { /* With the new early injector on Linux, we see access, open, + stat64 fail */ #ifdef WINDOWS ASSERT(false, "no syscalls in this app should fail"); #endif } else { if (drsys_iterate_memargs(drcontext, drsys_iter_memarg_cb, NULL) != DRMF_SUCCESS) ASSERT(false, "drsys_iterate_memargs failed"); } }
static void event_post_syscall(void *drcontext, int sysnum) { drsys_syscall_t *syscall; bool success = false; uint errno; drmf_status_t res; buf_info_t buf; buf.sofar = 0; if (drsys_cur_syscall(drcontext, &syscall) != DRMF_SUCCESS) ASSERT(false, "drsys_cur_syscall failed"); if (drsys_cur_syscall_result(drcontext, &success, NULL, &errno) != DRMF_SUCCESS) ASSERT(false, "drsys_cur_syscall_result failed"); if (success) OUTPUT(&buf, " succeeded =>\n"); else OUTPUT(&buf, " failed (error="IF_WINDOWS_ELSE(PIFX, "%d")") =>\n", errno); res = drsys_iterate_args(drcontext, drsys_iter_arg_cb, &buf); if (res != DRMF_SUCCESS && res != DRMF_ERROR_DETAILS_UNKNOWN) ASSERT(false, "drsys_iterate_args failed post-syscall"); FLUSH_BUFFER(outf, buf.buf, buf.sofar); }
bool wingdi_shared_process_syscall(bool pre, void *drcontext, drsys_sysnum_t sysnum, cls_syscall_t *pt, dr_mcontext_t *mc, drsys_syscall_t *syscall) { /* handlers here do not check for success so we check up front */ if (!pre) { bool success; if (drsys_cur_syscall_result(drcontext, &success, NULL, NULL) != DRMF_SUCCESS || !success) return true; } if (sysnum.number == sysnum_GdiCreateDIBSection.number) return handle_GdiCreateDIBSection(pre, drcontext, pt); if (options.check_gdi) { syscall_check_gdi(pre, drcontext, sysnum, pt, mc); } return true; /* execute syscall */ }