Leaked source code of windows server 2003
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.

60 lines
1.3 KiB

  1. //
  2. // MODULE: CRC.H
  3. //
  4. // PURPOSE: Header for CRC support
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  9. //
  10. // AUTHOR: Richard Meadows
  11. //
  12. // ORIGINAL DATE: 8/7/97
  13. //
  14. // NOTES:
  15. // 1.
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.2 8/7/97 RM Local Version for Memphis
  20. // V0.3 3/24/98 JM Local Version for NT5
  21. //
  22. #ifndef __CCRC_H_
  23. #define __CCRC_H_ 1
  24. #include "GenException.h"
  25. inline CString GlobFormatMessage(DWORD dwLastError)
  26. {
  27. CString strMessage;
  28. void *lpvMessage;
  29. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  30. NULL,
  31. dwLastError,
  32. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
  33. (LPTSTR) &lpvMessage, 0, NULL);
  34. strMessage = (LPCTSTR) lpvMessage;
  35. LocalFree(lpvMessage);
  36. return strMessage;
  37. }
  38. class CCRC
  39. {
  40. const DWORD POLYNOMIAL;
  41. public:
  42. CCRC();
  43. DWORD DscEncode(LPCTSTR szDsc);
  44. void AppendCRC(LPCTSTR szCache, DWORD dwCRCValue);
  45. bool Decode(LPCTSTR szDsc, LPCTSTR szCache, const CString& strCacheFileWithinCHM);
  46. protected:
  47. DWORD dwCrcTable[256];
  48. void BuildCrcTable();
  49. DWORD ComputeCRC(LPCSTR sznBuffer, DWORD dwBufSize, DWORD dwAccum);
  50. };
  51. #endif