Browse Source

Replace WINAPI by STORMAPI in StormLib

pull/35/head
Xadhoom 7 years ago
parent
commit
53c5ced09d
  1. 2
      3rdParty/StormLib/README
  2. 10
      3rdParty/StormLib/src/SCompression.cpp
  3. 2
      3rdParty/StormLib/src/SFileExtractFile.cpp
  4. 6
      3rdParty/StormLib/src/SFileFindFile.cpp
  5. 6
      3rdParty/StormLib/src/SFileGetFileInfo.cpp
  6. 14
      3rdParty/StormLib/src/SFileOpenArchive.cpp
  7. 10
      3rdParty/StormLib/src/SFileOpenFileEx.cpp
  8. 6
      3rdParty/StormLib/src/SFileReadFile.cpp
  9. 138
      3rdParty/StormLib/src/StormLib.h
  10. 8
      3rdParty/StormLib/src/StormPort.h
  11. 2
      SourceS/miniwin.h
  12. 8
      SourceS/miniwin_pushdecl.h

2
3rdParty/StormLib/README vendored

@ -6,7 +6,7 @@ Cosmetic changes:
Implementation changes: Implementation changes:
* Redefine `bool` to `BOOL`. * Redefine `bool` to `BOOL`.
* Use `stdcall` calling convention. * Use STORMAPI instead of WINAPI for calling convention (and define it as nothing).
* Use external Storm error handling (`SErrGetLastError()` etc.) * Use external Storm error handling (`SErrGetLastError()` etc.)
* Convert pathnames to Unix-style slashes. * Convert pathnames to Unix-style slashes.
* Bugfixes, with comment: // BUGFIX (devilutionX) * Bugfixes, with comment: // BUGFIX (devilutionX)

10
3rdParty/StormLib/src/SCompression.cpp vendored

@ -678,7 +678,7 @@ static int Decompress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void
/* */ /* */
/*****************************************************************************/ /*****************************************************************************/
int WINAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) int STORMAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{ {
int cbOutBuffer; int cbOutBuffer;
@ -710,7 +710,7 @@ int WINAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffe
/* */ /* */
/*****************************************************************************/ /*****************************************************************************/
int WINAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) int STORMAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{ {
int cbOutBuffer; int cbOutBuffer;
@ -774,7 +774,7 @@ static TCompressTable cmp_table[] =
#endif #endif
}; };
int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel) int STORMAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel)
{ {
COMPRESS CompressFuncArray[0x10]; // Array of compression functions, applied sequentially COMPRESS CompressFuncArray[0x10]; // Array of compression functions, applied sequentially
unsigned char CompressByte[0x10]; // CompressByte for each method in the CompressFuncArray array unsigned char CompressByte[0x10]; // CompressByte for each method in the CompressFuncArray array
@ -928,7 +928,7 @@ static TDecompressTable dcmp_table[] =
#endif #endif
}; };
int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) int STORMAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{ {
unsigned char * pbWorkBuffer = NULL; unsigned char * pbWorkBuffer = NULL;
unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer;
@ -1034,7 +1034,7 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
return nResult; return nResult;
} }
int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) int STORMAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{ {
DECOMPRESS pfnDecompress1 = NULL; DECOMPRESS pfnDecompress1 = NULL;
DECOMPRESS pfnDecompress2 = NULL; DECOMPRESS pfnDecompress2 = NULL;

2
3rdParty/StormLib/src/SFileExtractFile.cpp vendored

@ -12,7 +12,7 @@
#include "StormLib.h" #include "StormLib.h"
#include "StormCommon.h" #include "StormCommon.h"
bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope) bool STORMAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope)
{ {
TFileStream * pLocalFile = NULL; TFileStream * pLocalFile = NULL;
HANDLE hMpqFile = NULL; HANDLE hMpqFile = NULL;

6
3rdParty/StormLib/src/SFileFindFile.cpp vendored

@ -378,7 +378,7 @@ static void FreeMPQSearch(TMPQSearch *& hs)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Public functions // Public functions
HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile) HANDLE STORMAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile)
{ {
TMPQArchive * ha = (TMPQArchive *)hMpq; TMPQArchive * ha = (TMPQArchive *)hMpq;
TMPQSearch * hs = NULL; TMPQSearch * hs = NULL;
@ -446,7 +446,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA
return (HANDLE)hs; return (HANDLE)hs;
} }
bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) bool STORMAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData)
{ {
TMPQSearch * hs = IsValidSearchHandle(hFind); TMPQSearch * hs = IsValidSearchHandle(hFind);
int nError = ERROR_SUCCESS; int nError = ERROR_SUCCESS;
@ -465,7 +465,7 @@ bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData)
return (nError == ERROR_SUCCESS); return (nError == ERROR_SUCCESS);
} }
bool WINAPI SFileFindClose(HANDLE hFind) bool STORMAPI SFileFindClose(HANDLE hFind)
{ {
TMPQSearch * hs = IsValidSearchHandle(hFind); TMPQSearch * hs = IsValidSearchHandle(hFind);

6
3rdParty/StormLib/src/SFileGetFileInfo.cpp vendored

@ -131,7 +131,7 @@ static bool GetFilePatchChain(TMPQFile * hf, void * pvFileInfo, DWORD cbFileInfo
// cbFileInfo - Size of the buffer pointed by pvFileInfo // cbFileInfo - Size of the buffer pointed by pvFileInfo
// pcbLengthNeeded - Receives number of bytes necessary to store the information // pcbLengthNeeded - Receives number of bytes necessary to store the information
bool WINAPI SFileGetFileInfo( bool STORMAPI SFileGetFileInfo(
HANDLE hMpqOrFile, HANDLE hMpqOrFile,
SFileInfoClass InfoClass, SFileInfoClass InfoClass,
void * pvFileInfo, void * pvFileInfo,
@ -860,7 +860,7 @@ bool WINAPI SFileGetFileInfo(
} }
#ifdef FULL #ifdef FULL
bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass) bool STORMAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass)
{ {
switch(InfoClass) switch(InfoClass)
{ {
@ -963,7 +963,7 @@ static int CreatePseudoFileName(HANDLE hFile, TFileEntry * pFileEntry, char * sz
return ERROR_CAN_NOT_COMPLETE; return ERROR_CAN_NOT_COMPLETE;
} }
bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) bool STORMAPI SFileGetFileName(HANDLE hFile, char * szFileName)
{ {
TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle
int nError = ERROR_INVALID_HANDLE; int nError = ERROR_INVALID_HANDLE;

14
3rdParty/StormLib/src/SFileOpenArchive.cpp vendored

@ -127,12 +127,12 @@ static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize)
// SFileGetLocale and SFileSetLocale // SFileGetLocale and SFileSetLocale
// Set the locale for all newly opened files // Set the locale for all newly opened files
LCID WINAPI SFileGetLocale() LCID STORMAPI SFileGetLocale()
{ {
return lcFileLocale; return lcFileLocale;
} }
LCID WINAPI SFileSetLocale(LCID lcNewLocale) LCID STORMAPI SFileSetLocale(LCID lcNewLocale)
{ {
lcFileLocale = lcNewLocale; lcFileLocale = lcNewLocale;
return lcFileLocale; return lcFileLocale;
@ -146,7 +146,7 @@ LCID WINAPI SFileSetLocale(LCID lcNewLocale)
// dwFlags - See MPQ_OPEN_XXX in StormLib.h // dwFlags - See MPQ_OPEN_XXX in StormLib.h
// phMpq - Pointer to store open archive handle // phMpq - Pointer to store open archive handle
bool WINAPI SFileOpenArchive( bool STORMAPI SFileOpenArchive(
const TCHAR * szMpqName, const TCHAR * szMpqName,
DWORD dwPriority, DWORD dwPriority,
DWORD dwFlags, DWORD dwFlags,
@ -470,12 +470,12 @@ bool WINAPI SFileOpenArchive(
#ifdef FULL #ifdef FULL
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// bool WINAPI SFileSetDownloadCallback(HANDLE, SFILE_DOWNLOAD_CALLBACK, void *); // bool STORMAPI SFileSetDownloadCallback(HANDLE, SFILE_DOWNLOAD_CALLBACK, void *);
// //
// Sets a callback that is called when content is downloaded from the master MPQ // Sets a callback that is called when content is downloaded from the master MPQ
// //
bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData) bool STORMAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData)
{ {
TMPQArchive * ha = (TMPQArchive *)hMpq; TMPQArchive * ha = (TMPQArchive *)hMpq;
@ -498,7 +498,7 @@ bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK Downlo
// and terminating without calling SFileCloseArchive might corrupt the archive. // and terminating without calling SFileCloseArchive might corrupt the archive.
// //
bool WINAPI SFileFlushArchive(HANDLE hMpq) bool STORMAPI SFileFlushArchive(HANDLE hMpq)
{ {
TMPQArchive * ha; TMPQArchive * ha;
int nResultError = ERROR_SUCCESS; int nResultError = ERROR_SUCCESS;
@ -590,7 +590,7 @@ bool WINAPI SFileFlushArchive(HANDLE hMpq)
// bool SFileCloseArchive(HANDLE hMpq); // bool SFileCloseArchive(HANDLE hMpq);
// //
bool WINAPI SFileCloseArchive(HANDLE hMpq) bool STORMAPI SFileCloseArchive(HANDLE hMpq)
{ {
TMPQArchive * ha = IsValidMpqHandle(hMpq); TMPQArchive * ha = IsValidMpqHandle(hMpq);
bool bResult = true; bool bResult = true;

10
3rdParty/StormLib/src/SFileOpenFileEx.cpp vendored

@ -172,7 +172,7 @@ bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile)
// pointed by plcLocales. There must be enough entries to copy the localed, // pointed by plcLocales. There must be enough entries to copy the localed,
// otherwise the function returns ERROR_INSUFFICIENT_BUFFER. // otherwise the function returns ERROR_INSUFFICIENT_BUFFER.
int WINAPI SFileEnumLocales( int STORMAPI SFileEnumLocales(
HANDLE hMpq, HANDLE hMpq,
const char * szFileName, const char * szFileName,
LCID * PtrLocales, LCID * PtrLocales,
@ -228,7 +228,7 @@ int WINAPI SFileEnumLocales(
// dwSearchScope - Where to search // dwSearchScope - Where to search
// PtrFile - Pointer to store opened file handle // PtrFile - Pointer to store opened file handle
bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * PtrFile) bool STORMAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * PtrFile)
{ {
TMPQArchive * ha = IsValidMpqHandle(hMpq); TMPQArchive * ha = IsValidMpqHandle(hMpq);
TFileEntry * pFileEntry = NULL; TFileEntry * pFileEntry = NULL;
@ -372,15 +372,15 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch
// hMpq - Handle of opened MPQ archive // hMpq - Handle of opened MPQ archive
// szFileName - Name of file to look for // szFileName - Name of file to look for
bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName) bool STORMAPI SFileHasFile(HANDLE hMpq, const char * szFileName)
{ {
return SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_CHECK_EXISTS, NULL); return SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_CHECK_EXISTS, NULL);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// bool WINAPI SFileCloseFile(HANDLE hFile); // bool STORMAPI SFileCloseFile(HANDLE hFile);
bool WINAPI SFileCloseFile(HANDLE hFile) bool STORMAPI SFileCloseFile(HANDLE hFile)
{ {
TMPQFile * hf = (TMPQFile *)hFile; TMPQFile * hf = (TMPQFile *)hFile;

6
3rdParty/StormLib/src/SFileReadFile.cpp vendored

@ -670,7 +670,7 @@ static int ReadMpqFileLocalFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// SFileReadFile // SFileReadFile
bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped) bool STORMAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped)
{ {
TMPQFile * hf = (TMPQFile *)hFile; TMPQFile * hf = (TMPQFile *)hFile;
DWORD dwBytesRead = 0; // Number of bytes read DWORD dwBytesRead = 0; // Number of bytes read
@ -759,7 +759,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// SFileGetFileSize // SFileGetFileSize
DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh) DWORD STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh)
{ {
ULONGLONG FileSize; ULONGLONG FileSize;
TMPQFile * hf = (TMPQFile *)hFile; TMPQFile * hf = (TMPQFile *)hFile;
@ -806,7 +806,7 @@ DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh)
return SFILE_INVALID_SIZE; return SFILE_INVALID_SIZE;
} }
DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod) DWORD STORMAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod)
{ {
TMPQFile * hf = (TMPQFile *)hFile; TMPQFile * hf = (TMPQFile *)hFile;
ULONGLONG OldPosition; ULONGLONG OldPosition;

138
3rdParty/StormLib/src/StormLib.h vendored

@ -470,9 +470,9 @@ typedef enum _SFileInfoClass
#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) #define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total)
#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used #define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used
typedef void (WINAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes); typedef void (STORMAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes);
typedef void (WINAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall); typedef void (STORMAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall);
typedef void (WINAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes); typedef void (STORMAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes);
typedef struct TFileStream TFileStream; typedef struct TFileStream TFileStream;
@ -970,131 +970,131 @@ void FileStream_Close(TFileStream * pStream);
// Functions prototypes for Storm.dll // Functions prototypes for Storm.dll
// Typedefs for functions exported by Storm.dll // Typedefs for functions exported by Storm.dll
typedef LCID (WINAPI * SFILESETLOCALE)(LCID); typedef LCID (STORMAPI * SFILESETLOCALE)(LCID);
typedef bool (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); typedef bool (STORMAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *);
typedef bool (WINAPI * SFILECLOSEARCHIVE)(HANDLE); typedef bool (STORMAPI * SFILECLOSEARCHIVE)(HANDLE);
typedef bool (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); typedef bool (STORMAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *);
typedef bool (WINAPI * SFILECLOSEFILE)(HANDLE); typedef bool (STORMAPI * SFILECLOSEFILE)(HANDLE);
typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, LPDWORD); typedef DWORD (STORMAPI * SFILEGETFILESIZE)(HANDLE, LPDWORD);
typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); typedef DWORD (STORMAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD);
typedef bool (WINAPI * SFILEREADFILE)(HANDLE, void *, DWORD, LPDWORD, LPOVERLAPPED); typedef bool (STORMAPI * SFILEREADFILE)(HANDLE, void *, DWORD, LPDWORD, LPOVERLAPPED);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for manipulation with StormLib global flags // Functions for manipulation with StormLib global flags
LCID WINAPI SFileGetLocale(); LCID STORMAPI SFileGetLocale();
LCID WINAPI SFileSetLocale(LCID lcNewLocale); LCID STORMAPI SFileSetLocale(LCID lcNewLocale);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for archive manipulation // Functions for archive manipulation
bool WINAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq); bool STORMAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq);
bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq); bool STORMAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq);
bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq); bool STORMAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq);
bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData); bool STORMAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData);
bool WINAPI SFileFlushArchive(HANDLE hMpq); bool STORMAPI SFileFlushArchive(HANDLE hMpq);
bool WINAPI SFileCloseArchive(HANDLE hMpq); bool STORMAPI SFileCloseArchive(HANDLE hMpq);
// Adds another listfile into MPQ. The currently added listfile(s) remain, // Adds another listfile into MPQ. The currently added listfile(s) remain,
// so you can use this API to combining more listfiles. // so you can use this API to combining more listfiles.
// Note that this function is internally called by SFileFindFirstFile // Note that this function is internally called by SFileFindFirstFile
int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile); int STORMAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile);
// Archive compacting // Archive compacting
bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData); bool STORMAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData);
bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool bReserved); bool STORMAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool bReserved);
// Changing the maximum file count // Changing the maximum file count
DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq); DWORD STORMAPI SFileGetMaxFileCount(HANDLE hMpq);
bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount); bool STORMAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount);
// Changing (attributes) file // Changing (attributes) file
DWORD WINAPI SFileGetAttributes(HANDLE hMpq); DWORD STORMAPI SFileGetAttributes(HANDLE hMpq);
bool WINAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags); bool STORMAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags);
bool WINAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName); bool STORMAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for manipulation with patch archives // Functions for manipulation with patch archives
bool WINAPI SFileOpenPatchArchive(HANDLE hMpq, const TCHAR * szPatchMpqName, const char * szPatchPathPrefix, DWORD dwFlags); bool STORMAPI SFileOpenPatchArchive(HANDLE hMpq, const TCHAR * szPatchMpqName, const char * szPatchPathPrefix, DWORD dwFlags);
bool WINAPI SFileIsPatchedArchive(HANDLE hMpq); bool STORMAPI SFileIsPatchedArchive(HANDLE hMpq);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for file manipulation // Functions for file manipulation
// Reading from MPQ file // Reading from MPQ file
bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName); bool STORMAPI SFileHasFile(HANDLE hMpq, const char * szFileName);
bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); bool STORMAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile);
DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh); DWORD STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh);
DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod); DWORD STORMAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod);
bool WINAPI SFileReadFile(HANDLE hFile, void * lpBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped); bool STORMAPI SFileReadFile(HANDLE hFile, void * lpBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped);
bool WINAPI SFileCloseFile(HANDLE hFile); bool STORMAPI SFileCloseFile(HANDLE hFile);
// Retrieving info about a file in the archive // Retrieving info about a file in the archive
bool WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, SFileInfoClass InfoClass, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded); bool STORMAPI SFileGetFileInfo(HANDLE hMpqOrFile, SFileInfoClass InfoClass, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded);
bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); bool STORMAPI SFileGetFileName(HANDLE hFile, char * szFileName);
bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass); bool STORMAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass);
// High-level extract function // High-level extract function
bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope); bool STORMAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for file and archive verification // Functions for file and archive verification
// Generates file CRC32 // Generates file CRC32
bool WINAPI SFileGetFileChecksums(HANDLE hMpq, const char * szFileName, LPDWORD pdwCrc32, char * pMD5); bool STORMAPI SFileGetFileChecksums(HANDLE hMpq, const char * szFileName, LPDWORD pdwCrc32, char * pMD5);
// Verifies file against its checksums stored in (attributes) attributes (depending on dwFlags). // Verifies file against its checksums stored in (attributes) attributes (depending on dwFlags).
// For dwFlags, use one or more of MPQ_ATTRIBUTE_MD5 // For dwFlags, use one or more of MPQ_ATTRIBUTE_MD5
DWORD WINAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlags); DWORD STORMAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlags);
// Verifies raw data of the archive. Only works for MPQs version 4 or newer // Verifies raw data of the archive. Only works for MPQs version 4 or newer
int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName); int STORMAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName);
// Verifies the signature, if present // Verifies the signature, if present
bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType); bool STORMAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType);
DWORD WINAPI SFileVerifyArchive(HANDLE hMpq); DWORD STORMAPI SFileVerifyArchive(HANDLE hMpq);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions for file searching // Functions for file searching
HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile); HANDLE STORMAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile);
bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); bool STORMAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData);
bool WINAPI SFileFindClose(HANDLE hFind); bool STORMAPI SFileFindClose(HANDLE hFind);
HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); HANDLE STORMAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData);
bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); bool STORMAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData);
bool WINAPI SListFileFindClose(HANDLE hFind); bool STORMAPI SListFileFindClose(HANDLE hFind);
// Locale support // Locale support
int WINAPI SFileEnumLocales(HANDLE hMpq, const char * szFileName, LCID * plcLocales, LPDWORD pdwMaxLocales, DWORD dwSearchScope); int STORMAPI SFileEnumLocales(HANDLE hMpq, const char * szFileName, LCID * plcLocales, LPDWORD pdwMaxLocales, DWORD dwSearchScope);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Support for adding files to the MPQ // Support for adding files to the MPQ
bool WINAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLONG FileTime, DWORD dwFileSize, LCID lcLocale, DWORD dwFlags, HANDLE * phFile); bool STORMAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLONG FileTime, DWORD dwFileSize, LCID lcLocale, DWORD dwFlags, HANDLE * phFile);
bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression); bool STORMAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression);
bool WINAPI SFileFinishFile(HANDLE hFile); bool STORMAPI SFileFinishFile(HANDLE hFile);
bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME); bool STORMAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME);
bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags); bool STORMAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags);
bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); bool STORMAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope); bool STORMAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope);
bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName); bool STORMAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName);
bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); bool STORMAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale);
bool WINAPI SFileSetDataCompression(DWORD DataCompression); bool STORMAPI SFileSetDataCompression(DWORD DataCompression);
bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData); bool STORMAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Compression and decompression // Compression and decompression
int WINAPI SCompImplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); int STORMAPI SCompImplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer);
int WINAPI SCompExplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); int STORMAPI SCompExplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer);
int WINAPI SCompCompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel); int STORMAPI SCompCompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel);
int WINAPI SCompDecompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); int STORMAPI SCompDecompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer);
int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); int STORMAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Non-Windows support for SetLastError/GetLastError // Non-Windows support for SetLastError/GetLastError
@ -1110,8 +1110,8 @@ DWORD GetLastError();
extern DWORD nLastError; extern DWORD nLastError;
DWORD WINAPI SErrGetLastError(); DWORD STORMAPI SErrGetLastError();
void WINAPI SErrSetLastError(DWORD dwErrCode); void STORMAPI SErrSetLastError(DWORD dwErrCode);
#define SetLastError SErrSetLastError #define SetLastError SErrSetLastError
#define GetLastError SErrGetLastError #define GetLastError SErrGetLastError

8
3rdParty/StormLib/src/StormPort.h vendored

@ -27,6 +27,8 @@
#ifndef __STORMPORT_H__ #ifndef __STORMPORT_H__
#define __STORMPORT_H__ #define __STORMPORT_H__
#define STORMAPI
#ifndef __cplusplus #ifndef __cplusplus
#define bool char #define bool char
#define true 1 #define true 1
@ -170,13 +172,7 @@
#define _countof(x) (sizeof(x) / sizeof(x[0])) #define _countof(x) (sizeof(x) / sizeof(x[0]))
#endif #endif
// MINIWIN change
// (original calling conventions confuse address-sanitizer)
#if 0
#define WINAPI __attribute__((stdcall)) #define WINAPI __attribute__((stdcall))
#else
#define WINAPI
#endif
#define FILE_BEGIN SEEK_SET #define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR #define FILE_CURRENT SEEK_CUR

2
SourceS/miniwin.h

@ -30,7 +30,7 @@
#define __int8 char #define __int8 char
#define __int16 short #define __int16 short
#define __int32 int #define __int32 int
#define __int64 long long #define __int64 long long __attribute__((aligned(8)))
#endif #endif
#include "miniwin_misc.h" #include "miniwin_misc.h"

8
SourceS/miniwin_pushdecl.h

@ -9,6 +9,14 @@
#pragma push_macro("WINUSERAPI") #pragma push_macro("WINUSERAPI")
#endif #endif
#undef __cdecl
#undef __fastcall
#undef __stdcall
#undef CALLBACK
#undef APIENTRY
#undef WINAPI
#undef WINAPIV
#undef WINUSERAPI
#define __cdecl #define __cdecl
#define __fastcall #define __fastcall
#define __stdcall #define __stdcall

Loading…
Cancel
Save