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




06e04fb45874dde094eb599e8e8fb29b43eb413c
1 /*
3   ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2008
4   License information for this code is in license.txt and
5   included in this file at the end of this comment.
7   All functions below are actual functions that are part of this
8   library and do not need any additional dll files.  It does not
9   even require Storm to be able to decompress or compress files.
11   This library emulates the interface of Lmpqapi and Storm MPQ
12   functions, so it may be used as a replacement for them in
13   MPQ extractors/archivers without even needing to recompile
14   the program that uses Lmpqapi or Storm.  It has a few features
15   not included in Lmpqapi and Storm, such as extra flags for some
16   functions, setting the locale ID of existing files, and adding
17   files without having to write them somewhere else first.  Also,
18   MPQ handles used by functions prefixed with "SFile" and "Mpq"
19   can be used interchangably; all functions use the same type
20   of MPQ handles.  You cannot, however, use handles from this
21   library with storm or lmpqapi or vice-versa.  Doing so will
22   most likely result in a crash.
24   Revision History:
25   (Release date) 1.08 (ShadowFlare)
26   - Fixed a buffer overflow that would occur when reading files
27     if neither using a buffer that is large enough to contain the
28     entire file nor has a size that is a multiple of 4096
29   - Added SFileOpenFileAsArchive which opens an archive that is
30     contained within an already open archive
31   - Added MpqRenameAndSetFileLocale and MpqDeleteFileWithLocale.
32     These have extra parameters that allow you to use them with
33     files having language codes other than what was last set
34     using SFileSetLocale
35   - Fixed a bug that caused (listfile) to get cleared if adding
36     files with a locale ID other than 0
38   06/12/2002 1.07 (ShadowFlare)
39   - No longer requires Storm.dll to compress or decompress
40     Warcraft III files
41   - Added SFileListFiles for getting names and information
42     about all of the files in an archive
43   - Fixed a bug with renaming and deleting files
44   - Fixed a bug with adding wave compressed files with
45     low compression setting
46   - Added a check in MpqOpenArchiveForUpdate for proper
47     dwMaximumFilesInArchive values (should be a number that
48     is a power of 2).  If it is not a proper value, it will
49     be rounded up to the next higher power of 2
51   05/09/2002 1.06 (ShadowFlare)
52   - Compresses files without Storm.dll!
53   - If Warcraft III is installed, this library will be able to
54     find Storm.dll on its own. (Storm.dll is needed to
55     decompress Warcraft III files)
56   - Fixed a bug where an embedded archive and the file that
57     contains it would be corrupted if the archive was modified
58   - Able to open all .w3m maps now
60   29/06/2002 1.05 (ShadowFlare)
61   - Supports decompressing files from Warcraft III MPQ archives
62     if using Storm.dll from Warcraft III
63   - Added MpqAddFileToArchiveEx and MpqAddFileFromBufferEx for
64     using extra compression types
66   29/05/2002 1.04 (ShadowFlare)
67   - Files can be compressed now!
68   - Fixed a bug in SFileReadFile when reading data not aligned
69     to the block size
70   - Optimized some of SFileReadFile's code.  It can read files
71     faster now
72   - SFile functions may now be used to access files not in mpq
73     archives as you can with the real storm functions
74   - MpqCompactArchive will no longer corrupt files with the
75     MODCRYPTKEY flag as long as the file is either compressed,
76     listed in "(listfile)", is "(listfile)", or is located in
77     the same place in the compacted archive; so it is safe
78     enough to use it on almost any archive
79   - Added MpqAddWaveFromBuffer
80   - Better handling of archives with no files
81   - Fixed compression with COMPRESS2 flag
83   15/05/2002 1.03 (ShadowFlare)
84   - Supports adding files with the compression attribute (does
85     not actually compress files).  Now archives created with
86     this dll can have files added to them through lmpqapi
87     without causing staredit to crash
88   - SFileGetBasePath and SFileSetBasePath work more like their
89     Storm equivalents now
90   - Implemented MpqCompactArchive, but it is not finished yet.
91     In its current state, I would recommend against using it
92     on archives that contain files with the MODCRYPTKEY flag,
93     since it will corrupt any files with that flag
94   - Added SFMpqGetVersionString2 which may be used in Visual
95     Basic to get the version string
97   07/05/2002 1.02 (ShadowFlare)
98   - SFileReadFile no longer passes the lpOverlapped parameter it
99     receives to ReadFile.  This is what was causing the function
100     to fail when used in Visual Basic
101   - Added support for more Storm MPQ functions
102   - GetLastError may now be used to get information about why a
103     function failed
105   01/05/2002 1.01 (ShadowFlare)
106   - Added ordinals for Storm MPQ functions
107   - Fixed MPQ searching functionality of SFileOpenFileEx
108   - Added a check for whether a valid handle is given when
109     SFileCloseArchive is called
110   - Fixed functionality of SFileSetArchivePriority when multiple
111     files are open
112   - File renaming works for all filenames now
113   - SFileReadFile no longer reallocates the buffer for each block
114     that is decompressed.  This should make SFileReadFile at least
115     a little faster
117   30/04/2002 1.00 (ShadowFlare)
118   - First version.
119   - Compression not yet supported
120   - Does not use SetLastError yet, so GetLastError will not return any
121     errors that have to do with this library
122   - MpqCompactArchive not implemented
124   Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)
126   License information:
128   Copyright (c) 2002-2008, ShadowFlare <blakflare@hotmail.com>
129   All rights reserved.
131   Redistribution and use in source and binary forms, with or without
132   modification, are permitted provided that the following conditions
133   are met:
135   1. Redistributions of source code must retain the above copyright
136      notice, this list of conditions and the following disclaimer.
137   2. Redistributions in binary form must reproduce the above copyright
138      notice, this list of conditions and the following disclaimer in the
139      documentation and/or other materials provided with the distribution.
141   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
142   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
143   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
144   ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
145   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
146   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
147   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
148   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
149   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
150   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
151   SUCH DAMAGE.
152 */
154 #ifndef SHADOWFLARE_MPQ_API_INCLUDED
155 #define SHADOWFLARE_MPQ_API_INCLUDED
157 #include <windows.h>
159 #ifdef __cplusplus
160 extern "C" {
161 #endif
163 typedef struct {
164         WORD Major;
165         WORD Minor;
166         WORD Revision;
167         WORD Subrevision;
168 } SFMPQVERSION;
170 // These no longer need to be called.  They only provided for
171 // compatibility with older versions of this code
172 #define LoadSFMpq()
173 #define FreeSFMpq()
175 // MpqInitialize does nothing.  It is only provided for
176 // compatibility with MPQ archivers that use lmpqapi.
177 extern BOOL   (WINAPI* MpqInitialize)();
179 extern LPCSTR (WINAPI* MpqGetVersionString)();
180 extern float  (WINAPI* MpqGetVersion)();
182 extern void (WINAPI* SFMpqDestroy)(); // This no longer needs to be called.  It is only provided for compatibility with older versions
184 extern void (WINAPI* AboutSFMpq)(); // 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
186 // SFMpqGetVersionString2's return value is the required length of the buffer plus
187 // the terminating null, so use SFMpqGetVersionString2(0, 0); to get the length.
188 extern LPCSTR (WINAPI* SFMpqGetVersionString)();
189 extern DWORD  (WINAPI* SFMpqGetVersionString2)(LPCSTR lpBuffer, DWORD dwBufferLength);
190 extern SFMPQVERSION (WINAPI* SFMpqGetVersion)();
192 // Returns 0 if the dll version is equal to the version your program was compiled
193 // with, 1 if the dll is newer, -1 if the dll is older.
194 long SFMpqCompareVersion();
196 // General error codes
197 #define MPQ_ERROR_MPQ_INVALID      0x85200065
198 #define MPQ_ERROR_FILE_NOT_FOUND   0x85200066
199 #define MPQ_ERROR_DISK_FULL        0x85200068 //Physical write file to MPQ failed. Not sure of exact meaning
200 #define MPQ_ERROR_HASH_TABLE_FULL  0x85200069
201 #define MPQ_ERROR_ALREADY_EXISTS   0x8520006A
202 #define MPQ_ERROR_BAD_OPEN_MODE    0x8520006C //When MOAU_READ_ONLY is used without MOAU_OPEN_EXISTING
204 #define MPQ_ERROR_COMPACT_ERROR    0x85300001
206 // MpqOpenArchiveForUpdate flags
207 #define MOAU_CREATE_NEW          0x00 //If archive does not exist, it will be created. If it exists, the function will fail
208 #define MOAU_CREATE_ALWAYS       0x08 //Will always create a new archive
209 #define MOAU_OPEN_EXISTING       0x04 //If archive exists, it will be opened. If it does not exist, the function will fail
210 #define MOAU_OPEN_ALWAYS         0x20 //If archive exists, it will be opened. If it does not exist, it will be created
211 #define MOAU_READ_ONLY           0x10 //Must be used with MOAU_OPEN_EXISTING. Archive will be opened without write access
212 #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
213 #define MOAU_MAINTAIN_LISTFILE   0x01 //Creates and maintains a list of files in archive when they are added, replaced, or deleted
215 // MpqAddFileToArchive flags
216 #define MAFA_EXISTS           0x80000000 //This flag will be added if not present
217 #define MAFA_UNKNOWN40000000  0x40000000 //Unknown flag
218 #define MAFA_MODCRYPTKEY      0x00020000 //Used with MAFA_ENCRYPT. Uses an encryption key based on file position and size
219 #define MAFA_ENCRYPT          0x00010000 //Encrypts the file. The file is still accessible when using this, so the use of this has depreciated
220 #define MAFA_COMPRESS         0x00000200 //File is to be compressed when added. This is used for most of the compression methods
221 #define MAFA_COMPRESS2        0x00000100 //File is compressed with standard compression only (was used in Diablo 1)
222 #define MAFA_REPLACE_EXISTING 0x00000001 //If file already exists, it will be replaced
224 // MpqAddFileToArchiveEx compression flags
225 #define MAFA_COMPRESS_STANDARD 0x08 //Standard PKWare DCL compression
226 #define MAFA_COMPRESS_DEFLATE  0x02 //ZLib's deflate compression
227 #define MAFA_COMPRESS_WAVE     0x81 //Standard wave compression
228 #define MAFA_COMPRESS_WAVE2    0x41 //Unused wave compression
230 // Flags for individual compression types used for wave compression
231 #define MAFA_COMPRESS_WAVECOMP1 0x80 //Main compressor for standard wave compression
232 #define MAFA_COMPRESS_WAVECOMP2 0x40 //Main compressor for unused wave compression
233 #define MAFA_COMPRESS_WAVECOMP3 0x01 //Secondary compressor for wave compression
235 // ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)
236 #define Z_NO_COMPRESSION         0
237 #define Z_BEST_SPEED             1
238 #define Z_BEST_COMPRESSION       9
239 #define Z_DEFAULT_COMPRESSION  (-1) //Default level is 6 with current ZLib version
241 // MpqAddWaveToArchive quality flags
242 #define MAWA_QUALITY_HIGH    1 //Higher compression, lower quality
243 #define MAWA_QUALITY_MEDIUM  0 //Medium compression, medium quality
244 #define MAWA_QUALITY_LOW     2 //Lower compression, higher quality
246 // SFileGetFileInfo flags
247 #define SFILE_INFO_BLOCK_SIZE      0x01 //Block size in MPQ
248 #define SFILE_INFO_HASH_TABLE_SIZE 0x02 //Hash table size in MPQ
249 #define SFILE_INFO_NUM_FILES       0x03 //Number of files in MPQ
250 #define SFILE_INFO_TYPE            0x04 //Is MPQHANDLE a file or an MPQ?
251 #define SFILE_INFO_SIZE            0x05 //Size of MPQ or uncompressed file
252 #define SFILE_INFO_COMPRESSED_SIZE 0x06 //Size of compressed file
253 #define SFILE_INFO_FLAGS           0x07 //File flags (compressed, etc.), file attributes if a file not in an archive
254 #define SFILE_INFO_PARENT          0x08 //Handle of MPQ that file is in
255 #define SFILE_INFO_POSITION        0x09 //Position of file pointer in files
256 #define SFILE_INFO_LOCALEID        0x0A //Locale ID of file in MPQ
257 #define SFILE_INFO_PRIORITY        0x0B //Priority of open MPQ
258 #define SFILE_INFO_HASH_INDEX      0x0C //Hash index of file in MPQ
260 // Return values of SFileGetFileInfo when SFILE_INFO_TYPE flag is used
261 #define SFILE_TYPE_MPQ  0x01
262 #define SFILE_TYPE_FILE 0x02
264 // SFileListFiles flags
265 #define SFILE_LIST_MEMORY_LIST  0x01 // Specifies that lpFilelists is a file list from memory, rather than being a list of file lists
266 #define SFILE_LIST_ONLY_KNOWN   0x02 // Only list files that the function finds a name for
267 #define SFILE_LIST_ONLY_UNKNOWN 0x04 // Only list files that the function does not find a name for
268 #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
270 // SFileOpenArchive flags
271 #define SFILE_OPEN_HARD_DISK_FILE 0x0000 //Open archive without regard to the drive type it resides on
272 #define SFILE_OPEN_CD_ROM_FILE    0x0001 //Open the archive only if it is on a CD-ROM
273 #define SFILE_OPEN_ALLOW_WRITE    0x8000 //Open file with write access
275 // SFileOpenFileEx search scopes
276 #define SFILE_SEARCH_CURRENT_ONLY 0x00 //Used with SFileOpenFileEx; only the archive with the handle specified will be searched for the file
277 #define SFILE_SEARCH_ALL_OPEN     0x01 //SFileOpenFileEx will look through all open archives for the file. This flag also allows files outside the archive to be used
279 typedef HANDLE MPQHANDLE;
281 struct FILELISTENTRY {
282         DWORD dwFileExists; // Nonzero if this entry is used
283         LCID lcLocale; // Locale ID of file
284         DWORD dwCompressedSize; // Compressed size of file
285         DWORD dwFullSize; // Uncompressed size of file
286         DWORD dwFlags; // Flags for file
287         char szFileName[260];
288 };
290 struct MPQARCHIVE;
291 struct MPQFILE;
292 struct MPQHEADER;
293 struct BLOCKTABLEENTRY;
294 struct HASHTABLEENTRY;
296 struct MPQHEADER {
297         DWORD dwMPQID; //"MPQ\x1A" for mpq's, "BN3\x1A" for bncache.dat
298         DWORD dwHeaderSize; // Size of this header
299         DWORD dwMPQSize; //The size of the mpq archive
300         WORD wUnused0C; // Seems to always be 0
301         WORD wBlockSize; // Size of blocks in files equals 512 << wBlockSize
302         DWORD dwHashTableOffset; // Offset to hash table
303         DWORD dwBlockTableOffset; // Offset to block table
304         DWORD dwHashTableSize; // Number of entries in hash table
305         DWORD dwBlockTableSize; // Number of entries in block table
306 };
308 //Archive handles may be typecasted to this struct so you can access
309 //some of the archive's properties and the decrypted hash table and
310 //block table directly.  This struct is based on Storm's internal
311 //struct for archive handles.
312 struct MPQARCHIVE {
313         // Arranged according to priority with lowest priority first
314         MPQARCHIVE * lpNextArc; //0// Pointer to the next MPQARCHIVE struct. Pointer to addresses of first and last archives if last archive
315         MPQARCHIVE * lpPrevArc; //4// Pointer to the previous MPQARCHIVE struct. 0xEAFC5E23 if first archive
316         char szFileName[260]; //8// Filename of the archive
317         HANDLE hFile; //10C// The archive's file handle
318         DWORD dwFlags1; //110// Some flags, bit 0 seems to be set when opening an archive from a hard drive if bit 1 in the flags for SFileOpenArchive is set, bit 1 (0 based) seems to be set when opening an archive from a CD
319         DWORD dwPriority; //114// Priority of the archive set when calling SFileOpenArchive
320         MPQFILE * lpLastReadFile; //118// Pointer to the last read file's MPQFILE struct. This is cleared when finished reading a block
321         DWORD dwUnk; //11C// Seems to always be 0
322         DWORD dwBlockSize; //120// Size of file blocks in bytes
323         BYTE * lpLastReadBlock; //124// Pointer to the read buffer for archive. This is cleared when finished reading a block
324         DWORD dwBufferSize; //128// Size of the read buffer for archive. This is cleared when finished reading a block
325         DWORD dwMPQStart; //12C// The starting offset of the archive
326         DWORD dwMPQEnd; //130// The ending offset of the archive
327         MPQHEADER * lpMPQHeader; //134// Pointer to the archive header
328         BLOCKTABLEENTRY * lpBlockTable; //138// Pointer to the start of the block table
329         HASHTABLEENTRY * lpHashTable; //13C// Pointer to the start of the hash table
330         DWORD dwReadOffset; //140// Offset to the data for a file
331         DWORD dwRefCount; //144// Count of references to this open archive.  This is incremented for each file opened from the archive, and decremented for each file closed
332         // Extra struct members used by SFmpq
333         MPQHEADER MpqHeader;
334         DWORD dwFlags; //The only flags that should be changed are MOAU_MAINTAIN_LISTFILE and MOAU_MAINTAIN_ATTRIBUTES, changing any others can have unpredictable effects
335         LPSTR lpFileName;
336         DWORD dwExtraFlags;
337 };
339 //Handles to files in the archive may be typecasted to this struct
340 //so you can access some of the file's properties directly.  This
341 //struct is based on Storm's internal struct for file handles.
342 struct MPQFILE {
343         MPQFILE * lpNextFile; //0// Pointer to the next MPQFILE struct. Pointer to addresses of first and last files if last file
344         MPQFILE * lpPrevFile; //4// Pointer to the previous MPQFILE struct. 0xEAFC5E13 if first file
345         char szFileName[260]; //8// Filename of the file
346         HANDLE hFile; //10C// Always INVALID_HANDLE_VALUE for files in MPQ archives. For files not in MPQ archives, this is the file handle for the file and the rest of this struct is filled with zeros except for dwRefCount
347         MPQARCHIVE * lpParentArc; //110// Pointer to the MPQARCHIVE struct of the archive in which the file is contained
348         BLOCKTABLEENTRY * lpBlockEntry; //114// Pointer to the file's block table entry
349         DWORD dwCryptKey; //118// Decryption key for the file
350         DWORD dwFilePointer; //11C// Position of file pointer in the file
351         DWORD dwUnk; //120// Seems to always be 0
352         DWORD dwBlockCount; //124// Number of blocks in file
353         DWORD * lpdwBlockOffsets; //128// Offsets to blocks in file. There are 1 more of these than the number of blocks. The values for this are set after the first read
354         DWORD dwReadStarted; //12C// Set to 1 after first read
355         BOOL bStreaming; //130// 1 when streaming a WAVE
356         BYTE * lpLastReadBlock; //134// Pointer to the read buffer for file. This starts at the position specified in the last SFileSetFilePointer call. This is cleared when SFileSetFilePointer is called or when finished reading the block
357         DWORD dwBytesRead; //138// Total bytes read from the current block in the open file. This is cleared when SFileSetFilePointer is called or when finished reading the block
358         DWORD dwBufferSize; //13C// Size of the read buffer for file. This is cleared when SFileSetFilePointer is called or when finished reading the block
359         DWORD dwRefCount; //140// Count of references to this open file
360         // Extra struct members used by SFmpq
361         HASHTABLEENTRY *lpHashEntry;
362         LPSTR lpFileName;
363 };
365 struct BLOCKTABLEENTRY {
366         DWORD dwFileOffset; // Offset to file
367         DWORD dwCompressedSize; // Compressed size of file
368         DWORD dwFullSize; // Uncompressed size of file
369         DWORD dwFlags; // Flags for file
370 };
372 struct HASHTABLEENTRY {
373         DWORD dwNameHashA; // First name hash of file
374         DWORD dwNameHashB; // Second name hash of file
375         LCID lcLocale; // Locale ID of file
376         DWORD dwBlockTableIndex; // Index to the block table entry for the file
377 };
379 // Defines for backward compatibility with old lmpqapi function names
380 #define MpqAddFileToArcive MpqAddFileToArchive
381 #define MpqOpenArchive     SFileOpenArchive
382 #define MpqOpenFileEx      SFileOpenFileEx
383 #define MpqGetFileSize     SFileGetFileSize
384 #define MpqReadFile        SFileReadFile
385 #define MpqCloseFile       SFileCloseFile
386 #define MpqCloseArchive    SFileCloseArchive
388 // Storm functions implemented by this library
389 extern BOOL      (WINAPI* SFileOpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
390 extern BOOL      (WINAPI* SFileCloseArchive)(MPQHANDLE hMPQ);
391 extern BOOL      (WINAPI* SFileOpenFileAsArchive)(MPQHANDLE hSourceMPQ, LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
392 extern BOOL      (WINAPI* SFileGetArchiveName)(MPQHANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength);
393 extern BOOL      (WINAPI* SFileOpenFile)(LPCSTR lpFileName, MPQHANDLE *hFile);
394 extern BOOL      (WINAPI* SFileOpenFileEx)(MPQHANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, MPQHANDLE *hFile);
395 extern BOOL      (WINAPI* SFileCloseFile)(MPQHANDLE hFile);
396 extern DWORD     (WINAPI* SFileGetFileSize)(MPQHANDLE hFile, LPDWORD lpFileSizeHigh);
397 extern BOOL      (WINAPI* SFileGetFileArchive)(MPQHANDLE hFile, MPQHANDLE *hMPQ);
398 extern BOOL      (WINAPI* SFileGetFileName)(MPQHANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength);
399 extern DWORD     (WINAPI* SFileSetFilePointer)(MPQHANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod);
400 extern BOOL      (WINAPI* SFileReadFile)(MPQHANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped);
401 extern LCID      (WINAPI* SFileSetLocale)(LCID nNewLocale);
402 extern BOOL      (WINAPI* SFileGetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength);
403 extern BOOL      (WINAPI* SFileSetBasePath)(LPCSTR lpNewBasePath);
405 // Extra storm-related functions
406 extern DWORD     (WINAPI* SFileGetFileInfo)(MPQHANDLE hFile, DWORD dwInfoType);
407 extern BOOL      (WINAPI* SFileSetArchivePriority)(MPQHANDLE hMPQ, DWORD dwPriority);
408 extern DWORD     (WINAPI* SFileFindMpqHeader)(HANDLE hFile);
409 extern BOOL      (WINAPI* SFileListFiles)(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELISTENTRY *lpListBuffer, DWORD dwFlags);
411 // Archive editing functions implemented by this library
412 extern MPQHANDLE (WINAPI* MpqOpenArchiveForUpdate)(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive);
413 extern DWORD     (WINAPI* MpqCloseUpdatedArchive)(MPQHANDLE hMPQ, DWORD dwUnknown2);
414 extern BOOL      (WINAPI* MpqAddFileToArchive)(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags);
415 extern BOOL      (WINAPI* MpqAddWaveToArchive)(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwQuality);
416 extern BOOL      (WINAPI* MpqRenameFile)(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName);
417 extern BOOL      (WINAPI* MpqDeleteFile)(MPQHANDLE hMPQ, LPCSTR lpFileName);
418 extern BOOL      (WINAPI* MpqCompactArchive)(MPQHANDLE hMPQ);
420 // Extra archive editing functions
421 extern BOOL      (WINAPI* MpqAddFileToArchiveEx)(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
422 extern BOOL      (WINAPI* MpqAddFileFromBufferEx)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
423 extern BOOL      (WINAPI* MpqAddFileFromBuffer)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
424 extern BOOL      (WINAPI* MpqAddWaveFromBuffer)(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwQuality);
425 extern BOOL      (WINAPI* MpqRenameAndSetFileLocale)(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName, LCID nOldLocale, LCID nNewLocale);
426 extern BOOL      (WINAPI* MpqDeleteFileWithLocale)(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nLocale);
427 extern BOOL      (WINAPI* MpqSetFileLocale)(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nOldLocale, LCID nNewLocale);
429 // These functions do nothing.  They are only provided for
430 // compatibility with MPQ extractors that use storm.
431 extern BOOL      (WINAPI* SFileDestroy)();
432 extern void      (WINAPI* StormDestroy)();
434 #ifdef __cplusplus
435 };  // extern "C" 
436 #endif
438 #endif