mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
Support for big-endian systems.
This commit is contained in:
parent
db7fc1cd58
commit
ff25db08a5
1 changed files with 105 additions and 1 deletions
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
There is still some work to be done:
|
There is still some work to be done:
|
||||||
|
|
||||||
- currently no support for big-endian machines
|
|
||||||
- the ERF error structure aren't used on error
|
- the ERF error structure aren't used on error
|
||||||
- no real compression yet
|
- no real compression yet
|
||||||
- unknown behaviour if files>4GB or cabinet >4GB
|
- unknown behaviour if files>4GB or cabinet >4GB
|
||||||
|
@ -44,6 +43,7 @@ There is still some work to be done:
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
|
#include "winternl.h"
|
||||||
#include "fci.h"
|
#include "fci.h"
|
||||||
#include "cabinet.h"
|
#include "cabinet.h"
|
||||||
|
|
||||||
|
@ -442,7 +442,41 @@ static cab_ULONG fci_get_checksum(void *pv, UINT cb, CHECKSUM seed)
|
||||||
} /* end of fci_get_checksum */
|
} /* end of fci_get_checksum */
|
||||||
|
|
||||||
|
|
||||||
|
static inline cab_ULONG fci_set_little_endian_ulong( cab_ULONG i )
|
||||||
|
{
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
return RtlUlongByteSwap( i );
|
||||||
|
#else
|
||||||
|
return i;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline cab_ULONG fci_get_little_endian_ulong( cab_ULONG i )
|
||||||
|
{
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
return RtlUlongByteSwap( i );
|
||||||
|
#else
|
||||||
|
return i;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline cab_UWORD fci_set_little_endian_uword( cab_UWORD i )
|
||||||
|
{
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
return RtlUshortByteSwap( i );
|
||||||
|
#else
|
||||||
|
return i;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline cab_UWORD fci_get_little_endian_uword( cab_UWORD i )
|
||||||
|
{
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
return RtlUshortByteSwap( i );
|
||||||
|
#else
|
||||||
|
return i;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveCFData,
|
static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveCFData,
|
||||||
|
@ -599,12 +633,19 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
pcfdata->cbData=fci_set_little_endian_uword(pcfdata->cbData);
|
||||||
|
pcfdata->cbUncomp=fci_set_little_endian_uword(pcfdata->cbUncomp);
|
||||||
|
|
||||||
/* get checksum and write to cfdata.csum */
|
/* get checksum and write to cfdata.csum */
|
||||||
pcfdata->csum = fci_get_checksum( &(pcfdata->cbData),
|
pcfdata->csum = fci_get_checksum( &(pcfdata->cbData),
|
||||||
sizeof(CFDATA)+cbReserveCFData -
|
sizeof(CFDATA)+cbReserveCFData -
|
||||||
sizeof(pcfdata->csum), fci_get_checksum( p_fci_internal->data_out, /*buffer*/
|
sizeof(pcfdata->csum), fci_get_checksum( p_fci_internal->data_out, /*buffer*/
|
||||||
pcfdata->cbData, 0 ) );
|
pcfdata->cbData, 0 ) );
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
pcfdata->csum=fci_set_little_endian_ulong(pcfdata->csum);
|
||||||
|
|
||||||
/* write cfdata with checksum to p_fci_internal->handleCFDATA2 */
|
/* write cfdata with checksum to p_fci_internal->handleCFDATA2 */
|
||||||
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
|
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
|
||||||
buffer, /* memory buffer */
|
buffer, /* memory buffer */
|
||||||
|
@ -617,6 +658,11 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
|
||||||
|
|
||||||
p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData;
|
p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData;
|
||||||
|
|
||||||
|
/* reset little endian */
|
||||||
|
pcfdata->cbData=fci_get_little_endian_uword(pcfdata->cbData);
|
||||||
|
pcfdata->cbUncomp=fci_get_little_endian_uword(pcfdata->cbUncomp);
|
||||||
|
pcfdata->csum=fci_get_little_endian_ulong(pcfdata->csum);
|
||||||
|
|
||||||
/* write compressed data into p_fci_internal->handleCFDATA2 */
|
/* write compressed data into p_fci_internal->handleCFDATA2 */
|
||||||
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
|
if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */
|
||||||
p_fci_internal->data_out, /* memory buffer */
|
p_fci_internal->data_out, /* memory buffer */
|
||||||
|
@ -649,6 +695,7 @@ static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveC
|
||||||
|
|
||||||
/* reset checksum, it will be computed later */
|
/* reset checksum, it will be computed later */
|
||||||
pcfdata->csum=0;
|
pcfdata->csum=0;
|
||||||
|
|
||||||
/* write cfdata WITHOUT checksum to handleCFDATA1new */
|
/* write cfdata WITHOUT checksum to handleCFDATA1new */
|
||||||
if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */
|
if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */
|
||||||
buffer, /* memory buffer */
|
buffer, /* memory buffer */
|
||||||
|
@ -965,6 +1012,14 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne
|
||||||
cffile.iFolder=cffileCONTINUED_TO_NEXT;
|
cffile.iFolder=cffileCONTINUED_TO_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
cffile.cbFile=fci_set_little_endian_ulong(cffile.cbFile);
|
||||||
|
cffile.uoffFolderStart=fci_set_little_endian_ulong(cffile.uoffFolderStart);
|
||||||
|
cffile.iFolder=fci_set_little_endian_uword(cffile.iFolder);
|
||||||
|
cffile.date=fci_set_little_endian_uword(cffile.date);
|
||||||
|
cffile.time=fci_set_little_endian_uword(cffile.time);
|
||||||
|
cffile.attribs=fci_set_little_endian_uword(cffile.attribs);
|
||||||
|
|
||||||
/* write cffile to p_fci_internal->handleCFFILE2 */
|
/* write cffile to p_fci_internal->handleCFFILE2 */
|
||||||
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
|
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
|
||||||
&cffile, /* memory buffer */
|
&cffile, /* memory buffer */
|
||||||
|
@ -977,6 +1032,14 @@ static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1ne
|
||||||
|
|
||||||
p_fci_internal->sizeFileCFFILE2 += sizeof(cffile);
|
p_fci_internal->sizeFileCFFILE2 += sizeof(cffile);
|
||||||
|
|
||||||
|
/* reset little endian */
|
||||||
|
cffile.cbFile=fci_get_little_endian_ulong(cffile.cbFile);
|
||||||
|
cffile.uoffFolderStart=fci_get_little_endian_ulong(cffile.uoffFolderStart);
|
||||||
|
cffile.iFolder=fci_get_little_endian_uword(cffile.iFolder);
|
||||||
|
cffile.date=fci_get_little_endian_uword(cffile.date);
|
||||||
|
cffile.time=fci_get_little_endian_uword(cffile.time);
|
||||||
|
cffile.attribs=fci_get_little_endian_uword(cffile.attribs);
|
||||||
|
|
||||||
/* write file name to p_fci_internal->handleCFFILE2 */
|
/* write file name to p_fci_internal->handleCFFILE2 */
|
||||||
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
|
if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */
|
||||||
p_fci_internal->data_out, /* memory buffer */
|
p_fci_internal->data_out, /* memory buffer */
|
||||||
|
@ -1580,6 +1643,18 @@ static BOOL fci_flush_cabinet(
|
||||||
cfheader.iCabinet = p_fci_internal->pccab->iCab-1;
|
cfheader.iCabinet = p_fci_internal->pccab->iCab-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
cfheader.reserved1=fci_set_little_endian_ulong(cfheader.reserved1);
|
||||||
|
cfheader.cbCabinet=fci_set_little_endian_ulong(cfheader.cbCabinet);
|
||||||
|
cfheader.reserved2=fci_set_little_endian_ulong(cfheader.reserved2);
|
||||||
|
cfheader.coffFiles=fci_set_little_endian_ulong(cfheader.coffFiles);
|
||||||
|
cfheader.reserved3=fci_set_little_endian_ulong(cfheader.reserved3);
|
||||||
|
cfheader.cFolders=fci_set_little_endian_uword(cfheader.cFolders);
|
||||||
|
cfheader.cFiles=fci_set_little_endian_uword(cfheader.cFiles);
|
||||||
|
cfheader.flags=fci_set_little_endian_uword(cfheader.flags);
|
||||||
|
cfheader.setID=fci_set_little_endian_uword(cfheader.setID);
|
||||||
|
cfheader.iCabinet=fci_set_little_endian_uword(cfheader.iCabinet);
|
||||||
|
|
||||||
/* write CFHEADER into cabinet file */
|
/* write CFHEADER into cabinet file */
|
||||||
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
||||||
&cfheader, /* memory buffer */
|
&cfheader, /* memory buffer */
|
||||||
|
@ -1590,6 +1665,18 @@ static BOOL fci_flush_cabinet(
|
||||||
}
|
}
|
||||||
/* TODO error handling of err */
|
/* TODO error handling of err */
|
||||||
|
|
||||||
|
/* reset little endian */
|
||||||
|
cfheader.reserved1=fci_get_little_endian_ulong(cfheader.reserved1);
|
||||||
|
cfheader.cbCabinet=fci_get_little_endian_ulong(cfheader.cbCabinet);
|
||||||
|
cfheader.reserved2=fci_get_little_endian_ulong(cfheader.reserved2);
|
||||||
|
cfheader.coffFiles=fci_get_little_endian_ulong(cfheader.coffFiles);
|
||||||
|
cfheader.reserved3=fci_get_little_endian_ulong(cfheader.reserved3);
|
||||||
|
cfheader.cFolders=fci_get_little_endian_uword(cfheader.cFolders);
|
||||||
|
cfheader.cFiles=fci_get_little_endian_uword(cfheader.cFiles);
|
||||||
|
cfheader.flags=fci_get_little_endian_uword(cfheader.flags);
|
||||||
|
cfheader.setID=fci_get_little_endian_uword(cfheader.setID);
|
||||||
|
cfheader.iCabinet=fci_get_little_endian_uword(cfheader.iCabinet);
|
||||||
|
|
||||||
if( cfheader.flags & cfheadRESERVE_PRESENT ) {
|
if( cfheader.flags & cfheadRESERVE_PRESENT ) {
|
||||||
/* NOTE: No checks for maximum value overflows as designed by MS!!! */
|
/* NOTE: No checks for maximum value overflows as designed by MS!!! */
|
||||||
cfreserved.cbCFHeader = cbReserveCFHeader;
|
cfreserved.cbCFHeader = cbReserveCFHeader;
|
||||||
|
@ -1600,6 +1687,10 @@ static BOOL fci_flush_cabinet(
|
||||||
} else {
|
} else {
|
||||||
cfreserved.cbCFData = p_fci_internal->pccab->cbReserveCFData;
|
cfreserved.cbCFData = p_fci_internal->pccab->cbReserveCFData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
cfreserved.cbCFHeader=fci_set_little_endian_uword(cfreserved.cbCFHeader);
|
||||||
|
|
||||||
/* write reserved info into cabinet file */
|
/* write reserved info into cabinet file */
|
||||||
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
||||||
&cfreserved, /* memory buffer */
|
&cfreserved, /* memory buffer */
|
||||||
|
@ -1609,6 +1700,9 @@ static BOOL fci_flush_cabinet(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* TODO error handling of err */
|
/* TODO error handling of err */
|
||||||
|
|
||||||
|
/* reset little endian */
|
||||||
|
cfreserved.cbCFHeader=fci_get_little_endian_uword(cfreserved.cbCFHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add optional reserved area */
|
/* add optional reserved area */
|
||||||
|
@ -1735,6 +1829,11 @@ static BOOL fci_flush_cabinet(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set little endian */
|
||||||
|
cffolder.coffCabStart=fci_set_little_endian_ulong(cffolder.coffCabStart);
|
||||||
|
cffolder.cCFData=fci_set_little_endian_uword(cffolder.cCFData);
|
||||||
|
cffolder.typeCompress=fci_set_little_endian_uword(cffolder.typeCompress);
|
||||||
|
|
||||||
/* write cffolder to cabinet file */
|
/* write cffolder to cabinet file */
|
||||||
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
if( PFCI_WRITE(hfci, handleCABINET, /* file handle */
|
||||||
&cffolder, /* memory buffer */
|
&cffolder, /* memory buffer */
|
||||||
|
@ -1745,6 +1844,11 @@ static BOOL fci_flush_cabinet(
|
||||||
}
|
}
|
||||||
/* TODO error handling of err */
|
/* TODO error handling of err */
|
||||||
|
|
||||||
|
/* reset little endian */
|
||||||
|
cffolder.coffCabStart=fci_get_little_endian_ulong(cffolder.coffCabStart);
|
||||||
|
cffolder.cCFData=fci_get_little_endian_uword(cffolder.cCFData);
|
||||||
|
cffolder.typeCompress=fci_get_little_endian_uword(cffolder.typeCompress);
|
||||||
|
|
||||||
/* add optional reserved area */
|
/* add optional reserved area */
|
||||||
|
|
||||||
/* This allocation and freeing at each CFFolder block is a bit */
|
/* This allocation and freeing at each CFFolder block is a bit */
|
||||||
|
|
Loading…
Reference in a new issue