Ticket #2679: res-endian.patch

File res-endian.patch, 18.1 KB (added by fingolfin, 17 years ago)
  • resource_he.cpp

     
    4040
    4141namespace Scumm {
    4242
     43#define LE16(x)      ((x) = TO_LE_16(x))
     44#define LE32(x)      ((x) = TO_LE_32(x))
     45
     46
    4347ResExtractor::ResExtractor(ScummEngine_v70he *scumm)
    4448        : _vm(scumm) {
    4549
     
    353357        /* calculate total size of output file */
    354358        RETURN_IF_BAD_POINTER(NULL, icondir->count);
    355359        skipped = 0;
    356         for (c = 0 ; c < icondir->count ; c++) {
     360        for (c = 0 ; c < FROM_LE_16(icondir->count) ; c++) {
    357361                int level;
    358362                int iconsize;
    359363                char name[14];
    360364                WinResource *fwr;
    361365
    362366                RETURN_IF_BAD_POINTER(NULL, icondir->entries[c]);
    363                 /*printf("%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\n", c,
    364                         icondir->entries[c].bytes_in_res,
    365                         (is_icon ? icondir->entries[c].res_info.icon.width : icondir->entries[c].res_info.cursor.width),
    366                         (is_icon ? icondir->entries[c].res_info.icon.height : icondir->entries[c].res_info.cursor.height),
    367                         icondir->entries[c].plane_count,
    368                         icondir->entries[c].bit_count);*/
     367                printf("%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\n", c,
     368                        FROM_LE_32(icondir->entries[c].bytes_in_res),
     369                        (is_icon ? icondir->entries[c].res_info.icon.width : FROM_LE_16(icondir->entries[c].res_info.cursor.width)),
     370                        (is_icon ? icondir->entries[c].res_info.icon.height : FROM_LE_16(icondir->entries[c].res_info.cursor.height)),
     371                        FROM_LE_16(icondir->entries[c].plane_count),
     372                        FROM_LE_16(icondir->entries[c].bit_count));
    369373
    370374                /* find the corresponding icon resource */
    371                 snprintf(name, sizeof(name)/sizeof(char), "-%d", icondir->entries[c].res_id);
     375                snprintf(name, sizeof(name)/sizeof(char), "-%d", FROM_LE_16(icondir->entries[c].res_id));
    372376                fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level);
    373377                if (fwr == NULL) {
    374378                        error("%s: could not find `%s' in `%s' resource.",
     
    382386                                skipped++;
    383387                                continue;
    384388                    }
    385                     if ((uint32)iconsize != icondir->entries[c].bytes_in_res) {
     389                    if ((uint32)iconsize != FROM_LE_32(icondir->entries[c].bytes_in_res)) {
    386390                                debugC(DEBUG_RESOURCE, "%s: mismatch of size in icon resource `%s' and group (%d != %d)",
    387                                         fi->file->name(), name, iconsize, icondir->entries[c].bytes_in_res);
     391                                        fi->file->name(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res));
    388392                    }
    389                     size += iconsize; /* size += icondir->entries[c].bytes_in_res; */
     393                    size += iconsize; /* size += FROM_LE_32(icondir->entries[c].bytes_in_res); */
    390394
    391395                    /* cursor resources have two additional WORDs that contain
    392396                     * hotspot info */
     
    394398                        size -= sizeof(uint16)*2;
    395399                }
    396400        }
    397         offset = sizeof(Win32CursorIconFileDir) + (icondir->count-skipped) * sizeof(Win32CursorIconFileDirEntry);
     401        offset = sizeof(Win32CursorIconFileDir) + (FROM_LE_16(icondir->count)-skipped) * sizeof(Win32CursorIconFileDirEntry);
    398402        size += offset;
    399403        *ressize = size;
    400404
     
    405409        /* transfer Win32CursorIconDir structure members */
    406410        fileicondir->reserved = icondir->reserved;
    407411        fileicondir->type = icondir->type;
    408         fileicondir->count = icondir->count - skipped;
     412        fileicondir->count = TO_LE_16(FROM_LE_16(icondir->count) - skipped);
    409413
    410414        /* transfer each cursor/icon: Win32CursorIconDirEntry and data */
    411415        skipped = 0;
    412         for (c = 0 ; c < icondir->count ; c++) {
     416        for (c = 0 ; c < FROM_LE_16(icondir->count) ; c++) {
    413417                int level;
    414418                char name[14];
    415419                WinResource *fwr;
    416420                byte *data;
    417421
    418422                /* find the corresponding icon resource */
    419                 snprintf(name, sizeof(name)/sizeof(char), "-%d", icondir->entries[c].res_id);
     423                snprintf(name, sizeof(name)/sizeof(char), "-%d", FROM_LE_16(icondir->entries[c].res_id));
    420424                fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level);
    421425                if (fwr == NULL) {
    422426                        error("%s: could not find `%s' in `%s' resource.",
     
    430434                        /* get_resource_entry has printed error */
    431435                        return NULL;
    432436                }
    433                 if (size == 0) {
     437        if (size == 0) {
    434438                    skipped++;
    435439                    continue;
    436440                }
     
    442446                /* special treatment for cursors */
    443447                if (!is_icon) {
    444448                        fileicondir->entries[c-skipped].width = icondir->entries[c].res_info.cursor.width;
    445                         fileicondir->entries[c-skipped].height = icondir->entries[c].res_info.cursor.height / 2;
     449                        fileicondir->entries[c-skipped].height = TO_LE_16(FROM_LE_16(icondir->entries[c].res_info.cursor.height) / 2);
    446450                        fileicondir->entries[c-skipped].color_count = 0;
    447451                        fileicondir->entries[c-skipped].reserved = 0;
    448452                }
    449453
    450454                /* set image offset and increase it */
    451                 fileicondir->entries[c-skipped].dib_offset = offset;
     455                fileicondir->entries[c-skipped].dib_offset = TO_LE_32(offset);
    452456
    453457                /* transfer resource into file memory */
    454458                if (is_icon) {
    455                         memcpy(&memory[offset], data, icondir->entries[c].bytes_in_res);
     459                        memcpy(&memory[offset], data, FROM_LE_32(icondir->entries[c].bytes_in_res));
    456460                } else {
    457461                        fileicondir->entries[c-skipped].hotspot_x = ((uint16 *) data)[0];
    458462                        fileicondir->entries[c-skipped].hotspot_y = ((uint16 *) data)[1];
    459463                        memcpy(&memory[offset], data+sizeof(uint16)*2,
    460                                    icondir->entries[c].bytes_in_res-sizeof(uint16)*2);
     464                                   FROM_LE_32(icondir->entries[c].bytes_in_res)-sizeof(uint16)*2);
    461465                        offset -= sizeof(uint16)*2;
    462466                }
    463467
    464468                /* increase the offset pointer */
    465                 offset += icondir->entries[c].bytes_in_res;
     469                offset += FROM_LE_32(icondir->entries[c].bytes_in_res);
    466470        }
    467471
    468472        return memory;
     
    579583
    580584                /* copy each char of the string, and terminate it */
    581585                RETURN_IF_BAD_POINTER(false, *mem);
    582                 len = mem[0];
     586                len = FROM_LE_16(mem[0]);
    583587                RETURN_IF_BAD_OFFSET(false, &mem[1], sizeof(uint16) * len);
    584588
    585                 len = MIN(mem[0], (uint16)WINRES_ID_MAXLEN);
     589                len = MIN(FROM_LE_16(mem[0]), (uint16)WINRES_ID_MAXLEN);
    586590                for (c = 0 ; c < len ; c++)
    587                         wr->id[c] = mem[c+1] & 0x00FF;
     591                        wr->id[c] = FROM_LE_16(mem[c+1]) & 0x00FF;
    588592                wr->id[len] = '\0';
     593                wr->numeric_id = false;
    589594        } else {                                        /* Unicode string id */
    590595                /* translate id into a string */
    591596                snprintf(wr->id, WINRES_ID_MAXLEN, "%d", value);
     597                wr->numeric_id = true;
    592598        }
    593599
    594         wr->numeric_id = (value & IMAGE_RESOURCE_NAME_IS_STRING ? false:true);
    595600        return true;
    596601}
    597602
    598603byte *Win32ResExtractor::get_resource_entry(WinLibrary *fi, WinResource *wr, int *size) {
     604        byte *result;
     605
    599606        if (fi->is_PE_binary) {
    600607                Win32ImageResourceDataEntry *dataent;
    601608
    602609                dataent = (Win32ImageResourceDataEntry *) wr->children;
    603610                RETURN_IF_BAD_POINTER(NULL, *dataent);
    604                 *size = dataent->size;
    605                 RETURN_IF_BAD_OFFSET(NULL, fi->memory + dataent->offset_to_data, *size);
     611                *size = FROM_LE_32(dataent->size);
     612printf("get_resource_entry(PE): size %d, offset_to_data %d\n", *size, FROM_LE_32(dataent->offset_to_data));
    606613
    607                 return fi->memory + dataent->offset_to_data;
     614                result = fi->memory + FROM_LE_32(dataent->offset_to_data);
    608615        } else {
    609616                Win16NENameInfo *nameinfo;
    610617                int sizeshift;
    611618
    612619                nameinfo = (Win16NENameInfo *) wr->children;
    613620                sizeshift = *((uint16 *) fi->first_resource - 1);
    614                 *size = nameinfo->length << sizeshift;
    615                 RETURN_IF_BAD_OFFSET(NULL, fi->memory + (nameinfo->offset << sizeshift), *size);
     621                *size = FROM_LE_16(nameinfo->length) << sizeshift;
     622printf("get_resource_entry(NE): sizeshift %d, size %d, nameinfo->length %d, nameinfo->offset %d\n",
     623                                sizeshift, *size, FROM_LE_16(nameinfo->length), FROM_LE_16(nameinfo->offset));
    616624
    617                 return fi->memory + (nameinfo->offset << sizeshift);
     625                result = fi->memory + (FROM_LE_16(nameinfo->offset) << sizeshift);
    618626        }
     627
     628        RETURN_IF_BAD_OFFSET(NULL, result, *size);
     629
     630        return result;
    619631}
    620632
    621633bool Win32ResExtractor::decode_ne_resource_id(WinLibrary *fi, WinResource *wr, uint16 value) {
    622634        if (value & NE_RESOURCE_NAME_IS_NUMERIC) {              /* numeric id */
    623635                /* translate id into a string */
    624636                snprintf(wr->id, WINRES_ID_MAXLEN, "%d", value & ~NE_RESOURCE_NAME_IS_NUMERIC);
     637                wr->numeric_id = true;
    625638        } else {                                        /* ASCII string id */
    626639                int len;
    627640                char *mem = (char *)NE_HEADER(fi->memory)
     
    630643
    631644                /* copy each char of the string, and terminate it */
    632645                RETURN_IF_BAD_POINTER(false, *mem);
    633                 len = mem[0];
     646                len = FROM_LE_16(mem[0]);
    634647                RETURN_IF_BAD_OFFSET(false, &mem[1], sizeof(char) * len);
    635648                memcpy(wr->id, &mem[1], len);
    636649                wr->id[len] = '\0';
     650                wr->numeric_id = false;
    637651        }
    638652
    639         wr->numeric_id = (value & NE_RESOURCE_NAME_IS_NUMERIC ? true:false);
    640653        return true;
    641654}
    642655
     
    648661
    649662        /* count number of `type' resources */
    650663        RETURN_IF_BAD_POINTER(NULL, *dirent);
    651         rescnt = pe_res->number_of_named_entries + pe_res->number_of_id_entries;
     664        rescnt = FROM_LE_16(pe_res->number_of_named_entries) + FROM_LE_16(pe_res->number_of_id_entries);
    652665        *count = rescnt;
     666printf("list_pe_resources: level %d, count %d\n", level, rescnt);
    653667
    654668        /* allocate WinResource's */
    655669        wr = (WinResource *)malloc(sizeof(WinResource) * rescnt);
     
    659673                RETURN_IF_BAD_POINTER(NULL, dirent[c]);
    660674                wr[c].this_ = pe_res;
    661675                wr[c].level = level;
    662                 wr[c].is_directory = (dirent[c].u2.s.data_is_directory);
    663                 wr[c].children = fi->first_resource + dirent[c].u2.s.offset_to_directory;
     676                wr[c].is_directory = (FROM_LE_32(dirent[c].offset_to_data) & IMAGE_RESOURCE_DATA_IS_DIRECTORY);
     677                wr[c].children = fi->first_resource + (FROM_LE_32(dirent[c].offset_to_data) & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY);
    664678
    665679                /* fill in wr->id, wr->numeric_id */
    666                 if (!decode_pe_resource_id (fi, wr + c, dirent[c].u1.name))
     680                if (!decode_pe_resource_id(fi, wr + c, FROM_LE_32(dirent[c].name)))
    667681                        return NULL;
    668682        }
    669683
     
    678692
    679693        /* count number of `type' resources */
    680694        RETURN_IF_BAD_POINTER(NULL, typeinfo->count);
    681         *count = rescnt = typeinfo->count;
     695        *count = rescnt = FROM_LE_16(typeinfo->count);
    682696
    683697        /* allocate WinResource's */
    684698        wr = (WinResource *)malloc(sizeof(WinResource) * rescnt);
     
    692706                wr[c].level = 1;
    693707
    694708                /* fill in wr->id, wr->numeric_id */
    695                 if (!decode_ne_resource_id(fi, wr + c, (nameinfo+c)->id))
     709                if (!decode_ne_resource_id(fi, wr + c, FROM_LE_16(nameinfo[c].id)))
    696710                        return NULL;
    697711        }
    698712
     
    725739                wr[c].level = 0;
    726740
    727741                /* fill in wr->id, wr->numeric_id */
    728                 if (!decode_ne_resource_id(fi, wr + c, typeinfo->type_id))
     742                if (!decode_ne_resource_id(fi, wr + c, FROM_LE_16(typeinfo->type_id)))
    729743                        return NULL;
    730744
    731745                typeinfo = NE_TYPEINFO_NEXT(typeinfo);
     
    762776bool Win32ResExtractor::read_library(WinLibrary *fi) {
    763777        /* check for DOS header signature `MZ' */
    764778        RETURN_IF_BAD_POINTER(false, MZ_HEADER(fi->memory)->magic);
    765         if (MZ_HEADER(fi->memory)->magic == IMAGE_DOS_SIGNATURE) {
     779        if (FROM_LE_16(MZ_HEADER(fi->memory)->magic) == IMAGE_DOS_SIGNATURE) {
     780printf("Found DOS MZ header...\n");
    766781                DOSImageHeader *mz_header = MZ_HEADER(fi->memory);
    767782
    768783                RETURN_IF_BAD_POINTER(false, mz_header->lfanew);
     784               
     785                // Apply endian fix (currently only lfanew is used from the DOSImageHeader,
     786                // so we don't bother to 'fix' the rest).
     787                LE32(mz_header->lfanew);
     788
    769789                if (mz_header->lfanew < sizeof(DOSImageHeader)) {
    770790                        error("%s: not a Windows library", fi->file->name());
    771791                        return false;
     
    774794
    775795        /* check for OS2 (Win16) header signature `NE' */
    776796        RETURN_IF_BAD_POINTER(false, NE_HEADER(fi->memory)->magic);
    777         if (NE_HEADER(fi->memory)->magic == IMAGE_OS2_SIGNATURE) {
     797        if (FROM_LE_16(NE_HEADER(fi->memory)->magic) == IMAGE_OS2_SIGNATURE) {
    778798                OS2ImageHeader *header = NE_HEADER(fi->memory);
     799printf("Found OS/2 NE header...\n");
    779800
    780801                RETURN_IF_BAD_POINTER(false, header->rsrctab);
    781802                RETURN_IF_BAD_POINTER(false, header->restab);
    782                 if (header->rsrctab >= header->restab) {
     803
     804                if (FROM_LE_16(header->rsrctab) >= FROM_LE_16(header->restab)) {
    783805                        error("%s: no resource directory found", fi->file->name());
    784806                        return false;
    785807                }
    786808
     809                // Apply endian fix
     810                fix_os2_image_header_endian(header);
     811
    787812                fi->is_PE_binary = false;
    788813                fi->first_resource = (byte *) NE_HEADER(fi->memory)
    789814                  + header->rsrctab + sizeof(uint16);
     
    794819
    795820        /* check for NT header signature `PE' */
    796821        RETURN_IF_BAD_POINTER(false, PE_HEADER(fi->memory)->signature);
    797         if (PE_HEADER(fi->memory)->signature == IMAGE_NT_SIGNATURE) {
    798                 Win32ImageSectionHeader *pe_sec;
    799                 Win32ImageDataDirectory *dir;
     822        if (FROM_LE_32(PE_HEADER(fi->memory)->signature) == IMAGE_NT_SIGNATURE) {
     823printf("Found Win PE header...\n");
    800824                Win32ImageNTHeaders *pe_header;
    801825                int d;
    802826
     827                // Fix image header endianess
     828                fix_win32_image_header_endian(PE_HEADER(fi->memory));
     829
    803830                /* allocate new memory */
    804831                fi->total_size = calc_vma_size(fi);
     832printf("calc_vma_size returned %d\n", fi->total_size);
    805833                if (fi->total_size == 0) {
    806834                        /* calc_vma_size has reported error */
    807835                        return false;
     
    815843                /* we don't need to do OFFSET checking for the sections.
    816844                 * calc_vma_size has already done that */
    817845                for (d = pe_header->file_header.number_of_sections - 1; d >= 0 ; d--) {
    818                         pe_sec = PE_SECTIONS(fi->memory) + d;
     846                        Win32ImageSectionHeader *pe_sec = PE_SECTIONS(fi->memory) + d;
    819847
    820                         if (pe_sec->characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
    821                             continue;
     848                        if (pe_sec->characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
     849                                continue;
    822850
    823                         //if (pe_sec->virtual_address + pe_sec->size_of_raw_data > fi->total_size)
     851                        //if (pe_sec->virtual_address + pe_sec->size_of_raw_data > fi->total_size)
    824852
    825                         RETURN_IF_BAD_OFFSET(0, fi->memory + pe_sec->virtual_address, pe_sec->size_of_raw_data);
    826                         RETURN_IF_BAD_OFFSET(0, fi->memory + pe_sec->pointer_to_raw_data, pe_sec->size_of_raw_data);
    827                         if (pe_sec->virtual_address != pe_sec->pointer_to_raw_data) {
    828                             memmove(fi->memory + pe_sec->virtual_address,
    829                                     fi->memory + pe_sec->pointer_to_raw_data,
    830                                     pe_sec->size_of_raw_data);
     853                        RETURN_IF_BAD_OFFSET(0, fi->memory + pe_sec->virtual_address, pe_sec->size_of_raw_data);
     854                        RETURN_IF_BAD_OFFSET(0, fi->memory + pe_sec->pointer_to_raw_data, pe_sec->size_of_raw_data);
     855                        if (FROM_LE_32(pe_sec->virtual_address) != pe_sec->pointer_to_raw_data) {
     856                                memmove(fi->memory + pe_sec->virtual_address,
     857                                                fi->memory + pe_sec->pointer_to_raw_data,
     858                                                pe_sec->size_of_raw_data);
    831859                        }
    832860                }
    833861
    834862                /* find resource directory */
    835863                RETURN_IF_BAD_POINTER(false, pe_header->optional_header.data_directory[IMAGE_DIRECTORY_ENTRY_RESOURCE]);
    836                 dir = pe_header->optional_header.data_directory + IMAGE_DIRECTORY_ENTRY_RESOURCE;
     864                Win32ImageDataDirectory *dir = pe_header->optional_header.data_directory + IMAGE_DIRECTORY_ENTRY_RESOURCE;
    837865                if (dir->size == 0) {
    838866                        error("%s: file contains no resources", fi->file->name());
    839867                        return false;
    840868                }
     869               
     870                fix_win32_image_data_directory(dir);
    841871
    842872                fi->first_resource = fi->memory + dir->virtual_address;
    843873                fi->is_PE_binary = true;
     
    860890        size = 0;
    861891        RETURN_IF_BAD_POINTER(-1, PE_HEADER(fi->memory)->file_header.number_of_sections);
    862892        segcount = PE_HEADER(fi->memory)->file_header.number_of_sections;
     893printf("calc_vma_size: segcount = %d\n", segcount);
    863894
    864895        /* If there are no segments, just process file like it is.
    865896         * This is (probably) not the right thing to do, but problems
     
    872903        RETURN_IF_BAD_POINTER(-1, *seg);
    873904    for (c = 0 ; c < segcount ; c++) {
    874905                RETURN_IF_BAD_POINTER(0, *seg);
     906                fix_win32_image_section_header(seg);
    875907
    876         size = MAX((uint32)size, seg->virtual_address + seg->size_of_raw_data);
     908                size = MAX((uint32)size, seg->virtual_address + seg->size_of_raw_data);
    877909                /* I have no idea what misc.virtual_size is for... */
    878         size = MAX((uint32)size, seg->virtual_address + seg->misc.virtual_size);
    879         seg++;
     910                size = MAX((uint32)size, seg->virtual_address + seg->misc.virtual_size);
     911                seg++;
    880912    }
    881913
    882914    return size;
     
    11131145                                goto cleanup;
    11141146                        } else {
    11151147                                if (entries[c].dib_offset > offset)
    1116                                                 min_offset = MIN(min_offset, entries[c].dib_offset);
     1148                                        min_offset = MIN(min_offset, entries[c].dib_offset);
    11171149                        }
    11181150                }
    11191151
     
    11221154                                error("offset of bitmap header incorrect (too low)");
    11231155                                goto cleanup;
    11241156                        }
     1157                        assert(min_offset != 0x7fffffff);
    11251158                        debugC(DEBUG_RESOURCE, "skipping %d bytes of garbage at %d", min_offset-offset, offset);
    11261159                        in->seek(min_offset - offset, SEEK_CUR);
    11271160                        offset = min_offset;
     
    11581191        return 0;
    11591192}
    11601193
    1161 #define LE16(x)      ((x) = TO_LE_16(x))
    1162 #define LE32(x)      ((x) = TO_LE_32(x))
    1163 
    11641194void Win32ResExtractor::fix_win32_cursor_icon_file_dir_endian(Win32CursorIconFileDir *obj) {
    11651195    LE16(obj->reserved);
    11661196        LE16(obj->type);
     
    12411271    LE32(obj->file_header.number_of_symbols);
    12421272    LE16(obj->file_header.size_of_optional_header);
    12431273    LE16(obj->file_header.characteristics);
     1274
     1275        // FIXME: Does this assert ever trigger? If so, we should modify this function
     1276        // to properly deal with it.
     1277        assert(obj->file_header.size_of_optional_header >= sizeof(obj->optional_header));
    12441278    LE16(obj->optional_header.magic);
    12451279    LE32(obj->optional_header.size_of_code);
    12461280    LE32(obj->optional_header.size_of_initialized_data);
  • resource_he.h

     
    4444#define MZ_HEADER(x)    ((DOSImageHeader *)(x))
    4545#define NE_HEADER(x)    ((OS2ImageHeader *)PE_HEADER(x))
    4646#define NE_TYPEINFO_NEXT(x) ((Win16NETypeInfo *)((byte *)(x) + sizeof(Win16NETypeInfo) + \
    47                                                     ((Win16NETypeInfo *)x)->count * sizeof(Win16NENameInfo)))
     47                                                    FROM_LE_16(((Win16NETypeInfo *)x)->count) * sizeof(Win16NENameInfo)))
    4848#define NE_RESOURCE_NAME_IS_NUMERIC (0x8000)
    4949
    5050#define STRIP_RES_ID_FORMAT(x) (x != NULL && (x[0] == '-' || x[0] == '+') ? ++x : x)
     
    264264        };
    265265
    266266        struct Win32ImageResourceDirectoryEntry {
    267                 union {
    268                         struct {
    269                                 #ifdef SCUMM_BIGENDIAN
    270                                 unsigned name_is_string:1;
    271                                 unsigned name_offset:31;
    272                     #else
    273                                 unsigned name_offset:31;
    274                                 unsigned name_is_string:1;
    275                     #endif
    276                         } s1;
    277                         uint32 name;
    278                         struct {
    279                     #ifdef SCUMM_BIG_ENDIAN
    280                                 uint16 __pad;
    281                                 uint16 id;
    282                     #else
    283                                 uint16 id;
    284                                 uint16 __pad;
    285                     #endif
    286                         } s2;
    287                 } u1;
    288                 union {
    289                         uint32 offset_to_data;
    290                         struct {
    291                     #ifdef SCUMM_BIG_ENDIAN
    292                                 unsigned data_is_directory:1;
    293                                 unsigned offset_to_directory:31;
    294                     #else
    295                                 unsigned offset_to_directory:31;
    296                                 unsigned data_is_directory:1;
    297                     #endif
    298                         } s;
    299                 } u2;
     267                uint32 name;
     268                uint32 offset_to_data;
    300269        };
    301270
    302271        struct Win16NETypeInfo {