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.

64 lines
865 B

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. hivesum.c
  5. Abstract:
  6. Hive header checksum module.
  7. Author:
  8. Bryan M. Willman (bryanwi) 9-Apr-92
  9. Environment:
  10. Revision History:
  11. --*/
  12. #include "cmp.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE,HvpHeaderCheckSum)
  15. #endif
  16. ULONG
  17. HvpHeaderCheckSum(
  18. PHBASE_BLOCK BaseBlock
  19. )
  20. /*++
  21. Routine Description:
  22. Compute the checksum for a hive disk header.
  23. Arguments:
  24. BaseBlock - supplies pointer to the header to checksum
  25. Return Value:
  26. the check sum.
  27. --*/
  28. {
  29. ULONG sum;
  30. ULONG i;
  31. sum = 0;
  32. for (i = 0; i < 127; i++) {
  33. sum ^= ((PULONG)BaseBlock)[i];
  34. }
  35. if (sum == (ULONG)-1) {
  36. sum = (ULONG)-2;
  37. }
  38. if (sum == 0) {
  39. sum = 1;
  40. }
  41. return sum;
  42. }