xref: /reactos/sdk/lib/cmlib/hivesum.c (revision 8a978a17)
1 /*
2  * PROJECT:   Registry manipulation library
3  * LICENSE:   GPL - See COPYING in the top level directory
4  * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
5  *            Copyright 2001 - 2005 Eric Kohl
6  */
7 
8 #include "cmlib.h"
9 
10 /**
11  * @name HvpHiveHeaderChecksum
12  *
13  * Compute checksum of hive header and return it.
14  */
15 
16 ULONG CMAPI
17 HvpHiveHeaderChecksum(
18     PHBASE_BLOCK HiveHeader)
19 {
20     PULONG Buffer = (PULONG)HiveHeader;
21     ULONG Sum = 0;
22     ULONG i;
23 
24     for (i = 0; i < 127; i++)
25         Sum ^= Buffer[i];
26     if (Sum == (ULONG)-1)
27         Sum = (ULONG)-2;
28     if (Sum == 0)
29         Sum = 1;
30 
31     return Sum;
32 }
33