mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +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
|
||||
* 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
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/infcache.c
|
||||
|
@ -1386,7 +1386,7 @@ InfGetStringField (PINFCONTEXT Context,
|
|||
Ptr = CacheField->Data;
|
||||
}
|
||||
|
||||
Size = wcslen (Ptr) + 1;
|
||||
Size = strlen (Ptr) + 1;
|
||||
|
||||
if (RequiredSize != NULL)
|
||||
*RequiredSize = Size;
|
||||
|
|
|
@ -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: 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
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/mkhive.c
|
||||
|
@ -47,6 +47,36 @@
|
|||
void usage (void)
|
||||
{
|
||||
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];
|
||||
|
||||
printf ("Binary hive maker\n");
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
usage ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
RegInitializeRegistry ();
|
||||
|
||||
strcpy (FileName, argv[1]);
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivesys.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
|
||||
#if 0
|
||||
strcpy (FileName, argv[1]);
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivecls.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
|
||||
strcpy (FileName, argv[1]);
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivesft.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
|
||||
strcpy (FileName, argv[1]);
|
||||
convert_path (FileName, argv[1]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
strcat (FileName, "hivedef.inf");
|
||||
ImportRegistryFile (FileName, "AddReg", FALSE);
|
||||
#endif
|
||||
|
||||
strcpy (FileName, argv[2]);
|
||||
convert_path (FileName, argv[2]);
|
||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||
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 ();
|
||||
|
||||
printf (" Done.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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: 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
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/mkhive.h
|
||||
|
@ -31,12 +31,15 @@
|
|||
#define VOID void
|
||||
typedef void *PVOID;
|
||||
typedef char CHAR, *PCHAR;
|
||||
typedef short WCHAR, *PWCHAR;
|
||||
typedef unsigned char UCHAR, *PUCHAR;
|
||||
typedef short SHORT, *PSHORT;
|
||||
typedef unsigned short USHORT, *PUSHORT;
|
||||
typedef long LONG, *PLONG;
|
||||
typedef unsigned long ULONG, *PULONG;
|
||||
|
||||
typedef unsigned long ULONG_PTR;
|
||||
|
||||
typedef int BOOL, *PBOOL;
|
||||
|
||||
#ifndef FALSE
|
||||
|
|
|
@ -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: 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
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/registry.c
|
||||
|
@ -44,6 +44,9 @@ static HKEY RootKey;
|
|||
VOID
|
||||
RegInitializeRegistry(VOID)
|
||||
{
|
||||
HKEY ControlSetKey;
|
||||
HKEY LinkKey;
|
||||
|
||||
/* Create root key */
|
||||
RootKey = (HKEY)malloc(sizeof(KEY));
|
||||
|
||||
|
@ -51,6 +54,9 @@ RegInitializeRegistry(VOID)
|
|||
InitializeListHead(&RootKey->ValueList);
|
||||
InitializeListHead(&RootKey->KeyList);
|
||||
|
||||
RootKey->SubKeyCount = 0;
|
||||
RootKey->ValueCount = 0;
|
||||
|
||||
RootKey->NameSize = 2;
|
||||
RootKey->Name = (PUCHAR)malloc(2);
|
||||
strcpy(RootKey->Name, "\\");
|
||||
|
@ -64,10 +70,40 @@ RegInitializeRegistry(VOID)
|
|||
"Registry\\Machine\\SYSTEM",
|
||||
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 */
|
||||
RegCreateKey(RootKey,
|
||||
"Registry\\Machine\\HARDWARE",
|
||||
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->ValueList);
|
||||
|
||||
NewKey->SubKeyCount = 0;
|
||||
NewKey->ValueCount = 0;
|
||||
|
||||
NewKey->DataType = 0;
|
||||
NewKey->DataSize = 0;
|
||||
NewKey->Data = NULL;
|
||||
|
||||
InsertTailList (&CurrentKey->SubKeyList, &NewKey->KeyList);
|
||||
CurrentKey->SubKeyCount++;
|
||||
|
||||
NewKey->NameSize = subkeyLength + 1;
|
||||
NewKey->Name = (PCHAR)malloc (NewKey->NameSize);
|
||||
if (NewKey->Name == NULL)
|
||||
|
@ -406,6 +447,7 @@ RegSetValue(HKEY Key,
|
|||
if (Value == NULL)
|
||||
return(ERROR_OUTOFMEMORY);
|
||||
InsertTailList(&Key->ValueList, &Value->ValueList);
|
||||
Key->ValueCount++;
|
||||
Value->NameSize = strlen(ValueName)+1;
|
||||
Value->Name = (PCHAR)malloc(Value->NameSize);
|
||||
if (Value->Name == NULL)
|
||||
|
@ -564,6 +606,7 @@ RegDeleteValue(HKEY Key,
|
|||
return(ERROR_INVALID_PARAMETER);
|
||||
|
||||
/* delete value */
|
||||
Key->ValueCount--;
|
||||
if (Value->Name != NULL)
|
||||
free(Value->Name);
|
||||
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
|
||||
LONG
|
||||
RegQueryMultipleValue(HKEY Key,
|
||||
|
|
|
@ -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: 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
|
||||
* PROJECT: ReactOS hive maker
|
||||
* FILE: tools/mkhive/registry.h
|
||||
|
@ -43,6 +43,9 @@ typedef struct _REG_KEY
|
|||
LIST_ENTRY SubKeyList;
|
||||
LIST_ENTRY ValueList;
|
||||
|
||||
ULONG SubKeyCount;
|
||||
ULONG ValueCount;
|
||||
|
||||
ULONG NameSize;
|
||||
PUCHAR Name;
|
||||
|
||||
|
@ -280,6 +283,12 @@ RegEnumValue(HKEY Key,
|
|||
PUCHAR Data,
|
||||
PULONG DataSize);
|
||||
|
||||
ULONG
|
||||
RegGetSubKeyCount (HKEY Key);
|
||||
|
||||
ULONG
|
||||
RegGetValueCount (HKEY Key);
|
||||
|
||||
|
||||
#if 0
|
||||
BOOL
|
||||
|
|
Loading…
Reference in a new issue