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




CommitLineData
7df24e1f 1// License information for this code is in license.txt
2
3[ uuid(CF183E40-8316-11d6-9E07-00A0C9199875), version(1.08),
4 helpstring("ShadowFlare MPQ API Library v1.08")]
5
6library 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;
40
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;
52
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;
63
64 [helpstring("MpqAddFileToArchive flags")]
65 typedef enum {
66 MAFA_EXISTS = 0x80000000,
67 MAFA_UNKNOWN40000000 = 0x40000000,
68 MAFA_MODCRYPTKEY = 0x00020000,
69 MAFA_ENCRYPT = 0x00010000,
70 MAFA_COMPRESS = 0x00000200,
71 MAFA_COMPRESS2 = 0x00000100,
72 MAFA_REPLACE_EXISTING =0x00000001,
73 } MpqAddFileToArchive_Flags;
74
75 [helpstring("MpqAddFileToArchiveEx compression flags")]
76 typedef enum {
77 MAFA_COMPRESS_STANDARD = 0x08,
78 MAFA_COMPRESS_DEFLATE = 0x02,
79 MAFA_COMPRESS_WAVE = 0x81,
80 MAFA_COMPRESS_WAVE2 = 0x41,
81 MAFA_COMPRESS_WAVECOMP1 = 0x80,
82 MAFA_COMPRESS_WAVECOMP2 = 0x40,
83 MAFA_COMPRESS_WAVECOMP3 = 0x01,
84 } MpqAddFileToArchiveEx_Compression_Types;
85
86 [helpstring("Deflate compression level constants")]
87 typedef enum {
88 Z_NO_COMPRESSION = 0,
89 Z_BEST_SPEED = 1,
90 Z_BEST_COMPRESSION = 9,
91 Z_DEFAULT_COMPRESSION = (-1),
92 } Deflate_Compress_Level;
93
94 [helpstring("MpqAddWaveToArchive quality flags")]
95 typedef enum {
96 MAWA_QUALITY_HIGH = 1,
97 MAWA_QUALITY_MEDIUM = 0,
98 MAWA_QUALITY_LOW = 2,
99 } MpqAddWaveToArchive_Quality;
100
101 [helpstring("SFileGetFileInfo flags")]
102 typedef enum {
103 SFILE_INFO_BLOCK_SIZE = 0x01,
104 SFILE_INFO_HASH_TABLE_SIZE =0x02,
105 SFILE_INFO_NUM_FILES = 0x03,
106 SFILE_INFO_TYPE = 0x04,
107 SFILE_INFO_SIZE = 0x05,
108 SFILE_INFO_COMPRESSED_SIZE =0x06,
109 SFILE_INFO_FLAGS = 0x07,
110 SFILE_INFO_PARENT = 0x08,
111 SFILE_INFO_POSITION = 0x09,
112 SFILE_INFO_LOCALEID = 0x0A,
113 SFILE_INFO_PRIORITY = 0x0B,
114 SFILE_INFO_HASH_INDEX = 0x0C,
115 } SFileGetFileInfo_Flags;
116
117 [helpstring("SFileListFiles flags")]
118 typedef enum {
119 SFILE_LIST_MEMORY_LIST =0x01,
120 SFILE_LIST_ONLY_KNOWN =0x02,
121 SFILE_LIST_ONLY_UNKNOWN =0x04,
122 } SFileListFiles_Flags;
123
124 [helpstring("Handle type constants")]
125 typedef enum {
126 SFILE_TYPE_MPQ = 0x01,
127 SFILE_TYPE_FILE =0x02,
128 } Handle_Type_Constants;
129
130 [helpstring("SFileOpenArchive flags")]
131 typedef enum {
132 SFILE_OPEN_HARD_DISK_FILE =0x0000,
133 SFILE_OPEN_CD_ROM_FILE = 0x0001,
134 SFILE_OPEN_ALLOW_WRITE = 0x8000,
135 } SFileOpenArchive_Flags;
136
137 [helpstring("SFileOpenFileEx flags")]
138 typedef enum {
139 SFILE_SEARCH_CURRENT_ONLY =0x00,
140 SFILE_SEARCH_ALL_OPEN = 0x01
141 } SFileOpenFileEx_Flags;
142
143 [helpstring("Other misc. flags and constants")]
144 typedef enum {
145 INVALID_HANDLE_VALUE = 0xFFFFFFFF,
146 } Other;
147
148
149 [helpstring("SFileSetFilePointer move methods")]
150 typedef enum {
151 FILE_BEGIN = 0,
152 FILE_CURRENT = 1,
153 FILE_END = 2
154 } SFileSetFilePointer_Move_Methods;
155
156 [helpstring("Windows defined error codes")]
157 typedef enum {
158 ERROR_SUCCESS = 0,
159 NO_ERROR = 0,
160 ERROR_FILE_NOT_FOUND = 2,
161 ERROR_OUTOFMEMORY = 14,
162 ERROR_INVALID_PARAMETER = 87,
163 ERROR_DISK_FULL = 112,
164 ERROR_ALREADY_EXISTS = 183,
165 ERROR_FILE_INVALID = 1006,
166 ERROR_UNKNOWN_PROPERTY = 1608
167 } WinErrors;
168
169 [dllname("sfmpq.dll")]
170
171 [helpstring("Version and other misc. functions")]
172 module SFMpq
173 {
174 [entry("MpqInitialize"),helpstring("MpqInitialize does nothing; it is only provided for compatibility with MPQ archivers that use lmpqapi.")]
175 BOOL WINAPI MpqInitialize();
176 [entry("MpqGetVersionString"),helpstring("")]
177 LPCSTR WINAPI MpqGetVersionString();
178 [entry("MpqGetVersion"),helpstring("")]
179 float WINAPI MpqGetVersion();
180 [entry("SFMpqDestroy"),helpstring("This no longer needs to be called; it is only provided for compatibility with older versions")]
181 void WINAPI SFMpqDestroy();
182 [entry("SFMpqGetVersionString"),helpstring("")]
183 LPCSTR WINAPI SFMpqGetVersionString();
184 [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.")]
185 DWORD WINAPI SFMpqGetVersionString2(LPCSTR lpBuffer, DWORD dwBufferLength);
186 [entry("SFMpqGetVersion"),helpstring("")]
187 SFMPQVERSION WINAPI SFMpqGetVersion();
188 [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.")]
189 long SFMpqCompareVersion();
190 };
191
192 [helpstring("Storm SFile emulated functions")]
193 module SFile
194 {
195 [entry("SFileOpenArchive"),helpstring("")]
196 BOOL WINAPI SFileOpenArchive(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
197 [entry("SFileCloseArchive"),helpstring("")]
198 BOOL WINAPI SFileCloseArchive(MPQHANDLE hMPQ);
199 [entry("SFileOpenFileAsArchive"),helpstring("")]
200 BOOL WINAPI SFileOpenFileAsArchive(MPQHANDLE hSourceMPQ, LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);
201 [entry("SFileGetArchiveName"),helpstring("")]
202 BOOL WINAPI SFileGetArchiveName(MPQHANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength);
203 [entry("SFileOpenFile"),helpstring("")]
204 BOOL WINAPI SFileOpenFile(LPCSTR lpFileName, MPQHANDLE *hFile);
205 [entry("SFileOpenFileEx"),helpstring("")]
206 BOOL WINAPI SFileOpenFileEx(MPQHANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, MPQHANDLE *hFile);
207 [entry("SFileCloseFile"),helpstring("")]
208 BOOL WINAPI SFileCloseFile(MPQHANDLE hFile);
209 [entry("SFileGetFileSize"),helpstring("")]
210 DWORD WINAPI SFileGetFileSize(MPQHANDLE hFile, LPDWORD lpFileSizeHigh);
211 [entry("SFileGetFileArchive"),helpstring("")]
212 BOOL WINAPI SFileGetFileArchive(MPQHANDLE hFile, MPQHANDLE *hMPQ);
213 [entry("SFileGetFileName"),helpstring("")]
214 BOOL WINAPI SFileGetFileName(MPQHANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength);
215 [entry("SFileSetFilePointer"),helpstring("")]
216 DWORD WINAPI SFileSetFilePointer(MPQHANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod);
217 [entry("SFileReadFile"),helpstring("")]
218 BOOL WINAPI SFileReadFile(MPQHANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped);
219 [entry("SFileReadFile"),helpstring("")]
220 BOOL WINAPI SFileReadFileB(MPQHANDLE hFile,byte *lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped);
221 [entry("SFileSetLocale"),helpstring("")]
222 LCID WINAPI SFileSetLocale(LCID nNewLocale);
223 [entry("SFileGetBasePath"),helpstring("")]
224 BOOL WINAPI SFileGetBasePath(LPCSTR lpBuffer, DWORD dwBufferLength);
225 [entry("SFileSetBasePath"),helpstring("")]
226 BOOL WINAPI SFileSetBasePath(LPCSTR lpNewBasePath);
227 [entry("SFileGetFileInfo"),helpstring("")]
228 DWORD WINAPI SFileGetFileInfo(MPQHANDLE hFile, DWORD dwInfoType);
229 [entry("SFileSetArchivePriority"),helpstring("")]
230 BOOL WINAPI SFileSetArchivePriority(MPQHANDLE hMPQ, DWORD dwPriority);
231 [entry("SFileFindMpqHeader"),helpstring("")]
232 DWORD WINAPI SFileFindMpqHeader(HANDLE hFile);
233 [entry("SFileListFiles"),helpstring("")]
234 BOOL WINAPI SFileListFiles(MPQHANDLE hMPQ, LPCSTR lpFileLists, FILELISTENTRY *lpListBuffer, DWORD dwFlags);
235 [entry("SFileDestroy"),helpstring("")]
236 BOOL WINAPI SFileDestroy();
237 [entry("StormDestroy"),helpstring("")]
238 void WINAPI StormDestroy();
239 };
240
241 [helpstring("MPQ archive creation and editing functions")]
242 module MPQ
243 {
244 [entry("MpqOpenArchiveForUpdate"),helpstring("")]
245 MPQHANDLE WINAPI MpqOpenArchiveForUpdate(LPCSTR lpFileName, DWORD dwFlags, DWORD dwMaximumFilesInArchive);
246 [entry("MpqCloseUpdatedArchive"),helpstring("")]
247 DWORD WINAPI MpqCloseUpdatedArchive(MPQHANDLE hMPQ, DWORD dwUnknown2);
248 [entry("MpqAddFileToArchive"),helpstring("")]
249 BOOL WINAPI MpqAddFileToArchive(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags);
250 [entry("MpqAddWaveToArchive"),helpstring("")]
251 BOOL WINAPI MpqAddWaveToArchive(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwQuality);
252 [entry("MpqRenameFile"),helpstring("")]
253 BOOL WINAPI MpqRenameFile(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName);
254 [entry("MpqDeleteFile"),helpstring("")]
255 BOOL WINAPI MpqDeleteFile(MPQHANDLE hMPQ, LPCSTR lpFileName);
256 [entry("MpqCompactArchive"),helpstring("")]
257 BOOL WINAPI MpqCompactArchive(MPQHANDLE hMPQ);
258 [entry("MpqAddFileToArchiveEx"),helpstring("")]
259 BOOL WINAPI MpqAddFileToArchiveEx(MPQHANDLE hMPQ, LPCSTR lpSourceFileName, LPCSTR lpDestFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
260 [entry("MpqAddFileFromBufferEx"),helpstring("")]
261 BOOL WINAPI MpqAddFileFromBufferEx(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
262 [entry("MpqAddFileFromBufferEx"),helpstring("")]
263 BOOL WINAPI MpqAddFileFromBufferExB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwCompressionType, DWORD dwCompressLevel);
264 [entry("MpqAddFileFromBuffer"),helpstring("")]
265 BOOL WINAPI MpqAddFileFromBuffer(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
266 [entry("MpqAddFileFromBuffer"),helpstring("")]
267 BOOL WINAPI MpqAddFileFromBufferB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags);
268 [entry("MpqAddWaveFromBuffer"),helpstring("")]
269 BOOL WINAPI MpqAddWaveFromBuffer(MPQHANDLE hMPQ, LPVOID lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwQuality);
270 [entry("MpqAddWaveFromBuffer"),helpstring("")]
271 BOOL WINAPI MpqAddWaveFromBufferB(MPQHANDLE hMPQ, byte *lpBuffer, DWORD dwLength, LPCSTR lpFileName, DWORD dwFlags, DWORD dwQuality);
272 [entry("MpqRenameAndSetFileLocale"),helpstring("")]
273 BOOL WINAPI MpqRenameAndSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName, LCID nOldLocale, LCID nNewLocale);
274 [entry("MpqDeleteFileWithLocale"),helpstring("")]
275 BOOL WINAPI MpqDeleteFileWithLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nLocale);
276 [entry("MpqSetFileLocale"),helpstring("")]
277 BOOL WINAPI MpqSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nOldLocale, LCID nNewLocale);
278 };
279
280 [dllname("kernel32.dll")]
281
282 module LastError
283 {
284 [entry("GetLastError"),helpstring("")]
285 DWORD WINAPI GetLastError();
286 };
287};
288