Ejemplo n.º 1
0
bool prepare_object_event_logger(const char *log_dir)
{
	object_types_mutex = __malloc_lock_init();
	object_types_file = __init_object_type_file(log_dir);
	if (object_types_file == NULL) {
		return false;
	}
	
	// Insert vm memory type names
	for (int i = 0; i < sizeof(vm_memory_type_names) / sizeof(char *); ++i) {
		uintptr_t str_hash = __string_hash(vm_memory_type_names[i]);
		uint32_t type = object_types_file->object_type_list->size() + 1;
		object_types_file->object_type_exists->insert(str_hash);
		object_types_file->object_type_list->insert(object_type(type, vm_memory_type_names[i]));
	}
	
#ifdef USE_PRIVATE_API
    // __CFObjectAllocSetLastAllocEventNameFunction
	object_set_last_allocation_event_name_funcion = (void (**)(void *, const char *))dlsym(RTLD_DEFAULT, "__CFObjectAllocSetLastAllocEventNameFunction");
	if (object_set_last_allocation_event_name_funcion != NULL) {
		*object_set_last_allocation_event_name_funcion = object_set_last_allocation_event_name;
	}
	
	// __CFOASafe
	object_record_allocation_event_enable = (bool *)dlsym(RTLD_DEFAULT, "__CFOASafe");
	if (object_record_allocation_event_enable != NULL) {
		*object_record_allocation_event_enable = true;
	}
#endif
	
	nsobject_hook_alloc_method();
	
	return true;
}
Ejemplo n.º 2
0
void __libc_init(void)
{
    extern void (*__CTOR_LIST__[])();
    void (**pfunc)() = __CTOR_LIST__;

    if (ProcGetProcessInfo()->std_out != 0)
	ThrGetThreadInfo()->exception_handler = __libc_exception_handler;

    __malloc_lock_init();
    __malloc_debug_init();
    atexit(__malloc_lock_cleanup);
    __get_stdin();
    __get_stdout();
    __get_stderr();
    __setup_file_rec_list();

    while (*++pfunc)
	;
    while (--pfunc > __CTOR_LIST__)
	(*pfunc) ();
}