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
a36705ea 1// License information for this code is in license.txt
2
3#ifndef SFMPQ_INTERNAL_INCLUDED
4#define SFMPQ_INTERNAL_INCLUDED
5
6#include <windows.h>
7#include "SFmpqapi.h"
8
9struct MPQARCHIVE;
10struct MPQFILE;
11
12//Archive handles are typecasted to this struct internally to access
13//this data. This struct is based on Storm's internal struct for
14//archive handles.
15struct MPQARCHIVE {
16 // Arranged according to priority with lowest priority first
17 MPQARCHIVE * lpNextArc; //0// Pointer to the next MPQARCHIVE struct. Pointer to addresses of first and last archives if last archive
18 MPQARCHIVE * lpPrevArc; //4// Pointer to the previous MPQARCHIVE struct. 0xEAFC5E23 if first archive
19 char szFileName[260]; //8// Filename of the archive
20 HANDLE hFile; //10C// The archive's file handle
21 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
22 DWORD dwPriority; //114// Priority of the archive set when calling SFileOpenArchive
23 MPQFILE * lpLastReadFile; //118// Pointer to the last read file's MPQFILE struct. This is cleared when finished reading a block
24 DWORD dwUnk; //11C// Seems to always be 0
25 DWORD dwBlockSize; //120// Size of file blocks in bytes
26 BYTE * lpLastReadBlock; //124// Pointer to the read buffer for archive. This is cleared when finished reading a block
27 DWORD dwBufferSize; //128// Size of the read buffer for archive. This is cleared when finished reading a block
28 UINT64 qwMPQStart; //12C// The starting offset of the archive
29 UINT64 qwMPQEnd; //130// The ending offset of the archive
30 MPQHEADER * lpMPQHeader; //134// Pointer to the archive header
31 BLOCKTABLEENTRY * lpBlockTable; //138// Pointer to the start of the block table
32 HASHTABLEENTRY * lpHashTable; //13C// Pointer to the start of the hash table
33 UINT64 qwReadOffset; //140// Offset to the data for a file
34 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
35 // Extra struct members used by SFmpq
36 MPQHEADER MpqHeader;
37 DWORD dwFlags; //The only flags that should be changed are MOAU_MAINTAIN_LISTFILE and MOAU_MAINTAIN_ATTRIBUTES, changing any others can have unpredictable effects
38 LPSTR lpFileName;
39 DWORD dwExtraFlags;
40 MPQHEADER_EX MpqHeader_Ex;
41 DWORD dwHeaderSize;
42 WORD * lpFileOffsetsHigh;
43};
44
45//Handles to files in the archive are typecasted to this struct
46//internally to access this data. This struct is based on
47//Storm's internal struct for file handles.
48struct MPQFILE {
49 MPQFILE * lpNextFile; //0// Pointer to the next MPQFILE struct. Pointer to addresses of first and last files if last file
50 MPQFILE * lpPrevFile; //4// Pointer to the previous MPQFILE struct. 0xEAFC5E13 if first file
51 char szFileName[260]; //8// Filename of the file
52 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
53 MPQARCHIVE * lpParentArc; //110// Pointer to the MPQARCHIVE struct of the archive in which the file is contained
54 BLOCKTABLEENTRY * lpBlockEntry; //114// Pointer to the file's block table entry
55 DWORD dwCryptKey; //118// Decryption key for the file
56 DWORD dwFilePointer; //11C// Position of file pointer in the file
57 DWORD dwUnk; //120// Seems to always be 0
58 DWORD dwBlockCount; //124// Number of blocks in file
59 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
60 DWORD dwReadStarted; //12C// Set to 1 after first read
61 BOOL bStreaming; //130// 1 when streaming a WAVE
62 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
63 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
64 DWORD dwBufferSize; //13C// Size of the read buffer for file. This is cleared when SFileSetFilePointer is called or when finished reading the block
65 DWORD dwRefCount; //140// Count of references to this open file
66 // Extra struct members used by SFmpq
67 HASHTABLEENTRY *lpHashEntry;
68 LPSTR lpFileName;
69 WORD wFileOffsetHigh;
70};
71
72#endif // #ifndef SFMPQ_INTERNAL_INCLUDED