From 2cd0a85f576a50fd2c44827109e3a6dffa45da84 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 18 May 2003 13:50:58 +0000 Subject: [PATCH] Do not overwrite existing hive files. Add hive header checksum. svn path=/trunk/; revision=4710 --- reactos/tools/mkhive/binhive.c | 16 +++++++++++++--- reactos/tools/mkhive/infcache.c | 3 +-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/reactos/tools/mkhive/binhive.c b/reactos/tools/mkhive/binhive.c index ff7ca2e343a..764b8df1816 100644 --- a/reactos/tools/mkhive/binhive.c +++ b/reactos/tools/mkhive/binhive.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: binhive.c,v 1.3 2003/04/22 21:14:39 ekohl Exp $ +/* $Id: binhive.c,v 1.4 2003/05/18 13:50:58 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS hive maker * FILE: tools/mkhive/binhive.c @@ -1319,17 +1319,27 @@ CmiWriteHive(PREGISTRY_HIVE Hive, FILE *File; ULONG i; - /* FIXME: Calculate header checksum */ + /* Check for existing hive file */ + File = fopen (FileName, "rb"); + if (File != NULL) + { + printf (" File already exists\n"); + fclose (File); + return TRUE; + } + /* Create new hive file */ File = fopen (FileName, "w+b"); if (File == NULL) { - return FALSE; } fseek (File, 0, SEEK_SET); + /* Calculate header checksum */ + CmiCalcHiveChecksum (Hive); + /* Write hive header */ fwrite (Hive->HiveHeader, REG_BLOCK_SIZE, 1, File); diff --git a/reactos/tools/mkhive/infcache.c b/reactos/tools/mkhive/infcache.c index 6757b171fbb..9059c9301a8 100644 --- a/reactos/tools/mkhive/infcache.c +++ b/reactos/tools/mkhive/infcache.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: infcache.c,v 1.4 2003/05/18 12:12:07 ekohl Exp $ +/* $Id: infcache.c,v 1.5 2003/05/18 13:50:58 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS hive maker * FILE: tools/mkhive/infcache.c @@ -426,7 +426,6 @@ inline static int is_eof( struct parser *parser, const CHAR *ptr ) /* check if the pointer points to an end of line */ inline static int is_eol( struct parser *parser, const CHAR *ptr ) { -// return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\r' /*'\n'*/); return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\n' ||