Beispiel #1
0
 basic_managed_global_memory (open_only_t open_only, const char* name,
                              const void *addr = 0)
    : base_t()
    , base2_t(open_only, name, read_write, addr,
              create_open_func_t(get_this_pointer(),
              DoOpen))
 {}
Beispiel #2
0
void* CDECL MSVCRT___RTDynamicCast(void *cppobj, int unknown,
        type_info *src, type_info *dst,
        int do_throw)
{
    void *ret;

    if (!cppobj) return NULL;

    TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
            cppobj, unknown, src, dbgstr_type_info(src), dst, dbgstr_type_info(dst), do_throw);

    __TRY
    {
        int i;
        const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
        const rtti_object_hierarchy *obj_bases;
        const rtti_base_array *base_array;
        char *base;

        if (TRACE_ON(msvcrt)) dump_obj_locator(obj_locator);

        if(obj_locator->signature == 0)
            base = RtlPcToFileHeader((void*)obj_locator, (void**)&base);
        else
            base = (char*)obj_locator - obj_locator->object_locator;

        obj_bases = (const rtti_object_hierarchy*)(base + obj_locator->type_hierarchy);
        base_array = (const rtti_base_array*)(base + obj_bases->base_classes);

        ret = NULL;
        for (i = 0; i < obj_bases->array_len; i++)
        {
            const rtti_base_descriptor *base_desc = (const rtti_base_descriptor*)(base + base_array->bases[i]);
            const type_info *typ = (const type_info*)(base + base_desc->type_descriptor);

            if (!strcmp(typ->mangled, dst->mangled))
            {
                void *this_ptr = (char *)cppobj - obj_locator->base_class_offset;
                ret = get_this_pointer( &base_desc->offsets, this_ptr );
                break;
            }
        }
        if (!ret && do_throw)
        {
            const char *msg = "Bad dynamic_cast!";
            bad_cast e;
            MSVCRT_bad_cast_ctor( &e, &msg );
            _CxxThrowException( &e, &bad_cast_exception_type );
        }
    }
    __EXCEPT_PAGE_FAULT
    {
        __non_rtti_object e;
        MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
        _CxxThrowException( &e, &bad_typeid_exception_type );
        return NULL;
    }
    __ENDTRY
    return ret;
}
Beispiel #3
0
 //!Connects to a created shared memory and its segment manager.
 //!in read-only mode.
 //!This can throw.
 basic_managed_shared_memory (open_read_only_t, const char* name, 
                              const void *addr = 0)
    : base_t()
    , base2_t(open_only, name, read_only, addr, 
              create_open_func_t(get_this_pointer(), 
              ipcdetail::DoOpen))
 {}
 //!Creates mapped file and creates and places the segment manager if
 //!segment was not created. If segment was created it connects to the
 //!segment.
 //!This can throw.
 basic_managed_mapped_file (open_or_create_t open_or_create,
                            const char *name, std::size_t size, 
                            const void *addr = 0)
    : m_mfile(open_or_create, name, size, read_write, addr, 
              create_open_func_t(get_this_pointer(), 
              detail::DoOpenOrCreate))
 {}
Beispiel #5
0
 basic_managed_global_memory (open_or_create_t open_or_create,
                            const char *name, size_type size,
                            const void *addr = 0, const permissions& perm = permissions())
    : base_t()
    , base2_t(open_or_create, name, size, read_write, addr,
              create_open_func_t(get_this_pointer(),
              DoOpenOrCreate), perm)
 {}
 //!Creates shared memory and creates and places the segment manager if
 //!segment was not created. If segment was created it connects to the
 //!segment.
 //!This can throw.
 basic_managed_windows_shared_memory
    (open_or_create_t open_or_create,
    const char *name, std::size_t size, 
    const void *addr = 0)
    : m_wshm(open_or_create, name, size, read_write, addr, 
              create_open_func_t(get_this_pointer(), 
              detail::DoOpenOrCreate))
 {}
 //!Creates shared memory and creates and places the segment manager if
 //!segment was not created. If segment was created it connects to the
 //!segment.
 //!This can throw.
 basic_managed_windows_shared_memory
    (open_or_create_t open_or_create,
    const char *name, size_type size,
    const void *addr = 0,
    const permissions &perm = permissions())
    : m_wshm(open_or_create, name, size, read_write, addr,
              create_open_func_t(get_this_pointer(),
              ipcdetail::DoOpenOrCreate), perm)
 {}
Beispiel #8
0
 //!Creates shared memory and creates and places the segment manager. 
 //!This can throw.
 basic_managed_shared_memory(create_only_t create_only, const char *name,
                           size_type size, const void *addr = 0, const permissions& perm = permissions())
    : base_t()
    , base2_t(create_only, name, size, read_write, addr, 
              create_open_func_t(get_this_pointer(), ipcdetail::DoCreate), perm)
 {}
 //!Connects to a created mapped file and its segment manager.
 //!This can throw.
 basic_managed_mapped_file (open_only_t open_only, const char* name, 
                            const void *addr = 0)
    : m_mfile(open_only, name, read_write, addr, 
              create_open_func_t(get_this_pointer(), 
              detail::DoOpen))
 {}
 //!Connects to a created shared memory and its segment manager.
 //!This can throw.
 basic_managed_windows_shared_memory
    (open_only_t open_only, const char* name, const void *addr = 0)
    : m_wshm(open_only, name, read_write, addr, 
              create_open_func_t(get_this_pointer(), 
              detail::DoOpen))
 {}
 //!Creates shared memory and creates and places the segment manager. 
 //!This can throw.
 basic_managed_windows_shared_memory
    (create_only_t create_only, const char *name,
     std::size_t size, const void *addr = 0, const permissions &perm = permissions())
    : m_wshm(create_only, name, size, read_write, addr, 
              create_open_func_t(get_this_pointer(), detail::DoCreate), perm)
 {}
Beispiel #12
0
void* CDECL MSVCRT___RTDynamicCast(void *cppobj, int unknown,
                                   type_info *src, type_info *dst,
                                   int do_throw)
{
    void *ret;

    if (!cppobj) return NULL;

    TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
          cppobj, unknown, src, dbgstr_type_info(src), dst, dbgstr_type_info(dst), do_throw);

    /* To cast an object at runtime:
     * 1.Find out the true type of the object from the typeinfo at vtable[-1]
     * 2.Search for the destination type in the class hierarchy
     * 3.If destination type is found, return base object address + dest offset
     *   Otherwise, fail the cast
     *
     * FIXME: the unknown parameter doesn't seem to be used for anything
     */
    __TRY
    {
        int i;
        const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
        const rtti_object_hierarchy *obj_bases = obj_locator->type_hierarchy;
        const rtti_base_descriptor * const* base_desc = obj_bases->base_classes->bases;

        if (TRACE_ON(msvcrt)) dump_obj_locator(obj_locator);

        ret = NULL;
        for (i = 0; i < obj_bases->array_len; i++)
        {
            const type_info *typ = base_desc[i]->type_descriptor;

            if (!strcmp(typ->mangled, dst->mangled))
            {
                /* compute the correct this pointer for that base class */
                void *this_ptr = (char *)cppobj - obj_locator->base_class_offset;
                ret = get_this_pointer( &base_desc[i]->offsets, this_ptr );
                break;
            }
        }
        /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned
         * to a reference, since references cannot be NULL.
         */
        if (!ret && do_throw)
        {
            const char *msg = "Bad dynamic_cast!";
            bad_cast e;
            MSVCRT_bad_cast_ctor( &e, &msg );
            _CxxThrowException( &e, &bad_cast_exception_type );
        }
    }
    __EXCEPT_PAGE_FAULT
    {
        __non_rtti_object e;
        MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
        _CxxThrowException( &e, &bad_typeid_exception_type );
        return NULL;
    }
    __ENDTRY
    return ret;
}
 //!Constructor. Takes a pointer to the
 //!segment manager. Can throw
 iunordered_set_index(segment_manager_base *mngr)
    :  allocator_holder(mngr)
    ,  index_type(bucket_traits(&get_this_pointer()->init_bucket, 1))
 {}
 //!Creates shared memory and creates and places the segment manager. 
 //!This can throw.
 basic_managed_shared_memory(create_only_t create_only, const char *name,
                           std::size_t size, const void *addr = 0)
    : base_t()
    , base2_t(create_only, name, size, read_write, addr, 
              create_open_func_t(get_this_pointer(), detail::DoCreate))
 {}