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




index 9508d61..4facc42 100644 (file)
@@ -1,6 +1,6 @@
 /*
 
-  ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2009
+  ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2010
   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-2009, ShadowFlare <blakflare@hotmail.com>
+  Copyright (c) 2002-2010, ShadowFlare <blakflare@hotmail.com>
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
@@ -230,6 +230,7 @@ long SFMPQAPI __inline SFMpqCompareVersion();
 // MpqAddFileToArchive flags
 #define MAFA_EXISTS           0x80000000 //This flag will be added if not present
 #define MAFA_UNKNOWN40000000  0x40000000 //Unknown flag
+#define MAFA_SINGLEBLOCK      0x01000000 //File is stored as a single unit rather than being split by the block size
 #define MAFA_MODCRYPTKEY      0x00020000 //Used with MAFA_ENCRYPT. Uses an encryption key based on file position and size
 #define MAFA_ENCRYPT          0x00010000 //Encrypts the file. The file is still accessible when using this, so the use of this has depreciated
 #define MAFA_COMPRESS         0x00000200 //File is to be compressed when added. This is used for most of the compression methods
@@ -295,6 +296,8 @@ long SFMPQAPI __inline SFMpqCompareVersion();
 
 typedef HANDLE MPQHANDLE;
 
+#include <pshpack1.h>
+
 struct FILELISTENTRY {
        DWORD dwFileExists; // Nonzero if this entry is used
        LCID lcLocale; // Locale ID of file
@@ -304,9 +307,8 @@ struct FILELISTENTRY {
        char szFileName[260];
 };
 
-struct MPQARCHIVE;
-struct MPQFILE;
 struct MPQHEADER;
+struct MPQHEADER_EX;
 struct BLOCKTABLEENTRY;
 struct HASHTABLEENTRY;
 
@@ -314,7 +316,7 @@ struct MPQHEADER {
        DWORD dwMPQID; //"MPQ\x1A" for mpq's, "BN3\x1A" for bncache.dat
        DWORD dwHeaderSize; // Size of this header
        DWORD dwMPQSize; //The size of the mpq archive
-       WORD wUnused0C; // Seems to always be 0
+       WORD wVersion; // 0 for original format, 1 for large archive
        WORD wBlockSize; // Size of blocks in files equals 512 << wBlockSize
        DWORD dwHashTableOffset; // Offset to hash table
        DWORD dwBlockTableOffset; // Offset to block table
@@ -322,61 +324,11 @@ struct MPQHEADER {
        DWORD dwBlockTableSize; // Number of entries in block table
 };
 
-//Archive handles may be typecasted to this struct so you can access
-//some of the archive's properties and the decrypted hash table and
-//block table directly.  This struct is based on Storm's internal
-//struct for archive handles.
-struct MPQARCHIVE {
-       // Arranged according to priority with lowest priority first
-       MPQARCHIVE * lpNextArc; //0// Pointer to the next MPQARCHIVE struct. Pointer to addresses of first and last archives if last archive
-       MPQARCHIVE * lpPrevArc; //4// Pointer to the previous MPQARCHIVE struct. 0xEAFC5E23 if first archive
-       char szFileName[260]; //8// Filename of the archive
-       HANDLE hFile; //10C// The archive's file handle
-       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
-       DWORD dwPriority; //114// Priority of the archive set when calling SFileOpenArchive
-       MPQFILE * lpLastReadFile; //118// Pointer to the last read file's MPQFILE struct. This is cleared when finished reading a block
-       DWORD dwUnk; //11C// Seems to always be 0
-       DWORD dwBlockSize; //120// Size of file blocks in bytes
-       BYTE * lpLastReadBlock; //124// Pointer to the read buffer for archive. This is cleared when finished reading a block
-       DWORD dwBufferSize; //128// Size of the read buffer for archive. This is cleared when finished reading a block
-       DWORD dwMPQStart; //12C// The starting offset of the archive
-       DWORD dwMPQEnd; //130// The ending offset of the archive
-       MPQHEADER * lpMPQHeader; //134// Pointer to the archive header
-       BLOCKTABLEENTRY * lpBlockTable; //138// Pointer to the start of the block table
-       HASHTABLEENTRY * lpHashTable; //13C// Pointer to the start of the hash table
-       DWORD dwReadOffset; //140// Offset to the data for a file
-       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
-       // Extra struct members used by SFmpq
-       MPQHEADER MpqHeader;
-       DWORD dwFlags; //The only flags that should be changed are MOAU_MAINTAIN_LISTFILE and MOAU_MAINTAIN_ATTRIBUTES, changing any others can have unpredictable effects
-       LPSTR lpFileName;
-       DWORD dwExtraFlags;
-};
-
-//Handles to files in the archive may be typecasted to this struct
-//so you can access some of the file's properties directly.  This
-//struct is based on Storm's internal struct for file handles.
-struct MPQFILE {
-       MPQFILE * lpNextFile; //0// Pointer to the next MPQFILE struct. Pointer to addresses of first and last files if last file
-       MPQFILE * lpPrevFile; //4// Pointer to the previous MPQFILE struct. 0xEAFC5E13 if first file
-       char szFileName[260]; //8// Filename of the file
-       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
-       MPQARCHIVE * lpParentArc; //110// Pointer to the MPQARCHIVE struct of the archive in which the file is contained
-       BLOCKTABLEENTRY * lpBlockEntry; //114// Pointer to the file's block table entry
-       DWORD dwCryptKey; //118// Decryption key for the file
-       DWORD dwFilePointer; //11C// Position of file pointer in the file
-       DWORD dwUnk; //120// Seems to always be 0
-       DWORD dwBlockCount; //124// Number of blocks in file
-       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
-       DWORD dwReadStarted; //12C// Set to 1 after first read
-       BOOL bStreaming; //130// 1 when streaming a WAVE
-       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
-       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
-       DWORD dwBufferSize; //13C// Size of the read buffer for file. This is cleared when SFileSetFilePointer is called or when finished reading the block
-       DWORD dwRefCount; //140// Count of references to this open file
-       // Extra struct members used by SFmpq
-       HASHTABLEENTRY *lpHashEntry;
-       LPSTR lpFileName;
+// Large archive format only
+struct MPQHEADER_EX {
+       UINT64 qwExtendedBlockOffsetTable; // Offset to table containing upper 16 bits of block offsets
+       WORD wHashTableOffsetHigh; // High 16 bits of the hash table offset for large archives
+       WORD wBlockTableOffsetHigh; // High 16 bits of the block table offset for large archives
 };
 
 struct BLOCKTABLEENTRY {
@@ -393,6 +345,8 @@ struct HASHTABLEENTRY {
        DWORD dwBlockTableIndex; // Index to the block table entry for the file
 };
 
+#include <poppack.h>
+
 // Defines for backward compatibility with old lmpqapi function names
 #define MpqAddFileToArcive MpqAddFileToArchive
 #define MpqOpenArchive     SFileOpenArchive
@@ -443,6 +397,7 @@ BOOL      SFMPQAPI WINAPI MpqAddWaveFromBuffer(MPQHANDLE hMPQ, LPVOID lpBuffer,
 BOOL      SFMPQAPI WINAPI MpqRenameAndSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpcOldFileName, LPCSTR lpcNewFileName, LCID nOldLocale, LCID nNewLocale);
 BOOL      SFMPQAPI WINAPI MpqDeleteFileWithLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nLocale);
 BOOL      SFMPQAPI WINAPI MpqSetFileLocale(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID nOldLocale, LCID nNewLocale);
+BOOL      SFMPQAPI WINAPI MpqCreateArchiveVersion(WORD wVersion);
 
 // These functions do nothing.  They are only provided for
 // compatibility with MPQ extractors that use storm.