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