Exemplo n.º 1
0
WdeDialogBoxControl *WdeMem2DialogBoxControl( const uint_8 **pdata, bool is32bit, bool is32bitEx )
{
    WdeDialogBoxControl         *dbc;
    bool                        ok;
    const uint_8                *data;

    dbc = NULL;
    data = NULL;

    ok = (pdata != NULL && *pdata != NULL);

    if( ok ) {
        dbc = WdeAllocDialogBoxControl();
        ok = (dbc != NULL);
    }

    if( ok ) {
        data = *pdata;
        if( is32bitEx ) {
            U32FromMem( data, GETCTL_HELPID( dbc ) );
            U32FromMem( data, GETCTL_EXSTYLE( dbc ) );
            U32FromMem( data, GETCTL_STYLE( dbc ) );
        } else if( is32bit ) {
            U32FromMem( data, GETCTL_STYLE( dbc ) );
            U32FromMem( data, GETCTL_EXSTYLE( dbc ) );
        }
        U16FromMem( data, GETCTL_SIZEX( dbc ) );
        U16FromMem( data, GETCTL_SIZEY( dbc ) );
        U16FromMem( data, GETCTL_SIZEW( dbc ) );
        U16FromMem( data, GETCTL_SIZEH( dbc ) );
        if( is32bitEx ) {
            U32FromMem( data, GETCTL_ID( dbc ) );
        } else {
            U16FromMem( data, GETCTL_ID( dbc ) );
        }
        if( !is32bit ) {
            U32FromMem( data, GETCTL_STYLE( dbc ) );
        }
        SETCTL_CLASSID( dbc, WdeMem2ControlClass( &data, is32bit ) );
        ok = (GETCTL_CLASSID( dbc ) != NULL);
    }

    if( ok ) {
        SETCTL_TEXT( dbc, WdeMem2NameOrOrdinal( &data, is32bit ) );
        ok = (GETCTL_TEXT( dbc ) != NULL);
    }

    if( ok ) {
        if( is32bit ) {
            U16FromMem( data, GETCTL_EXTRABYTES( dbc ) );
        } else {
            U8FromMem( data, GETCTL_EXTRABYTES( dbc ) );
        }
    }

    if( dbc != NULL ) {
        *pdata = data;
        if( !ok ) {
            WdeFreeDialogBoxControl( &dbc );
        }
    }
    return( dbc );
}
Exemplo n.º 2
0
WdeDialogBoxControl *WdeMem2DialogBoxControl( uint_8 **data, Bool is32bit,
                                              Bool is32bitEx )
{
    DialogBoxControl            *c16;
    DialogBoxControl32          *c32;
    DialogBoxExControl32        *c32ex;

    WdeDialogBoxControl *dbc;
    int                 fixedbytes;
    Bool                ok;

    dbc = NULL;

    ok = ( data && *data );

    if( ok ) {
        dbc = WdeAllocDialogBoxControl();
        ok = ( dbc != NULL );
    }

    if( ok ) {
        if( is32bit ) {
            if (is32bitEx) {
                fixedbytes = offsetof( DialogBoxExControl32, ClassID );
                c32ex = (DialogBoxExControl32 *) *data;
                dbc->HelpId = c32ex->HelpId;
                dbc->Style = c32ex->Style;
                dbc->ExtendedStyle = c32ex->ExtendedStyle;
                dbc->Size = c32ex->Size;
                dbc->ID = c32ex->ID;
            } else {
                fixedbytes = offsetof( DialogBoxControl32, ClassID );
                c32 = (DialogBoxControl32 *) *data;
                dbc->Style = c32->Style;
                dbc->ExtendedStyle = c32->ExtendedStyle;
                dbc->Size = c32->Size;
                dbc->ID = c32->ID;
            }
        } else {
            fixedbytes = offsetof( DialogBoxControl, ClassID );
            c16 = (DialogBoxControl *) *data;
            dbc->Size = c16->Size;
            dbc->ID = c16->ID;
            dbc->Style = c16->Style;
        }

        *data += fixedbytes;
        SETCTL_CLASSID( dbc, WdeMem2ControlClass(data, is32bit) );
        ok = ( GETCTL_CLASSID(dbc) != NULL );
    }

    if( ok ) {
        SETCTL_TEXT(dbc, WdeMem2NameOrOrdinal(data, is32bit) );
        ok = ( GETCTL_TEXT(dbc) != NULL );
    }

    if( ok ) {
        if( is32bit ) {
            if (is32bitEx) {
                dbc->ExtraBytes = *((uint_16 *)*data);
            } else {
                dbc->ExtraBytes = *((uint_16 *)*data);
            }
            *data += sizeof(uint_16);
        } else {
            dbc->ExtraBytes = (uint_8)((*data)[0]);
            *data += sizeof(uint_8);
        }
    } else {
        if( dbc != NULL ) {
            WdeFreeDialogBoxControl( &dbc );
        }
    }

    return( dbc );
}
Exemplo n.º 3
0
static size_t WdeDialogBoxControlToMem( WdeDialogBoxControl *control,
                                     uint_8 *data, bool is32bit, bool is32bitEx )
{
    ControlClass            *cclass;
    size_t                  size;
    bool                    ok;
    uint_8                  *start;

    ok = (control != NULL && data != NULL);
    start = NULL;

    if( ok ) {
        start = data;
        if( is32bitEx ) {
            U32ToMem( data, GETCTL_HELPID( control ) );
            U32ToMem( data, GETCTL_EXSTYLE( control ) );
            U32ToMem( data, GETCTL_STYLE( control ) );
        } else if( is32bit ) {
            U32ToMem( data, GETCTL_STYLE( control ) );
            U32ToMem( data, GETCTL_EXSTYLE( control ) );
        }
        U16ToMem( data, GETCTL_SIZEX( control ) );
        U16ToMem( data, GETCTL_SIZEY( control ) );
        U16ToMem( data, GETCTL_SIZEW( control ) );
        U16ToMem( data, GETCTL_SIZEH( control ) );
        if( is32bitEx ) {
            U32ToMem( data, GETCTL_ID( control ) );
        } else {
            U16ToMem( data, GETCTL_ID( control ) );
        }
        if( !is32bit ) {
            U32ToMem( data, GETCTL_STYLE( control ) );
        }
        cclass = GETCTL_CLASSID( control );
        if( cclass->Class & 0x80 ) {
            if( is32bit ) {
                U16ToMem( data, (uint_16)-1 );
                U16ToMem( data, cclass->Class );
            } else {
                U8ToMem( data, cclass->Class );
            }
        } else {
            size = WdeStringToMem( cclass->ClassName, is32bit, data );
            data += size;
            ok = (size != 0);
        }
    }

    if( ok ) {
        size = WdeNameOrOrdToMem( GETCTL_TEXT( control ), is32bit, data );
        data += size;
        ok = (size != 0);
    }

    if( ok ) {
        if( is32bit ) {
            U16ToMem( data, GETCTL_EXTRABYTES( control ) );
        } else {
            U8ToMem( data, GETCTL_EXTRABYTES( control ) );
        }
    }

    if ( ok )
        return( data - start );
    return( 0 );
}
Exemplo n.º 4
0
static int WdeDialogBoxControlToMem( WdeDialogBoxControl *control,
                                     uint_8 *mem, Bool is32bit,
                                     Bool is32bitEx )
{
    DialogBoxControl            *c16;
    DialogBoxControl32          *c32;
    DialogBoxExControl32        *c32ex;

    ControlClass        *cclass;
    int                 pos, size;
    uint_16             *data16;
    Bool                ok;

    ok = ( control && mem );

    if( ok ) {
        if( is32bit ) {
            if( is32bitEx ) {
                pos = offsetof( DialogBoxExControl32, ClassID );
                c32ex = (DialogBoxExControl32 *)mem;
                c32ex->HelpId = control->HelpId;
                c32ex->Style = control->Style;
                c32ex->ExtendedStyle = control->ExtendedStyle;
                c32ex->Size = control->Size;
                c32ex->ID = control->ID;
            } else {
                pos = offsetof( DialogBoxControl32, ClassID );
                c32 = (DialogBoxControl32 *)mem;
                c32->Style = control->Style;
                c32->ExtendedStyle = control->ExtendedStyle;
                c32->Size = control->Size;
                c32->ID = control->ID;
            }
        } else {
            pos = offsetof( DialogBoxControl, ClassID );
            c16 = (DialogBoxControl *)mem;
            c16->Size = control->Size;
            c16->ID = control->ID;
            c16->Style = control->Style;
        }

        cclass = GETCTL_CLASSID( control );
        if( cclass->Class & 0x80 ) {
            if( is32bit ) {
                data16 = (uint_16 *)(mem+pos);
                data16[0] = 0xffff;
                data16[1] = (uint_16)cclass->Class;
                size = sizeof(uint_16)*2;
            } else {
                memcpy( mem+pos, &(cclass->Class), sizeof(uint_8) );
                size = sizeof(uint_8);
            }
        } else {
            size = WdeStringToMem( cclass->ClassName, is32bit, mem+pos );
            ok = ( size != 0 );
        }
    }

    if( ok ) {
        pos += size;
        size = WdeNameOrOrdToMem( GETCTL_TEXT(control), is32bit, mem+pos );
        ok = ( size != 0 );
    }

    if( ok ) {
        pos += size;
        if( is32bit ) {
            memcpy( mem+pos, &control->ExtraBytes, sizeof(uint_16) );
            size = sizeof(uint_16);
        } else {
            uint_8 eb = control->ExtraBytes;
            memcpy( mem+pos, &eb, sizeof(uint_8) );
            size = sizeof(uint_8);
        }
    }

    if ( ok ) {
        pos += size;
    } else {
        pos = 0;
    }

    return ( pos );
}