Esempio n. 1
0
std::string expr2javat::convert(
  const exprt &src,
  unsigned &precedence)
{
  if(src.id()=="java-this")
    return convert_java_this(src, precedence=15);
  if(src.id()=="java_instanceof")
    return convert_java_instanceof(src, precedence=15);
  else if(src.id()==ID_side_effect &&
          (src.get(ID_statement)==ID_java_new ||
           src.get(ID_statement)==ID_java_new_array))
    return convert_java_new(src, precedence=15);
  else if(src.id()==ID_side_effect &&
          src.get(ID_statement)==ID_throw)
    return convert_function(src, "throw", precedence=16);
  else if(src.is_constant() && to_constant_expr(src).get_value()==ID_nullptr)
    return "nullptr";
  else if(src.id()==ID_unassigned)
    return "?";
  else if(src.id()=="pod_constructor")
    return "pod_constructor";
  else if(src.id()==ID_virtual_function)
    return convert_function(src, "VIRTUAL_FUNCTION", precedence=16);
  else if(src.id()==ID_java_string_literal)
    return '"'+id2string(src.get(ID_value))+'"'; // Todo: add escaping as needed
  else
    return expr2ct::convert(src, precedence);
}
Esempio n. 2
0
uintptr_t search_jass_vmmain()
{
    war3_searcher& s = get_war3_searcher();
    uintptr_t ptr = 0;

    //=========================================
    //  (1)
    //
    //    push    493E0h
    //    push    1
    //    push    1
    //    push    0
    //    mov     edx, offset s_Config ; "config"
    //    mov     ecx, esi
    //    call    UnknowFunc  <----
    //=========================================
    ptr = s.search_string("config");
    ptr += sizeof uintptr_t;
    ptr = next_opcode(ptr, 0xE8, 5);
    ptr = convert_function(ptr);
    //=========================================
    //  (2)
    //
    //  UnknowFunc:
    //    push    esi
    //    mov     esi, edx
    //    call    GetVMInstance
    //    cmp     [esp+4+arg_8], 0
    //    mov     ecx, eax
    //    jz      short loc_6F44C170
    //    cmp     dword ptr [ecx+20h], 0
    //    jz      short loc_6F44C170
    //    call    UnknowFunc2         <----
    //=========================================
    ptr = next_opcode(ptr, 0xE8, 5);
    ptr += 5;
    ptr = next_opcode(ptr, 0xE8, 5);
    ptr = convert_function(ptr);
    //=========================================
    //  (3)
    //
    //  UnknowFunc2:
    //    mov     eax, [ecx+20h]
    //    push    0
    //    push    493E0h
    //    push    0
    //    push    eax
    //    call    JassVMMain    <----
    //    retn
    //=========================================
    ptr = next_opcode(ptr, 0xE8, 5);
    ptr = convert_function(ptr);
    return ptr;
}
Esempio n. 3
0
uintptr_t searchInGameChatWhat()
{
	//=========================================
	// (1)
	//
	//  mov     ecx, "InGameChatWhat" 
	//  call    sub_6F3304C0
	//  ds:flt_6F946378
	//  mov     eax, [esi+98h]
	//  movzx   edx, byte ptr [esi+15h]
	//  push    ecx             ; txtTime
	//  lea     ecx, [esp+114h+text]
	//  fstp    [esp+114h+var_114]
	//  push    eax             ; ctype
	//  push    ecx             ; text
	//  push    edx             ; PlayerID
	//  mov     ecx, ebx        ; this
	//  call    InGameChatWhat                  <----
	//=========================================
	uintptr_t ptr = get_war3_searcher().search_string("InGameChatWhat");
	ptr += 0x04;
	ptr = next_opcode(ptr, 0xE8, 5);
	ptr += 0x05;
	ptr = next_opcode(ptr, 0xE8, 5);
	return convert_function(ptr);
}
void cpp_typecheckt::typecheck_function_bodies()
{
  instantiation_stackt old_instantiation_stack;
  old_instantiation_stack.swap(instantiation_stack);

  while(!function_bodies.empty())
  {
    symbolt &function_symbol=*function_bodies.front().function_symbol;
    template_map.swap(function_bodies.front().template_map);
    instantiation_stack.swap(function_bodies.front().instantiation_stack);
    
    function_bodies.pop_front();

    if(function_symbol.name=="c::main")
      add_argc_argv(function_symbol);

    exprt &body=function_symbol.value;
    if(body.id()=="cpp_not_typechecked")
      continue;

    if(body.is_not_nil() &&
       !body.is_zero())
    {
      convert_function(function_symbol);
    }
  }

  old_instantiation_stack.swap(instantiation_stack);
}
Esempio n. 5
0
void cpp_typecheckt::do_not_typechecked()
{
  bool cont;

  do
  {
    cont = false;

    std::vector<symbolt *> to_typecheck_list;

    context.Foreach_operand([&to_typecheck_list](symbolt &s) {
      if(s.value.id() == "cpp_not_typechecked" && s.value.get_bool("is_used"))
      {
        assert(s.type.is_code());
        to_typecheck_list.push_back(&s);
      }
    });

    for(symbolt *sym : to_typecheck_list)
    {
      if(sym->base_name == "operator=")
      {
        cpp_declaratort declarator;
        declarator.location() = sym->location;
        default_assignop_value(
          lookup(sym->type.get("#member_name")), declarator);
        sym->value.swap(declarator.value());
        convert_function(*sym);
        cont = true;
      }
      else if(sym->value.operands().size() == 1)
      {
        exprt tmp = sym->value.operands()[0];
        sym->value.swap(tmp);
        convert_function(*sym);
        cont = true;
      }
      else
        assert(0); // Don't know what to do!
    }
  } while(cont);

  context.Foreach_operand([](symbolt &s) {
    if(s.value.id() == "cpp_not_typechecked")
      s.value.make_nil();
  });
}
Esempio n. 6
0
File: jass.cpp Progetto: hjhong/YDWE
	uintptr_t search_create_string()
	{
		uintptr_t ptr = get_war3_searcher().search_string("I2S");
		ptr = *(uintptr_t*)(ptr + 0x05);
		ptr = next_opcode(ptr, 0xE8, 5);
		ptr += 0x05;
		ptr = next_opcode(ptr, 0xE8, 5);
		return convert_function(ptr);
	}
Esempio n. 7
0
void goto_difft::convert_function_group(
  json_arrayt &result,
  const irep_id_sett &function_group) const
{
  for(irep_id_sett::const_iterator it=function_group.begin();
      it!=function_group.end(); ++it)
  {
    convert_function(result.push_back(jsont()).make_object(), *it);
  }
}
Esempio n. 8
0
std::string expr2javat::convert(
  const exprt &src,
  unsigned &precedence)
{
  if(src.id()=="java-this")
    return convert_java_this(src, precedence=15);
  else if(src.id()==ID_side_effect &&
          (src.get(ID_statement)==ID_java_new ||
           src.get(ID_statement)==ID_java_new_array))
    return convert_java_new(src, precedence=15);
  else if(src.id()==ID_side_effect &&
          src.get(ID_statement)==ID_throw)
    return convert_function(src, "throw", precedence=16);
  else if(src.is_constant() && to_constant_expr(src).get_value()==ID_nullptr)
    return "nullptr";
  else if(src.id()==ID_unassigned)
    return "?";
  else if(src.id()=="pod_constructor")
    return "pod_constructor";
  else
    return expr2ct::convert(src, precedence);
}
Esempio n. 9
0
int msgpack_convert_object(zval *return_value, zval *tpl, zval **value)
{
    zend_class_entry *ce, **pce;
    TSRMLS_FETCH();

    switch (Z_TYPE_P(tpl))
    {
        case IS_STRING:
            if (zend_lookup_class(
                    Z_STRVAL_P(tpl), Z_STRLEN_P(tpl),
                    &pce TSRMLS_CC) != SUCCESS)
            {
                MSGPACK_ERROR("[msgpack] (%s) Class '%s' not found",
                              __FUNCTION__, Z_STRVAL_P(tpl));
                return FAILURE;
            }
            ce = *pce;
            break;
        case IS_OBJECT:
            ce = zend_get_class_entry(tpl TSRMLS_CC);
            break;
        default:
            MSGPACK_ERROR("[msgpack] (%s) object type is unsupported",
                          __FUNCTION__);
            return FAILURE;
    }

    if (Z_TYPE_PP(value) == IS_OBJECT)
    {
        zend_class_entry *vce;

        vce = zend_get_class_entry(*value TSRMLS_CC);
        if (strcmp(ce->name, vce->name) == 0)
        {
            *return_value = **value;
            zval_copy_ctor(return_value);
            zval_ptr_dtor(value);
            return SUCCESS;
        }
    }

    object_init_ex(return_value, ce);

    /* Run the constructor if there is one */
    if (ce->constructor
        && (ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC))
    {
        zval *retval_ptr = NULL;
        zval ***params = NULL;
        int num_args = 0;
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;

#if ZEND_MODULE_API_NO >= 20090626
        fci.size = sizeof(fci);
        fci.function_table = EG(function_table);
        fci.function_name = NULL;
        fci.symbol_table = NULL;
        fci.object_ptr = return_value;
        fci.retval_ptr_ptr = &retval_ptr;
        fci.param_count = num_args;
        fci.params = params;
        fci.no_separation = 1;

        fcc.initialized = 1;
        fcc.function_handler = ce->constructor;
        fcc.calling_scope = EG(scope);
        fcc.called_scope = Z_OBJCE_P(return_value);
        fcc.object_ptr = return_value;
#else
        fci.size = sizeof(fci);
        fci.function_table = EG(function_table);
        fci.function_name = NULL;
        fci.symbol_table = NULL;
        fci.object_pp = &return_value;
        fci.retval_ptr_ptr = &retval_ptr;
        fci.param_count = num_args;
        fci.params = params;
        fci.no_separation = 1;

        fcc.initialized = 1;
        fcc.function_handler = ce->constructor;
        fcc.calling_scope = EG(scope);
        fcc.object_pp = &return_value;
#endif

        if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE)
        {
            if (params)
            {
                efree(params);
            }
            if (retval_ptr)
            {
                zval_ptr_dtor(&retval_ptr);
            }

            MSGPACK_WARNING(
                "[msgpack] (%s) Invocation of %s's constructor failed",
                __FUNCTION__, ce->name);

            return FAILURE;
        }
        if (retval_ptr)
        {
            zval_ptr_dtor(&retval_ptr);
        }
        if (params)
        {
            efree(params);
        }
    }

    switch (Z_TYPE_PP(value))
    {
        case IS_ARRAY:
        {
            char *key;
            uint key_len;
            int key_type;
            ulong key_index;
            zval **data;
            HashPosition pos;
            HashTable *ht, *ret;
            HashTable *var = NULL;
            int num;

            ht = HASH_OF(*value);
            ret = HASH_OF(return_value);

            num = zend_hash_num_elements(ht);
            if (num <= 0)
            {
                zval_ptr_dtor(value);
                break;
            }

            /* string - php_only mode? */
            if (ht->nNumOfElements != ht->nNextFreeElement
                || ht->nNumOfElements != ret->nNumOfElements)
            {
                HashTable *properties = NULL;
                HashPosition prop_pos;

                ALLOC_HASHTABLE(var);
                zend_hash_init(var, num, NULL, NULL, 0);

                zend_hash_internal_pointer_reset_ex(ht, &pos);
                for (;; zend_hash_move_forward_ex(ht, &pos))
                {
                    key_type = zend_hash_get_current_key_ex(
                        ht, &key, &key_len, &key_index, 0, &pos);

                    if (key_type == HASH_KEY_NON_EXISTANT)
                    {
                        break;
                    }

                    if (zend_hash_get_current_data_ex(
                            ht, (void *)&data, &pos) != SUCCESS)
                    {
                        continue;
                    }

                    if (key_type == HASH_KEY_IS_STRING)
                    {
                        zval *val;
                        MSGPACK_CONVERT_COPY_ZVAL(val, data);
                        if (msgpack_convert_string_to_properties(
                                return_value, key, key_len, val, var) != SUCCESS)
                        {
                            zval_ptr_dtor(&val);
                            MSGPACK_WARNING(
                                "[msgpack] (%s) "
                                "illegal offset type, skip this decoding",
                                __FUNCTION__);
                        }
                    }
                }

                /* index */
                properties = Z_OBJ_HT_P(return_value)->get_properties(
                    return_value TSRMLS_CC);

                if (HASH_OF(tpl))
                {
                    properties = HASH_OF(tpl);
                }
                zend_hash_internal_pointer_reset_ex(properties, &prop_pos);

                zend_hash_internal_pointer_reset_ex(ht, &pos);
                for (;; zend_hash_move_forward_ex(ht, &pos))
                {
                    key_type = zend_hash_get_current_key_ex(
                        ht, &key, &key_len, &key_index, 0, &pos);

                    if (key_type == HASH_KEY_NON_EXISTANT)
                    {
                        break;
                    }

                    if (zend_hash_get_current_data_ex(
                            ht, (void *)&data, &pos) != SUCCESS)
                    {
                        continue;
                    }

                    switch (key_type)
                    {
                        case HASH_KEY_IS_LONG:
                        {
                            zval *val;
                            MSGPACK_CONVERT_COPY_ZVAL(val, data);
                            if (msgpack_convert_long_to_properties(
                                    ret, &properties, &prop_pos,
                                    key_index, val, var) != SUCCESS)
                            {
                                zval_ptr_dtor(&val);
                                MSGPACK_WARNING(
                                    "[msgpack] (%s) "
                                    "illegal offset type, skip this decoding",
                                    __FUNCTION__);
                            }
                            break;
                        }
                        case HASH_KEY_IS_STRING:
                            break;
                        default:
                            MSGPACK_WARNING(
                                "[msgpack] (%s) key is not string nor array",
                                __FUNCTION__);
                            break;
                    }
                }

                zend_hash_destroy(var);
                FREE_HASHTABLE(var);
            }
            else
            {
                HashPosition valpos;
                int (*convert_function)(zval *, zval *, zval **) = NULL;
                zval **arydata, *aryval;

                /* index */
                zend_hash_internal_pointer_reset_ex(ret, &pos);
                zend_hash_internal_pointer_reset_ex(ht, &valpos);
                for (;; zend_hash_move_forward_ex(ret, &pos),
                        zend_hash_move_forward_ex(ht, &valpos))
                {
                    key_type = zend_hash_get_current_key_ex(
                        ret, &key, &key_len, &key_index, 0, &pos);

                    if (key_type == HASH_KEY_NON_EXISTANT)
                    {
                        break;
                    }

                    if (zend_hash_get_current_data_ex(
                            ret, (void *)&data, &pos) != SUCCESS)
                    {
                        continue;
                    }

                    switch (Z_TYPE_PP(data))
                    {
                        case IS_ARRAY:
                            convert_function = msgpack_convert_array;
                            break;
                        case IS_OBJECT:
                        //case IS_STRING: -- may have default values of
                        // class members, so it's not wise to allow
                            convert_function = msgpack_convert_object;
                            break;
                        default:
                            break;
                    }

                    if (zend_hash_get_current_data_ex(
                            ht, (void *)&arydata, &valpos) != SUCCESS)
                    {
                        MSGPACK_WARNING(
                            "[msgpack] (%s) can't get data value by index",
                            __FUNCTION__);
                        return FAILURE;
                    }

                    MSGPACK_CONVERT_COPY_ZVAL(aryval, arydata);

                    if (convert_function)
                    {
                        zval *rv;
                        ALLOC_INIT_ZVAL(rv);

                        if (convert_function(rv, *data, &aryval) != SUCCESS)
                        {
                            zval_ptr_dtor(&aryval);
                            MSGPACK_WARNING(
                                "[msgpack] (%s) "
                                "convert failure in convert_object",
                                __FUNCTION__);
                            return FAILURE;
                        }

                        zend_symtable_update(
                            ret, key, key_len, &rv, sizeof(rv), NULL);
                    }
                    else
                    {
                        zend_symtable_update(
                            ret, key, key_len, &aryval, sizeof(aryval), NULL);
                    }
                }
            }

            zval_ptr_dtor(value);
            break;
        }
        default:
        {
            HashTable *properties = NULL;
            HashPosition prop_pos;

            properties = Z_OBJ_HT_P(return_value)->get_properties(
                return_value TSRMLS_CC);
            zend_hash_internal_pointer_reset_ex(properties, &prop_pos);

            if (msgpack_convert_long_to_properties(
                    HASH_OF(return_value), &properties, &prop_pos,
                    0, *value, NULL) != SUCCESS)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) illegal offset type, skip this decoding",
                    __FUNCTION__);
            }
            break;
        }
    }

    return SUCCESS;
}
Esempio n. 10
0
int msgpack_convert_array(zval *return_value, zval *tpl, zval **value)
{
    TSRMLS_FETCH();

    if (Z_TYPE_P(tpl) == IS_ARRAY)
    {
        char *key;
        uint key_len;
        int key_type;
        ulong key_index;
        zval **data, **arydata;
        HashPosition pos, valpos;
        HashTable *ht, *htval;
        int num;

        ht = HASH_OF(tpl);
        // TODO: maybe need to release memory?
        array_init(return_value);

        num = zend_hash_num_elements(ht);
        if (num <= 0)
        {
            MSGPACK_WARNING(
                "[msgpack] (%s) template array length is 0",
                __FUNCTION__);
            zval_ptr_dtor(value);
            return FAILURE;
        }

        /* string */
        if (ht->nNumOfElements != ht->nNextFreeElement)
        {
            htval = HASH_OF(*value);
            if (!htval)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) input data is not array",
                    __FUNCTION__);
                zval_ptr_dtor(value);
                return FAILURE;
            }

            zend_hash_internal_pointer_reset_ex(ht, &pos);
            zend_hash_internal_pointer_reset_ex(htval, &valpos);
            for (;; zend_hash_move_forward_ex(ht, &pos),
                        zend_hash_move_forward_ex(htval, &valpos))
            {
                key_type = zend_hash_get_current_key_ex(
                    ht, &key, &key_len, &key_index, 0, &pos);

                if (key_type == HASH_KEY_NON_EXISTANT)
                {
                    break;
                }

                if (zend_hash_get_current_data_ex(
                        ht, (void *)&data, &pos) != SUCCESS)
                {
                    continue;
                }

                if (key_type == HASH_KEY_IS_STRING)
                {
                    int (*convert_function)(zval *, zval *, zval **) = NULL;
                    zval **dataval, *val;

                    switch (Z_TYPE_PP(data))
                    {
                        case IS_ARRAY:
                            convert_function = msgpack_convert_array;
                            break;
                        case IS_OBJECT:
                        // case IS_STRING:
                            convert_function = msgpack_convert_object;
                            break;
                        default:
                            break;
                    }

                    if (zend_hash_get_current_data_ex(
                            htval, (void *)&dataval, &valpos) != SUCCESS)
                    {
                        MSGPACK_WARNING(
                            "[msgpack] (%s) can't get data",
                            __FUNCTION__);
                        zval_ptr_dtor(value);
                        return FAILURE;
                    }

                    MSGPACK_CONVERT_COPY_ZVAL(val, dataval);

                    if (convert_function)
                    {
                        zval *rv;
                        ALLOC_INIT_ZVAL(rv);
                        if (convert_function(rv, *data, &val) != SUCCESS)
                        {
                            zval_ptr_dtor(&val);
                            return FAILURE;
                        }
                        add_assoc_zval_ex(return_value, key, key_len, rv);
                    }
                    else
                    {
                        add_assoc_zval_ex(return_value, key, key_len, val);
                    }
                }
            }

            zval_ptr_dtor(value);

            return SUCCESS;
        }
        else
        {
            /* index */
            int (*convert_function)(zval *, zval *, zval **) = NULL;

            if (Z_TYPE_PP(value) != IS_ARRAY)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) unserialized data must be array.",
                    __FUNCTION__);
                zval_ptr_dtor(value);
                return FAILURE;
            }

            zend_hash_internal_pointer_reset_ex(ht, &pos);

            key_type = zend_hash_get_current_key_ex(
                ht, &key, &key_len, &key_index, 0, &pos);

            if (key_type == HASH_KEY_NON_EXISTANT)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) first element in template array is empty",
                    __FUNCTION__);
                zval_ptr_dtor(value);
                return FAILURE;
            }

            if (zend_hash_get_current_data_ex(
                    ht, (void *)&data, &pos) != SUCCESS)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) invalid template: empty array?",
                    __FUNCTION__);
                zval_ptr_dtor(value);
                return FAILURE;
            }

            switch (Z_TYPE_PP(data))
            {
                case IS_ARRAY:
                    convert_function = msgpack_convert_array;
                    break;
                case IS_OBJECT:
                case IS_STRING:
                    convert_function = msgpack_convert_object;
                    break;
                default:
                    break;
            }

            htval = HASH_OF(*value);
            num = zend_hash_num_elements(htval);
            if (num <= 0)
            {
                MSGPACK_WARNING(
                    "[msgpack] (%s) array length is 0 in unserialized data",
                    __FUNCTION__);
                zval_ptr_dtor(value);
                return FAILURE;
            }

            zend_hash_internal_pointer_reset_ex(htval, &valpos);
            for (;; zend_hash_move_forward_ex(htval, &valpos))
            {
                key_type = zend_hash_get_current_key_ex(
                    htval, &key, &key_len, &key_index, 0, &valpos);

                if (key_type == HASH_KEY_NON_EXISTANT)
                {
                    break;
                }

                if (zend_hash_get_current_data_ex(
                        htval, (void *)&arydata, &valpos) != SUCCESS)
                {
                    MSGPACK_WARNING(
                        "[msgpack] (%s) can't get next data in indexed array",
                        __FUNCTION__);
                    continue;
                }

                switch (key_type)
                {
                    case HASH_KEY_IS_LONG:
                    {
                        zval *aryval, *rv;
                        ALLOC_INIT_ZVAL(rv);
                        MSGPACK_CONVERT_COPY_ZVAL(aryval, arydata);
                        if (convert_function)
                        {
                            if (convert_function(rv, *data, &aryval) != SUCCESS)
                            {
                                zval_ptr_dtor(&aryval);
                                MSGPACK_WARNING(
                                    "[msgpack] (%s) "
                                    "convert failure in HASH_KEY_IS_LONG "
                                    "in indexed array",
                                    __FUNCTION__);
                                zval_ptr_dtor(value);
                                return FAILURE;
                            }
                            add_next_index_zval(return_value, rv);
                        }
                        else
                        {
                            add_next_index_zval(return_value, aryval);
                        }
                        break;
                    }
                    case HASH_KEY_IS_STRING:
                        MSGPACK_WARNING(
                            "[msgpack] (%s) key is string",
                            __FUNCTION__);
                        zval_ptr_dtor(value);
                        return FAILURE;
                    default:
                        MSGPACK_WARNING(
                            "[msgpack] (%s) key is not string nor array",
                            __FUNCTION__);
                        zval_ptr_dtor(value);
                        return FAILURE;
                }
            }

            zval_ptr_dtor(value);
            return SUCCESS;
        }
    }
    else
    {
        // shouldn't reach
        MSGPACK_WARNING(
            "[msgpack] (%s) template is not array",
            __FUNCTION__);
        zval_ptr_dtor(value);
        return FAILURE;
    }

    // shouldn't reach
    zval_ptr_dtor(value);
    return FAILURE;
}
Esempio n. 11
0
int msgpack_convert_array(zval *return_value, zval *tpl, zval *value) /* {{{ */ {
    zend_string *key;
    int key_type;
    ulong key_index;
    zval *data;
    HashTable *ht, *htval;

    if (Z_TYPE_P(tpl) != IS_ARRAY) {
        MSGPACK_WARNING("[msgpack] (%s) template is not array", __FUNCTION__);
        return FAILURE;
    }

    if (Z_TYPE_P(value) == IS_INDIRECT) {
        value = Z_INDIRECT_P(value);
    }

    ht = HASH_OF(tpl);
    array_init(return_value);

    if (zend_hash_num_elements(ht) == 0) {
        MSGPACK_WARNING("[msgpack] (%s) template array length is 0", __FUNCTION__);
        return FAILURE;
    }

    /* string */
	if (ht->nNumOfElements != ht->nNextFreeElement) {
		HashPosition valpos;

		htval = HASH_OF(value);

		if (!htval) {
			MSGPACK_WARNING("[msgpack] (%s) input data is not array", __FUNCTION__);
			return FAILURE;
		}

		zend_hash_internal_pointer_reset_ex(htval, &valpos);
		ZEND_HASH_FOREACH_KEY_VAL(ht, key_index, key, data) { 
			if (key) {
				zval *dataval;
				int (*convert_function)(zval *, zval *, zval *) = NULL;
				switch (Z_TYPE_P(data)) {
					case IS_ARRAY:
						convert_function = msgpack_convert_array;
						break;
					case IS_OBJECT:
						// case IS_STRING:
						convert_function = msgpack_convert_object;
						break;
					default:
						break;
				}

				if ((dataval = zend_hash_get_current_data_ex(htval, &valpos)) == NULL) {
					MSGPACK_WARNING("[msgpack] (%s) can't get data", __FUNCTION__);
					return FAILURE;
				}

				if (Z_TYPE_P(dataval) == IS_INDIRECT) {
					dataval = Z_INDIRECT_P(dataval);
				}

				if (convert_function) {
					zval rv;
					if (convert_function(&rv, data, dataval) != SUCCESS) {
						return FAILURE;
					}
					zend_symtable_update(Z_ARRVAL_P(return_value), key, &rv);
				} else {
					Z_TRY_ADDREF_P(dataval);
					zend_symtable_update(Z_ARRVAL_P(return_value), key, dataval);
				}
			}
			zend_hash_move_forward_ex(htval, &valpos);
		} ZEND_HASH_FOREACH_END();

		return SUCCESS;
    } else {