mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Finished mkhive.
svn path=/trunk/; revision=4541
This commit is contained in:
parent
273b6dd69f
commit
8b6b2e1d5b
6 changed files with 1478 additions and 15 deletions
File diff suppressed because it is too large
Load diff
|
@ -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.1 2003/04/14 17:18:48 ekohl Exp $
|
/* $Id: infcache.c,v 1.2 2003/04/16 15:06:33 ekohl 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
|
||||||
|
@ -1386,7 +1386,7 @@ InfGetStringField (PINFCONTEXT Context,
|
||||||
Ptr = CacheField->Data;
|
Ptr = CacheField->Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = wcslen (Ptr) + 1;
|
Size = strlen (Ptr) + 1;
|
||||||
|
|
||||||
if (RequiredSize != NULL)
|
if (RequiredSize != NULL)
|
||||||
*RequiredSize = Size;
|
*RequiredSize = Size;
|
||||||
|
|
|
@ -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.1 2003/04/14 17:18:48 ekohl Exp $
|
/* $Id: mkhive.c,v 1.2 2003/04/16 15:06:33 ekohl 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
|
||||||
|
@ -47,6 +47,36 @@
|
||||||
void usage (void)
|
void usage (void)
|
||||||
{
|
{
|
||||||
printf ("Usage: mkhive <srcdir> <dstdir>\n\n");
|
printf ("Usage: mkhive <srcdir> <dstdir>\n\n");
|
||||||
|
printf (" srcdir - inf files are read from this directory\n");
|
||||||
|
printf (" dstdir - binary hive files are created in this directory\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert_path(char *dst, char *src)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (src[i] != 0)
|
||||||
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
if (src[i] == '/')
|
||||||
|
{
|
||||||
|
dst[i] = '\\';
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (src[i] == '\\')
|
||||||
|
{
|
||||||
|
dst[i] = '/';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dst[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
dst[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,43 +84,65 @@ int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char FileName[PATH_MAX];
|
char FileName[PATH_MAX];
|
||||||
|
|
||||||
|
printf ("Binary hive maker\n");
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
usage ();
|
usage ();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegInitializeRegistry ();
|
RegInitializeRegistry ();
|
||||||
|
|
||||||
strcpy (FileName, argv[1]);
|
convert_path (FileName, argv[1]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "hivesys.inf");
|
strcat (FileName, "hivesys.inf");
|
||||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||||
|
|
||||||
#if 0
|
convert_path (FileName, argv[1]);
|
||||||
strcpy (FileName, argv[1]);
|
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "hivecls.inf");
|
strcat (FileName, "hivecls.inf");
|
||||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||||
|
|
||||||
strcpy (FileName, argv[1]);
|
convert_path (FileName, argv[1]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "hivesft.inf");
|
strcat (FileName, "hivesft.inf");
|
||||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||||
|
|
||||||
strcpy (FileName, argv[1]);
|
convert_path (FileName, argv[1]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "hivedef.inf");
|
strcat (FileName, "hivedef.inf");
|
||||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||||
#endif
|
|
||||||
|
|
||||||
strcpy (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "system");
|
strcat (FileName, "system");
|
||||||
ExportBinaryHive (FileName, "\\Registy\\Machine\\System");
|
ExportBinaryHive (FileName, "\\Registry\\Machine\\SYSTEM");
|
||||||
|
|
||||||
|
convert_path (FileName, argv[2]);
|
||||||
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
|
strcat (FileName, "software");
|
||||||
|
ExportBinaryHive (FileName, "\\Registry\\Machine\\SOFTWARE");
|
||||||
|
|
||||||
|
convert_path (FileName, argv[2]);
|
||||||
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
|
strcat (FileName, "sam");
|
||||||
|
ExportBinaryHive (FileName, "\\Registry\\Machine\\SAM");
|
||||||
|
|
||||||
|
convert_path (FileName, argv[2]);
|
||||||
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
|
strcat (FileName, "security");
|
||||||
|
ExportBinaryHive (FileName, "\\Registry\\Machine\\SECURITY");
|
||||||
|
|
||||||
|
convert_path (FileName, argv[2]);
|
||||||
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
|
strcat (FileName, "default");
|
||||||
|
ExportBinaryHive (FileName, "\\Registry\\User\\.DEFAULT");
|
||||||
|
|
||||||
// RegShutdownRegistry ();
|
// RegShutdownRegistry ();
|
||||||
|
|
||||||
|
printf (" Done.\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.1 2003/04/14 17:18:48 ekohl Exp $
|
/* $Id: mkhive.h,v 1.2 2003/04/16 15:06:33 ekohl 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
|
||||||
|
@ -31,12 +31,15 @@
|
||||||
#define VOID void
|
#define VOID void
|
||||||
typedef void *PVOID;
|
typedef void *PVOID;
|
||||||
typedef char CHAR, *PCHAR;
|
typedef char CHAR, *PCHAR;
|
||||||
|
typedef short WCHAR, *PWCHAR;
|
||||||
typedef unsigned char UCHAR, *PUCHAR;
|
typedef unsigned char UCHAR, *PUCHAR;
|
||||||
typedef short SHORT, *PSHORT;
|
typedef short SHORT, *PSHORT;
|
||||||
typedef unsigned short USHORT, *PUSHORT;
|
typedef unsigned short USHORT, *PUSHORT;
|
||||||
typedef long LONG, *PLONG;
|
typedef long LONG, *PLONG;
|
||||||
typedef unsigned long ULONG, *PULONG;
|
typedef unsigned long ULONG, *PULONG;
|
||||||
|
|
||||||
|
typedef unsigned long ULONG_PTR;
|
||||||
|
|
||||||
typedef int BOOL, *PBOOL;
|
typedef int BOOL, *PBOOL;
|
||||||
|
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
|
|
|
@ -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.1 2003/04/14 17:18:48 ekohl Exp $
|
/* $Id: registry.c,v 1.2 2003/04/16 15:06:33 ekohl 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
|
||||||
|
@ -44,6 +44,9 @@ static HKEY RootKey;
|
||||||
VOID
|
VOID
|
||||||
RegInitializeRegistry(VOID)
|
RegInitializeRegistry(VOID)
|
||||||
{
|
{
|
||||||
|
HKEY ControlSetKey;
|
||||||
|
HKEY LinkKey;
|
||||||
|
|
||||||
/* Create root key */
|
/* Create root key */
|
||||||
RootKey = (HKEY)malloc(sizeof(KEY));
|
RootKey = (HKEY)malloc(sizeof(KEY));
|
||||||
|
|
||||||
|
@ -51,6 +54,9 @@ RegInitializeRegistry(VOID)
|
||||||
InitializeListHead(&RootKey->ValueList);
|
InitializeListHead(&RootKey->ValueList);
|
||||||
InitializeListHead(&RootKey->KeyList);
|
InitializeListHead(&RootKey->KeyList);
|
||||||
|
|
||||||
|
RootKey->SubKeyCount = 0;
|
||||||
|
RootKey->ValueCount = 0;
|
||||||
|
|
||||||
RootKey->NameSize = 2;
|
RootKey->NameSize = 2;
|
||||||
RootKey->Name = (PUCHAR)malloc(2);
|
RootKey->Name = (PUCHAR)malloc(2);
|
||||||
strcpy(RootKey->Name, "\\");
|
strcpy(RootKey->Name, "\\");
|
||||||
|
@ -64,10 +70,40 @@ RegInitializeRegistry(VOID)
|
||||||
"Registry\\Machine\\SYSTEM",
|
"Registry\\Machine\\SYSTEM",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* Create link 'CurrentControlSet' --> 'ControlSet001' */
|
||||||
|
RegCreateKey(RootKey,
|
||||||
|
"Registry\\Machine\\SYSTEM\\ControlSet001",
|
||||||
|
&ControlSetKey);
|
||||||
|
|
||||||
|
RegCreateKey(RootKey,
|
||||||
|
"Registry\\Machine\\SYSTEM\\CurrentControlSet",
|
||||||
|
&LinkKey);
|
||||||
|
|
||||||
|
RegSetValue(LinkKey,
|
||||||
|
NULL,
|
||||||
|
REG_LINK,
|
||||||
|
(PUCHAR)&ControlSetKey,
|
||||||
|
sizeof(PVOID));
|
||||||
|
|
||||||
/* Create HARDWARE key */
|
/* Create HARDWARE key */
|
||||||
RegCreateKey(RootKey,
|
RegCreateKey(RootKey,
|
||||||
"Registry\\Machine\\HARDWARE",
|
"Registry\\Machine\\HARDWARE",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* Create SAM key */
|
||||||
|
RegCreateKey(RootKey,
|
||||||
|
"Registry\\Machine\\SAM",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* Create SECURITY key */
|
||||||
|
RegCreateKey(RootKey,
|
||||||
|
"Registry\\Machine\\SECURITY",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* Create DEFAULT key */
|
||||||
|
RegCreateKey(RootKey,
|
||||||
|
"Registry\\User\\.DEFAULT",
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,11 +189,16 @@ RegCreateKey(HKEY ParentKey,
|
||||||
InitializeListHead (&NewKey->SubKeyList);
|
InitializeListHead (&NewKey->SubKeyList);
|
||||||
InitializeListHead (&NewKey->ValueList);
|
InitializeListHead (&NewKey->ValueList);
|
||||||
|
|
||||||
|
NewKey->SubKeyCount = 0;
|
||||||
|
NewKey->ValueCount = 0;
|
||||||
|
|
||||||
NewKey->DataType = 0;
|
NewKey->DataType = 0;
|
||||||
NewKey->DataSize = 0;
|
NewKey->DataSize = 0;
|
||||||
NewKey->Data = NULL;
|
NewKey->Data = NULL;
|
||||||
|
|
||||||
InsertTailList (&CurrentKey->SubKeyList, &NewKey->KeyList);
|
InsertTailList (&CurrentKey->SubKeyList, &NewKey->KeyList);
|
||||||
|
CurrentKey->SubKeyCount++;
|
||||||
|
|
||||||
NewKey->NameSize = subkeyLength + 1;
|
NewKey->NameSize = subkeyLength + 1;
|
||||||
NewKey->Name = (PCHAR)malloc (NewKey->NameSize);
|
NewKey->Name = (PCHAR)malloc (NewKey->NameSize);
|
||||||
if (NewKey->Name == NULL)
|
if (NewKey->Name == NULL)
|
||||||
|
@ -406,6 +447,7 @@ RegSetValue(HKEY Key,
|
||||||
if (Value == NULL)
|
if (Value == NULL)
|
||||||
return(ERROR_OUTOFMEMORY);
|
return(ERROR_OUTOFMEMORY);
|
||||||
InsertTailList(&Key->ValueList, &Value->ValueList);
|
InsertTailList(&Key->ValueList, &Value->ValueList);
|
||||||
|
Key->ValueCount++;
|
||||||
Value->NameSize = strlen(ValueName)+1;
|
Value->NameSize = strlen(ValueName)+1;
|
||||||
Value->Name = (PCHAR)malloc(Value->NameSize);
|
Value->Name = (PCHAR)malloc(Value->NameSize);
|
||||||
if (Value->Name == NULL)
|
if (Value->Name == NULL)
|
||||||
|
@ -564,6 +606,7 @@ RegDeleteValue(HKEY Key,
|
||||||
return(ERROR_INVALID_PARAMETER);
|
return(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
/* delete value */
|
/* delete value */
|
||||||
|
Key->ValueCount--;
|
||||||
if (Value->Name != NULL)
|
if (Value->Name != NULL)
|
||||||
free(Value->Name);
|
free(Value->Name);
|
||||||
Value->Name = NULL;
|
Value->Name = NULL;
|
||||||
|
@ -641,6 +684,24 @@ RegEnumValue(HKEY Key,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
RegGetSubKeyCount (HKEY Key)
|
||||||
|
{
|
||||||
|
return Key->SubKeyCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
RegGetValueCount (HKEY Key)
|
||||||
|
{
|
||||||
|
if (Key->DataSize != 0)
|
||||||
|
return Key->ValueCount + 1;
|
||||||
|
|
||||||
|
return Key->ValueCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
LONG
|
LONG
|
||||||
RegQueryMultipleValue(HKEY Key,
|
RegQueryMultipleValue(HKEY Key,
|
||||||
|
|
|
@ -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.1 2003/04/14 17:18:48 ekohl Exp $
|
/* $Id: registry.h,v 1.2 2003/04/16 15:06:33 ekohl 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,6 +43,9 @@ typedef struct _REG_KEY
|
||||||
LIST_ENTRY SubKeyList;
|
LIST_ENTRY SubKeyList;
|
||||||
LIST_ENTRY ValueList;
|
LIST_ENTRY ValueList;
|
||||||
|
|
||||||
|
ULONG SubKeyCount;
|
||||||
|
ULONG ValueCount;
|
||||||
|
|
||||||
ULONG NameSize;
|
ULONG NameSize;
|
||||||
PUCHAR Name;
|
PUCHAR Name;
|
||||||
|
|
||||||
|
@ -280,6 +283,12 @@ RegEnumValue(HKEY Key,
|
||||||
PUCHAR Data,
|
PUCHAR Data,
|
||||||
PULONG DataSize);
|
PULONG DataSize);
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
RegGetSubKeyCount (HKEY Key);
|
||||||
|
|
||||||
|
ULONG
|
||||||
|
RegGetValueCount (HKEY Key);
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
BOOL
|
BOOL
|
||||||
|
|
Loading…
Reference in a new issue