msvc6 and gcc4 support

svn path=/trunk/; revision=12405
This commit is contained in:
Royce Mitchell III 2004-12-30 16:02:12 +00:00
parent 365dff816f
commit 78c79c31e7
7 changed files with 80 additions and 37 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: binhive.c,v 1.12 2004/11/15 19:20:23 gdalsnes Exp $ /* $Id: binhive.c,v 1.13 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/binhive.c * FILE: tools/mkhive/binhive.c
@ -58,7 +58,15 @@
// BLOCK_OFFSET = offset in file after header block // BLOCK_OFFSET = offset in file after header block
typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET; typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET;
#ifdef _MSC_VER
typedef unsigned __int64 FILETIME;
#else
typedef unsigned long long FILETIME; typedef unsigned long long FILETIME;
#endif
#ifdef _MSC_VER
#pragma pack ( push, hive_header, 1 )
#endif//_MSC_VER
/* header for registry hive file : */ /* header for registry hive file : */
typedef struct _HIVE_HEADER typedef struct _HIVE_HEADER
@ -105,7 +113,7 @@ typedef struct _HIVE_HEADER
/* Checksum of first 0x200 bytes */ /* Checksum of first 0x200 bytes */
ULONG Checksum; ULONG Checksum;
} __attribute__((packed)) HIVE_HEADER, *PHIVE_HEADER; } GCC_PACKED HIVE_HEADER, *PHIVE_HEADER;
typedef struct _HBIN typedef struct _HBIN
{ {
@ -126,13 +134,13 @@ typedef struct _HBIN
/* ? */ /* ? */
ULONG Unused2; ULONG Unused2;
} __attribute__((packed)) HBIN, *PHBIN; } GCC_PACKED HBIN, *PHBIN;
typedef struct _CELL_HEADER typedef struct _CELL_HEADER
{ {
/* <0 if used, >0 if free */ /* <0 if used, >0 if free */
LONG CellSize; LONG CellSize;
} __attribute__((packed)) CELL_HEADER, *PCELL_HEADER; } GCC_PACKED CELL_HEADER, *PCELL_HEADER;
typedef struct _KEY_CELL typedef struct _KEY_CELL
{ {
@ -189,7 +197,7 @@ typedef struct _KEY_CELL
/* Name of key (not zero terminated) */ /* Name of key (not zero terminated) */
UCHAR Name[0]; UCHAR Name[0];
} __attribute__((packed)) KEY_CELL, *PKEY_CELL; } GCC_PACKED KEY_CELL, *PKEY_CELL;
/* KEY_CELL.Type constants */ /* KEY_CELL.Type constants */
#define REG_LINK_KEY_CELL_TYPE 0x10 #define REG_LINK_KEY_CELL_TYPE 0x10
@ -203,7 +211,7 @@ typedef struct _HASH_RECORD
{ {
BLOCK_OFFSET KeyOffset; BLOCK_OFFSET KeyOffset;
ULONG HashValue; ULONG HashValue;
} __attribute__((packed)) HASH_RECORD, *PHASH_RECORD; } GCC_PACKED HASH_RECORD, *PHASH_RECORD;
typedef struct _HASH_TABLE_CELL typedef struct _HASH_TABLE_CELL
{ {
@ -211,13 +219,13 @@ typedef struct _HASH_TABLE_CELL
USHORT Id; USHORT Id;
USHORT HashTableSize; USHORT HashTableSize;
HASH_RECORD Table[0]; HASH_RECORD Table[0];
} __attribute__((packed)) HASH_TABLE_CELL, *PHASH_TABLE_CELL; } GCC_PACKED HASH_TABLE_CELL, *PHASH_TABLE_CELL;
typedef struct _VALUE_LIST_CELL typedef struct _VALUE_LIST_CELL
{ {
LONG CellSize; LONG CellSize;
BLOCK_OFFSET ValueOffset[0]; BLOCK_OFFSET ValueOffset[0];
} __attribute__((packed)) VALUE_LIST_CELL, *PVALUE_LIST_CELL; } GCC_PACKED VALUE_LIST_CELL, *PVALUE_LIST_CELL;
typedef struct _VALUE_CELL typedef struct _VALUE_CELL
{ {
@ -230,7 +238,7 @@ typedef struct _VALUE_CELL
USHORT Flags; USHORT Flags;
USHORT Unused1; USHORT Unused1;
UCHAR Name[0]; /* warning : not zero terminated */ UCHAR Name[0]; /* warning : not zero terminated */
} __attribute__((packed)) VALUE_CELL, *PVALUE_CELL; } GCC_PACKED VALUE_CELL, *PVALUE_CELL;
/* VALUE_CELL.Flags constants */ /* VALUE_CELL.Flags constants */
#define REG_VALUE_NAME_PACKED 0x0001 #define REG_VALUE_NAME_PACKED 0x0001
@ -243,7 +251,11 @@ typedef struct _DATA_CELL
{ {
LONG CellSize; LONG CellSize;
UCHAR Data[0]; UCHAR Data[0];
} __attribute__((packed)) DATA_CELL, *PDATA_CELL; } GCC_PACKED DATA_CELL, *PDATA_CELL;
#ifdef _MSC_VER
#pragma pack ( pop, hive_header )
#endif//_MSC_VER
typedef struct _REGISTRY_HIVE typedef struct _REGISTRY_HIVE
{ {
@ -279,7 +291,7 @@ CmiCreateDefaultHiveHeader (PHIVE_HEADER Header)
Header->BlockId = REG_HIVE_ID; Header->BlockId = REG_HIVE_ID;
Header->UpdateCounter1 = 0; Header->UpdateCounter1 = 0;
Header->UpdateCounter2 = 0; Header->UpdateCounter2 = 0;
Header->DateModified = 0ULL; Header->DateModified = 0;
Header->Unused3 = 1; Header->Unused3 = 1;
Header->Unused4 = 3; Header->Unused4 = 3;
Header->Unused5 = 0; Header->Unused5 = 0;
@ -298,7 +310,7 @@ CmiCreateDefaultBinCell(PHBIN BinCell)
assert (BinCell); assert (BinCell);
memset (BinCell, 0, REG_BLOCK_SIZE); memset (BinCell, 0, REG_BLOCK_SIZE);
BinCell->HeaderId = REG_BIN_ID; BinCell->HeaderId = REG_BIN_ID;
BinCell->DateModified = 0ULL; BinCell->DateModified = 0;
BinCell->BinSize = REG_BLOCK_SIZE; BinCell->BinSize = REG_BLOCK_SIZE;
} }
@ -307,7 +319,7 @@ static VOID
CmiCreateDefaultRootKeyCell(PKEY_CELL RootKeyCell, PCHAR KeyName) CmiCreateDefaultRootKeyCell(PKEY_CELL RootKeyCell, PCHAR KeyName)
{ {
PCHAR BaseKeyName; PCHAR BaseKeyName;
ULONG NameSize; USHORT NameSize;
ULONG CellSize; ULONG CellSize;
assert (RootKeyCell); assert (RootKeyCell);
@ -317,10 +329,10 @@ CmiCreateDefaultRootKeyCell(PKEY_CELL RootKeyCell, PCHAR KeyName)
CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize - 1, 16); CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize - 1, 16);
memset (RootKeyCell, 0, CellSize); memset (RootKeyCell, 0, CellSize);
RootKeyCell->CellSize = -CellSize; RootKeyCell->CellSize = (ULONG)-(LONG)CellSize;
RootKeyCell->Id = REG_KEY_CELL_ID; RootKeyCell->Id = REG_KEY_CELL_ID;
RootKeyCell->Type = REG_ROOT_KEY_CELL_TYPE; RootKeyCell->Type = REG_ROOT_KEY_CELL_TYPE;
RootKeyCell->LastWriteTime = 0ULL; RootKeyCell->LastWriteTime = 0;
RootKeyCell->ParentKeyOffset = 0; RootKeyCell->ParentKeyOffset = 0;
RootKeyCell->NumberOfSubKeys = 0; RootKeyCell->NumberOfSubKeys = 0;
RootKeyCell->HashTableOffset = -1; RootKeyCell->HashTableOffset = -1;
@ -725,7 +737,7 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
RegistryHive->FileSize += BinSize; RegistryHive->FileSize += BinSize;
tmpBin->BinSize = BinSize; tmpBin->BinSize = BinSize;
tmpBin->Unused1 = 0; tmpBin->Unused1 = 0;
tmpBin->DateModified = 0ULL; tmpBin->DateModified = 0;
tmpBin->Unused2 = 0; tmpBin->Unused2 = 0;
/* Increase size of list of blocks */ /* Increase size of list of blocks */
@ -840,7 +852,7 @@ CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
static BOOL static BOOL
CmiAllocateHashTableCell (PREGISTRY_HIVE Hive, CmiAllocateHashTableCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET HBOffset, PBLOCK_OFFSET HBOffset,
ULONG SubKeyCount) USHORT SubKeyCount)
{ {
PHASH_TABLE_CELL HashCell; PHASH_TABLE_CELL HashCell;
ULONG NewHashSize; ULONG NewHashSize;
@ -941,7 +953,7 @@ CmiAllocateValueCell(PREGISTRY_HIVE Hive,
PCHAR ValueName) PCHAR ValueName)
{ {
PVALUE_CELL NewValueCell; PVALUE_CELL NewValueCell;
ULONG NameSize; USHORT NameSize;
BOOL Status; BOOL Status;
NameSize = (ValueName == NULL) ? 0 : strlen (ValueName); NameSize = (ValueName == NULL) ? 0 : strlen (ValueName);
@ -1123,7 +1135,7 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
BLOCK_OFFSET NKBOffset; BLOCK_OFFSET NKBOffset;
PKEY_CELL NewKeyCell; PKEY_CELL NewKeyCell;
ULONG KeyCellSize; ULONG KeyCellSize;
ULONG SubKeyCount; USHORT SubKeyCount;
ULONG ValueCount; ULONG ValueCount;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
HKEY SubKey; HKEY SubKey;
@ -1146,7 +1158,7 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
/* Initialize key cell */ /* Initialize key cell */
NewKeyCell->Id = REG_KEY_CELL_ID; NewKeyCell->Id = REG_KEY_CELL_ID;
NewKeyCell->Type = REG_KEY_CELL_TYPE; NewKeyCell->Type = REG_KEY_CELL_TYPE;
NewKeyCell->LastWriteTime = 0ULL; NewKeyCell->LastWriteTime = 0;
NewKeyCell->ParentKeyOffset = ParentKeyOffset; NewKeyCell->ParentKeyOffset = ParentKeyOffset;
NewKeyCell->NumberOfSubKeys = 0; NewKeyCell->NumberOfSubKeys = 0;
NewKeyCell->HashTableOffset = -1; NewKeyCell->HashTableOffset = -1;
@ -1249,7 +1261,7 @@ CmiExportHive (PREGISTRY_HIVE Hive,
{ {
PKEY_CELL KeyCell; PKEY_CELL KeyCell;
HKEY Key; HKEY Key;
ULONG SubKeyCount; USHORT SubKeyCount;
ULONG ValueCount; ULONG ValueCount;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
HKEY SubKey; HKEY SubKey;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: infcache.c,v 1.8 2003/11/14 17:13:36 weiden Exp $ /* $Id: infcache.c,v 1.9 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/infcache.c * FILE: tools/mkhive/infcache.c
@ -57,7 +57,7 @@ typedef struct _INFCACHELINE
struct _INFCACHELINE *Next; struct _INFCACHELINE *Next;
struct _INFCACHELINE *Prev; struct _INFCACHELINE *Prev;
LONG FieldCount; ULONG FieldCount;
PCHAR Key; PCHAR Key;
@ -437,7 +437,7 @@ inline static int is_eol( struct parser *parser, const CHAR *ptr )
/* push data from current token start up to pos into the current token */ /* push data from current token start up to pos into the current token */
static int push_token( struct parser *parser, const CHAR *pos ) static int push_token( struct parser *parser, const CHAR *pos )
{ {
int len = pos - parser->start; ULONG len = pos - parser->start;
const CHAR *src = parser->start; const CHAR *src = parser->start;
CHAR *dst = parser->token + parser->token_len; CHAR *dst = parser->token + parser->token_len;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: mkhive.c,v 1.5 2004/11/15 19:20:23 gdalsnes Exp $ /* $Id: mkhive.c,v 1.6 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/mkhive.c * FILE: tools/mkhive/mkhive.c
@ -33,6 +33,11 @@
#include "reginf.h" #include "reginf.h"
#include "binhive.h" #include "binhive.h"
#ifdef _MSC_VER
#include <stdlib.h>
#define PATH_MAX _MAX_PATH
#endif//_MSC_VER
#ifndef WIN32 #ifndef WIN32
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 260 #define PATH_MAX 260

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: mkhive.h,v 1.2 2003/04/16 15:06:33 ekohl Exp $ /* $Id: mkhive.h,v 1.3 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/mkhive.h * FILE: tools/mkhive/mkhive.h
@ -65,12 +65,38 @@ typedef int BOOL, *PBOOL;
/* Debugging macros */ /* Debugging macros */
#ifdef _MSC_VER
#include <stdio.h>
#include <stdarg.h>
static void DPRINT1(const char* fmt, ... )
{
va_list args;
va_start ( args, fmt );
vprintf ( fmt, args );
va_end ( args );
}
static void DPRINT ( const char* fmt, ... )
{
}
#else
#define DPRINT1(args...) do { printf("(%s:%d) ",__FILE__,__LINE__); printf(args); } while(0); #define DPRINT1(args...) do { printf("(%s:%d) ",__FILE__,__LINE__); printf(args); } while(0);
#define DPRINT(args...)
#endif//_MSC_VER
#define CHECKPOINT1 do { printf("%s:%d\n",__FILE__,__LINE__); } while(0); #define CHECKPOINT1 do { printf("%s:%d\n",__FILE__,__LINE__); } while(0);
#define DPRINT(args...)
#define CHECKPOINT #define CHECKPOINT
#ifdef WIN32
#define strncasecmp strnicmp
#define strcasecmp stricmp
#endif//WIN32
#ifdef _MSC_VER
#define GCC_PACKED
#define inline
#else//_MSC_VER
#define GCC_PACKED __attribute__((packed))
#endif//_MSC_VER
#endif /* __MKHIVE_H__ */ #endif /* __MKHIVE_H__ */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: reginf.c,v 1.7 2004/06/04 23:47:04 navaraf Exp $ /* $Id: reginf.c,v 1.8 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/reginf.h * FILE: tools/mkhive/reginf.h
@ -298,7 +298,7 @@ do_reg_operation(HKEY KeyHandle,
{ {
ULONG dw = Str ? strtoul (Str, NULL, 0) : 0; ULONG dw = Str ? strtoul (Str, NULL, 0) : 0;
DPRINT("setting dword %s to %lx\n", ValueName, dw); DPRINT1("setting dword %s to %lx\n", ValueName, dw);
RegSetValue (KeyHandle, RegSetValue (KeyHandle,
ValueName, ValueName,
@ -308,7 +308,7 @@ do_reg_operation(HKEY KeyHandle,
} }
else else
{ {
DPRINT ("setting value %s to %s\n", ValueName, Str); DPRINT1 ("setting value %s to %s\n", ValueName, Str);
if (Str) if (Str)
{ {

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: registry.c,v 1.10 2004/06/04 23:47:04 navaraf Exp $ /* $Id: registry.c,v 1.11 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/registry.c * FILE: tools/mkhive/registry.c
@ -126,7 +126,7 @@ RegCreateKey(HKEY ParentKey,
int subkeyLength; int subkeyLength;
int stringLength; int stringLength;
DPRINT ("KeyName '%s'\n", KeyName); DPRINT ("RegCreateKey('%s')\n", KeyName);
if (*KeyName == '\\') if (*KeyName == '\\')
{ {
@ -687,7 +687,7 @@ RegEnumValue(HKEY Key,
} }
ULONG USHORT
RegGetSubKeyCount (HKEY Key) RegGetSubKeyCount (HKEY Key)
{ {
return Key->SubKeyCount; return Key->SubKeyCount;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: registry.h,v 1.2 2003/04/16 15:06:33 ekohl Exp $ /* $Id: registry.h,v 1.3 2004/12/30 16:02:12 royce Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker * PROJECT: ReactOS hive maker
* FILE: tools/mkhive/registry.h * FILE: tools/mkhive/registry.h
@ -43,10 +43,10 @@ typedef struct _REG_KEY
LIST_ENTRY SubKeyList; LIST_ENTRY SubKeyList;
LIST_ENTRY ValueList; LIST_ENTRY ValueList;
ULONG SubKeyCount; USHORT SubKeyCount;
ULONG ValueCount; ULONG ValueCount;
ULONG NameSize; USHORT NameSize;
PUCHAR Name; PUCHAR Name;
/* default data */ /* default data */
@ -283,7 +283,7 @@ RegEnumValue(HKEY Key,
PUCHAR Data, PUCHAR Data,
PULONG DataSize); PULONG DataSize);
ULONG USHORT
RegGetSubKeyCount (HKEY Key); RegGetSubKeyCount (HKEY Key);
ULONG ULONG