本文整理汇总了C++中IsValidMpqHandle函数的典型用法代码示例。如果您正苦于以下问题:C++ IsValidMpqHandle函数的具体用法?C++ IsValidMpqHandle怎么用?C++ IsValidMpqHandle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsValidMpqHandle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SFileVerifyArchive
// Verifies the archive against the signature
DWORD WINAPI SFileVerifyArchive(HANDLE hMpq)
{
MPQ_SIGNATURE_INFO si;
TMPQArchive * ha = (TMPQArchive *)hMpq;
// Verify input parameters
if(!IsValidMpqHandle(hMpq))
return ERROR_VERIFY_FAILED;
// If the archive was modified, we need to flush it
if(ha->dwFlags & MPQ_FLAG_CHANGED)
SFileFlushArchive(hMpq);
// Get the MPQ signature and signature type
memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO));
if(!QueryMpqSignatureInfo(ha, &si))
return ERROR_VERIFY_FAILED;
// If there is no signature
if(si.SignatureTypes == 0)
return ERROR_NO_SIGNATURE;
// We haven't seen a MPQ with both signatures
assert(si.SignatureTypes == SIGNATURE_TYPE_WEAK || si.SignatureTypes == SIGNATURE_TYPE_STRONG);
// Verify the strong signature, if present
if(si.SignatureTypes & SIGNATURE_TYPE_STRONG)
return VerifyStrongSignature(ha, &si);
// Verify the weak signature, if present
if(si.SignatureTypes & SIGNATURE_TYPE_WEAK)
return VerifyWeakSignature(ha, &si);
return ERROR_NO_SIGNATURE;
}
示例2: SFileVerifyArchive
// Verifies the archive against the signature
DWORD WINAPI SFileVerifyArchive(HANDLE hMpq)
{
MPQ_SIGNATURE_INFO si;
TMPQArchive * ha = (TMPQArchive *)hMpq;
// Verify input parameters
if(!IsValidMpqHandle(ha))
return ERROR_VERIFY_FAILED;
// Get the MPQ signature and signature type
memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO));
if(!QueryMpqSignatureInfo(ha, &si))
return ERROR_VERIFY_FAILED;
// Verify the signature
switch(si.nSignatureType)
{
case SIGNATURE_TYPE_NONE:
return ERROR_NO_SIGNATURE;
case SIGNATURE_TYPE_WEAK:
return VerifyWeakSignature(ha, &si);
case SIGNATURE_TYPE_STRONG:
return VerifyStrongSignature(ha, &si);
}
return ERROR_VERIFY_FAILED;
}
示例3: SFileFlushArchive
bool WINAPI SFileFlushArchive(HANDLE hMpq)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
int nResultError = ERROR_SUCCESS;
int nError;
// Do nothing if 'hMpq' is bad parameter
if (!IsValidMpqHandle(ha))
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
// If the archive has been changed, update the changes on the disk drive.
// Save listfile (if created), attributes (if created) and also save MPQ tables.
if (ha->dwFlags & MPQ_FLAG_CHANGED)
{
nError = SListFileSaveToMpq(ha);
if (nError != ERROR_SUCCESS)
nResultError = nError;
nError = SAttrFileSaveToMpq(ha);
if (nError != ERROR_SUCCESS)
nResultError = nError;
nError = SaveMPQTables(ha);
if (nError != ERROR_SUCCESS)
nResultError = nError;
}
// Return the error
if (nResultError != ERROR_SUCCESS)
SetLastError(nResultError);
return (nResultError == ERROR_SUCCESS);
}
示例4: IsValidSearchHandle
static bool IsValidSearchHandle(TMPQSearch * hs)
{
if(hs == NULL)
return false;
return IsValidMpqHandle(hs->ha);
}
示例5: SFileSetHashTableSize
bool WINAPI SFileSetHashTableSize(HANDLE hMpq, DWORD dwNewTableSize)
{
SFILE_FIND_DATA sf;
TMPQArchive * ha = (TMPQArchive *)hMpq;
TFileNode ** pListFileToFree = NULL;
TFileNode ** pNewListFile = NULL;
TMPQHash * pOldHashTable = NULL;
TMPQHash * pNewHashTable = NULL;
TMPQHash * pTableToFree = NULL;
TMPQHash * pNewHash = NULL;
HANDLE hFind;
DWORD dwOldTableSize = ha->pHeader->dwHashTableSize;
DWORD dwIndex;
bool bFoundSomething = true;
int nError = ERROR_SUCCESS;
// Test the valid parameters
if(!IsValidMpqHandle(ha))
nError = ERROR_INVALID_HANDLE;
if(ha->dwFlags & MPQ_FLAG_READ_ONLY)
nError = ERROR_ACCESS_DENIED;
// New hash table size must be a power of two
if(dwNewTableSize & (dwNewTableSize - 1))
nError = ERROR_INVALID_PARAMETER;
// Allocate buffers for copy of the old hash table and new hash table
if(nError == ERROR_SUCCESS)
{
pOldHashTable = ALLOCMEM(TMPQHash, dwOldTableSize);
pNewHashTable = ALLOCMEM(TMPQHash, dwNewTableSize);
pNewListFile = ALLOCMEM(TFileNode *, dwNewTableSize);
if(pOldHashTable == NULL || pNewHashTable == NULL)
nError = ERROR_NOT_ENOUGH_MEMORY;
}
示例6: SFileRemoveFile
bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope)
{
TMPQArchive * ha = IsValidMpqHandle(hMpq);
TMPQFile * hf = NULL;
int nError = ERROR_SUCCESS;
// Keep compiler happy
dwSearchScope = dwSearchScope;
// Check the parameters
if(ha == NULL)
nError = ERROR_INVALID_HANDLE;
if(szFileName == NULL || *szFileName == 0)
nError = ERROR_INVALID_PARAMETER;
if(IsInternalMpqFileName(szFileName))
nError = ERROR_INTERNAL_FILE;
// Do not allow to remove files from read-only or patched MPQs
if(nError == ERROR_SUCCESS)
{
if((ha->dwFlags & MPQ_FLAG_READ_ONLY) || (ha->haPatch != NULL))
nError = ERROR_ACCESS_DENIED;
}
// If all checks have passed, we can delete the file from the MPQ
if(nError == ERROR_SUCCESS)
{
// Open the file from the MPQ
if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf))
{
// Delete the file entry
nError = DeleteFileEntry(ha, hf);
FreeFileHandle(hf);
}
else
nError = GetLastError();
}
// If the file has been deleted, we need to invalidate
// the internal files and recreate HET table
if(nError == ERROR_SUCCESS)
{
// Invalidate the entries for internal files
// After we are done with MPQ changes, we need to re-create them anyway
InvalidateInternalFiles(ha);
//
// Don't rebuild HET table now; the file's flags indicate
// that it's been deleted, which is enough
//
}
// Resolve error and exit
if(nError != ERROR_SUCCESS)
SetLastError(nError);
return (nError == ERROR_SUCCESS);
}
示例7: IsValidSearchHandle
static TMPQSearch * IsValidSearchHandle(HANDLE hFind)
{
TMPQSearch * hs = (TMPQSearch *)hFind;
if(hs != NULL && IsValidMpqHandle(hs->ha))
return hs;
return NULL;
}
示例8: SFileIsPatchedArchive
bool WINAPI SFileIsPatchedArchive(HANDLE hMpq)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
// Verify input parameters
if(!IsValidMpqHandle(ha))
return false;
return (ha->haPatch != NULL);
}
示例9: SFileCreateFile
bool WINAPI SFileCreateFile(
HANDLE hMpq,
const char * szArchivedName,
ULONGLONG FileTime,
DWORD dwFileSize,
LCID lcLocale,
DWORD dwFlags,
HANDLE * phFile)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
int nError = ERROR_SUCCESS;
// Check valid parameters
if(!IsValidMpqHandle(hMpq))
nError = ERROR_INVALID_HANDLE;
if(szArchivedName == NULL || *szArchivedName == 0)
nError = ERROR_INVALID_PARAMETER;
if(phFile == NULL)
nError = ERROR_INVALID_PARAMETER;
// Don't allow to add file if the MPQ is open for read only
if(nError == ERROR_SUCCESS)
{
if(ha->dwFlags & MPQ_FLAG_READ_ONLY)
nError = ERROR_ACCESS_DENIED;
// Don't allow to add a file under pseudo-file name
if(IsPseudoFileName(szArchivedName, NULL))
nError = ERROR_INVALID_PARAMETER;
// Don't allow to add any of the internal files
if(IsInternalMpqFileName(szArchivedName))
nError = ERROR_INTERNAL_FILE;
}
// Perform validity check of the MPQ flags
if(nError == ERROR_SUCCESS)
{
// Mask all unsupported flags out
dwFlags &= MPQ_FILE_VALID_FLAGS;
// Check for valid flag combinations
if((dwFlags & (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) == (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS))
nError = ERROR_INVALID_PARAMETER;
}
// Initiate the add file operation
if(nError == ERROR_SUCCESS)
nError = SFileAddFile_Init(ha, szArchivedName, FileTime, dwFileSize, lcLocale, dwFlags, (TMPQFile **)phFile);
// Deal with the errors
if(nError != ERROR_SUCCESS)
SetLastError(nError);
return (nError == ERROR_SUCCESS);
}
示例10: SFileHasFile
bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
TFileEntry * pFileEntry;
DWORD dwFlagsToCheck = MPQ_FILE_EXISTS;
DWORD dwFileIndex = 0;
char szPatchFileName[MAX_PATH];
bool bIsPseudoName;
int nError = ERROR_SUCCESS;
if(!IsValidMpqHandle(ha))
nError = ERROR_INVALID_HANDLE;
if(szFileName == NULL || *szFileName == 0)
nError = ERROR_INVALID_PARAMETER;
// Prepare the file opening
if(nError == ERROR_SUCCESS)
{
// Different processing for pseudo-names
bIsPseudoName = IsPseudoFileName(szFileName, &dwFileIndex);
// Walk through the MPQ and all patches
while(ha != NULL)
{
// Verify presence of the file
pFileEntry = (bIsPseudoName == false) ? GetFileEntryLocale(ha, szFileName, lcFileLocale)
: GetFileEntryByIndex(ha, dwFileIndex);
// Verify the file flags
if(pFileEntry != NULL && (pFileEntry->dwFlags & dwFlagsToCheck) == MPQ_FILE_EXISTS)
return true;
// If this is patched archive, go to the patch
dwFlagsToCheck = MPQ_FILE_EXISTS | MPQ_FILE_PATCH_FILE;
ha = ha->haPatch;
// Prepare the patched file name
if(ha != NULL)
{
strcpy(szPatchFileName, ha->szPatchPrefix);
strcat(szPatchFileName, szFileName);
szFileName = szPatchFileName;
}
}
// Not found, sorry
nError = ERROR_FILE_NOT_FOUND;
}
// Cleanup
SetLastError(nError);
return false;
}
示例11: SFileSetDownloadCallback
bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
// Do nothing if 'hMpq' is bad parameter
if(!IsValidMpqHandle(hMpq))
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
return FileStream_SetCallback(ha->pStream, DownloadCB, pvUserData);
}
示例12: SFileSetAddFileCallback
bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData)
{
TMPQArchive * ha = (TMPQArchive *) hMpq;
if(!IsValidMpqHandle(hMpq))
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
ha->pvAddFileUserData = pvUserData;
ha->pfnAddFileCB = AddFileCB;
return true;
}
示例13: SFileSetCompactCallback
int EXPORT_SYMBOL SFileSetCompactCallback(void * hMpq, SFILE_COMPACT_CALLBACK pfnCompactCB, void * pvUserData)
{
TMPQArchive * ha = (TMPQArchive *) hMpq;
if (!IsValidMpqHandle(hMpq))
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
ha->pfnCompactCB = pfnCompactCB;
ha->pvCompactUserData = pvUserData;
return 1;
}
示例14: SFileSetCompactCallback
bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK pfnCompactCB, void * pvUserData)
{
TMPQArchive * ha = (TMPQArchive *) hMpq;
if (!IsValidMpqHandle(hMpq))
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
ha->pfnCompactCB = pfnCompactCB;
ha->pvCompactUserData = pvUserData;
return true;
}
示例15: SFileAddFileEx
BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType)
{
TMPQArchive * ha = (TMPQArchive *)hMPQ;
HANDLE hFile = INVALID_HANDLE_VALUE;
BOOL bReplaced = FALSE; // TRUE if replacing file in the archive
int nError = ERROR_SUCCESS;
if(nError == ERROR_SUCCESS)
{
// Check valid parameters
if(IsValidMpqHandle(ha) == FALSE || szFileName == NULL || *szFileName == 0 || szArchivedName == NULL || *szArchivedName == 0)
nError = ERROR_INVALID_PARAMETER;
// Check the values of dwFlags
if((dwFlags & MPQ_FILE_IMPLODE) && (dwFlags & MPQ_FILE_COMPRESS))
nError = ERROR_INVALID_PARAMETER;
}
// If anyone is trying to add listfile, and the archive already has a listfile,
// deny the operation, but return success.
if(nError == ERROR_SUCCESS)
{
if(ha->pListFile != NULL && !_stricmp(szFileName, LISTFILE_NAME))
return ERROR_SUCCESS;
}
// Open added file
if(nError == ERROR_SUCCESS)
{
hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
nError = GetLastError();
}
if(nError == ERROR_SUCCESS)
nError = AddFileToArchive(ha, hFile, szArchivedName, dwFlags, dwQuality, nFileType, &bReplaced);
// Add the file into listfile also
if(nError == ERROR_SUCCESS && bReplaced == FALSE)
nError = SListFileCreateNode(ha, szArchivedName, lcLocale);
// Cleanup and exit
if(hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
if(nError != ERROR_SUCCESS)
SetLastError(nError);
return (nError == ERROR_SUCCESS);
}