| 303 | } |
| 304 | |
| 305 | ULONGLONG CalculateRawSectorOffset( |
| 306 | TMPQFile * hf, |
| 307 | DWORD dwSectorOffset) |
| 308 | { |
| 309 | ULONGLONG RawFilePos; |
| 310 | |
| 311 | // Must be used for files within a MPQ |
| 312 | assert(hf->ha != NULL); |
| 313 | assert(hf->ha->pHeader != NULL); |
| 314 | |
| 315 | // |
| 316 | // Some MPQ protectors place the sector offset table after the actual file data. |
| 317 | // Sector offsets in the sector offset table are negative. When added |
| 318 | // to MPQ file offset from the block table entry, the result is a correct |
| 319 | // position of the file data in the MPQ. |
| 320 | // |
| 321 | // For MPQs version 1.0, the offset is purely 32-bit |
| 322 | // |
| 323 | |
| 324 | RawFilePos = hf->RawFilePos + dwSectorOffset; |
| 325 | if(hf->ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) |
| 326 | RawFilePos = (DWORD)hf->ha->MpqPos + (DWORD)hf->pFileEntry->ByteOffset + dwSectorOffset; |
| 327 | |
| 328 | // We also have to add patch header size, if patch header is present |
| 329 | if(hf->pPatchInfo != NULL) |
| 330 | RawFilePos += hf->pPatchInfo->dwLength; |
| 331 | |
| 332 | // Return the result offset |
| 333 | return RawFilePos; |
| 334 | } |
| 335 | |
| 336 | // This function converts the MPQ header so it always looks like version 4 |
| 337 | int ConvertMpqHeaderToFormat4( |
no outgoing calls
no test coverage detected