gboolean g_dbus_register_interface(DBusConnection *connection, const char *path, const char *name, const GDBusMethodTable *methods, const GDBusSignalTable *signals, const GDBusPropertyTable *properties, void *user_data, GDBusDestroyFunction destroy) { struct generic_data *data; data = object_path_ref(connection, path); if (data == NULL) return FALSE; if (find_interface(data->interfaces, name)) { object_path_unref(connection, path); return FALSE; } if (properties != NULL && !find_interface(data->interfaces, DBUS_INTERFACE_PROPERTIES)) add_interface(data, DBUS_INTERFACE_PROPERTIES, properties_methods, properties_signals, NULL, data, NULL); add_interface(data, name, methods, signals, properties, user_data, destroy); g_free(data->introspect); data->introspect = NULL; return TRUE; }
void GMWMI_finder::crop_track (std::vector< Point<float> >& tck) const { if (tck.size() < 3) return; Interp interp (interp_template); const Point<float> new_first_point = find_interface (tck, false, interp); tck[0] = new_first_point; const Point<float> new_last_point = find_interface (tck, true, interp); tck[tck.size() - 1] = new_last_point; }
void handle_interface(int action, const char *ifname) { struct if_head *ifs; struct interface *ifp, *ifn, *ifl = NULL; const char * const argv[] = { ifname }; int i; if (action == -1) { ifp = find_interface(ifname); if (ifp != NULL) { ifp->options->options |= DHCPCD_DEPARTED; stop_interface(ifp); } return; } /* If running off an interface list, check it's in it. */ if (ifc) { for (i = 0; i < ifc; i++) if (strcmp(ifv[i], ifname) == 0) break; if (i >= ifc) return; } ifs = discover_interfaces(-1, UNCONST(argv)); TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { if (strcmp(ifp->name, ifname) != 0) continue; /* Check if we already have the interface */ ifl = find_interface(ifp->name); if (ifl) { /* The flags and hwaddr could have changed */ ifl->flags = ifp->flags; ifl->hwlen = ifp->hwlen; if (ifp->hwlen != 0) memcpy(ifl->hwaddr, ifp->hwaddr, ifl->hwlen); } else { TAILQ_REMOVE(ifs, ifp, next); TAILQ_INSERT_TAIL(ifaces, ifp, next); } if (action == 1) { init_state(ifp, margc, margv); start_interface(ifp); } } /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); free_interface(ifp); } free(ifs); }
static ProcReact_Future next_derivation_future(void *data) { /* Declarations */ DerivationIteratorData *derivation_iterator_data = (DerivationIteratorData*)data; /* Retrieve derivation item, interface pair */ DerivationItem *item = g_ptr_array_index(derivation_iterator_data->derivation_array, derivation_iterator_data->index); Interface *interface = find_interface(derivation_iterator_data->interface_array, item->target); /* Invoke the next derivation item operation process */ ProcReact_Future future = derivation_iterator_data->map_derivation_item_function.future(derivation_iterator_data->data, item, interface); /* Increase the iterator index */ derivation_iterator_data->index++; if(future.pid > 0) { /* Add pid to the pid table so that we know what the corresponding derivation item is */ gint *pid_ptr = g_malloc(sizeof(gint)); *pid_ptr = future.pid; g_hash_table_insert(derivation_iterator_data->pid_table, pid_ptr, item); } /* Return the pid of the invoked process */ return future; }
static gboolean remove_interface(struct generic_data *data, const char *name) { struct interface_data *iface; LOG("remove_interface"); iface = find_interface(data->interfaces, name); if (iface == NULL) return FALSE; data->interfaces = g_slist_remove(data->interfaces, iface); if (iface->destroy) { iface->destroy(iface->user_data); iface->user_data = NULL; } if (g_slist_find(data->added, iface)) { data->added = g_slist_remove(data->added, iface); g_free(iface->name); g_free(iface); return TRUE; } g_free(iface); return TRUE; }
EXPORT int start(mach_port_t task, pid_t infoPid) { kern_return_t kret; pthread_t tid[2]; interface* face = find_interface(task); kret = mach_port_allocate(current_task(), MACH_PORT_RIGHT_RECEIVE, &face->server_port); RETURN_ON_MACH_ERROR("[-start] mach_port_allocate failed", kret); kret = mach_port_insert_right(current_task(), face->server_port, face->server_port, MACH_MSG_TYPE_MAKE_SEND); RETURN_ON_MACH_ERROR("[-start] mach_port_insert_right failed", kret); kret = task_set_exception_ports(task, EXC_MASK_ALL, face->server_port, EXCEPTION_DEFAULT|MACH_EXCEPTION_CODES, THREAD_STATE_NONE); RETURN_ON_MACH_ERROR("[-start] task_set_exception_ports failed", kret); int err = pthread_create(&tid[0], NULL, (void *(*)(void*))kqueue_loop, (void *)(unsigned long long)infoPid); if (err != 0) DEBUG_PRINT("\n[-start] can't create thread :[%s]", strerror(err)); else DEBUG_PRINT("\n[-start] Thread created successfully %d\n", 0); err = pthread_create(&tid[1], NULL, (void *(*)(void*))exception_server, (void *(*)(void*))(unsigned long long)face->server_port); if (err != 0) DEBUG_PRINT("\n[-start] can't create thread :[%s]", strerror(err)); else DEBUG_PRINT("\n[-start] Thread created successfully %d\n", 0); return 1; }
static void reconf_reboot(int action, int argc, char **argv, int oi) { struct if_head *ifs; struct interface *ifn, *ifp; ifs = discover_interfaces(argc - oi, argv + oi); if (ifs == NULL) return; while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); ifn = find_interface(ifp->name); if (ifn) { if (action) if_reboot(ifn, argc, argv); else ipv4_applyaddr(ifn); free_interface(ifp); } else { init_state(ifp, argc, argv); TAILQ_INSERT_TAIL(ifaces, ifp, next); start_interface(ifp); } } free(ifs); sort_interfaces(); }
static DBusHandlerResult generic_message(DBusConnection *connection, DBusMessage *message, void *user_data) { struct generic_data *data = user_data; struct interface_data *iface; const GDBusMethodTable *method; const char *interface; interface = dbus_message_get_interface(message); iface = find_interface(data->interfaces, interface); if (iface == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; for (method = iface->methods; method && method->name && method->function; method++) { if (dbus_message_is_method_call(message, iface->name, method->name) == FALSE) continue; if (dbus_message_has_signature(message, method->signature) == FALSE) continue; if (check_privilege(connection, message, method, iface->user_data) == TRUE) return DBUS_HANDLER_RESULT_HANDLED; return process_message(connection, message, method, iface->user_data); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
status_t add_interface(const char* name, net_domain_private* domain, const ifaliasreq& request, net_device_interface* deviceInterface) { RecursiveLocker locker(sLock); if (find_interface(name) != NULL) return B_NAME_IN_USE; Interface* interface = new(std::nothrow) Interface(name, deviceInterface); if (interface == NULL) return B_NO_MEMORY; sInterfaces.Add(interface); interface->AcquireReference(); // We need another reference to be able to use the interface without // holding sLock. locker.Unlock(); status_t status = add_interface_address(interface, domain, request); if (status == B_OK) notify_interface_added(interface); else { locker.Lock(); sInterfaces.Remove(interface); locker.Unlock(); interface->ReleaseReference(); } interface->ReleaseReference(); return status; }
static DBusMessage *properties_get_all(DBusConnection *connection, DBusMessage *message, void *user_data) { struct generic_data *data = user_data; struct interface_data *iface; const char *interface; DBusMessageIter iter; DBusMessage *reply; if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &interface, DBUS_TYPE_INVALID)) return NULL; iface = find_interface(data->interfaces, interface); if (iface == NULL) return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, "No such interface '%s'", interface); reply = dbus_message_new_method_return(message); if (reply == NULL) return NULL; dbus_message_iter_init_append(reply, &iter); append_properties(iface, &iter); return reply; }
static gboolean check_signal(DBusConnection *conn, const char *path, const char *interface, const char *name, const GDBusArgInfo **args) { struct generic_data *data = NULL; struct interface_data *iface; const GDBusSignalTable *signal; *args = NULL; if (!dbus_connection_get_object_path_data(conn, path, (void *) &data) || data == NULL) { error("dbus_connection_emit_signal: path %s isn't registered", path); return FALSE; } iface = find_interface(data->interfaces, interface); if (iface == NULL) { error("dbus_connection_emit_signal: %s does not implement %s", path, interface); return FALSE; } for (signal = iface->signals; signal && signal->name; signal++) { if (!strcmp(signal->name, name)) { *args = signal->args; return TRUE; } } error("No signal named %s on interface %s", name, interface); return FALSE; }
EXPORT int add_breakpoint(mach_port_t task, vm_address_t patch_addr, int cont, callback handler) { kern_return_t kret; char *tmp; mach_vm_size_t len = 1; // number of bytes to write uint8_t opcode = 0xcc; // the CC byte to write interface *face; face = find_interface(task); if(face->registered_exception_handler == 0) { DEBUG_PRINT("[+add_breakpoint] HERE IN ADD BREAK\n %d", 0); register_(task); } kret = mach_vm_protect(task, patch_addr, len, FALSE, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); RETURN_ON_MACH_ERROR("[-add_breakpoint] mach_vm_protect()", kret); if (patch_addr <= MAX_BREAKS) { DEBUG_PRINT("[-add_breakpoint] INVALID BREAKPOINT ADDRESS %lx\n", patch_addr); return -1; } else if(face->current_break >= MAX_BREAKS) { DEBUG_PRINT("[-add_breakpoint] Max %d breaks reached!\n", MAX_BREAKS); return -1; } DEBUG_PRINT("[+add_breakpoint] Breakpoint %u: %lx added\n", face->current_break, patch_addr); tmp = (char*) read_memory(task, patch_addr, 1); breakpoint_struct *new_break = safe_malloc(sizeof(breakpoint_struct)); new_break->address = patch_addr; new_break->original = tmp[0] & 0xff; new_break->handler = handler; if(face->single_step) { new_break->index = face->single_step_index; } else { new_break->index = face->current_break == 0 ? 0 : face->breaks[face->current_break-1]->index + 1; } new_break->flags = cont; if(face->max_break == 0) { face->max_break = 1; } if(face->current_break >= (face->max_break - 1)) { DEBUG_PRINT("[+add_breakpoint] ALLOCATING MORE BP! CURRENTLY: %d\n", face->current_break); face->breaks = safe_realloc(face->breaks, sizeof(breakpoint_struct*) *(face->max_break*2)); face->max_break *= 2; } // face->breaks = safe_realloc(face->breaks, sizeof(breakpoint_struct*) *(face->current_break+1)); face->breaks[face->current_break++] = new_break; write_memory(task, patch_addr, opcode, len); // write the byte kret = mach_vm_protect(task, patch_addr, (mach_vm_size_t)1, FALSE, VM_PROT_READ | VM_PROT_EXECUTE); RETURN_ON_MACH_ERROR("[-add_breakpoint] RESTORE mach_vm_protect()", kret); return 1; }
void g_dbus_emit_property_changed(DBusConnection *connection, const char *path, const char *interface, const char *name) { const GDBusPropertyTable *property; struct generic_data *data; struct interface_data *iface; if (!dbus_connection_get_object_path_data(connection, path, (void **) &data) || data == NULL) return; iface = find_interface(data->interfaces, interface); if (iface == NULL) return; property = find_property(iface->properties, name); if (property == NULL) { error("Could not find property %s in %p", name, iface->properties); return; } data->pending_prop = TRUE; iface->pending_prop = g_slist_prepend(iface->pending_prop, (void *) property); if (!data->process_id) { data->process_id = g_idle_add(process_changes, data); return; } }
status_t add_interface_to_domain(net_domain* _domain, struct ifreq& request) { net_domain_private* domain = (net_domain_private*)_domain; const char* deviceName = request.ifr_parameter.device[0] ? request.ifr_parameter.device : request.ifr_name; const char* baseName = request.ifr_parameter.base_name[0] ? request.ifr_parameter.base_name : request.ifr_name; net_device_interface* deviceInterface = get_device_interface(deviceName); if (deviceInterface == NULL) return ENODEV; RecursiveLocker locker(domain->lock); net_interface_private* interface = NULL; status_t status; if (find_interface(domain, request.ifr_name) == NULL) { // We must not hold the domain's link when creating the interface: // this will call get_module() which might want to access a network // device when booting from network. locker.Unlock(); status = create_interface(domain, request.ifr_name, baseName, deviceInterface, &interface); locker.Lock(); if (find_interface(domain, request.ifr_name) != NULL) { delete_interface(interface); status = B_NAME_IN_USE; } } else status = B_NAME_IN_USE; put_device_interface(deviceInterface); if (status == B_OK) { list_add_item(&domain->interfaces, interface); notify_interface_added(interface); } return status; }
/*! This is called whenever a device interface is being removed. We will get the corresponding Interface, and remove it. */ void interface_removed_device_interface(net_device_interface* deviceInterface) { RecursiveLocker locker(sLock); Interface* interface = find_interface(deviceInterface->device->name); if (interface != NULL) remove_interface(interface); }
//++++++++++++++++++++++++++++++++++++++++++++++++ //FIFO: attach session data(buf, sess_id) // Lists all subflows, fourtuples for all sessions //++++++++++++++++++++++++++++++++++++++++++++++++ void attach_session_data(char* resp) { char buf[100]; struct subflow *current_sfl, *tmp_sfl; HASH_ITER(hh, sfl_hash, current_sfl, tmp_sfl) { if(strlen(resp) > LEN_FIFO_RSP - 100){ strcat(resp, "\n...\n"); return; } strcat(resp,"\n"); strcat(resp,"sfl="); sprintf(buf,"%zu",current_sfl->index); strcat(resp,buf); strcat(resp," sess="); sprintf(buf,"%zu",current_sfl->sess->index); strcat(resp,buf); if(current_sfl->act_state == 1) strcat(resp," active"); else strcat(resp," candid"); strcat(resp," if="); if(find_interface(&if_tab1, buf, current_sfl->ft.ip_loc)) strcat(resp,buf); else strcat(resp,"N/A"); strcat(resp," ipL="); sprintIPaddr(buf, current_sfl->ft.ip_loc); strcat(resp,buf); strcat(resp," ipR="); sprintIPaddr(buf, current_sfl->ft.ip_rem); strcat(resp,buf); strcat(resp," prtL="); sprintf(buf,"%d",current_sfl->ft.prt_loc); strcat(resp,buf); strcat(resp," prtR="); sprintf(buf,"%d",current_sfl->ft.prt_rem); strcat(resp,buf); char sess_state_str[20]; translate_SM_state(current_sfl->sess->sess_state, sess_state_str); strcat(resp," sess_state="); strcat(resp,sess_state_str); char sfl_state_str[20]; translate_SM_state(current_sfl->tcp_state, sfl_state_str); strcat(resp," sfl_state="); strcat(resp,sfl_state_str); } }
void handle_carrier(int carrier, int flags, const char *ifname) { struct interface *ifp; if (!(options & DHCPCD_LINK)) return; ifp = find_interface(ifname); if (ifp == NULL) { handle_interface(1, ifname); return; } if (!(ifp->options->options & DHCPCD_LINK)) return; if (carrier == LINK_UNKNOWN) carrier = carrier_status(ifp); /* will set ifp->flags */ else ifp->flags = flags; if (carrier == LINK_UNKNOWN) syslog(LOG_ERR, "%s: carrier_status: %m", ifname); /* IFF_RUNNING is checked, if needed, earlier and is OS dependant */ else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) { if (ifp->carrier != LINK_DOWN) { if (ifp->carrier == LINK_UP) syslog(LOG_INFO, "%s: carrier lost", ifp->name); ifp->carrier = LINK_DOWN; dhcp_close(ifp); dhcp6_drop(ifp, "EXPIRE6"); ipv6rs_drop(ifp); /* Don't blindly delete our knowledge of LL addresses. * We need to listen to what the kernel does with * them as some OS's will remove, mark tentative or * do nothing. */ ipv6_free_ll_callbacks(ifp); dhcp_drop(ifp, "NOCARRIER"); } } else if (carrier == LINK_UP && ifp->flags & IFF_UP) { if (ifp->carrier != LINK_UP) { syslog(LOG_INFO, "%s: carrier acquired", ifp->name); ifp->carrier = LINK_UP; #if !defined(__linux__) && !defined(__NetBSD__) /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the * hardware address changes so we have to go * through the disovery process to work it out. */ handle_interface(0, ifp->name); #endif if (ifp->wireless) getifssid(ifp->name, ifp->ssid); configure_interface(ifp, margc, margv); script_runreason(ifp, "CARRIER"); start_interface(ifp); } } }
bool GMWMI::perturb (Point<float>& p, Interp& interp) { const Point<float> normal (get_normal (p, interp)); if (!normal.valid()) return false; Point<float> plane_one ((normal.cross (Point<float> (0.0f,0.0f,1.0f))).normalise()); if (!plane_one.valid()) plane_one = (normal.cross (Point<float> (0.0f,1.0f,0.0f))).normalise(); const Point<float> plane_two ((normal.cross (plane_one)).normalise()); p += ((rng()-0.5f) * perturb_max_step * plane_one) + ((rng()-0.5f) * perturb_max_step * plane_two); return find_interface (p, interp); }
bool GMWMI::get_seed (Point<float>& p) { Interp interp (interp_template); do { init_seeder.get_seed (p); if (find_interface (p, interp)) { if (perturb (p, interp)) return true; } } while (1); return false; }
EXPORT int remove_all_breaks(mach_port_t task) { interface *face = find_interface(task); int i = face->current_break-1; while(i>=0) { remove_breakpoint(task, face->breaks[i]->address); --i; } return 1; }
status_t domain_interface_control(net_domain_private* domain, int32 option, ifreq* request) { const char* name = request->ifr_name; status_t status = B_OK; net_device_interface* device = get_device_interface(name, false); if (device == NULL) return ENODEV; RecursiveLocker _(domain->lock); net_interface* interface = find_interface(domain, name); if (interface != NULL) { switch (option) { case SIOCDIFADDR: remove_interface_from_domain(interface); break; case SIOCSIFFLAGS: { uint32 requestFlags = request->ifr_flags; request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST); if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) { if (requestFlags & IFF_UP) { status = interface->first_info->interface_up( interface->first_protocol); if (status == B_OK) interface->flags |= IFF_UP; } else { interface_set_down(interface); } } if (status == B_OK) { // TODO: why shouldn't we able to delete IFF_BROADCAST? interface->flags &= IFF_UP | IFF_LINK | IFF_BROADCAST; interface->flags |= request->ifr_flags; } break; } } } // If the SIOCDIFADDR call above removed the last interface associated with // the device interface, this will effectively remove the interface put_device_interface(device); return status; }
static DBusMessage *properties_get(DBusConnection *connection, DBusMessage *message, void *user_data) { struct generic_data *data = user_data; struct interface_data *iface; const GDBusPropertyTable *property; const char *interface, *name; DBusMessageIter iter, value; DBusMessage *reply; if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) return NULL; iface = find_interface(data->interfaces, interface); if (iface == NULL) return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, "No such interface '%s'", interface); property = find_property(iface->properties, name); if (property == NULL) return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, "No such property '%s'", name); if (property->exists != NULL && !property->exists(property, iface->user_data)) return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, "No such property '%s'", name); if (property->get == NULL) return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, "Property '%s' is not readable", name); reply = dbus_message_new_method_return(message); if (reply == NULL) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, property->type, &value); if (!property->get(property, &value, iface->user_data)) { dbus_message_unref(reply); return NULL; } dbus_message_iter_close_container(&iter, &value); return reply; }
//++++++++++++++++++++++++++++++++++++++++++++++++ //handle_remove_addr_event: executes remove_addr message retransmission (REMOVE_ADDR) //++++++++++++++++++++++++++++++++++++++++++++++++ void handle_remove_addr_event(struct tp_event *evt) { struct remove_addr_event_data *rmadd = (struct remove_addr_event_data*) evt->data; //check if IP address was assigned again char ifname[MAX_LENGTH_IFACE_NAME]; if( !find_interface(&if_tab1, ifname, rmadd->ipaddr) ) { struct session *curr_sess, *tmp_sess; HASH_ITER(hh, sess_hash, curr_sess, tmp_sess) { if(curr_sess != NULL) do_remove_address(curr_sess, rmadd->ipaddr); } } delete_remove_addr_event(evt); }
/*! \internal * \brief determine if a list of attribute key value pairs are set on a format */ static int format_isset_helper(const struct ast_format *format, va_list ap) { int res; struct interface_ao2_wrapper *wrapper; struct ast_format tmp = { .id = format->id, .fattr = { { 0, }, }, }; if (!(wrapper = find_interface(format))) { return -1; } ast_rwlock_rdlock(&wrapper->wraplock); if (!wrapper->interface || !wrapper->interface->format_attr_set || !wrapper->interface->format_attr_cmp) { ast_rwlock_unlock(&wrapper->wraplock); ao2_ref(wrapper, -1); return -1; } /* if isset is present, use that function, else just build a new * format and use the cmp function */ if (wrapper->interface->format_attr_isset) { res = wrapper->interface->format_attr_isset(&format->fattr, ap); } else { wrapper->interface->format_attr_set(&tmp.fattr, ap); /* use our tmp structure to tell if the attributes are set or not */ res = wrapper->interface->format_attr_cmp(&tmp.fattr, &format->fattr); res = (res == AST_FORMAT_CMP_NOT_EQUAL) ? -1 : 0; } ast_rwlock_unlock(&wrapper->wraplock); ao2_ref(wrapper, -1); return res; } int ast_format_isset(const struct ast_format *format, ... ) { va_list ap; int res; va_start(ap, format); res = format_isset_helper(format, ap); va_end(ap); return res; }
EXPORT vm_address_t* list_breaks(mach_port_t task, int *count) { interface *face = find_interface(task); vm_address_t *list = safe_malloc(sizeof(vm_address_t) * face->current_break); int i = 0; while(i < face->current_break) { DEBUG_PRINT("[+list_breaks] Breakpoint [%lu] %lx\n", face->breaks[i]->index, face->breaks[i]->address); list[i] = face->breaks[i]->address; ++i; } *count = i; return list; }
Interface* get_interface(net_domain* domain, const char* name) { RecursiveLocker locker(sLock); Interface* interface = find_interface(name); if (interface == NULL || interface->IsBusy()) return NULL; if (interface->CreateDomainDatalinkIfNeeded(domain) != B_OK) return NULL; interface->AcquireReference(); return interface; }
void domain_removed_device_interface(net_device_interface* deviceInterface) { MutexLocker locker(sDomainLock); DomainList::Iterator iterator = sDomains.GetIterator(); while (net_domain_private* domain = iterator.Next()) { RecursiveLocker locker(domain->lock); net_interface_private* interface = find_interface(domain, deviceInterface->device->name); if (interface == NULL) continue; remove_interface_from_domain(interface); } }
/* * Removes a breakpoint from breaks array indicated by index or address (both are unsigned long long) */ EXPORT int remove_breakpoint(mach_port_t task, vm_address_t bp) { kern_return_t kret; int c, position, index; mach_vm_address_t address; interface *face; face = find_interface(task); if(!face->registered_exception_handler) { DEBUG_PRINT("SHOULD NEVER HAPPEN :| %d\n", 1); return -1; } position = find_break(task, bp); if(position == -1) { DEBUG_PRINT("[-remove_breakpoint] Failed find_break %d\n", position); return -1; } breakpoint_struct *breakpoint = face->breaks[position]; uint8_t opcode = breakpoint->original; // CC byte to write mach_vm_size_t len = 1; // number of bytes to write kret = mach_vm_protect(task, breakpoint->address, len, FALSE, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); RETURN_ON_MACH_ERROR("[-remove_breakpoint] mach_vm_protect()", kret); write_memory(task, breakpoint->address, opcode, len); // and write the byte kret = mach_vm_protect(task, breakpoint->address, len, FALSE, VM_PROT_READ | VM_PROT_EXECUTE); RETURN_ON_MACH_ERROR("[-remove_breakpoint] RESTORE mach_vm_protect()", kret); address = face->breaks[position]->address; index = face->breaks[position]->index; if(face->single_step) face->single_step_index = index; for(c = position; c < face->current_break; c++) { face->breaks[c] = face->breaks[c+1]; } DEBUG_PRINT("[-remove_breakpoint] Breakpoint %x at %llx removed\n", index, address); face->current_break -= 1; // decrement counter return 1; }
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path, const char *interface, DBusMessageIter *iter) { struct generic_data *data; struct interface_data *iface; if (!dbus_connection_get_object_path_data(connection, path, (void **) &data) || data == NULL) return FALSE; iface = find_interface(data->interfaces, interface); if (iface == NULL) return FALSE; append_properties(iface, iter); return TRUE; }
static gboolean remove_interface(struct generic_data *data, const char *name) { struct interface_data *iface; iface = find_interface(data->interfaces, name); if (iface == NULL) return FALSE; process_properties_from_interface(data, iface); data->interfaces = g_slist_remove(data->interfaces, iface); if (iface->destroy) { iface->destroy(iface->user_data); iface->user_data = NULL; } /* * Interface being removed was just added, on the same mainloop * iteration? Don't send any signal */ if (g_slist_find(data->added, iface)) { data->added = g_slist_remove(data->added, iface); g_free(iface->name); g_free(iface); return TRUE; } if (data->parent == NULL) { g_free(iface->name); g_free(iface); return TRUE; } data->removed = g_slist_prepend(data->removed, iface->name); g_free(iface); if (data->process_id > 0) return TRUE; data->process_id = g_idle_add(process_changes, data); return TRUE; }