Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: filecrc.h
  6. //
  7. // Purpose: Calculating and using CRC for files
  8. //
  9. //=======================================================================
  10. #ifndef _FILECRC_H
  11. #define _FILECRC_H
  12. // size of the CRC hash in bytes
  13. const int WUCRC_HASH_SIZE = 20;
  14. // binary structure to hold the hash
  15. struct WUCRC_HASH
  16. {
  17. BYTE HashBytes[WUCRC_HASH_SIZE];
  18. };
  19. struct WUCRCMAP
  20. {
  21. DWORD dwKey;
  22. WUCRC_HASH CRC;
  23. };
  24. HRESULT CalculateFileCRC(LPCTSTR pszFN, WUCRC_HASH* pCRC);
  25. HRESULT StringFromCRC(const WUCRC_HASH* pCRC, LPTSTR pszBuf, int cbBuf);
  26. HRESULT CRCFromString(LPCSTR pszCRC, WUCRC_HASH* pCRC);
  27. HRESULT SplitCRCName(LPCSTR pszCRCName, WUCRC_HASH* pCRC, LPSTR pszName);
  28. HRESULT MakeCRCName(LPCTSTR pszFromName, const WUCRC_HASH* pCRC, LPTSTR pszToName, int cbToName);
  29. HRESULT GetCRCNameFromList(int iNo, PBYTE pmszCabList, PBYTE pCRCList, LPTSTR pszCRCName, int cbCRCName, LPTSTR pszCabName);
  30. int __cdecl CompareWUCRCMAP(const void* p1, const void* p2);
  31. class CCRCMapFile
  32. {
  33. public:
  34. CCRCMapFile(const BYTE* pMemData, DWORD dwMemSize);
  35. HRESULT GetValue(DWORD dwKey, WUCRC_HASH* pCRC);
  36. HRESULT GetCRCName(DWORD dwKey, LPCTSTR pszFromName, LPTSTR pszToName, int cbToName);
  37. private:
  38. CCRCMapFile() {} // cannot use default constructor
  39. WUCRCMAP* m_pEntries;
  40. DWORD m_cEntries;
  41. };
  42. #endif // _FILECRC_H