Current News Archived News Search News Discussion Forum Old Forum Install Programs More Downloads... Troubleshooting Source Code Format Specs. Misc. Information Non-SF Stuff Links Small banner for links to this site: |
diff --git a/SFmpqapi.bas b/SFmpqapi.bas
--- a/SFmpqapi.bas
+++ b/SFmpqapi.bas
Attribute VB_Name = "SFmpqapi"\r
Option Explicit\r
\r
-' ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2008\r
-' License information for this code is in license.txt\r
+' ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2009\r
+' License information for this code is in license.txt and\r
+' included in this file at the end of this comment.\r
\r
' All functions below are actual functions that are part of this\r
' library and do not need any additional dll files. It does not\r
' most likely result in a crash.\r
\r
' Revision History:\r
+' (Release date) 1.08 (ShadowFlare)\r
+' - Fixed a buffer overflow that would occur when reading files\r
+' if neither using a buffer that is large enough to contain the\r
+' entire file nor has a size that is a multiple of 4096\r
+' - Added SFileOpenFileAsArchive which opens an archive that is\r
+' contained within an already open archive\r
+' - Added MpqRenameAndSetFileLocale and MpqDeleteFileWithLocale.\r
+' These have extra parameters that allow you to use them with\r
+' files having language codes other than what was last set\r
+' using SFileSetLocale\r
+' - Fixed a bug that caused (listfile) to get cleared if adding\r
+' files with a locale ID other than 0\r
+' - Added MpqOpenArchiveForUpdateEx which allows creating\r
+' archives with different block sizes\r
+' - SFileListFiles can list the contents of bncache.dat without\r
+' needing an external list\r
+\r
' 06/12/2002 1.07 (ShadowFlare)\r
' - No longer requires Storm.dll to compress or decompress\r
' Warcraft III files\r
\r
' Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)\r
\r
+' License information:\r
+\r
+' Copyright (c) 2002-2009, ShadowFlare <blakflare@hotmail.com>\r
+' All rights reserved.\r
+\r
+' Redistribution and use in source and binary forms, with or without\r
+' modification, are permitted provided that the following conditions\r
+' are met:\r
+\r
+' 1. Redistributions of source code must retain the above copyright\r
+' notice, this list of conditions and the following disclaimer.\r
+' 2. Redistributions in binary form must reproduce the above copyright\r
+' notice, this list of conditions and the following disclaimer in the\r
+' documentation and/or other materials provided with the distribution.\r
+\r
+' THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND\r
+' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+' ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
+' FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+' DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+' OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+' HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+' OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+' SUCH DAMAGE.\r
+\r
Type SFMPQVERSION\r
Major As Integer\r
Minor As Integer\r
\r
Declare Sub SFMpqDestroy Lib "SFmpq.dll" () ' This no longer needs to be called. It is only provided for compatibility with older versions\r
\r
+Declare Sub AboutSFMpq Lib "SFmpq.dll" () ' Displays an about page in a web browser (this has only been tested in Internet Explorer). This is only for the dll version of SFmpq\r
+\r
' SFMpqGetVersionString2's return value is the required length of the buffer plus\r
' the terminating null, so use SFMpqGetVersionString2(ByVal 0&, 0) to get the length.\r
Declare Function SFMpqGetVersionString Lib "SFmpq.dll" () As String\r
@@ -148,8 +195,13 @@ Public Const MOAU_CREATE_ALWAYS As Long = &H8 'Was wrongly named MOAU_CREATE_NEW
Public Const MOAU_OPEN_EXISTING As Long = &H4\r
Public Const MOAU_OPEN_ALWAYS As Long = &H20\r
Public Const MOAU_READ_ONLY As Long = &H10 'Must be used with MOAU_OPEN_EXISTING\r
+Public Const MOAU_MAINTAIN_ATTRIBUTES As Long = &H2 'Will be used in a future version to create the (attributes) file\r
Public Const MOAU_MAINTAIN_LISTFILE As Long = &H1\r
\r
+' MpqOpenArchiveForUpdateEx constants\r
+Public Const DEFAULT_BLOCK_SIZE As Long = 3 ' 512 << number = block size\r
+Public Const USE_DEFAULT_BLOCK_SIZE As Long = &HFFFF ' Use default block size that is defined internally\r
+\r
' MpqAddFileToArchive flags\r
Public Const MAFA_EXISTS As Long = &H80000000 'Will be added if not present\r
Public Const MAFA_UNKNOWN40000000 As Long = &H40000000\r
' MpqAddFileToArchiveEx compression flags\r
Public Const MAFA_COMPRESS_STANDARD As Long = &H8 'Standard PKWare DCL compression\r
Public Const MAFA_COMPRESS_DEFLATE As Long = &H2 'ZLib's deflate compression\r
-Public Const MAFA_COMPRESS_WAVE As Long = &H81 'Standard wave compression\r
-Public Const MAFA_COMPRESS_WAVE2 As Long = &H41 'Unused wave compression\r
+Public Const MAFA_COMPRESS_BZIP2 As Long = &H10 'bzip2 compression\r
+Public Const MAFA_COMPRESS_WAVE As Long = &H81 'Stereo wave compression\r
+Public Const MAFA_COMPRESS_WAVE2 As Long = &H41 'Mono wave compression\r
\r
' Flags for individual compression types used for wave compression\r
-Public Const MAFA_COMPRESS_WAVECOMP1 As Long = &H80 'Main compressor for standard wave compression\r
-Public Const MAFA_COMPRESS_WAVECOMP2 As Long = &H40 'Main compressor for unused wave compression\r
+Public Const MAFA_COMPRESS_WAVECOMP1 As Long = &H80 'Main compressor for stereo wave compression\r
+Public Const MAFA_COMPRESS_WAVECOMP2 As Long = &H40 'Main compressor for mono wave compression\r
Public Const MAFA_COMPRESS_WAVECOMP3 As Long = &H1 'Secondary compressor for wave compression\r
\r
' ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)\r
@@ -194,15 +247,17 @@ Public Const SFILE_INFO_POSITION As Long = &H9 'Position of file pointer in file
Public Const SFILE_INFO_LOCALEID As Long = &HA 'Locale ID of file in MPQ\r
Public Const SFILE_INFO_PRIORITY As Long = &HB 'Priority of open MPQ\r
Public Const SFILE_INFO_HASH_INDEX As Long = &HC 'Hash index of file in MPQ\r
+Public Const SFILE_INFO_BLOCK_INDEX As Long = &HD 'Block table index of file in MPQ\r
+\r
+' Return values of SFileGetFileInfo when SFILE_INFO_TYPE flag is used\r
+Public Const SFILE_TYPE_MPQ As Long = &H1\r
+Public Const SFILE_TYPE_FILE As Long = &H2\r
\r
' SFileListFiles flags\r
Public Const SFILE_LIST_MEMORY_LIST As Long = &H1 ' Specifies that lpFilelists is a file list from memory, rather than being a list of file lists\r
Public Const SFILE_LIST_ONLY_KNOWN As Long = &H2 ' Only list files that the function finds a name for\r
Public Const SFILE_LIST_ONLY_UNKNOWN As Long = &H4 ' Only list files that the function does not find a name for\r
-Public Const SFILE_LIST_FLAG_UNKNOWN As Long = &H8 ' Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found\r
-\r
-Public Const SFILE_TYPE_MPQ As Long = &H1\r
-Public Const SFILE_TYPE_FILE As Long = &H2\r
+Public Const SFILE_LIST_FLAG_UNKNOWN As Long = &H8 ' Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but will set dwFileExists to 3 if file's name is not found\r
\r
Public Const INVALID_HANDLE_VALUE As Long = -1\r
\r
Public Const FILE_CURRENT As Long = 1\r
Public Const FILE_END As Long = 2\r
\r
+' SFileOpenArchive flags\r
Public Const SFILE_OPEN_HARD_DISK_FILE As Long = &H0 'Open archive without regard to the drive type it resides on\r
Public Const SFILE_OPEN_CD_ROM_FILE As Long = &H1 'Open the archive only if it is on a CD-ROM\r
Public Const SFILE_OPEN_ALLOW_WRITE As Long = &H8000 'Open file with write access\r
\r
+' SFileOpenFileEx search scopes\r
Public Const SFILE_SEARCH_CURRENT_ONLY As Long = &H0 'Used with SFileOpenFileEx; only the archive with the handle specified will be searched for the file\r
Public Const SFILE_SEARCH_ALL_OPEN As Long = &H1 'SFileOpenFileEx will look through all open archives for the file\r
\r
' Storm functions implemented by this library\r
Declare Function SFileOpenArchive Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwPriority As Long, ByVal dwFlags As Long, ByRef hMPQ As Long) As Boolean\r
Declare Function SFileCloseArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean\r
+Declare Function SFileOpenFileAsArchive Lib "SFmpq.dll" (ByVal hSourceMPQ As Long, ByVal lpFileName As String, ByVal dwPriority As Long, ByVal dwFlags As Long, ByRef hMPQ As Long) As Boolean\r
Declare Function SFileGetArchiveName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
Declare Function SFileOpenFile Lib "SFmpq.dll" (ByVal lpFileName As String, ByRef hFile As Long) As Boolean\r
Declare Function SFileOpenFileEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal dwSearchScope As Long, ByRef hFile As Long) As Boolean\r
@@ -237,7 +295,7 @@ Declare Function SFileGetFileSize Lib "SFmpq.dll" (ByVal hFile As Long, lpFileSi
Declare Function SFileGetFileArchive Lib "SFmpq.dll" (ByVal hFile As Long, ByRef hMPQ As Long) As Boolean\r
Declare Function SFileGetFileName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
Declare Function SFileSetFilePointer Lib "SFmpq.dll" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lplDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long\r
-Declare Function SFileReadFile Lib "SFmpq.dll" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Boolean\r
+Declare Function SFileReadFile Lib "SFmpq.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Boolean\r
Declare Function SFileSetLocale Lib "SFmpq.dll" (ByVal nNewLocale As Long) As Long\r
Declare Function SFileGetBasePath Lib "SFmpq.dll" (ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
Declare Function SFileSetBasePath Lib "SFmpq.dll" (ByVal lpNewBasePath As String) As Boolean\r
@@ -258,10 +316,13 @@ Declare Function MpqDeleteFile Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFile
Declare Function MpqCompactArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean\r
\r
' Extra archive editing functions\r
+Declare Function MpqOpenArchiveForUpdateEx Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwMaximumFilesInArchive As Long, ByVal dwBlockSize As Long) As Long\r
Declare Function MpqAddFileToArchiveEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpSourceFileName As String, ByVal lpDestFileName As String, ByVal dwFlags As Long, ByVal dwCompressionType As Long, ByVal dwCompressLevel As Long) As Boolean\r
-Declare Function MpqAddFileFromBufferEx Lib "SFmpq.dll" (ByVal hMPQ As Long, lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwCompressionType As Long, ByVal dwCompressLevel As Long) As Boolean\r
-Declare Function MpqAddFileFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long) As Boolean\r
-Declare Function MpqAddWaveFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwQuality As Long) As Boolean\r
+Declare Function MpqAddFileFromBufferEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwCompressionType As Long, ByVal dwCompressLevel As Long) As Boolean\r
+Declare Function MpqAddFileFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long) As Boolean\r
+Declare Function MpqAddWaveFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwQuality As Long) As Boolean\r
+Declare Function MpqRenameAndSetFileLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpcOldFileName As String, ByVal lpcNewFileName As String, ByVal nOldLocale As Long, ByVal nNewLocale As Long) As Boolean\r
+Declare Function MpqDeleteFileWithLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal nLocale As Long) As Boolean\r
Declare Function MpqSetFileLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal nOldLocale As Long, ByVal nNewLocale As Long) As Boolean\r
\r
' These functions do nothing. They are only provided for\r
With ExeVersion\r
.Major = 1\r
.Minor = 0\r
- .Revision = 7\r
- .Subrevision = 4\r
+ .Revision = 8\r
+ .Subrevision = 1\r
End With\r
DllVersion = SFMpqGetVersion()\r
If DllVersion.Major > ExeVersion.Major Then\r
diff --git a/SFmpqapi.h b/SFmpqapi.h
--- a/SFmpqapi.h
+++ b/SFmpqapi.h
/*
- ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2008
+ ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2009
License information for this code is in license.txt and
included in this file at the end of this comment.
License information:
- Copyright (c) 2002-2008, ShadowFlare <blakflare@hotmail.com>
+ Copyright (c) 2002-2009, ShadowFlare <blakflare@hotmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
// MpqAddFileToArchiveEx compression flags
#define MAFA_COMPRESS_STANDARD 0x08 //Standard PKWare DCL compression
#define MAFA_COMPRESS_DEFLATE 0x02 //ZLib's deflate compression
-#define MAFA_COMPRESS_WAVE 0x81 //Standard wave compression
-#define MAFA_COMPRESS_WAVE2 0x41 //Unused wave compression
+#define MAFA_COMPRESS_BZIP2 0x10 //bzip2 compression
+#define MAFA_COMPRESS_WAVE 0x81 //Stereo wave compression
+#define MAFA_COMPRESS_WAVE2 0x41 //Mono wave compression
// Flags for individual compression types used for wave compression
-#define MAFA_COMPRESS_WAVECOMP1 0x80 //Main compressor for standard wave compression
-#define MAFA_COMPRESS_WAVECOMP2 0x40 //Main compressor for unused wave compression
+#define MAFA_COMPRESS_WAVECOMP1 0x80 //Main compressor for stereo wave compression
+#define MAFA_COMPRESS_WAVECOMP2 0x40 //Main compressor for mono wave compression
#define MAFA_COMPRESS_WAVECOMP3 0x01 //Secondary compressor for wave compression
// ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)
#define SFILE_LIST_MEMORY_LIST 0x01 // Specifies that lpFilelists is a file list from memory, rather than being a list of file lists
#define SFILE_LIST_ONLY_KNOWN 0x02 // Only list files that the function finds a name for
#define SFILE_LIST_ONLY_UNKNOWN 0x04 // Only list files that the function does not find a name for
-#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found
+#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but will set dwFileExists to 3 if file's name is not found
// SFileOpenArchive flags
#define SFILE_OPEN_HARD_DISK_FILE 0x0000 //Open archive without regard to the drive type it resides on
diff --git a/SFmpqapi.odl b/SFmpqapi.odl
--- a/SFmpqapi.odl
+++ b/SFmpqapi.odl
MOAU_MAINTAIN_LISTFILE =0x01,
} MpqOpenArchiveForUpdate_Flags;
+ [helpstring("MpqOpenArchiveForUpdateEx constants")]
+ typedef enum {
+ DEFAULT_BLOCK_SIZE = 3,
+ USE_DEFAULT_BLOCK_SIZE = 0xFFFFFFFF,
+ } MpqOpenArchiveForUpdateEx_Constants;
+
[helpstring("MpqAddFileToArchive flags")]
typedef enum {
MAFA_EXISTS = 0x80000000,
typedef enum {
MAFA_COMPRESS_STANDARD = 0x08,
MAFA_COMPRESS_DEFLATE = 0x02,
+ MAFA_COMPRESS_BZIP2 = 0x10,
MAFA_COMPRESS_WAVE = 0x81,
MAFA_COMPRESS_WAVE2 = 0x41,
MAFA_COMPRESS_WAVECOMP1 = 0x80,
SFILE_INFO_LOCALEID = 0x0A,
SFILE_INFO_PRIORITY = 0x0B,
SFILE_INFO_HASH_INDEX = 0x0C,
+ SFILE_INFO_BLOCK_INDEX = 0x0D,
} SFileGetFileInfo_Flags;
+ [helpstring("Handle type constants")]
+ typedef enum {
+ SFILE_TYPE_MPQ = 0x01,
+ SFILE_TYPE_FILE =0x02,
+ } Handle_Type_Constants;
+
[helpstring("SFileListFiles flags")]
typedef enum {
SFILE_LIST_MEMORY_LIST =0x01,
SFILE_LIST_ONLY_KNOWN =0x02,
SFILE_LIST_ONLY_UNKNOWN =0x04,
+ SFILE_LIST_FLAG_UNKNOWN =0x08,
} SFileListFiles_Flags;
- [helpstring("Handle type constants")]
- typedef enum {
- SFILE_TYPE_MPQ = 0x01,
- SFILE_TYPE_FILE =0x02,
- } Handle_Type_Constants;
-
[helpstring("SFileOpenArchive flags")]
typedef enum {
SFILE_OPEN_HARD_DISK_FILE =0x0000,
float WINAPI MpqGetVersion();
[entry("SFMpqDestroy"),helpstring("This no longer needs to be called; it is only provided for compatibility with older versions")]
void WINAPI SFMpqDestroy();
+ [entry("AboutSFMpq"),helpstring("Displays an about page in a web browser (this has only been tested in Internet Explorer)")]
+ void WINAPI AboutSFMpq();
[entry("SFMpqGetVersionString"),helpstring("")]
LPCSTR WINAPI SFMpqGetVersionString();
[entry("SFMpqGetVersionString2"),helpstring("SFMpqGetVersionString2's return value is the required length of the buffer plus the terminating null, so use SFMpqGetVersionString2(0, 0) to get the length.")]
DWORD WINAPI SFMpqGetVersionString2(LPCSTR lpBuffer, DWORD dwBufferLength);
[entry("SFMpqGetVersion"),helpstring("")]
SFMPQVERSION WINAPI SFMpqGetVersion();
- [entry("SFMpqCompareVersion"),helpstring("Returns 0 if the dll version is equal to the version your program was compiled with, 1 if the dll is newer, -1 if the dll is older.")]
- long SFMpqCompareVersion();
};
[helpstring("Storm SFile emulated functions")]
BOOL WINAPI MpqDeleteFile(MPQHANDLE hMPQ, LPCSTR lpFileName);
[entry("MpqCompactArchive"),helpstring("")]
BOOL WINAPI MpqCompactArchive(MPQHANDLE hMPQ);
+ [entry("MpqOpenArchiveForUpdateEx"),helpstring("")]
+ MPQHANDLE WINAPI MpqOpenArchiveForUpdateEx(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive, DWORD dwBlockSize);
[entry("MpqAddFileToArchiveEx"),helpstring("")]
BOOL WINAPI MpqAddFileToArchiveEx(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
[entry("MpqAddFileFromBufferEx"),helpstring("")]
diff --git a/SFmpqapi_no-lib.cpp b/SFmpqapi_no-lib.cpp
--- a/SFmpqapi_no-lib.cpp
+++ b/SFmpqapi_no-lib.cpp
return FALSE;
}
+MPQHANDLE WINAPI MpqOpenArchiveForUpdateEx_stub(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive, DWORD dwBlockSize)
+{
+ LoadSFMpqDll();
+ if (hSFMpq) {
+ *(FARPROC *)&MpqOpenArchiveForUpdateEx = GetProcAddress(hSFMpq,"MpqOpenArchiveForUpdateEx");
+ if (MpqOpenArchiveForUpdateEx) return MpqOpenArchiveForUpdateEx(lpFileName,dwFlags,dwMaximumFilesInArchive,dwBlockSize);
+ }
+ return INVALID_HANDLE_VALUE;
+}
+
BOOL WINAPI MpqAddFileToArchiveEx_stub(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel)
{
LoadSFMpqDll();
BOOL (WINAPI* MpqDeleteFile)(MPQHANDLE hMPQ, LPCSTR lpFileName) = MpqDeleteFile_stub;
BOOL (WINAPI* MpqCompactArchive)(MPQHANDLE hMPQ) = MpqCompactArchive_stub;
+MPQHANDLE (WINAPI* MpqOpenArchiveForUpdateEx)(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive, DWORD dwBlockSize) = MpqOpenArchiveForUpdateEx_stub;
BOOL (WINAPI* MpqAddFileToArchiveEx)(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel) = MpqAddFileToArchiveEx_stub;
BOOL (WINAPI* MpqAddFileFromBufferEx)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel) = MpqAddFileFromBufferEx_stub;
BOOL (WINAPI* MpqAddFileFromBuffer)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags) = MpqAddFileFromBuffer_stub;
MpqDeleteFile = 0;
MpqCompactArchive = 0;
+ MpqOpenArchiveForUpdateEx = 0;
MpqAddFileToArchiveEx = 0;
MpqAddFileFromBufferEx = 0;
MpqAddFileFromBuffer = 0;
diff --git a/SFmpqapi_no-lib.h b/SFmpqapi_no-lib.h
--- a/SFmpqapi_no-lib.h
+++ b/SFmpqapi_no-lib.h
/*
- ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2008
+ ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2009
License information for this code is in license.txt and
included in this file at the end of this comment.
using SFileSetLocale
- Fixed a bug that caused (listfile) to get cleared if adding
files with a locale ID other than 0
+ - Added MpqOpenArchiveForUpdateEx which allows creating
+ archives with different block sizes
+ - SFileListFiles can list the contents of bncache.dat without
+ needing an external list
06/12/2002 1.07 (ShadowFlare)
- No longer requires Storm.dll to compress or decompress
License information:
- Copyright (c) 2002-2008, ShadowFlare <blakflare@hotmail.com>
+ Copyright (c) 2002-2009, ShadowFlare <blakflare@hotmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
#define MOAU_MAINTAIN_ATTRIBUTES 0x02 //Will be used in a future version to create the (attributes) file. Contact me about any information you may have about the format of this file
#define MOAU_MAINTAIN_LISTFILE 0x01 //Creates and maintains a list of files in archive when they are added, replaced, or deleted
+// MpqOpenArchiveForUpdateEx constants
+#define DEFAULT_BLOCK_SIZE 3 // 512 << number = block size
+#define USE_DEFAULT_BLOCK_SIZE 0xFFFFFFFF // Use default block size that is defined internally
+
// MpqAddFileToArchive flags
#define MAFA_EXISTS 0x80000000 //This flag will be added if not present
#define MAFA_UNKNOWN40000000 0x40000000 //Unknown flag
// MpqAddFileToArchiveEx compression flags
#define MAFA_COMPRESS_STANDARD 0x08 //Standard PKWare DCL compression
#define MAFA_COMPRESS_DEFLATE 0x02 //ZLib's deflate compression
-#define MAFA_COMPRESS_WAVE 0x81 //Standard wave compression
-#define MAFA_COMPRESS_WAVE2 0x41 //Unused wave compression
+#define MAFA_COMPRESS_BZIP2 0x10 //bzip2 compression
+#define MAFA_COMPRESS_WAVE 0x81 //Stereo wave compression
+#define MAFA_COMPRESS_WAVE2 0x41 //Mono wave compression
// Flags for individual compression types used for wave compression
-#define MAFA_COMPRESS_WAVECOMP1 0x80 //Main compressor for standard wave compression
-#define MAFA_COMPRESS_WAVECOMP2 0x40 //Main compressor for unused wave compression
+#define MAFA_COMPRESS_WAVECOMP1 0x80 //Main compressor for stereo wave compression
+#define MAFA_COMPRESS_WAVECOMP2 0x40 //Main compressor for mono wave compression
#define MAFA_COMPRESS_WAVECOMP3 0x01 //Secondary compressor for wave compression
// ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)
#define SFILE_INFO_LOCALEID 0x0A //Locale ID of file in MPQ
#define SFILE_INFO_PRIORITY 0x0B //Priority of open MPQ
#define SFILE_INFO_HASH_INDEX 0x0C //Hash index of file in MPQ
+#define SFILE_INFO_BLOCK_INDEX 0x0D //Block table index of file in MPQ
// Return values of SFileGetFileInfo when SFILE_INFO_TYPE flag is used
#define SFILE_TYPE_MPQ 0x01
#define SFILE_LIST_MEMORY_LIST 0x01 // Specifies that lpFilelists is a file list from memory, rather than being a list of file lists
#define SFILE_LIST_ONLY_KNOWN 0x02 // Only list files that the function finds a name for
#define SFILE_LIST_ONLY_UNKNOWN 0x04 // Only list files that the function does not find a name for
-#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but set dwFileExists to 3 if file's name is not found
+#define SFILE_LIST_FLAG_UNKNOWN 0x08 // Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but will set dwFileExists to 3 if file's name is not found
// SFileOpenArchive flags
#define SFILE_OPEN_HARD_DISK_FILE 0x0000 //Open archive without regard to the drive type it resides on
extern BOOL (WINAPI* MpqCompactArchive)(MPQHANDLE hMPQ);
// Extra archive editing functions
+extern MPQHANDLE (WINAPI* MpqOpenArchiveForUpdateEx)(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive, DWORD dwBlockSize);
extern BOOL (WINAPI* MpqAddFileToArchiveEx)(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
extern BOOL (WINAPI* MpqAddFileFromBufferEx)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
extern BOOL (WINAPI* MpqAddFileFromBuffer)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
--- a/about
+++ b/about
<html>
<title>About ShadowFlare MPQ API Library</title>
-<pre> ShadowFlare MPQ API Library v1.08 (c) ShadowFlare Software 2002-2008
+<pre> ShadowFlare MPQ API Library v1.08 (c) ShadowFlare Software 2002-2009
This library emulates the interface of Lmpqapi and Storm MPQ
functions, so it may be used as a replacement for them in
License information:
- Copyright (c) 2002-2008, ShadowFlare <<a href="mailto:blakflare@hotmail.com">blakflare@hotmail.com</a>>
+ Copyright (c) 2002-2009, ShadowFlare <<a href="mailto:blakflare@hotmail.com">blakflare@hotmail.com</a>>
All rights reserved.
Redistribution and use in source and binary forms, with or without
|