Beispiel #1
0
static int WdeDialogBoxExHeaderToMem( WdeDialogBoxHeader *dhd, uint_8 *mem )
{
    int       pos, size;
    uint_16   miscbytes[2] = { 0x0001, 0xFFFF };

    /* copy the miscellaneous two WORDs 01 00 FF FF */
    memcpy(mem, miscbytes, sizeof(miscbytes));
    pos = sizeof(miscbytes);

    memcpy( mem+pos, &dhd->HelpId, sizeof(uint_32) );
    pos += sizeof(uint_32);

    memcpy( mem+pos, &dhd->ExtendedStyle, sizeof(uint_32) );
    pos += sizeof(uint_32);

    memcpy( mem+pos, &dhd->Style, sizeof(uint_32) );
    pos += sizeof(uint_32);

    memcpy( mem+pos, &dhd->NumOfItems, sizeof(uint_16) );
    pos += sizeof(uint_16);

    memcpy( mem+pos, &dhd->Size, sizeof(DialogSizeInfo) );
    pos += sizeof(DialogSizeInfo);

    size = WdeNameOrOrdToMem(GETHDR_MENUNAME(dhd), dhd->is32bit, mem+pos);
    pos += size;

    size = WdeNameOrOrdToMem(GETHDR_CLASSNAME(dhd), dhd->is32bit, mem+pos);
    pos += size;

    size = WdeStringToMem(GETHDR_CAPTION(dhd), dhd->is32bit, mem+pos);
    pos += size;

    if (GETHDR_STYLE(dhd) & DS_SETFONT) {
        memcpy( mem+pos, &dhd->PointSize, sizeof(uint_16) );
        pos += sizeof(uint_16);

        memcpy( mem+pos, &dhd->FontWeight, sizeof(uint_16) );
        pos += sizeof(uint_16);

        memcpy( mem+pos, &dhd->FontItalic, sizeof(uint_16) );
        pos += sizeof(uint_16);

        size = WdeStringToMem( dhd->FontName, dhd->is32bit, mem+pos );
        pos += size;
    }

    return(pos);
}
Beispiel #2
0
WdeDialogBoxHeader *WdeMem2DialogBoxHeader( const uint_8 **pdata, bool is32bit, bool is32bitEx )
{
    WdeDialogBoxHeader  *dbh;
    bool                ok;
    const uint_8        *data;

    dbh = NULL;
    data = NULL;

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

    if( ok ) {
        dbh = WdeAllocDialogBoxHeader();
        ok = (dbh != NULL);
    }

    if( ok ) {
        data = *pdata;
        dbh->symbol = NULL;
        dbh->helpsymbol = NULL;
        dbh->is32bit = is32bit;
        dbh->is32bitEx = is32bitEx;
        if( is32bitEx ) {
            /* skip the miscellaneous two WORDs 0x0001, 0xFFFF */
            data += 2 * sizeof( uint_16 );
            U32FromMem( data, GETHDR_HELPID( dbh ) );
            U32FromMem( data, GETHDR_EXSTYLE( dbh ) );
            U32FromMem( data, GETHDR_STYLE( dbh ) );
        } else if( is32bit ) {
            U32FromMem( data, GETHDR_STYLE( dbh ) );
            U32FromMem( data, GETHDR_EXSTYLE( dbh ) );
        } else {
            U32FromMem( data, GETHDR_STYLE( dbh ) );
        }
        if( is32bit ) {
            U16FromMem( data, GETHDR_NUMITEMS( dbh ) );
        } else {
            U8FromMem( data, GETHDR_NUMITEMS( dbh ) );
        }
        U16FromMem( data, GETHDR_SIZEX( dbh ) );
        U16FromMem( data, GETHDR_SIZEY( dbh ) );
        U16FromMem( data, GETHDR_SIZEW( dbh ) );
        U16FromMem( data, GETHDR_SIZEH( dbh ) );

        SETHDR_MENUNAME( dbh, WdeMem2NameOrOrdinal( &data, is32bit ) );
        ok = (GETHDR_MENUNAME( dbh ) != NULL);
    }

    if( ok ) {
        SETHDR_CLASSNAME( dbh, WdeMem2NameOrOrdinal( &data, is32bit ) );
        ok = (GETHDR_CLASSNAME( dbh ) != NULL);
    }

    if( ok ) {
        SETHDR_CAPTION( dbh, WdeMem2String( &data, is32bit ) );
        ok = (GETHDR_CAPTION( dbh ) != NULL);
    }

    if( ok ) {
        if( GETHDR_STYLE( dbh ) & DS_SETFONT ) {
            U16FromMem( data, GETHDR_POINTSIZE( dbh ) );
            if( is32bitEx ) {
                U16FromMem( data, GETHDR_FONTWEIGHT( dbh ) );
                U8FromMem( data, GETHDR_FONTITALIC( dbh ) );
                U8FromMem( data, GETHDR_FONTCHARSET( dbh ) );
            }
            SETHDR_FONTNAME( dbh, WdeMem2String( &data, is32bit ) );
            ok = (GETHDR_FONTNAME( dbh ) != NULL);
        } else {
            SETHDR_POINTSIZE( dbh, 0 );
            SETHDR_FONTNAME( dbh, NULL );
        }
    }

    if( dbh != NULL ) {
        *pdata = data;
        if( !ok ) {
            WdeFreeDialogBoxHeader( &dbh );
        }
    }
    return( dbh );
}
Beispiel #3
0
static size_t WdeDialogBoxHeaderToMem( WdeDialogBoxHeader *head, uint_8 *data )
{
    bool                ok;
    size_t              size;
    uint_8              *start;

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

    if( ok ) {
        start = data;
        if( head->is32bitEx ) {
            /* copy the miscellaneous two WORDs 0x0001, 0xFFFF */
            U16ToMem( data, 0x0001 );
            U16ToMem( data, 0xFFFF );
            U32ToMem( data, GETHDR_HELPID( head ) );
            U32ToMem( data, GETHDR_EXSTYLE( head ) );
            U32ToMem( data, GETHDR_STYLE( head ) );
        } else if( head->is32bit ) {
            U32ToMem( data, GETHDR_STYLE( head ) );
            U32ToMem( data, GETHDR_EXSTYLE( head ) );
        } else {
            U32ToMem( data, GETHDR_STYLE( head ) );
        }
        if( head->is32bit ) {
            U16ToMem( data, GETHDR_NUMITEMS( head ) );
        } else {
            U8ToMem( data, GETHDR_NUMITEMS( head ) );
        }
        U16ToMem( data, GETHDR_SIZEX( head ) );
        U16ToMem( data, GETHDR_SIZEY( head ) );
        U16ToMem( data, GETHDR_SIZEW( head ) );
        U16ToMem( data, GETHDR_SIZEH( head ) );
    }

    if( ok ) {
        size = WdeNameOrOrdToMem( GETHDR_MENUNAME( head ), head->is32bit, data );
        data += size;
        ok = (size != 0);
    }

    if( ok ) {
        size = WdeNameOrOrdToMem( GETHDR_CLASSNAME( head ), head->is32bit, data );
        data += size;
        ok = (size != 0);
    }

    if( ok ) {
        size = WdeStringToMem( GETHDR_CAPTION( head ), head->is32bit, data );
        data += size;
        ok = (size != 0);
    }

    if( ok ) {
        if( GETHDR_STYLE( head ) & DS_SETFONT ) {
            U16ToMem( data, GETHDR_POINTSIZE( head ) );
            if( head->is32bitEx ) {
                U16ToMem( data, GETHDR_FONTWEIGHT( head ) );
                U8ToMem( data, GETHDR_FONTITALIC( head ) );
                U8ToMem( data, GETHDR_FONTCHARSET( head ) );
            }
            size = WdeStringToMem( GETHDR_FONTNAME( head ), head->is32bit, data );
            data += size;
            ok = (size != 0);
        }
    }

    if( ok )
        return( data - start );
    return( 0 );
}
Beispiel #4
0
WdeDialogBoxHeader *WdeMem2DialogBoxExHeader( uint_8 **data )
{
    uint_16             miscbytes[2] = { 0x0001, 0xFFFF };
    WdeDialogBoxHeader  *dbh;
    Bool                ok;

    dbh = NULL;

    if ( !data || !*data ) {
        return(NULL);
    }

    dbh = WdeAllocDialogBoxHeader();
    if ( dbh == NULL ) {
        return(NULL);
    }

    dbh->is32bit    = TRUE;
    dbh->is32bitEx  = TRUE;

    /* skip the miscellaneous two WORDs 01 00 FF FF */
    *data += sizeof(miscbytes);

    memcpy( &dbh->HelpId, *data, sizeof(uint_32) );
    *data += sizeof(uint_32);

    memcpy( &dbh->ExtendedStyle, *data, sizeof(uint_32) );
    *data += sizeof(uint_32);

    memcpy( &dbh->Style, *data, sizeof(uint_32) );
    *data += sizeof(uint_32);

    memcpy( &dbh->NumOfItems, *data, sizeof(uint_16) );
    *data += sizeof(uint_16);

    memcpy( &dbh->Size, *data, sizeof(DialogSizeInfo) );
    *data += sizeof(DialogSizeInfo);

    SETHDR_MENUNAME(dbh, WdeMem2NameOrOrdinal( data, TRUE ) );
    ok = ( GETHDR_MENUNAME(dbh) != NULL );

    if( ok ) {
        SETHDR_CLASSNAME( dbh, WdeMem2NameOrOrdinal( data, TRUE ) );
        ok = ( GETHDR_CLASSNAME(dbh) != NULL );
    }

    if( ok ) {
        SETHDR_CAPTION( dbh, WdeMem2String( data, TRUE ) );
        ok = ( GETHDR_CAPTION(dbh) != NULL );
    }

    if( ok ) {
        if( GETHDR_STYLE(dbh) & DS_SETFONT ) {
            dbh->FontWeightDefined = TRUE;
            dbh->FontItalicDefined = TRUE;
            SETHDR_POINTSIZE( dbh, *((uint_16 *)*data) );
            *data += sizeof(uint_16);
            SETHDR_FONTWEIGHT( dbh, *((uint_16 *)*data) );
            *data += sizeof(uint_16);
            SETHDR_FONTITALIC( dbh, *((uint_16 *)*data) );
            *data += sizeof(uint_16);
            SETHDR_FONTNAME( dbh, WdeMem2String( data, TRUE ) );
            ok = ( GETHDR_FONTNAME(dbh) != NULL );
        }
    }

    if( !ok ) {
        if( dbh ) {
            WdeFreeDialogBoxHeader ( &dbh );
        }
    }

    return( dbh );
}
Beispiel #5
0
WdeDialogBoxHeader *WdeMem2DialogBoxHeader( uint_8 **data, Bool is32bit )
{
    DialogBoxHeader32   *h32;
    DialogBoxHeader     *h16;
    WdeDialogBoxHeader  *dbh;
    int                 fixedbytes;
    Bool                ok;

    dbh = NULL;

    ok = ( data && *data );

    if( ok ) {
        dbh = WdeAllocDialogBoxHeader();
        ok = ( dbh != NULL );
    }

    if( ok ) {
        dbh->symbol      = NULL;
        dbh->helpsymbol  = NULL;
        dbh->is32bit     = is32bit;
        dbh->is32bitEx   = FALSE;
        if( is32bit ) {
            fixedbytes = offsetof( DialogBoxHeader32, MenuName );
            h32 = (DialogBoxHeader32 *)*data;
            dbh->Style = h32->Style;
            dbh->ExtendedStyle = h32->ExtendedStyle;
            dbh->NumOfItems = h32->NumOfItems;
            dbh->Size = h32->Size;
        } else {
            fixedbytes = offsetof( DialogBoxHeader, MenuName );
            h16 = (DialogBoxHeader *)*data;
            dbh->Style = h16->Style;
            dbh->NumOfItems = h16->NumOfItems;
            dbh->Size = h16->Size;
        }
        *data += fixedbytes;
        SETHDR_MENUNAME(dbh, WdeMem2NameOrOrdinal( data, is32bit ) );
        ok = ( GETHDR_MENUNAME(dbh) != NULL );
    }

    if( ok ) {
        SETHDR_CLASSNAME( dbh, WdeMem2NameOrOrdinal( data, is32bit ) );
        ok = ( GETHDR_CLASSNAME(dbh) != NULL );
    }

    if( ok ) {
        SETHDR_CAPTION( dbh, WdeMem2String( data, is32bit ) );
        ok = ( GETHDR_CAPTION(dbh) != NULL );
    }

    if( ok ) {
        if( GETHDR_STYLE(dbh) & DS_SETFONT ) {
            SETHDR_POINTSIZE( dbh, *( (uint_16 *)*data ) );
            *data += sizeof(uint_16);
            SETHDR_FONTNAME( dbh, WdeMem2String( data, is32bit ) );
            ok = ( GETHDR_FONTNAME(dbh) != NULL );
        } else {
            SETHDR_POINTSIZE( dbh, 0 );
            SETHDR_FONTNAME( dbh, NULL );
        }
    }

    if( !ok ) {
        if( dbh ) {
            WdeFreeDialogBoxHeader ( &dbh );
        }
    }

    return( dbh );
}
Beispiel #6
0
static int WdeDialogBoxHeaderToMem( WdeDialogBoxHeader *head, uint_8 *mem )
{
    Bool                ok;
    int                 pos, size;
    uint_16             pointsize;
    DialogBoxHeader32   h32;
    DialogBoxHeader     h16;
    void                *d;

    ok = ( head && mem );

    if( ok ) {
        if( head->is32bit ) {
            pos = offsetof( DialogBoxHeader32, MenuName );
            h32.Style = head->Style;
            h32.ExtendedStyle = head->ExtendedStyle;
            h32.NumOfItems = head->NumOfItems;
            h32.Size = head->Size;
            d = &h32;
        } else {
            pos = offsetof( DialogBoxHeader, MenuName );
            h16.Style = head->Style;
            h16.NumOfItems = head->NumOfItems;
            h16.Size = head->Size;
            d = &h16;
        }
        ok = ( pos != 0 );
    }

    if( ok ) {
        memcpy( mem, d, pos );
        size = WdeNameOrOrdToMem( GETHDR_MENUNAME(head), head->is32bit, mem+pos );
        ok = ( size != 0 );
    }

    if( ok ) {
        pos += size;
        size = WdeNameOrOrdToMem( GETHDR_CLASSNAME(head), head->is32bit, mem+pos );
        ok = ( size != 0 );
    }

    if( ok ) {
        pos += size;
        size = WdeStringToMem( GETHDR_CAPTION(head), head->is32bit, mem+pos );
        ok = ( size != 0 );
    }

    if( ok && ( GETHDR_STYLE(head) & DS_SETFONT ) ) {
        pos += size;
        pointsize = GETHDR_POINTSIZE(head);
        memcpy( mem+pos, &pointsize, sizeof(uint_16) );
        pos += sizeof(uint_16);
        size = WdeStringToMem( GETHDR_FONTNAME(head), head->is32bit, mem+pos );
        ok = ( size != 0 );
    }

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

    return( pos );
}