MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / CascImportKeysFromFile

Function CascImportKeysFromFile

src/External/CascLib/src/CascDecrypt.cpp:898–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898bool WINAPI CascImportKeysFromFile(HANDLE hStorage, LPCTSTR szFileName)
899{
900 TFileStream * pFileStream;
901 ULONGLONG FileSize = 0;
902 LPSTR szKeyList;
903 bool bResult = false;
904
905 // Open the file
906 if((pFileStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY)) != NULL)
907 {
908 // Load the entire file to memory, up to 10 MB
909 if(FileStream_GetSize(pFileStream, &FileSize) && FileSize < 0xA00000)
910 {
911 DWORD FileSize32 = (DWORD)FileSize;
912
913 // Allocate buffer for the key stream
914 if((szKeyList = CASC_ALLOC<char>(FileSize32 + 1)) != NULL)
915 {
916 // Read the entire file and terminate it with zero
917 FileStream_Read(pFileStream, NULL, szKeyList, FileSize32);
918 szKeyList[FileSize] = 0;
919
920 // Import the buffer
921 bResult = CascImportKeysFromString(hStorage, szKeyList);
922 CASC_FREE(szKeyList);
923 }
924 }
925 else
926 SetCascError(ERROR_FILE_TOO_LARGE);
927
928 FileStream_Close(pFileStream);
929 }
930
931 return bResult;
932}
933
934DWORD CascDirectCopy(LPBYTE pbOutBuffer, PDWORD pcbOutBuffer, LPBYTE pbInBuffer, DWORD cbInBuffer)
935{

Callers

nothing calls this directly

Calls 7

FileStream_OpenFileFunction · 0.85
FileStream_GetSizeFunction · 0.85
FileStream_ReadFunction · 0.85
CascImportKeysFromStringFunction · 0.85
CASC_FREEFunction · 0.85
SetCascErrorFunction · 0.85
FileStream_CloseFunction · 0.85

Tested by

no test coverage detected