Пример #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);
}
Пример #2
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 );
}
Пример #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 );
}
Пример #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 );
}
Пример #5
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 );
}