Exemple #1
0
int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
{
    GetBitContext gb;
    int specific_config_bitindex;

    init_get_bits(&gb, buf, buf_size*8);
    c->object_type = get_object_type(&gb);
    c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
    c->chan_config = get_bits(&gb, 4);
    if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
        c->channels = ff_mpeg4audio_channels[c->chan_config];
    c->sbr = -1;
    if (c->object_type == AOT_SBR) {
        c->ext_object_type = c->object_type;
        c->sbr = 1;
        c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
        c->object_type = get_object_type(&gb);
        if (c->object_type == AOT_ER_BSAC)
            c->ext_chan_config = get_bits(&gb, 4);
    } else {
        c->ext_object_type = AOT_NULL;
        c->ext_sample_rate = 0;
    }
    specific_config_bitindex = get_bits_count(&gb);

    if (c->object_type == AOT_ALS) {
        skip_bits(&gb, 5);
        if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
            skip_bits_long(&gb, 24);

        specific_config_bitindex = get_bits_count(&gb);

        if (parse_config_ALS(&gb, c))
            return -1;
    }

    if (c->ext_object_type != AOT_SBR) {
        int bits_left = buf_size*8 - get_bits_count(&gb);
        for (; bits_left > 15; bits_left--) {
            if (show_bits(&gb, 11) == 0x2b7) { // sync extension
                get_bits(&gb, 11);
                c->ext_object_type = get_object_type(&gb);
                if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1)
                    c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
                break;
            } else
                get_bits1(&gb); // skip 1 bit
        }
    }
    return specific_config_bitindex;
}
int  main(
    int    argc,
    char   *argv[] )
{
    STRING               src_filename, dest_filename;
    int                  n_objects;
    File_formats         format;
    object_struct        **object_list;
    polygons_struct      *polygons;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &src_filename ) ||
        !get_string_argument( NULL, &dest_filename ) )
    {
        print_error( "Usage: %s  input.obj output.obj\n", argv[0] );
        return( 1 );
    }

    if( input_graphics_file( src_filename, &format, &n_objects,
                             &object_list ) != OK || n_objects != 1 ||
        get_object_type(object_list[0]) != POLYGONS )
        return( 1 );

    polygons = get_polygons_ptr( object_list[0] );

    create_2d_coordinates( polygons, 0 );

    (void) output_graphics_file( dest_filename, format, 1, object_list );

    return( 0 );
}
Exemple #3
0
ClassScopes::ClassScopes(const Scope& scope) {
  m_hierarchy = build_type_hierarchy(scope);
  m_interface_map = build_interface_map(m_hierarchy);
  m_sig_map = build_signature_map(m_hierarchy);
  build_class_scopes(get_object_type());
  build_interface_scopes();
}
Exemple #4
0
void MethodBlock::load_null(Location& loc) {
  always_assert(!loc.is_wide());
  DexInstruction* load = new DexInstruction(OPCODE_CONST_4);
  load->set_dest(reg_num(loc));
  load->set_literal(0);
  loc.type = get_object_type();
  push_instruction(load);
}
 RemoveUnusedArgsTest() {
   g_redex = new RedexContext();
   Scope dummy_scope;
   auto obj_t = get_object_type();
   auto dummy_t = DexType::make_type("LA;");
   auto dummy_cls = create_internal_class(dummy_t, obj_t, {});
   dummy_scope.push_back(dummy_cls);
   m_remove_args = new remove_unused_args::RemoveArgs(dummy_scope);
 }
Exemple #6
0
bool has_hierarchy_in_scope(DexClass* cls) {
  DexType* super = nullptr;
  const DexClass* super_cls = cls;
  while (super_cls) {
    super = super_cls->get_super_class();
    super_cls = type_class_internal(super);
  }
  return super == get_object_type();
}
int  main(
    int    argc,
    char   *argv[] )
{
    STRING               polygons_filename, dest_filename, lines_filename;
    int                  n_objects, n_l_objects;
    File_formats         format;
    object_struct        **object_list, **l_object_list;
    polygons_struct      *polygons, *new_polygons;
    lines_struct         *lines;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &polygons_filename ) ||
            !get_string_argument( NULL, &lines_filename ) ||
            !get_string_argument( NULL, &dest_filename ) )
    {
        print_error( "Usage: %s  polygons.obj lines.obj output.obj\n",
                     argv[0] );
        return( 1 );
    }

    if( input_graphics_file( polygons_filename, &format, &n_objects,
                             &object_list ) != OK || n_objects != 1 ||
            get_object_type(object_list[0]) != POLYGONS )
        return( 1 );

    polygons = get_polygons_ptr( object_list[0] );

    if( input_graphics_file( lines_filename, &format, &n_l_objects,
                             &l_object_list ) != OK || n_l_objects != 1 ||
            get_object_type(l_object_list[0]) != LINES )
        return( 1 );

    lines = get_lines_ptr( l_object_list[0] );

    new_polygons = NULL;
    segment_polygons( polygons, lines, new_polygons );

    (void) output_graphics_file( dest_filename, format, n_objects, object_list);

    return( 0 );
}
Exemple #8
0
const std::vector<DexMethod*>& get_vmethods(const DexType* type) {
  const DexClass* cls = type_class(type);
  if (cls == nullptr) {
    always_assert_log(
        type == get_object_type(), "Unknown type %s\n", SHOW(type));
    create_object_class();
    cls = type_class(type);
  }
  return cls->get_vmethods();
}
Exemple #9
0
/**
 * Builds the ClassScope for type and children.
 * Calling with get_object_type() builds the ClassScope
 * for the entire system as redex knows it.
 */
void ClassScopes::build_class_scopes(const DexType* type) {
  auto cls = type_class(type);
  always_assert(cls != nullptr || type == get_object_type());
  get_root_scopes(m_sig_map, type, m_scopes);

  const auto& children_it = m_hierarchy.find(type);
  if (children_it != m_hierarchy.end()) {
    for (const auto& child : children_it->second) {
      build_class_scopes(child);
    }
  }
}
Exemple #10
0
const VirtualScope& find_virtual_scope(const SignatureMap& sig_map,
                                       const DexMethod* meth) {
  const auto& protos = sig_map.find(meth->get_name());
  always_assert(protos != sig_map.end());
  const auto& scopes = protos->second.find(meth->get_proto());
  always_assert(scopes != protos->second.end());
  const auto meth_type = meth->get_class();
  for (const auto& scope : scopes->second) {
    if (scope.type == get_object_type()) return scope;
    if (is_subclass(scope.type, meth_type)) return scope;
  }
  always_assert_log(false, "unreachable. Scope not found for %s\n", SHOW(meth));
}
Exemple #11
0
static size_t get_return_struct(code_system *system, type *return_type) {
  if (is_void(return_type)) {
    return 0;
  }

  size_t count = system->struct_count;
  code_struct *return_struct;

  for (size_t i = 0; i < count; i++) {
    return_struct = get_code_struct(system, i);
    if (return_struct->field_count != 1) {
      continue;
    }

    code_field *first_field = &return_struct->fields[0];
    type *first = first_field->field_type;

    if (first->type != T_BLOCKREF || !first->blocktype ||
        !first->blocktype->next || first->blocktype->next->next) {
      continue;
    }

    type *second = first->blocktype->next->argument_type;
    first = first->blocktype->argument_type;

    if (first->type == T_OBJECT && first->struct_index == i &&
        equivalent_type(return_type, second)) {
      return i;
    }
  }

  return_struct = add_struct(system);
  return_struct->field_count = 1;
  return_struct->fields = xmalloc(sizeof(code_field));
  return_struct->fields[0].field_type = new_type(T_BLOCKREF);

  argument *blocktype = xmalloc(sizeof(*blocktype));
  blocktype->symbol_name = NULL;
  blocktype->argument_type = get_object_type(count);
  return_struct->fields[0].field_type->blocktype = blocktype;

  blocktype->next = xmalloc(sizeof(argument));
  blocktype = blocktype->next;
  blocktype->symbol_name = NULL;
  blocktype->argument_type = copy_type(return_type);
  blocktype->next = NULL;

  return count;
}
std::vector<DexField*> create_merger_fields(
    const DexType* owner, const std::vector<DexField*>& mergeable_fields) {
  std::vector<DexField*> res;
  size_t cnt = 0;
  for (const auto f : mergeable_fields) {
    auto type = f->get_type();
    std::string name;
    if (type == get_byte_type() || type == get_char_type() ||
        type == get_short_type() || type == get_int_type()) {
      type = get_int_type();
      name = "i";
    } else if (type == get_boolean_type()) {
      type = get_boolean_type();
      name = "z";
    } else if (type == get_long_type()) {
      type = get_long_type();
      name = "j";
    } else if (type == get_float_type()) {
      type = get_float_type();
      name = "f";
    } else if (type == get_double_type()) {
      type = get_double_type();
      name = "d";
    } else {
      static DexType* string_type = DexType::make_type("Ljava/lang/String;");
      if (type == string_type) {
        type = string_type;
        name = "s";
      } else {
        char t = type_shorty(type);
        always_assert(t == 'L' || t == '[');
        type = get_object_type();
        name = "l";
      }
    }

    name = name + std::to_string(cnt);
    auto field = static_cast<DexField*>(
        DexField::make_field(owner, DexString::make_string(name), type));
    field->make_concrete(ACC_PUBLIC);
    res.push_back(field);
    cnt++;
  }

  TRACE(TERA, 8, "  created merger fields %d \n", res.size());
  return res;
}
Exemple #13
0
/**
 * Rename virtual methods.
 */
size_t rename_virtuals(Scope& classes) {
  // build a ClassScope a RefsMap and a VirtualRenamer
  ClassScopes class_scopes(classes);
  scope_info(class_scopes);
  RefsMap def_refs;
  collect_refs(classes, def_refs);
  VirtualRenamer vr(class_scopes, def_refs);

  // rename virtual only first
  const auto obj_t = get_object_type();
  int seed = 0;
  size_t renamed = vr.rename_virtual_scopes(obj_t, seed);
  TRACE(OBFUSCATE, 2, "Virtual renamed: %ld\n", renamed);

  // rename interfaces
  std::unordered_set<const VirtualScope*> visited;
  size_t intf_renamed = vr.rename_interface_scopes(seed);
  TRACE(OBFUSCATE, 2, "Interface renamed: %ld\n", intf_renamed);
  TRACE(OBFUSCATE, 2, "MAX seed: %d\n", seed);
  return renamed + intf_renamed;
}
int  main(
    int    argc,
    char   *argv[] )
{
    STRING           input_filename, output_filename;
    int              n_objects, start_poly;
    File_formats     format;
    object_struct    **object_list;
    polygons_struct  *polygons;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &input_filename ) ||
        !get_string_argument( NULL, &output_filename ) )
    {
        print_error(
          "Usage: %s  input.obj  output.obj\n",
                      argv[0] );
        return( 1 );
    }

    (void) get_int_argument( 0, &start_poly );

    if( input_graphics_file( input_filename, &format, &n_objects,
                             &object_list ) != OK || n_objects != 1 ||
        get_object_type(object_list[0]) != POLYGONS )
    {
        print_error( "Error reading %s.\n", input_filename );
        return( 1 );
    }

    polygons = get_polygons_ptr( object_list[0] );

    check_polygons_neighbours_computed( polygons );

    create_tristrip( polygons, start_poly );

    return( 0 );
}
Exemple #15
0
//	---------------------------------------------------------------------------------------------------
void info_display_object_placement(int show_all)
{
	static	int	old_Cur_object_index;
	static	int	old_type;
	static	int	old_movement_type;
	static	int	old_control_type;
	static	int	old_mode;

	char		name[30];

	if (init_info | show_all) {
		old_Cur_object_index = -2;
		old_type = -2;
		old_movement_type = -2;
		old_control_type = -2;
		old_mode = -2;
	}

	if ( ( Cur_object_index != old_Cur_object_index) || 
			( Objects[Cur_object_index].type != old_type) || 
			( Objects[Cur_object_index].movement_type != old_movement_type) || 
			( Objects[Cur_object_index].control_type != old_control_type) || 
			( Objects[Cur_object_index].ctype.ai_info.behavior != old_mode) ) {

		gr_uprintf( 0, 0, "Object id: %4d\n", Cur_object_index);
		gr_uprintf( 0, 16, "Type: %s\n", get_object_type(Objects[Cur_object_index].type , name));
		gr_uprintf( 0, 32, "Movmnt: %s\n", get_movement_type(Objects[Cur_object_index].movement_type, name));
		gr_uprintf( 0, 48, "Cntrl: %s\n", get_control_type(Objects[Cur_object_index].control_type, name));
		gr_uprintf( 0, 64, "Mode: %s\n", get_ai_behavior(Objects[Cur_object_index].ctype.ai_info.behavior, name));

		old_Cur_object_index = Cur_object_index;
		old_type = Objects[Cur_object_index].type;
		old_movement_type = Objects[Cur_object_index].movement_type;
		old_mode = Objects[Cur_object_index].control_type;
		old_mode = Objects[Cur_object_index].ctype.ai_info.behavior;
	}

}
int  main(
    int    argc,
    char   *argv[] )
{
    STRING               src_filename, dest_filename;
    int                  n_objects, n_iters;
    File_formats         format;
    object_struct        **object_list;
    polygons_struct      *polygons;
    Real                 step_ratio;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &src_filename ) ||
        !get_string_argument( NULL, &dest_filename ) )
    {
        print_error( "Usage: %s  input.obj output.obj [step] [n_iters]\n",
                     argv[0] );
        return( 1 );
    }

    (void) get_real_argument( 0.2, &step_ratio );
    (void) get_int_argument( 1000, &n_iters );

    if( input_graphics_file( src_filename, &format, &n_objects,
                             &object_list ) != OK || n_objects != 1 ||
        get_object_type(object_list[0]) != POLYGONS )
        return( 1 );

    polygons = get_polygons_ptr( object_list[0] );

    flatten_polygons( polygons, step_ratio, n_iters );

    (void) output_graphics_file( dest_filename, format, 1, object_list );

    return( 0 );
}
Exemple #17
0
static struct object_type *file_get_type( struct object *obj )
{
    static const WCHAR name[] = {'F','i','l','e'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
int  main(
    int   argc,
    char  *argv[] )
{
    STRING               src_polygons_filename;
    File_formats         format;
    int                  n_src_objects, poly;
    object_struct        **src_objects;
    polygons_struct      *polygons, unit_sphere;
    Real                 x, y, z, xs, ys, zs, u, v, dist;
    Point                point, centre, unit_point, poly_point;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &src_polygons_filename ) ||
        !get_real_argument( 0.0, &x ) ||
        !get_real_argument( 0.0, &y ) ||
        !get_real_argument( 0.0, &z ) )
    {
        print_error( "Usage: %s  input.obj  x y z\n", argv[0] );
        return( 1 );
    }

    if( input_graphics_file( src_polygons_filename,
                             &format, &n_src_objects, &src_objects ) != OK )
        return( 1 );

    if( n_src_objects != 1 || get_object_type( src_objects[0] ) != POLYGONS ||
        !is_this_tetrahedral_topology( get_polygons_ptr(src_objects[0]) ) )
    {
        print( "First argument must contain one tetrahedral mesh.\n" );
        return( 1 );
    }

    polygons = get_polygons_ptr(src_objects[0]);

    create_polygons_bintree( polygons,
                        ROUND( (Real) polygons->n_items * BINTREE_FACTOR ) );

    fill_Point( centre, 0.0, 0.0, 0.0 );

    create_tetrahedral_sphere( &centre, 1.0, 1.0, 1.0, polygons->n_items,
                               &unit_sphere );

    fill_Point( point, x, y, z );

    poly = find_closest_polygon_point( &point, polygons, &poly_point );

    dist = distance_between_points( &point, &poly_point );

    if( dist > 1.0 )
        print( "Warning point is %.1f millimetres from the surface.\n", dist );

    map_point_to_unit_sphere( polygons, &point, &unit_sphere, &unit_point );

    xs = RPoint_x( unit_point );
    ys = RPoint_y( unit_point );
    zs = RPoint_z( unit_point );

    map_sphere_to_uv( xs, ys, zs, &u, &v );

    print( "%g %g %g -> %g %g\n", x, y, z, u, v );

    delete_object_list( n_src_objects, src_objects );

    delete_polygons( &unit_sphere );

    return( 0 );
}
Exemple #19
0
static struct object_type *semaphore_get_type( struct object *obj )
{
    static const WCHAR name[] = {'S','e','m','a','p','h','o','r','e'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
Exemple #20
0
static struct object_type *completion_get_type(struct object *obj)
{
	static const WCHAR name[] = {'C','o','m','p','l','e','t','i','o','n'};
	static const struct unicode_str str = {name, sizeof(name)};
	return get_object_type(&str);
}
Exemple #21
0
static struct object_type *keyed_event_get_type( struct object *obj )
{
    static const WCHAR name[] = {'K','e','y','e','d','E','v','e','n','t'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
Exemple #22
0
int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
{
    GetBitContext gb;
    int specific_config_bitindex;

    init_get_bits(&gb, buf, buf_size*8);
    c->object_type = get_object_type(&gb);
    c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
    c->chan_config = get_bits(&gb, 4);
    if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
        c->channels = ff_mpeg4audio_channels[c->chan_config];
    c->sbr = -1;
    c->ps  = -1;
    if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
        // check for W6132 Annex YYYY draft MP3onMP4
        !(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
        if (c->object_type == AOT_PS)
            c->ps = 1;
        c->ext_object_type = AOT_SBR;
        c->sbr = 1;
        c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
        c->object_type = get_object_type(&gb);
        if (c->object_type == AOT_ER_BSAC)
            c->ext_chan_config = get_bits(&gb, 4);
    } else {
        c->ext_object_type = AOT_NULL;
        c->ext_sample_rate = 0;
    }
    specific_config_bitindex = get_bits_count(&gb);

    if (c->object_type == AOT_ALS) {
        skip_bits(&gb, 5);
        if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
            skip_bits_long(&gb, 24);

        specific_config_bitindex = get_bits_count(&gb);

        if (parse_config_ALS(&gb, c))
            return -1;
    }

    if (c->ext_object_type != AOT_SBR) {
        while (get_bits_left(&gb) > 15) {
            if (show_bits(&gb, 11) == 0x2b7) { // sync extension
                get_bits(&gb, 11);
                c->ext_object_type = get_object_type(&gb);
                if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1)
                    c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
                if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
                    c->ps = get_bits1(&gb);
                break;
            } else
                get_bits1(&gb); // skip 1 bit
        }
    }

    //PS requires SBR
    if (!c->sbr)
        c->ps = 0;
    //Limit implicit PS to the HE-AACv2 Profile
    if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01)
        c->ps = 0;

    return specific_config_bitindex;
}
Exemple #23
0
static struct object_type *symlink_get_type( struct object *obj )
{
    static const WCHAR name[] = {'S','y','m','b','o','l','i','c','L','i','n','k'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
Exemple #24
0
static struct object_type *mapping_get_type( struct object *obj )
{
    static const WCHAR name[] = {'S','e','c','t','i','o','n'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
int  main(
    int   argc,
    char  *argv[] )
{
    STRING               input_filename, output_filename;
    STRING               model_filename;
    File_formats         src_format, model_format;
    int                  n_src_objects, n_model_objects;
    object_struct        **src_objects, **model_objects;
    polygons_struct      *original, *model;
    Real                 movement_threshold, ratio;
    int                  n_iters, method, grid_size;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( NULL, &input_filename ) ||
        !get_string_argument( NULL, &model_filename ) ||
        !get_string_argument( NULL, &output_filename ) )
    {
        print_error( "Usage: %s  input.obj  model.obj output.obj\n", argv[0] );
        return( 1 );
    }

    (void) get_int_argument( 1, &n_iters );
    (void) get_real_argument( 1.0, &ratio );
    (void) get_int_argument( 0, &method );
    (void) get_int_argument( 30, &grid_size );
    (void) get_real_argument( 0.0, &movement_threshold );

    if( input_graphics_file( input_filename, &src_format,
                             &n_src_objects, &src_objects ) != OK ||
        n_src_objects != 1 || get_object_type(src_objects[0]) != POLYGONS )
    {
        print_error( "Error in %s\n", input_filename );
        return( 1 );
    }

    if( input_graphics_file( model_filename, &model_format,
                             &n_model_objects, &model_objects ) != OK ||
        n_model_objects != 1 || get_object_type(model_objects[0]) != POLYGONS )
    {
        print_error( "Error in %s\n", model_filename );
        return( 1 );
    }

    original = get_polygons_ptr( src_objects[0] );
    model = get_polygons_ptr( model_objects[0] );

    if( !objects_are_same_topology( original->n_points,
                                    original->n_items,
                                    original->end_indices,
                                    original->indices,
                                    model->n_points,
                                    model->n_items,
                                    model->end_indices,
                                    model->indices ) )
    {
        print_error( "Mismatched topology.\n" );
        return( 1 );
    }

    reparameterize( original, model, method, grid_size, ratio,
                    movement_threshold, n_iters );

    if( output_graphics_file( output_filename, src_format, n_src_objects,
                              src_objects ) != OK )
        return( 1 );

    delete_object_list( n_src_objects, src_objects );

    output_alloc_to_file( NULL );

    return( 0 );
}
void *iKX::instantiate_object(const char *library,int id) // returns 0 if failed
{
 int type=get_object_type(library);
 int ver=KXPLUGIN_VERSION;

 char *func="publish_plugins";

 switch(type)
 {
  case KX_OBJECT_RIFX:
  case KX_OBJECT_DANE:
  {
     strcpy(error_name,"Error loading Dane Source");

     if(id!=0)
     {
       debug("iKX plugin: instantiate source with id=%d\n",id);
       return NULL;
     }

     iKXDaneSource *dane;
     dane=new iKXDaneSource();

     if(dane==0)
     {
       debug("iKX plugin: instantiate: no more memory\n");
       return NULL;
     }

     if(dane->init(library,this)==0)
     {
        return dane;
     }
     debug("iKX plugin: instantiate: init() failed [id: %d; %s]\n",id,dane->name_?dane->name_:NULL);

     delete dane;

     return NULL;
 }
 case KX_OBJECT_ADDON:
   func="publish_addons";
   ver=KXADDON_VERSION;
   // fall thru
 case KX_OBJECT_KXL:
 {
    HINSTANCE inst;
    inst=LoadLibrary(library);
    if(inst!=0)
    {
     kxplugin_publish_t pp;
     pp=(kxplugin_publish_t)GetProcAddress(inst,func);
     if(pp)
     {
      uintptr_t ret=0;
      uintptr_t result;

      try
      {
       result=pp(KXPLUGIN_GET_VERSION,ver,&ret);
      }
      catch(...)
      {
       debug("iKXPlugin: exception on getting plugin version\n");
       result=(uintptr_t)-1;
      }

      if(result || (ret!=(dword)ver))
      {
       debug("iKX plugin: version=%d; should be %d; result=%d\n",ret,ver,result);
       strcpy(error_name,"Invalid Plugin Version");
       return 0;
      }

      ret=0;
      try
      {
       result=pp(KXPLUGIN_INSTANTIATE,id,&ret);
      }
      catch(...)
      {
       debug("iKXPlugin: exception on instantiation\n");
       result=(uintptr_t)-1;
      }
      if((result==0) && (ret!=0)) // ok
      {
       if(type==KX_OBJECT_KXL)
       {
         iKXPlugin *plugin=(iKXPlugin *)ret;
         plugin->instance=inst;
         plugin->ikx=this;
         plugin->kxdevice=device_num;
         plugin->cp=NULL;
         plugin->pm=NULL;

         // init() is NOT called by the constructor
         plugin->init();

         return plugin;
       }
       else
        if(type==KX_OBJECT_ADDON)
        {
         iKXAddOn *addon=(iKXAddOn *)ret;
         addon->instance=inst;

         return addon;
        }
        else
        {
         debug("iKXPlugin: internal error\n");
         return NULL;
        }
      }
      debug("iKX plugin: instantiate: pp(instantiate) failed [%d]\n",result);
      strcpy(error_name,"Error instantiating plugin");
      // error
      FreeLibrary(inst);
      return 0;
     }
     debug("iKX plugin: instantiate: getprocaddress invalid\n");
    }
    debug("iKX plugin: instantiate: loadlibrary failed [%x]\n",GetLastError());
    strcpy(error_name,"Error loading Plugin DLL");
 }
 }
 return 0;
}
int iKX::get_object_guid(const char *library,int id,char *ret_name) // returns 0 if failed
{
 int type=get_object_type(library);
 char *func="publish_plugins";
 int ver=KXPLUGIN_VERSION;

 switch(type)
 {
  case KX_OBJECT_RIFX:
  case KX_OBJECT_DANE:
  {
    if(id!=0)
      return -2;

    iKXDaneSource dane;

    if(dane.init(library,this)==0)
    {
       strncpy(ret_name,dane.guid,KX_MAX_STRING);
       return 0;
    }
        debug("iKX plugin: get_guid(): dane.init failed\n");

    return -5;
 }
 case KX_OBJECT_ADDON:
    func="publish_addons";
    ver=KXADDON_VERSION;
        // fall thru
 case KX_OBJECT_KXL:
 {
 HINSTANCE inst;
 inst=LoadLibrary(library);
 if(inst!=0)
 {
  kxplugin_publish_t pp;
  pp=(kxplugin_publish_t)GetProcAddress(inst,func);
  if(pp)
  {
   uintptr_t ret=0;
   uintptr_t result;

   try
   {
    result=pp(KXPLUGIN_GET_VERSION,id,&ret);
   }
   catch(...)
   {
    result=(uintptr_t)-1;
    debug("iKXPlugin: exception on plugin actions 3\n");
   }
   if(result || (ret!=(dword)ver))
   {
    debug("iKX plugin: get_guid(): version invalid: res=%d ret=%d v=%d\n",result,ret,ver);
    strcpy(error_name,"Invalid Plugin Version");
    return 0;
   }

   try
   {
    ret=pp(KXPLUGIN_GET_GUID,id,(uintptr_t *)ret_name);
   }
   catch(...)
   {
    ret=(uintptr_t)-1;
    debug("iKXPlugin: exception on plugin actions 4\n");
   }
   FreeLibrary(inst);
   if(ret==0)
   {
    return 0;
   }
   debug("iKX plugin: get_guid(): pp(get_guid) failed [%d]\n",ret);
   return -1;
  }
  debug("iKX plugin: get_guid(): getprocaddress failed\n");
  strcpy(error_name,"Invalid FX Library");
  FreeLibrary(inst);
  return -2;
 }
 debug("iKX plugin: get_guid(): loadlibrary failed\n");
 strcpy(error_name,"FX Library not found");
 return -3;
 }
 }

 return -5;
}
int iKX::get_object_count(const char *library) // returns <=0 if failed
{
 int type=get_object_type(library);
 char *func="publish_plugins";
 int ver=KXPLUGIN_VERSION;

 switch(type)
 {
 case KX_OBJECT_DANE:
 case KX_OBJECT_RIFX:
 {
    strcpy(error_name,"Error loading Dane Source");
    iKXDaneSource dane;

    if(dane.init(library,this)==0)
    {
      return 1;
    }
    debug("!! iKX plugin: iKXDaneSource.init failed [%s]\n",library);
    return -5;
 }
 case KX_OBJECT_ADDON:
  func="publish_addons";
  ver=KXADDON_VERSION;
  // fall thru
 case KX_OBJECT_KXL:
 {
    HINSTANCE inst;
    inst=LoadLibrary(library);
    if(inst!=0)
    {
     kxplugin_publish_t pp;
     pp=(kxplugin_publish_t)GetProcAddress(inst,func);
     if(pp)
     {
      uintptr_t ret=0;
      uintptr_t result;

      try
      {
       result=pp(KXPLUGIN_GET_VERSION,ver,&ret);
      }
      catch(...)
      {
       debug("iKXPlugin: exception on getting plugin version\n");
       result=(uintptr_t)-1;
      }
      if(result || (ret!=(dword)ver))
      {
       debug("iKX plugin: get_count(): ret=%d result=%d v=%d\n",ret,result,ver);
       strcpy(error_name,"Invalid Plugin Version");
       return 0;
      }

      uintptr_t num=0;
      try
      {
       ret=pp(KXPLUGIN_GET_COUNT,ver,&num);
      }
      catch(...)
      {
       debug("iKXPlugin: exception on getting plugin count\n");
       ret=(uintptr_t)-1;
      }
      FreeLibrary(inst);
      if(ret==0)
      {
       return (int)num;
      }
      debug("iKX plugin: pp(get_count) failed [%d]\n",ret);
      return 0;
     }
     debug("iKX plugin: get_count(): getprocaddress failed\n");
     strcpy(error_name,"Invalid FX Library");
     FreeLibrary(inst);
     return 0;
    }
    debug("iKX plugin: get_count(): loadlibrary failed [%x]\n",GetLastError());
    strcpy(error_name,"Error loading Plugin DLL");
    return 0;
 }
 }

 return -1;
}
Exemple #29
0
static struct object_type *desktop_get_type( struct object *obj )
{
    static const WCHAR name[] = {'D','e','s','k','t','o','p'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}
Exemple #30
0
static struct object_type *mutex_get_type( struct object *obj )
{
    static const WCHAR name[] = {'M','u','t','a','n','t'};
    static const struct unicode_str str = { name, sizeof(name) };
    return get_object_type( &str );
}