DWORD WINAPI CascGetFileSize(HANDLE hFile, PDWORD pdwFileSizeHigh) { TCascFile * hf; int nError; CASCLIB_UNUSED(pdwFileSizeHigh); // Validate the file handle if((hf = IsValidFileHandle(hFile)) == NULL) { SetLastError(ERROR_INVALID_HANDLE); return CASC_INVALID_SIZE; } // Make sure that the file header area is loaded nError = EnsureHeaderAreaIsLoaded(hf); if(nError != ERROR_SUCCESS) { SetLastError(nError); return CASC_INVALID_SIZE; } // Give the file size to the caller if(pdwFileSizeHigh != NULL) *pdwFileSizeHigh = 0; return hf->FileSize; }
static void ResolveFullFileNames( TRootHandler_Diablo3 * pRootHandler, PDIABLO3_CORE_TOC_ENTRY pCoreTocEntries, PCASC_MAP pPackageMap, LPBYTE pbCoreTocFile, DWORD dwFileIndexes) { PCASC_FILE_ENTRY pFileEntry; char * szPlainName; char * szNamePtr; size_t nLength; DWORD dwRootIndex; DWORD dwFileIndex; DWORD dwSubIndex; char szShortName[MAX_PATH+1]; char szFullName[MAX_PATH+1]; // Keep compiler happy CASCLIB_UNUSED(dwFileIndexes); // Parse the entire file table for(size_t i = 0; i < pRootHandler->FileTable.ItemCount; i++) { // Retrieve the file entry at n-th position pFileEntry = (PCASC_FILE_ENTRY)Array_ItemAt(&pRootHandler->FileTable, i); // Skip the items that already have full name if(pFileEntry->dwFlags & CASC_ENTRY_SHORT_NAME) { // Retrieve the file index of that file dwRootIndex = INDEX64_ROOT_INDEX(pFileEntry->FileNameHash); dwFileIndex = INDEX64_FILE_INDEX(pFileEntry->FileNameHash); dwSubIndex = (pFileEntry->dwFlags & CASC_ENTRY_HAS_SUBINDEX) ? INDEX64_SUB_INDEX(pFileEntry->FileNameHash) : DIABLO3_INVALID_INDEX; assert(dwFileIndex < dwFileIndexes); // Get the plain name of the file szPlainName = (char *)(pbCoreTocFile + pCoreTocEntries[dwFileIndex].NameOffset); // Create the short file name nLength = CreateShortName(pPackageMap, dwRootIndex, pCoreTocEntries[dwFileIndex].AssetIndex, szPlainName, dwSubIndex, szShortName); // Insert the short name to the list of the names szNamePtr = (char *)Array_Insert(&pRootHandler->FileNames, szShortName, nLength + 1); pFileEntry->dwFileName = (DWORD)Array_IndexOf(&pRootHandler->FileNames, szNamePtr); // Create the full file name nLength = CreateFileName(pRootHandler, szShortName, szFullName); pFileEntry->FileNameHash = CalcFileNameHash(szFullName); // Insert the entry to the name map. Use the mapping of FullName -> FileHash Map_InsertObject(pRootHandler->pRootMap, pFileEntry, &pFileEntry->FileNameHash); } } }