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 ); }
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 ); }
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 ); }