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




1 // License information for this code is in license.txt
3 [ uuid(CF183E40-8316-11d6-9E07-00A0C9199875), version(1.08),
4   helpstring("ShadowFlare MPQ API Library v1.08")]
6 library SFMPQAPI
7 {
8         #define WINAPI __stdcall
9         #define HANDLE long
10         #define MPQHANDLE HANDLE
11         #define DWORD long
12         #define LPDWORD DWORD *
13         #define LCID DWORD
14         #define PLONG LONG *
15         #define LPVOID LPSTR
16         #define BOOL boolean
17         typedef struct _OVERLAPPED {
18                 DWORD  Internal;
19                 DWORD  InternalHigh;
20                 DWORD  Offset;
21                 DWORD  OffsetHigh;
22                 HANDLE hEvent;
23         } OVERLAPPED;
24         //#define LPOVERLAPPED OVERLAPPED *
25         #define LPOVERLAPPED long
26         typedef struct _SFMPQVERSION {
27                 WORD Major;
28                 WORD Minor;
29                 WORD Revision;
30                 WORD Subrevision;
31         } SFMPQVERSION;
32         typedef struct _FILELISTENTRY {
33                 DWORD dwFileExists; // Nonzero if this entry is used
34                 LCID lcLocale; // Locale ID of file
35                 DWORD dwCompressedSize; // Compressed size of file
36                 DWORD dwFullSize; // Uncompressed size of file
37                 DWORD dwFlags; // Flags for file
38                 char szFileName[260];
39         } FILELISTENTRY;
41         //[uuid(CF183E43-8316-11d6-9E07-00A0C9199875)] 
42         [helpstring("General error codes")]
43         typedef enum {
44                 MPQ_ERROR_MPQ_INVALID =     0x85200065,
45                 MPQ_ERROR_FILE_NOT_FOUND =  0x85200066,
46                 MPQ_ERROR_DISK_FULL =       0x85200068,
47                 MPQ_ERROR_HASH_TABLE_FULL = 0x85200069,
48                 MPQ_ERROR_ALREADY_EXISTS =  0x8520006A,
49                 MPQ_ERROR_BAD_OPEN_MODE =   0x8520006C,
50                 MPQ_ERROR_COMPACT_ERROR =   0x85300001,
51         } Error_Constants;
53         [helpstring("MpqOpenArchiveForUpdate flags")]
54         typedef enum {
55                 MOAU_CREATE_NEW =       0x00,
56                 MOAU_CREATE_ALWAYS =    0x08,
57                 MOAU_OPEN_EXISTING =    0x04,
58                 MOAU_OPEN_ALWAYS =      0x20,
59                 MOAU_READ_ONLY =        0x10,
60                 MOAU_MAINTAIN_ATTRIBUTES=0x02,
61                 MOAU_MAINTAIN_LISTFILE =0x01,
62         } MpqOpenArchiveForUpdate_Flags;
64         [helpstring("MpqOpenArchiveForUpdateEx constants")]
65         typedef enum {
66                 DEFAULT_BLOCK_SIZE = 3,
67                 USE_DEFAULT_BLOCK_SIZE = 0xFFFFFFFF,
68         } MpqOpenArchiveForUpdateEx_Constants;
70         [helpstring("MpqAddFileToArchive flags")]
71         typedef enum {
72                 MAFA_EXISTS =          0x80000000,
73                 MAFA_UNKNOWN40000000 = 0x40000000,
74                 MAFA_MODCRYPTKEY =     0x00020000,
75                 MAFA_ENCRYPT =         0x00010000,
76                 MAFA_COMPRESS =        0x00000200,
77                 MAFA_COMPRESS2 =       0x00000100,
78                 MAFA_REPLACE_EXISTING =0x00000001,
79         } MpqAddFileToArchive_Flags;
81         [helpstring("MpqAddFileToArchiveEx compression flags")]
82         typedef enum {
83                 MAFA_COMPRESS_STANDARD = 0x08,
84                 MAFA_COMPRESS_DEFLATE  = 0x02,
85                 MAFA_COMPRESS_BZIP2    = 0x10,
86                 MAFA_COMPRESS_WAVE     = 0x81,
87                 MAFA_COMPRESS_WAVE2    = 0x41,
88                 MAFA_COMPRESS_WAVECOMP1 = 0x80,
89                 MAFA_COMPRESS_WAVECOMP2 = 0x40,
90                 MAFA_COMPRESS_WAVECOMP3 = 0x01,
91         } MpqAddFileToArchiveEx_Compression_Types;
93         [helpstring("Deflate compression level constants")]
94         typedef enum {
95                 Z_NO_COMPRESSION = 0,
96                 Z_BEST_SPEED = 1,
97                 Z_BEST_COMPRESSION = 9,
98                 Z_DEFAULT_COMPRESSION = (-1),
99         } Deflate_Compress_Level;
101         [helpstring("MpqAddWaveToArchive quality flags")]
102         typedef enum {
103                 MAWA_QUALITY_HIGH =   1,
104                 MAWA_QUALITY_MEDIUM = 0,
105                 MAWA_QUALITY_LOW =    2,
106         } MpqAddWaveToArchive_Quality;
108         [helpstring("SFileGetFileInfo flags")]
109         typedef enum {
110                 SFILE_INFO_BLOCK_SIZE =     0x01,
111                 SFILE_INFO_HASH_TABLE_SIZE =0x02,
112                 SFILE_INFO_NUM_FILES =      0x03,
113                 SFILE_INFO_TYPE =           0x04,
114                 SFILE_INFO_SIZE =           0x05,
115                 SFILE_INFO_COMPRESSED_SIZE =0x06,
116                 SFILE_INFO_FLAGS =          0x07,
117                 SFILE_INFO_PARENT =         0x08,
118                 SFILE_INFO_POSITION =       0x09,
119                 SFILE_INFO_LOCALEID =       0x0A,
120                 SFILE_INFO_PRIORITY =       0x0B,
121                 SFILE_INFO_HASH_INDEX =     0x0C,
122                 SFILE_INFO_BLOCK_INDEX =    0x0D,
123         } SFileGetFileInfo_Flags;
125         [helpstring("Handle type constants")]
126         typedef enum {
127                 SFILE_TYPE_MPQ = 0x01,
128                 SFILE_TYPE_FILE =0x02,
129         } Handle_Type_Constants;
131         [helpstring("SFileListFiles flags")]
132         typedef enum {
133                 SFILE_LIST_MEMORY_LIST  =0x01,
134                 SFILE_LIST_ONLY_KNOWN   =0x02,
135                 SFILE_LIST_ONLY_UNKNOWN =0x04,
136                 SFILE_LIST_FLAG_UNKNOWN =0x08,
137         } SFileListFiles_Flags;
139         [helpstring("SFileOpenArchive flags")]
140         typedef enum {
141                 SFILE_OPEN_HARD_DISK_FILE =0x0000,
142                 SFILE_OPEN_CD_ROM_FILE =   0x0001,
143                 SFILE_OPEN_ALLOW_WRITE =   0x8000,
144         } SFileOpenArchive_Flags;
146         [helpstring("SFileOpenFileEx flags")]
147         typedef enum {
148                 SFILE_SEARCH_CURRENT_ONLY =0x00,
149                 SFILE_SEARCH_ALL_OPEN =    0x01
150         } SFileOpenFileEx_Flags;
152         [helpstring("Other misc. flags and constants")]
153         typedef enum {
154                 INVALID_HANDLE_VALUE = 0xFFFFFFFF,
155         } Other;
158         [helpstring("SFileSetFilePointer move methods")]
159         typedef enum {
160                 FILE_BEGIN = 0,
161                 FILE_CURRENT = 1,
162                 FILE_END = 2
163         } SFileSetFilePointer_Move_Methods;
165         [helpstring("Windows defined error codes")]
166         typedef enum {
167                 ERROR_SUCCESS           = 0,
168                 NO_ERROR                = 0,
169                 ERROR_FILE_NOT_FOUND    = 2,
170                 ERROR_OUTOFMEMORY       = 14,
171                 ERROR_INVALID_PARAMETER = 87,
172                 ERROR_DISK_FULL         = 112,
173                 ERROR_ALREADY_EXISTS    = 183,
174                 ERROR_FILE_INVALID      = 1006,
175                 ERROR_UNKNOWN_PROPERTY  = 1608
176         } WinErrors;
178         [dllname("sfmpq.dll")]
180         [helpstring("Version and other misc. functions")]
181         module SFMpq
182         {
183                 [entry("MpqInitialize"),helpstring("MpqInitialize does nothing; it is only provided for compatibility with MPQ archivers that use lmpqapi.")]
184                         BOOL   WINAPI MpqInitialize();
185                 [entry("MpqGetVersionString"),helpstring("")]
186                         LPCSTR WINAPI MpqGetVersionString();
187                 [entry("MpqGetVersion"),helpstring("")]
188                         float  WINAPI MpqGetVersion();
189                 [entry("SFMpqDestroy"),helpstring("This no longer needs to be called; it is only provided for compatibility with older versions")]
190                         void   WINAPI SFMpqDestroy();
191                 [entry("AboutSFMpq"),helpstring("Displays an about page in a web browser (this has only been tested in Internet Explorer)")]
192                         void   WINAPI AboutSFMpq();
193                 [entry("SFMpqGetVersionString"),helpstring("")]
194                         LPCSTR WINAPI SFMpqGetVersionString();
195                 [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.")]
196                         DWORD  WINAPI SFMpqGetVersionString2(LPCSTR lpBuffer, DWORD dwBufferLength);
197                 [entry("SFMpqGetVersion"),helpstring("")]
198                         SFMPQVERSION WINAPI SFMpqGetVersion();
199         };
201         [helpstring("Storm SFile emulated functions")]
202         module SFile
203         {
204                 [entry("SFileOpenArchive"),helpstring("")]
205                         BOOL      WINAPI SFileOpenArchive(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
206                 [entry("SFileCloseArchive"),helpstring("")]
207                         BOOL      WINAPI SFileCloseArchive(MPQHANDLE hMPQ);
208                 [entry("SFileOpenFileAsArchive"),helpstring("")]
209                         BOOL      WINAPI SFileOpenFileAsArchive(MPQHANDLE hSourceMPQ, LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
210                 [entry("SFileGetArchiveName"),helpstring("")]
211                         BOOL      WINAPI SFileGetArchiveName(MPQHANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength);
212                 [entry("SFileOpenFile"),helpstring("")]
213                         BOOL      WINAPI SFileOpenFile(LPCSTR lpFileName, MPQHANDLE *hFile);
214                 [entry("SFileOpenFileEx"),helpstring("")]
215                         BOOL      WINAPI SFileOpenFileEx(MPQHANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, MPQHANDLE *hFile);
216                 [entry("SFileCloseFile"),helpstring("")]
217                         BOOL      WINAPI SFileCloseFile(MPQHANDLE hFile);
218                 [entry("SFileGetFileSize"),helpstring("")]
219                         DWORD     WINAPI SFileGetFileSize(MPQHANDLE hFile, LPDWORD lpFileSizeHigh);
220                 [entry("SFileGetFileArchive"),helpstring("")]
221                         BOOL      WINAPI SFileGetFileArchive(MPQHANDLE hFile, MPQHANDLE *hMPQ);
222                 [entry("SFileGetFileName"),helpstring("")]
223                         BOOL      WINAPI SFileGetFileName(MPQHANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength);
224                 [entry("SFileSetFilePointer"),helpstring("")]
225                         DWORD     WINAPI SFileSetFilePointer(MPQHANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod);
226                 [entry("SFileReadFile"),helpstring("")]
227                         BOOL      WINAPI SFileReadFile(MPQHANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped);
228                 [entry("SFileReadFile"),helpstring("")]
229                         BOOL      WINAPI SFileReadFileB(MPQHANDLE hFile,byte *lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped);
230                 [entry("SFileSetLocale"),helpstring("")]
231                         LCID      WINAPI SFileSetLocale(LCID nNewLocale);
232                 [entry("SFileGetBasePath"),helpstring("")]
233                         BOOL      WINAPI SFileGetBasePath(LPCSTR lpBuffer, DWORD dwBufferLength);
234                 [entry("SFileSetBasePath"),helpstring("")]
235                         BOOL      WINAPI SFileSetBasePath(LPCSTR lpNewBasePath);
236                 [entry("SFileGetFileInfo"),helpstring("")]
237                         DWORD     WINAPI SFileGetFileInfo(MPQHANDLE hFile, DWORD dwInfoType);
238                 [entry("SFileSetArchivePriority"),helpstring("")]
239                         BOOL      WINAPI SFileSetArchivePriority(MPQHANDLE hMPQ, DWORD dwPriority);
240                 [entry("SFileFindMpqHeader"),helpstring("")]
241                         DWORD     WINAPI SFileFindMpqHeader(HANDLE hFile);
242                 [entry("SFileListFiles"),helpstring("")]
243                         BOOL      WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELISTENTRY *lpListBuffer, DWORD dwFlags);
244                 [entry("SFileDestroy"),helpstring("")]
245                         BOOL      WINAPI SFileDestroy();
246                 [entry("StormDestroy"),helpstring("")]
247                         void      WINAPI StormDestroy();
248         };
250         [helpstring("MPQ archive creation and editing functions")]
251         module MPQ
252         {
253                 [entry("MpqOpenArchiveForUpdate"),helpstring("")]
254                         MPQHANDLE WINAPI MpqOpenArchiveForUpdate(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive);
255                 [entry("MpqCloseUpdatedArchive"),helpstring("")]
256                         DWORD     WINAPI MpqCloseUpdatedArchive(MPQHANDLE hMPQ, DWORD dwUnknown2);
257                 [entry("MpqAddFileToArchive"),helpstring("")]
258                         BOOL      WINAPI MpqAddFileToArchive(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags);
259                 [entry("MpqAddWaveToArchive"),helpstring("")]
260                         BOOL      WINAPI MpqAddWaveToArchive(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwQuality);
261                 [entry("MpqRenameFile"),helpstring("")]
262                         BOOL      WINAPI MpqRenameFile(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName);
263                 [entry("MpqDeleteFile"),helpstring("")]
264                         BOOL      WINAPI MpqDeleteFile(MPQHANDLE hMPQ, LPCSTR lpFileName);
265                 [entry("MpqCompactArchive"),helpstring("")]
266                         BOOL      WINAPI MpqCompactArchive(MPQHANDLE hMPQ);
267                 [entry("MpqOpenArchiveForUpdateEx"),helpstring("")]
268                         MPQHANDLE WINAPI MpqOpenArchiveForUpdateEx(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive, DWORD dwBlockSize);
269                 [entry("MpqAddFileToArchiveEx"),helpstring("")]
270                         BOOL      WINAPI MpqAddFileToArchiveEx(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
271                 [entry("MpqAddFileFromBufferEx"),helpstring("")]
272                         BOOL      WINAPI MpqAddFileFromBufferEx(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
273                 [entry("MpqAddFileFromBufferEx"),helpstring("")]
274                         BOOL      WINAPI MpqAddFileFromBufferExB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
275                 [entry("MpqAddFileFromBuffer"),helpstring("")]
276                         BOOL      WINAPI MpqAddFileFromBuffer(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
277                 [entry("MpqAddFileFromBuffer"),helpstring("")]
278                         BOOL      WINAPI MpqAddFileFromBufferB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
279                 [entry("MpqAddWaveFromBuffer"),helpstring("")]
280                         BOOL      WINAPI MpqAddWaveFromBuffer(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwQuality);
281                 [entry("MpqAddWaveFromBuffer"),helpstring("")]
282                         BOOL      WINAPI MpqAddWaveFromBufferB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwQuality);
283                 [entry("MpqRenameAndSetFileLocale"),helpstring("")]
284                         BOOL      WINAPI MpqRenameAndSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName, LCID nOldLocale, LCID nNewLocale);
285                 [entry("MpqDeleteFileWithLocale"),helpstring("")]
286                         BOOL      WINAPI MpqDeleteFileWithLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nLocale);
287                 [entry("MpqSetFileLocale"),helpstring("")]
288                         BOOL      WINAPI MpqSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nOldLocale, LCID nNewLocale);
289         };
291         [dllname("kernel32.dll")]
293         module LastError
294         {
295                 [entry("GetLastError"),helpstring("")]
296                         DWORD WINAPI GetLastError();
297         };
298 };