| 956 | // Public functions |
| 957 | |
| 958 | bool WINAPI CascGetFileInfo(HANDLE hFile, CASC_FILE_INFO_CLASS InfoClass, void * pvFileInfo, size_t cbFileInfo, size_t * pcbLengthNeeded) |
| 959 | { |
| 960 | TCascFile * hf; |
| 961 | LPBYTE pbOutputValue = NULL; |
| 962 | LPBYTE pbInfoValue = NULL; |
| 963 | size_t cbInfoValue = 0; |
| 964 | |
| 965 | // Validate the file handle |
| 966 | if((hf = TCascFile::IsValid(hFile)) == NULL) |
| 967 | { |
| 968 | SetCascError(ERROR_INVALID_HANDLE); |
| 969 | return false; |
| 970 | } |
| 971 | |
| 972 | // Differentiate between info classes |
| 973 | switch(InfoClass) |
| 974 | { |
| 975 | case CascFileContentKey: |
| 976 | |
| 977 | // Do we have content key at all? |
| 978 | if(hf->pCKeyEntry == NULL || (hf->pCKeyEntry->Flags & CASC_CE_HAS_CKEY) == 0) |
| 979 | { |
| 980 | SetCascError(ERROR_NOT_SUPPORTED); |
| 981 | return false; |
| 982 | } |
| 983 | |
| 984 | // Give the content key |
| 985 | pbInfoValue = hf->pCKeyEntry->CKey; |
| 986 | cbInfoValue = CASC_CKEY_SIZE; |
| 987 | break; |
| 988 | |
| 989 | case CascFileEncodedKey: |
| 990 | |
| 991 | // Do we have content key at all? |
| 992 | if(hf->pCKeyEntry == NULL || (hf->pCKeyEntry->Flags & CASC_CE_HAS_EKEY) == 0) |
| 993 | { |
| 994 | SetCascError(ERROR_NOT_SUPPORTED); |
| 995 | return false; |
| 996 | } |
| 997 | |
| 998 | // Give the content key |
| 999 | pbInfoValue = hf->pCKeyEntry->EKey; |
| 1000 | cbInfoValue = CASC_CKEY_SIZE; |
| 1001 | break; |
| 1002 | |
| 1003 | case CascFileFullInfo: |
| 1004 | return GetFileFullInfo(hf, pvFileInfo, cbFileInfo, pcbLengthNeeded); |
| 1005 | |
| 1006 | case CascFileSpanInfo: |
| 1007 | return GetFileSpanInfo(hf, pvFileInfo, cbFileInfo, pcbLengthNeeded); |
| 1008 | |
| 1009 | default: |
| 1010 | SetCascError(ERROR_INVALID_PARAMETER); |
| 1011 | return false; |
| 1012 | } |
| 1013 | |
| 1014 | // Sanity check |
| 1015 | assert(pbInfoValue != NULL); |