Exemplo n.º 1
0
void change_visibility(DexMethod* method) {
  auto code = method->get_code();
  always_assert(code != nullptr);

  editable_cfg_adapter::iterate(code, [](MethodItemEntry& mie) {
    auto insn = mie.insn;

    if (insn->has_field()) {
      auto cls = type_class(insn->get_field()->get_class());
      if (cls != nullptr && !cls->is_external()) {
        set_public(cls);
      }
      auto field =
          resolve_field(insn->get_field(), is_sfield_op(insn->opcode())
              ? FieldSearch::Static : FieldSearch::Instance);
      if (field != nullptr && field->is_concrete()) {
        set_public(field);
        set_public(type_class(field->get_class()));
        // FIXME no point in rewriting opcodes in the method
        insn->set_field(field);
      }
    } else if (insn->has_method()) {
      auto cls = type_class(insn->get_method()->get_class());
      if (cls != nullptr && !cls->is_external()) {
        set_public(cls);
      }
      auto current_method = resolve_method(
          insn->get_method(), opcode_to_search(insn));
      if (current_method != nullptr && current_method->is_concrete()) {
        set_public(current_method);
        set_public(type_class(current_method->get_class()));
        // FIXME no point in rewriting opcodes in the method
        insn->set_method(current_method);
      }
    } else if (insn->has_type()) {
      auto type = insn->get_type();
      auto cls = type_class(type);
      if (cls != nullptr && !cls->is_external()) {
        set_public(cls);
      }
    }
    return editable_cfg_adapter::LOOP_CONTINUE;
  });

  std::vector<DexType*> types;
  if (code->editable_cfg_built()) {
    code->cfg().gather_catch_types(types);
  } else {
    code->gather_catch_types(types);
  }
  for (auto type : types) {
    auto cls = type_class(type);
    if (cls != nullptr && !cls->is_external()) {
      set_public(cls);
    }
  }
}
Exemplo n.º 2
0
	String const & HTTPHeader::field(String const & name) const
	{
		static String const emptyDef;
		if(!has_field(name))
		{
			return emptyDef;
		}
		return m_fields.find(name)->second;
	}
int32_t RSSIData_frameNum(const RSSIData *msg) {
  check_magic(msg);
  if (has_field(msg, 5)) {
    return ntohl(msg->frameNum);
  } else {
    fprintf(stderr, "Requested field frameNum from RSSIData at address %p, but "
                    "message do3s not have the field \n",
            (void *)msg);
    return -1;
  }
}
 void flexible_type_registry::register_id_fields(flex_type_enum id_type) {
   if (!has_field("__id")) {
     register_field("__id", id_type);
     register_field("__src_id", id_type);
     register_field("__dst_id", id_type);
   } else {
     if (get_field_type("__id").second != id_type) {
       log_and_throw(std::string("ID field type mismatch"));
     }
   }
 }
int16_t RSSIData_rssi(const RSSIData *msg) {
  check_magic(msg);
  if (has_field(msg, 2)) {
    return ntohs(msg->rssi);
  } else {
    fprintf(stderr, "Requested field rssi from RSSIData at address %p, but "
                    "message do3s not have the field \n",
            (void *)msg);
    return -1;
  }
}
size_t RSSIData_bssid(const RSSIData *msg, char *dest, size_t lim) {
  if (has_field(msg, 1)) {
    size_t char_count = (lim - 1 < msg->bssid_size ? lim - 1 : msg->bssid_size);
    memmove(dest, msg->bssid, char_count);
    dest[char_count] = '\0';
    return char_count;
  } else {
    fprintf(stderr, "Requested field bssid from RSSIData at address %p, but "
                    "message does not have the field\n",
            (void *)msg);
    return 0;
  }
}
size_t WiFlyStringWireFormat_msg(const WiFlyStringWireFormat *msg, char *dest,
                                 size_t lim) {
  if (has_field(msg, 1)) {
    size_t char_count = (lim - 1 < msg->msg_size ? lim - 1 : msg->msg_size);
    memmove(dest, msg->msg, char_count);
    dest[char_count] = '\0';
    return char_count;
  } else {
    fprintf(stderr, "Requested field msg from WiFlyStringWireFormat at address "
                    "%p, but message does not have the field\n",
            (void *)msg);
    return 0;
  }
}
Exemplo n.º 8
0
uint64_t IRInstruction::hash() const {
  std::vector<uint64_t> bits;
  bits.push_back(opcode());

  for (size_t i = 0; i < srcs_size(); i++) {
    bits.push_back(src(i));
  }

  if (dests_size() > 0) {
    bits.push_back(dest());
  }

  if (has_data()) {
    size_t size = get_data()->data_size();
    const auto& data = get_data()->data();
    for (size_t i = 0; i < size; i++) {
      bits.push_back(data[i]);
    }
  }

  if (has_type()) {
    bits.push_back(reinterpret_cast<uint64_t>(get_type()));
  }
  if (has_field()) {
    bits.push_back(reinterpret_cast<uint64_t>(get_field()));
  }
  if (has_method()) {
    bits.push_back(reinterpret_cast<uint64_t>(get_method()));
  }
  if (has_string()) {
    bits.push_back(reinterpret_cast<uint64_t>(get_string()));
  }
  if (has_literal()) {
    bits.push_back(get_literal());
  }

  uint64_t result = 0;
  for (uint64_t elem : bits) {
    result ^= elem;
  }
  return result;
}
/*
 * string msg
 */
bool WiFlyStringWireFormat_has_msg(const WiFlyStringWireFormat *msg) {
  check_magic(msg);
  return has_field(msg, 1);
}
Exemplo n.º 10
0
 /**
   Check if a field is present.
   @param name the field name
   @return true if the field is present, false if not
 */
 bool has_field(const char* name) const {
     return has_field(name, strlen(name));
 }
/*
 * int32 rssi
 */
bool RSSIData_has_rssi(const RSSIData *msg) {
  check_magic(msg);
  return has_field(msg, 2);
}
void RSSIData_clear_bssid(RSSIData *msg) {
  if (has_field(msg, 1)) {
    set_field_absent(msg, 1);
    msg->bssid_size = 0;
  }
}
Exemplo n.º 13
0
	inline std::string destination() { if(has_field("__dst__")) return mf["__dst__"]; else return ""; }
/*
 * string bssid
 */
bool RSSIData_has_bssid(const RSSIData *msg) {
  check_magic(msg);
  return has_field(msg, 1);
}
Exemplo n.º 15
0
 bool pakfile::has_operator( const std::string &plugin, const std::string &opcode ) const
 {
     return has_field("operators") && ( get_value<pakstring>("operators").find( std::string(",") + plugin + ':' + opcode + ',' ) != std::string::npos );
 }
/*
 * int32 frameNum
 */
bool RSSIData_has_frameNum(const RSSIData *msg) {
  check_magic(msg);
  return has_field(msg, 5);
}
/*
 * int32 frameSize
 */
bool RSSIData_has_frameSize(const RSSIData *msg) {
  check_magic(msg);
  return has_field(msg, 4);
}
/*
 * int32 pairSeq
 */
bool RSSIData_has_pairSeq(const RSSIData *msg) {
  check_magic(msg);
  return has_field(msg, 3);
}
Exemplo n.º 19
0
	inline bool broadcast() { return has_field("__brd__"); }
void WiFlyStringWireFormat_clear_msg(WiFlyStringWireFormat *msg) {
  if (has_field(msg, 1)) {
    set_field_absent(msg, 1);
    msg->msg_size = 0;
  }
}
Exemplo n.º 21
0
	inline std::string source() { if(has_field("__src__")) return mf["__src__"]; else return ""; }