MCPcopy Create free account
hub / github.com/capstone-engine/capstone / cs_option

Function cs_option

cs.c:704–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702
703CAPSTONE_EXPORT
704cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
705{
706 struct cs_struct *handle;
707 cs_opt_mnem *opt;
708
709 // cs_option() can be called with NULL handle just for CS_OPT_MEM
710 // This is supposed to be executed before all other APIs (even cs_open())
711 if (type == CS_OPT_MEM) {
712 cs_opt_mem *mem = (cs_opt_mem *)value;
713
714 cs_mem_malloc = mem->malloc;
715 cs_mem_calloc = mem->calloc;
716 cs_mem_realloc = mem->realloc;
717 cs_mem_free = mem->free;
718 cs_vsnprintf = mem->vsnprintf;
719
720 return CS_ERR_OK;
721 }
722
723 handle = (struct cs_struct *)(uintptr_t)ud;
724 if (!handle)
725 return CS_ERR_CSH;
726
727 switch(type) {
728 default:
729 break;
730
731 case CS_OPT_UNSIGNED:
732 handle->imm_unsigned = (cs_opt_value)value;
733 return CS_ERR_OK;
734
735 case CS_OPT_DETAIL:
736 handle->detail = (cs_opt_value)value;
737 return CS_ERR_OK;
738
739 case CS_OPT_SKIPDATA:
740 handle->skipdata = (value == CS_OPT_ON);
741 if (handle->skipdata) {
742 if (handle->skipdata_size == 0) {
743 // set the default skipdata size
744 handle->skipdata_size = skipdata_size(handle);
745 }
746 }
747 return CS_ERR_OK;
748
749 case CS_OPT_SKIPDATA_SETUP:
750 if (value) {
751 handle->skipdata_setup = *((cs_opt_skipdata *)value);
752 if (handle->skipdata_setup.mnemonic == NULL) {
753 handle->skipdata_setup.mnemonic = SKIPDATA_MNEM;
754 }
755 }
756 return CS_ERR_OK;
757
758 case CS_OPT_MNEMONIC:
759 opt = (cs_opt_mnem *)value;
760 if (opt->id) {
761 if (opt->mnemonic) {

Callers 15

testFunction · 0.85
test_single_MCFunction · 0.85
setup_MCFunction · 0.85
setup_issueFunction · 0.85
test_invalidsFunction · 0.85
test_validsFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
mainFunction · 0.85
bs_optionFunction · 0.85
ocaml_optionFunction · 0.85
testFunction · 0.85
testFunction · 0.85

Calls 1

skipdata_sizeFunction · 0.85

Tested by 15

testFunction · 0.68
test_single_MCFunction · 0.68
test_invalidsFunction · 0.68
test_validsFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68
testFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…