* 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.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
* PROJECT: ReactOS hive maker
* FILE: tools/mkhive/binhive.c
// BLOCK_OFFSET = offset in file after header block
typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET;
+#ifdef _MSC_VER
+typedef unsigned __int64 FILETIME;
+#else
typedef unsigned long long FILETIME;
+#endif
+
+#ifdef _MSC_VER
+#pragma pack ( push, hive_header, 1 )
+#endif//_MSC_VER
/* header for registry hive file : */
typedef struct _HIVE_HEADER
/* Checksum of first 0x200 bytes */
ULONG Checksum;
-} __attribute__((packed)) HIVE_HEADER, *PHIVE_HEADER;
+} GCC_PACKED HIVE_HEADER, *PHIVE_HEADER;
typedef struct _HBIN
{
/* ? */
ULONG Unused2;
-} __attribute__((packed)) HBIN, *PHBIN;
+} GCC_PACKED HBIN, *PHBIN;
typedef struct _CELL_HEADER
{
/* <0 if used, >0 if free */
LONG CellSize;
-} __attribute__((packed)) CELL_HEADER, *PCELL_HEADER;
+} GCC_PACKED CELL_HEADER, *PCELL_HEADER;
typedef struct _KEY_CELL
{
/* Name of key (not zero terminated) */
UCHAR Name[0];
-} __attribute__((packed)) KEY_CELL, *PKEY_CELL;
+} GCC_PACKED KEY_CELL, *PKEY_CELL;
/* KEY_CELL.Type constants */
#define REG_LINK_KEY_CELL_TYPE 0x10
{
BLOCK_OFFSET KeyOffset;
ULONG HashValue;
-} __attribute__((packed)) HASH_RECORD, *PHASH_RECORD;
+} GCC_PACKED HASH_RECORD, *PHASH_RECORD;
typedef struct _HASH_TABLE_CELL
{
USHORT Id;
USHORT HashTableSize;
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
{
LONG CellSize;
BLOCK_OFFSET ValueOffset[0];
-} __attribute__((packed)) VALUE_LIST_CELL, *PVALUE_LIST_CELL;
+} GCC_PACKED VALUE_LIST_CELL, *PVALUE_LIST_CELL;
typedef struct _VALUE_CELL
{
USHORT Flags;
USHORT Unused1;
UCHAR Name[0]; /* warning : not zero terminated */
-} __attribute__((packed)) VALUE_CELL, *PVALUE_CELL;
+} GCC_PACKED VALUE_CELL, *PVALUE_CELL;
/* VALUE_CELL.Flags constants */
#define REG_VALUE_NAME_PACKED 0x0001
{
LONG CellSize;
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
{
Header->BlockId = REG_HIVE_ID;
Header->UpdateCounter1 = 0;
Header->UpdateCounter2 = 0;
- Header->DateModified = 0ULL;
+ Header->DateModified = 0;
Header->Unused3 = 1;
Header->Unused4 = 3;
Header->Unused5 = 0;
assert (BinCell);
memset (BinCell, 0, REG_BLOCK_SIZE);
BinCell->HeaderId = REG_BIN_ID;
- BinCell->DateModified = 0ULL;
+ BinCell->DateModified = 0;
BinCell->BinSize = REG_BLOCK_SIZE;
}
CmiCreateDefaultRootKeyCell(PKEY_CELL RootKeyCell, PCHAR KeyName)
{
PCHAR BaseKeyName;
- ULONG NameSize;
+ USHORT NameSize;
ULONG CellSize;
assert (RootKeyCell);
CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize - 1, 16);
memset (RootKeyCell, 0, CellSize);
- RootKeyCell->CellSize = -CellSize;
+ RootKeyCell->CellSize = (ULONG)-(LONG)CellSize;
RootKeyCell->Id = REG_KEY_CELL_ID;
RootKeyCell->Type = REG_ROOT_KEY_CELL_TYPE;
- RootKeyCell->LastWriteTime = 0ULL;
+ RootKeyCell->LastWriteTime = 0;
RootKeyCell->ParentKeyOffset = 0;
RootKeyCell->NumberOfSubKeys = 0;
RootKeyCell->HashTableOffset = -1;
RegistryHive->FileSize += BinSize;
tmpBin->BinSize = BinSize;
tmpBin->Unused1 = 0;
- tmpBin->DateModified = 0ULL;
+ tmpBin->DateModified = 0;
tmpBin->Unused2 = 0;
/* Increase size of list of blocks */
static BOOL
CmiAllocateHashTableCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET HBOffset,
- ULONG SubKeyCount)
+ USHORT SubKeyCount)
{
PHASH_TABLE_CELL HashCell;
ULONG NewHashSize;
PCHAR ValueName)
{
PVALUE_CELL NewValueCell;
- ULONG NameSize;
+ USHORT NameSize;
BOOL Status;
NameSize = (ValueName == NULL) ? 0 : strlen (ValueName);
BLOCK_OFFSET NKBOffset;
PKEY_CELL NewKeyCell;
ULONG KeyCellSize;
- ULONG SubKeyCount;
+ USHORT SubKeyCount;
ULONG ValueCount;
PLIST_ENTRY Entry;
HKEY SubKey;
/* Initialize key cell */
NewKeyCell->Id = REG_KEY_CELL_ID;
NewKeyCell->Type = REG_KEY_CELL_TYPE;
- NewKeyCell->LastWriteTime = 0ULL;
+ NewKeyCell->LastWriteTime = 0;
NewKeyCell->ParentKeyOffset = ParentKeyOffset;
NewKeyCell->NumberOfSubKeys = 0;
NewKeyCell->HashTableOffset = -1;
{
PKEY_CELL KeyCell;
HKEY Key;
- ULONG SubKeyCount;
+ USHORT SubKeyCount;
ULONG ValueCount;
PLIST_ENTRY Entry;
HKEY SubKey;
* along with this program; if not, write to the Free Software
* 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
* PROJECT: ReactOS hive maker
* FILE: tools/mkhive/mkhive.h
/* 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 DPRINT(args...)
+#endif//_MSC_VER
#define CHECKPOINT1 do { printf("%s:%d\n",__FILE__,__LINE__); } while(0);
-#define DPRINT(args...)
#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__ */