Exemplo n.º 1
0
bool ResReadMenuExItem( MenuExItem *curritem, WResFileID handle )
/***************************************************************/
{
    bool               error;
    uint_32            type, state, id, helpId;
    uint_16            resInfo;

    state = 0;
    id = 0;
    resInfo = 0;

    // Store first structure members in temporary variables until
    // we know whether or not the item is a MenuExItemNormal or a
    // MenuExItemPopup

    error = ResReadUint32( &type, handle );
    if( !error ) {
        error = ResReadUint32( &state, handle );
    }
    if( !error ) {
        error = ResReadUint32( &id, handle );
    }
    if( !error ) {
        error = ResReadUint16( &resInfo, handle );
    }

    // Determine if this is a normal menu item or a popup menu item

    if( resInfo & MENUEX_POPUP ) {
        curritem->IsPopup = true;
        curritem->Item.ExPopup.Popup.ItemFlags = resInfo;
        curritem->Item.ExPopup.ExData.ItemId = id;
        curritem->Item.ExPopup.ExData.ItemType = type;
        curritem->Item.ExPopup.ExData.ItemState = state;
        curritem->Item.ExPopup.Popup.ItemText = ResRead32String( handle, NULL );

        // Careful! The string is DWORD aligned.
        ResPadDWord( handle );
        error = ResReadUint32( &helpId, handle );
        curritem->Item.ExPopup.ExData.HelpId = helpId;
    } else {
        curritem->IsPopup = false;
        curritem->Item.ExNormal.Normal.ItemFlags = resInfo;
        curritem->Item.ExNormal.Normal.ItemID = id;
        curritem->Item.ExNormal.Normal.ItemText = ResRead32String( handle, NULL );

        // Careful! The string is DWORD aligned.
        ResPadDWord( handle );
        curritem->Item.ExNormal.ExData.ItemType = type;
        curritem->Item.ExNormal.ExData.ItemState = state;
    }

    return( error );
}
Exemplo n.º 2
0
WResTypeNode *WRReadWResTypeNodeFromExe( WResFileID file_handle, uint_16 align_shift )
{
    uint_16         type_id;
    uint_16         resource_count;
    uint_32         reserved;
    WResTypeNode    *type_node;
    WResResNode     *res_node;

    ResReadUint16( &type_id, file_handle );
    if( type_id == 0x0000 ) {
        return( NULL );
    }

    type_node = (WResTypeNode *)WRMemAlloc( sizeof( WResTypeNode ) );
    if( type_node == NULL ) {
        return( NULL );
    }

    ResReadUint16( &resource_count, file_handle );
    ResReadUint32( &reserved, file_handle );

    type_node->Next = NULL;
    type_node->Prev = NULL;
    type_node->Head = NULL;
    type_node->Tail = NULL;
    type_node->Info.NumResources = resource_count;
    if( type_id & 0x8000 ) {
        type_node->Info.TypeName.IsName = FALSE;
    } else {
        type_node->Info.TypeName.IsName = TRUE;
    }
    type_node->Info.TypeName.ID.Num = (type_id & 0x7fff);

    for( ; resource_count != 0; resource_count-- ) {
        res_node = WRReadWResResNodeFromExe( file_handle, align_shift );
        if( type_node->Head == NULL ) {
            type_node->Head = res_node;
        }
        if( type_node->Tail != NULL ) {
            type_node->Tail->Next = res_node;
        }
        res_node->Prev = type_node->Tail;
        type_node->Tail = res_node;
    }

    return( type_node );
}
Exemplo n.º 3
0
MResResourceHeader *MResReadResourceHeader( WResFileID handle )
/*************************************************************/
{
    MResResourceHeader     *newhead;
    int                     error;
    uint_16                 tmp16;
    uint_32                 tmp32;

    newhead = WRESALLOC( sizeof(MResResourceHeader) );
    if( newhead == NULL ) {
        error = TRUE;
        WRES_ERROR( WRS_MALLOC_FAILED );
    } else {
        error = FALSE;
    }

    if (!error) {
        newhead->Type = ResReadNameOrOrdinal( handle );
        error = (newhead->Type == NULL);
    }
    if (!error) {
        newhead->Name = ResReadNameOrOrdinal( handle );
        error = (newhead->Name == NULL);
    }
    if (!error) {
        error = ResReadUint16( &tmp16, handle);
        newhead->MemoryFlags = tmp16;
    }
    if (!error) {
        error = ResReadUint32( &tmp32, handle );
        newhead->Size = tmp32;
    }

    if (error && newhead != NULL) {
        WRESFREE( newhead );
        newhead = NULL;
    }

    return( newhead );
} /* MResReadResourceHeader */
Exemplo n.º 4
0
extern M32ResResourceHeader *M32ResReadResourceHeader( WResFileID handle )
/************************************************************************/
{
    M32ResResourceHeader     *newhead;
    int                       error = FALSE;
    uint_16                   tmp16;
    uint_32                   tmp32;

    newhead = WRESALLOC( sizeof( M32ResResourceHeader ) );
    if( newhead == NULL ) {
        error = TRUE;
        WRES_ERROR( WRS_MALLOC_FAILED );
    }
    newhead->head16 = WRESALLOC( sizeof( MResResourceHeader ) );
    if( newhead->head16 == NULL ) {
        error = TRUE;
        WRES_ERROR( WRS_MALLOC_FAILED );
    }
    if( !error ) {
        error = ResPadDWord( handle );
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Size = tmp32;
    }
    if( !error ) {
        error = ResReadUint32( &(newhead->HeaderSize), handle );
    }
    if( !error ) {
        newhead->head16->Type = ResRead32NameOrOrdinal( handle );
        error = (newhead->head16->Type == NULL );
    }
    if( !error ) {
        newhead->head16->Name = ResRead32NameOrOrdinal( handle );
        error = (newhead->head16->Name == NULL );
    }
    if( !error ) {
        error = ResPadDWord( handle );
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->DataVersion = tmp32;
    }
    if( !error ) {
        error = ResReadUint16( &tmp16, handle );
        newhead->head16->MemoryFlags = tmp16;
    }
    if( !error ) {
        error = ResReadUint16( &tmp16, handle );
        newhead->head16->LanguageId = tmp16;
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Version = tmp32;
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Characteristics = tmp32;
    }
    if( error && newhead != NULL ) {
        WRESFREE( newhead->head16 );
        WRESFREE( newhead );
        newhead = NULL;
    }

    return( newhead );
}