int main(int argc, char** argv) { dpy = XOpenDisplay(NULL); if(!dpy) die(ERR_CANNOT_OPEN_DISPLAY, "Cannot open display!\n"); setup_app(); check_features(); setup_x(); setup_gl(); start(); clean(); return 0; }
static vk::Device create_device( vk::PhysicalDevice physical, const core::ArrayView<QueueFamily>& queue_families, const DebugParams& debug) { auto queue_create_infos = core::vector_with_capacity<vk::DeviceQueueCreateInfo>(queue_families.size()); auto prio_count = std::max_element(queue_families.begin(), queue_families.end(), [](const auto& a, const auto& b) { return a.count() < b.count(); })->count(); core::Vector<float> priorities(prio_count, 1.0f); std::transform(queue_families.begin(), queue_families.end(), std::back_inserter(queue_create_infos), [&](const auto& q) { return vk::DeviceQueueCreateInfo() .setQueueFamilyIndex(q.index()) .setPQueuePriorities(priorities.begin()) .setQueueCount(q.count()) ; }); auto required = vk::PhysicalDeviceFeatures(); required.multiDrawIndirect = true; required.drawIndirectFirstInstance = true; required.fullDrawIndexUint32 = true; required.textureCompressionBC = true; required.shaderStorageImageExtendedFormats = true; required.shaderUniformBufferArrayDynamicIndexing = true; required.shaderSampledImageArrayDynamicIndexing = true; required.shaderStorageBufferArrayDynamicIndexing = true; required.shaderStorageImageArrayDynamicIndexing = true; if(debug.debug_features_enabled()) { required.robustBufferAccess = true; } check_features(physical.getFeatures(), required); auto exts = extensions(debug); return physical.createDevice(vk::DeviceCreateInfo() .setEnabledExtensionCount(u32(exts.size())) .setPpEnabledExtensionNames(exts.begin()) .setEnabledLayerCount(u32(debug.device_layers().size())) .setPpEnabledLayerNames(debug.device_layers().begin()) .setQueueCreateInfoCount(queue_create_infos.size()) .setPQueueCreateInfos(queue_create_infos.begin()) .setPEnabledFeatures(&required) ); }
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { static int omode = 0; int mode, ret; ut64 off = a->pc; mode = (a->bits==64)? CS_MODE_64: (a->bits==32)? CS_MODE_32: (a->bits==16)? CS_MODE_16: 0; if (cd && mode != omode) { cs_close (&cd); cd = 0; } op->size = 0; omode = mode; if (cd == 0) { ret = cs_open (CS_ARCH_X86, mode, &cd); if (ret) return 0; } if (a->features && *a->features) { cs_option (cd, CS_OPT_DETAIL, CS_OPT_ON); } else { cs_option (cd, CS_OPT_DETAIL, CS_OPT_OFF); } if (a->syntax == R_ASM_SYNTAX_MASM) { #if CS_API_MAJOR >= 4 cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_MASM); #endif } else if (a->syntax == R_ASM_SYNTAX_ATT) { cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); } else { cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL); } op->size = 1; #if USE_ITER_API { size_t size = len; if (!insn) insn = cs_malloc (cd); insn->size = 1; memset (insn, 0, insn->size); n = cs_disasm_iter (cd, (const uint8_t**)&buf, &size, (uint64_t*)&off, insn); } #else n = cs_disasm (cd, (const ut8*)buf, len, off, 1, &insn); #endif op->size = 0; if (a->features && *a->features) { if (!check_features (a, insn)) { op->size = insn->size; strcpy (op->buf_asm, "illegal"); } } if (op->size==0 && n>0 && insn->size>0) { char *ptrstr; op->size = insn->size; snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s%s%s", insn->mnemonic, insn->op_str[0]?" ":"", insn->op_str); ptrstr = strstr (op->buf_asm, "ptr "); if (ptrstr) { memmove (ptrstr, ptrstr+4, strlen (ptrstr+4)+1); } } if (a->syntax == R_ASM_SYNTAX_JZ) { if (!strncmp (op->buf_asm, "je ", 3)) { memcpy (op->buf_asm, "jz", 2); } else if (!strncmp (op->buf_asm, "jne ", 4)) { memcpy (op->buf_asm, "jnz", 3); } } #if USE_ITER_API /* do nothing because it should be allocated once and freed in the_end */ #else cs_free (insn, n); insn = NULL; #endif return op->size; }
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { static int omode = -1; static int obits = 32; cs_insn* insn = NULL; cs_mode mode = 0; int ret, n = 0; mode |= (a->big_endian)? CS_MODE_BIG_ENDIAN: CS_MODE_LITTLE_ENDIAN; if (mode != omode || a->bits != obits) { cs_close (&cd); cd = 0; // unnecessary omode = mode; obits = a->bits; } // replace this with the asm.features? if (a->cpu && strstr (a->cpu, "68000")) mode |= CS_MODE_M68K_000; if (a->cpu && strstr (a->cpu, "68010")) mode |= CS_MODE_M68K_010; if (a->cpu && strstr (a->cpu, "68020")) mode |= CS_MODE_M68K_020; if (a->cpu && strstr (a->cpu, "68030")) mode |= CS_MODE_M68K_030; if (a->cpu && strstr (a->cpu, "68040")) mode |= CS_MODE_M68K_040; if (a->cpu && strstr (a->cpu, "68060")) mode |= CS_MODE_M68K_060; op->size = 4; op->buf_asm[0] = 0; if (cd == 0) { ret = cs_open (CS_ARCH_M68K, mode, &cd); if (ret) { ret = -1; goto beach; } } if (a->features && *a->features) { cs_option (cd, CS_OPT_DETAIL, CS_OPT_ON); } else { cs_option (cd, CS_OPT_DETAIL, CS_OPT_OFF); } n = cs_disasm (cd, buf, R_MIN (8, len), a->pc, 1, &insn); if (n<1) { ret = -1; goto beach; } op->size = 0; if (insn->size<1) { ret = -1; goto beach; } if (a->features && *a->features) { if (!check_features (a, insn)) { op->size = insn->size; strcpy (op->buf_asm, "illegal"); } } if (!op->size) { op->size = insn->size; snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s%s%s", insn->mnemonic, insn->op_str[0]?" ":"", insn->op_str); } { char *p = r_str_replace (strdup (op->buf_asm), "$", "0x", true); if (p) { strncpy (op->buf_asm, p, R_ASM_BUFSIZE-1); free (p); } } cs_free (insn, n); beach: //cs_close (&cd); if (!strncmp (op->buf_asm, "dc.w", 4)) { strcpy (op->buf_asm, "invalid"); } r_str_rmch (op->buf_asm, '#'); return op->size; }
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { static int omode = 0; int mode, ret; ut64 off = a->pc; mode = (a->bits == 64)? CS_MODE_64: (a->bits == 32)? CS_MODE_32: (a->bits == 16)? CS_MODE_16: 0; if (cd && mode != omode) { cs_close (&cd); cd = 0; } if (op) { op->size = 0; } omode = mode; if (cd == 0) { ret = cs_open (CS_ARCH_X86, mode, &cd); if (ret) { return 0; } } if (a->features && *a->features) { cs_option (cd, CS_OPT_DETAIL, CS_OPT_ON); } else { cs_option (cd, CS_OPT_DETAIL, CS_OPT_OFF); } // always unsigned immediates (kernel addresses) // maybe r2 should have an option for this too? #if CS_API_MAJOR >= 4 cs_option (cd, CS_OPT_UNSIGNED, CS_OPT_ON); #endif if (a->syntax == R_ASM_SYNTAX_MASM) { #if CS_API_MAJOR >= 4 cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_MASM); #endif } else if (a->syntax == R_ASM_SYNTAX_ATT) { cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); } else { cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL); } if (!op) { return true; } op->size = 1; cs_insn *insn = NULL; #if USE_ITER_API { size_t size = len; if (!insn || cd < 1) { insn = cs_malloc (cd); } if (!insn) { cs_free (insn, n); return 0; } memset (insn, 0, insn->size); insn->size = 1; n = cs_disasm_iter (cd, (const uint8_t**)&buf, &size, (uint64_t*)&off, insn); } #else n = cs_disasm (cd, (const ut8*)buf, len, off, 1, &insn); #endif if (op) { op->size = 0; } if (a->features && *a->features) { if (!check_features (a, insn)) { op->size = insn->size; r_asm_op_set_asm (op, "illegal"); } } if (op->size == 0 && n > 0 && insn->size > 0) { char *ptrstr; op->size = insn->size; char *buf_asm = sdb_fmt ("%s%s%s", insn->mnemonic, insn->op_str[0]?" ":"", insn->op_str); ptrstr = strstr (buf_asm, "ptr "); if (ptrstr) { memmove (ptrstr, ptrstr + 4, strlen (ptrstr + 4) + 1); } r_asm_op_set_asm (op, buf_asm); } else { decompile_vm (a, op, buf, len); } if (a->syntax == R_ASM_SYNTAX_JZ) { char *buf_asm = r_strbuf_get (&op->buf_asm); if (!strncmp (buf_asm, "je ", 3)) { memcpy (buf_asm, "jz", 2); } else if (!strncmp (buf_asm, "jne ", 4)) { memcpy (buf_asm, "jnz", 3); } } #if 0 // [eax + ebx*4] => [eax + ebx * 4] char *ast = strchr (op->buf_asm, '*'); if (ast && ast > op->buf_asm) { ast--; if (ast[0] != ' ') { char *tmp = strdup (ast + 1); if (tmp) { ast[0] = ' '; if (tmp[0] && tmp[1] && tmp[1] != ' ') { strcpy (ast, " * "); strcpy (ast + 3, tmp + 1); } else { strcpy (ast + 1, tmp); } free (tmp); } } } #endif #if USE_ITER_API /* do nothing because it should be allocated once and freed in the_end */ #else if (insn) { cs_free (insn, n); } #endif return op->size; }
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { static int omode = -1; static int obits = 32; cs_insn* insn = NULL; cs_mode mode = 0; int ret, n = 0; mode |= (a->bits == 16)? CS_MODE_THUMB: CS_MODE_ARM; mode |= (a->big_endian)? CS_MODE_BIG_ENDIAN: CS_MODE_LITTLE_ENDIAN; if (mode != omode || a->bits != obits) { cs_close (&cd); cd = 0; // unnecessary omode = mode; obits = a->bits; } if (a->features && strstr (a->features, "mclass")) mode |= CS_MODE_MCLASS; if (a->features && strstr (a->features, "v8")) mode |= CS_MODE_V8; op->size = 4; op->buf_asm[0] = 0; if (cd == 0) { ret = (a->bits == 64)? cs_open (CS_ARCH_ARM64, mode, &cd): cs_open (CS_ARCH_ARM, mode, &cd); if (ret) { ret = -1; goto beach; } } if (a->syntax == R_ASM_SYNTAX_REGNUM) { cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_NOREGNAME); } else cs_option (cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_DEFAULT); if (a->features && *a->features) { cs_option (cd, CS_OPT_DETAIL, CS_OPT_ON); } else { cs_option (cd, CS_OPT_DETAIL, CS_OPT_OFF); } n = cs_disasm (cd, buf, R_MIN (4, len), a->pc, 1, &insn); if (n < 1) { ret = -1; goto beach; } op->size = 0; if (insn->size<1) { ret = -1; goto beach; } if (a->features && *a->features) { if (!check_features (a, insn)) { op->size = insn->size; strcpy (op->buf_asm, "illegal"); } } if (!op->size) { op->size = insn->size; snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s%s%s", insn->mnemonic, insn->op_str[0]?" ":"", insn->op_str); r_str_rmch (op->buf_asm, '#'); } cs_free (insn, n); beach: //cs_close (&cd); if (!op->buf_asm[0]) strcpy (op->buf_asm, "invalid"); return op->size; }