mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 04:20:46 +00:00
[FORMATTING] Fix spaces/tabs mess
No code change. svn path=/trunk/; revision=28667
This commit is contained in:
parent
157fa523ae
commit
7395ac2cc6
2 changed files with 439 additions and 432 deletions
|
@ -49,127 +49,126 @@
|
||||||
|
|
||||||
void usage (void)
|
void usage (void)
|
||||||
{
|
{
|
||||||
printf ("Usage: mkhive <srcdir> <dstdir> [addinf]\n\n");
|
printf ("Usage: mkhive <srcdir> <dstdir> [addinf]\n\n");
|
||||||
printf (" srcdir - inf files are read from this directory\n");
|
printf (" srcdir - inf files are read from this directory\n");
|
||||||
printf (" dstdir - binary hive files are created in this directory\n");
|
printf (" dstdir - binary hive files are created in this directory\n");
|
||||||
printf (" addinf - additional inf files with full path\n");
|
printf (" addinf - additional inf files with full path\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert_path(char *dst, char *src)
|
void convert_path(char *dst, char *src)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (src[i] != 0)
|
while (src[i] != 0)
|
||||||
{
|
{
|
||||||
#ifdef WINDOWS_HOST
|
#ifdef WINDOWS_HOST
|
||||||
if (src[i] == '/')
|
if (src[i] == '/')
|
||||||
{
|
{
|
||||||
dst[i] = '\\';
|
dst[i] = '\\';
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (src[i] == '\\')
|
if (src[i] == '\\')
|
||||||
{
|
{
|
||||||
dst[i] = '/';
|
dst[i] = '/';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dst[i] = src[i];
|
dst[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
dst[i] = 0;
|
||||||
i++;
|
|
||||||
}
|
|
||||||
dst[i] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char FileName[PATH_MAX];
|
char FileName[PATH_MAX];
|
||||||
int Param;
|
int Param;
|
||||||
|
|
||||||
printf ("Binary hive maker\n");
|
printf ("Binary hive maker\n");
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
usage ();
|
usage ();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegInitializeRegistry ();
|
RegInitializeRegistry ();
|
||||||
|
|
||||||
convert_path (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);
|
ImportRegistryFile (FileName);
|
||||||
|
|
||||||
convert_path (FileName, argv[1]);
|
convert_path (FileName, argv[1]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "hivecls.inf");
|
strcat (FileName, "hivecls.inf");
|
||||||
ImportRegistryFile (FileName);
|
ImportRegistryFile (FileName);
|
||||||
|
|
||||||
convert_path (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);
|
ImportRegistryFile (FileName);
|
||||||
|
|
||||||
convert_path (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);
|
ImportRegistryFile (FileName);
|
||||||
|
|
||||||
for (Param = 3; Param < argc; Param++)
|
for (Param = 3; Param < argc; Param++)
|
||||||
{
|
{
|
||||||
convert_path (FileName, argv[Param]);
|
convert_path (FileName, argv[Param]);
|
||||||
ImportRegistryFile (FileName);
|
ImportRegistryFile (FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_path (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "default");
|
strcat (FileName, "default");
|
||||||
if (!ExportBinaryHive (FileName, &DefaultHive))
|
if (!ExportBinaryHive (FileName, &DefaultHive))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_path (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "sam");
|
strcat (FileName, "sam");
|
||||||
if (!ExportBinaryHive (FileName, &SamHive))
|
if (!ExportBinaryHive (FileName, &SamHive))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_path (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "security");
|
strcat (FileName, "security");
|
||||||
if (!ExportBinaryHive (FileName, &SecurityHive))
|
if (!ExportBinaryHive (FileName, &SecurityHive))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_path (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "software");
|
strcat (FileName, "software");
|
||||||
if (!ExportBinaryHive (FileName, &SoftwareHive))
|
if (!ExportBinaryHive (FileName, &SoftwareHive))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_path (FileName, argv[2]);
|
convert_path (FileName, argv[2]);
|
||||||
strcat (FileName, DIR_SEPARATOR_STRING);
|
strcat (FileName, DIR_SEPARATOR_STRING);
|
||||||
strcat (FileName, "system");
|
strcat (FileName, "system");
|
||||||
if (!ExportBinaryHive (FileName, &SystemHive))
|
if (!ExportBinaryHive (FileName, &SystemHive))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegShutdownRegistry ();
|
//RegShutdownRegistry ();
|
||||||
|
|
||||||
printf (" Done.\n");
|
printf (" Done.\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -53,33 +53,33 @@
|
||||||
static BOOL
|
static BOOL
|
||||||
GetRootKey (PCHAR Name)
|
GetRootKey (PCHAR Name)
|
||||||
{
|
{
|
||||||
if (!strcasecmp (Name, "HKCR"))
|
if (!strcasecmp (Name, "HKCR"))
|
||||||
{
|
{
|
||||||
strcpy (Name, "\\Registry\\Machine\\SOFTWARE\\Classes\\");
|
strcpy (Name, "\\Registry\\Machine\\SOFTWARE\\Classes\\");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp (Name, "HKCU"))
|
if (!strcasecmp (Name, "HKCU"))
|
||||||
{
|
{
|
||||||
strcpy (Name, "\\Registry\\User\\.DEFAULT\\");
|
strcpy (Name, "\\Registry\\User\\.DEFAULT\\");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp (Name, "HKLM"))
|
if (!strcasecmp (Name, "HKLM"))
|
||||||
{
|
{
|
||||||
strcpy (Name, "\\Registry\\Machine\\");
|
strcpy (Name, "\\Registry\\Machine\\");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp (Name, "HKU"))
|
if (!strcasecmp (Name, "HKU"))
|
||||||
{
|
{
|
||||||
strcpy (Name, "\\Registry\\User\\");
|
strcpy (Name, "\\Registry\\User\\");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!strcasecmp (Name, "HKR"))
|
if (!strcasecmp (Name, "HKR"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -92,74 +92,78 @@ GetRootKey (PCHAR Name)
|
||||||
* Append a multisz string to a multisz registry value.
|
* Append a multisz string to a multisz registry value.
|
||||||
*/
|
*/
|
||||||
static VOID
|
static VOID
|
||||||
AppendMultiSzValue (HKEY KeyHandle,
|
AppendMultiSzValue (
|
||||||
PCHAR ValueName,
|
IN HKEY KeyHandle,
|
||||||
PCHAR Strings,
|
IN PCHAR ValueName,
|
||||||
SIZE_T StringSize)
|
IN PCHAR Strings,
|
||||||
|
IN SIZE_T StringSize)
|
||||||
{
|
{
|
||||||
SIZE_T Size;
|
SIZE_T Size;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
size_t Total;
|
size_t Total;
|
||||||
PCHAR Buffer;
|
PCHAR Buffer;
|
||||||
PCHAR p;
|
PCHAR p;
|
||||||
size_t len;
|
size_t len;
|
||||||
LONG Error;
|
LONG Error;
|
||||||
|
|
||||||
Error = RegQueryValueExA (KeyHandle,
|
Error = RegQueryValueExA (
|
||||||
ValueName,
|
KeyHandle,
|
||||||
NULL,
|
ValueName,
|
||||||
&Type,
|
NULL,
|
||||||
NULL,
|
&Type,
|
||||||
&Size);
|
NULL,
|
||||||
if ((Error != ERROR_SUCCESS) ||
|
&Size);
|
||||||
(Type != REG_MULTI_SZ))
|
if ((Error != ERROR_SUCCESS) ||
|
||||||
return;
|
(Type != REG_MULTI_SZ))
|
||||||
|
return;
|
||||||
|
|
||||||
Buffer = malloc (Size + StringSize);
|
Buffer = malloc (Size + StringSize);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Error = RegQueryValueExA (KeyHandle,
|
Error = RegQueryValueExA (
|
||||||
ValueName,
|
KeyHandle,
|
||||||
NULL,
|
ValueName,
|
||||||
NULL,
|
NULL,
|
||||||
(PUCHAR)Buffer,
|
NULL,
|
||||||
&Size);
|
(PUCHAR)Buffer,
|
||||||
if (Error != ERROR_SUCCESS)
|
&Size);
|
||||||
goto done;
|
if (Error != ERROR_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
/* compare each string against all the existing ones */
|
/* compare each string against all the existing ones */
|
||||||
Total = Size;
|
Total = Size;
|
||||||
while (*Strings != 0)
|
while (*Strings != 0)
|
||||||
{
|
{
|
||||||
len = strlen (Strings) + 1;
|
len = strlen (Strings) + 1;
|
||||||
|
|
||||||
for (p = Buffer; *p != 0; p += strlen (p) + 1)
|
for (p = Buffer; *p != 0; p += strlen (p) + 1)
|
||||||
if (!strcasecmp (p, Strings))
|
if (!strcasecmp (p, Strings))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (*p == 0) /* not found, need to append it */
|
if (*p == 0) /* not found, need to append it */
|
||||||
{
|
{
|
||||||
memcpy (p, Strings, len);
|
memcpy (p, Strings, len);
|
||||||
p[len] = 0;
|
p[len] = 0;
|
||||||
Total += len;
|
Total += len;
|
||||||
}
|
}
|
||||||
Strings += len;
|
Strings += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Total != Size)
|
if (Total != Size)
|
||||||
{
|
{
|
||||||
DPRINT ("setting value %s to %s\n", ValueName, Buffer);
|
DPRINT ("setting value %s to %s\n", ValueName, Buffer);
|
||||||
RegSetValueExA (KeyHandle,
|
RegSetValueExA (
|
||||||
ValueName,
|
KeyHandle,
|
||||||
0,
|
ValueName,
|
||||||
REG_MULTI_SZ,
|
0,
|
||||||
(PCHAR)Buffer,
|
REG_MULTI_SZ,
|
||||||
(ULONG)Total);
|
(PCHAR)Buffer,
|
||||||
}
|
(ULONG)Total);
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
free (Buffer);
|
free (Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,201 +173,205 @@ done:
|
||||||
* Perform an add/delete registry operation depending on the flags.
|
* Perform an add/delete registry operation depending on the flags.
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
do_reg_operation(HKEY KeyHandle,
|
do_reg_operation(
|
||||||
PCHAR ValueName,
|
IN HKEY KeyHandle,
|
||||||
PINFCONTEXT Context,
|
IN PCHAR ValueName,
|
||||||
ULONG Flags)
|
IN PINFCONTEXT Context,
|
||||||
|
IN ULONG Flags)
|
||||||
{
|
{
|
||||||
CHAR EmptyStr = (CHAR)0;
|
CHAR EmptyStr = (CHAR)0;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
SIZE_T Size;
|
SIZE_T Size;
|
||||||
LONG Error;
|
LONG Error;
|
||||||
|
|
||||||
if (Flags & FLG_ADDREG_DELVAL) /* deletion */
|
if (Flags & FLG_ADDREG_DELVAL) /* deletion */
|
||||||
{
|
|
||||||
if (ValueName)
|
|
||||||
{
|
{
|
||||||
RegDeleteValueA (KeyHandle,
|
if (ValueName)
|
||||||
ValueName);
|
{
|
||||||
}
|
RegDeleteValueA (KeyHandle, ValueName);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
RegDeleteKeyA (KeyHandle,
|
{
|
||||||
NULL);
|
RegDeleteKeyA (KeyHandle, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
if (Flags & FLG_ADDREG_KEYONLY)
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags & FLG_ADDREG_KEYONLY)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
|
||||||
{
|
|
||||||
Error = RegQueryValueExA (KeyHandle,
|
|
||||||
ValueName,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if ((Error == ERROR_SUCCESS) &&
|
|
||||||
(Flags & FLG_ADDREG_NOCLOBBER))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if ((Error != ERROR_SUCCESS) &&
|
|
||||||
(Flags & FLG_ADDREG_OVERWRITEONLY))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Flags & FLG_ADDREG_TYPE_MASK)
|
|
||||||
{
|
|
||||||
case FLG_ADDREG_TYPE_SZ:
|
|
||||||
Type = REG_SZ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLG_ADDREG_TYPE_MULTI_SZ:
|
|
||||||
Type = REG_MULTI_SZ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLG_ADDREG_TYPE_EXPAND_SZ:
|
|
||||||
Type = REG_EXPAND_SZ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLG_ADDREG_TYPE_BINARY:
|
|
||||||
Type = REG_BINARY;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLG_ADDREG_TYPE_DWORD:
|
|
||||||
Type = REG_DWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLG_ADDREG_TYPE_NONE:
|
|
||||||
Type = REG_NONE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Type = Flags >> 16;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
|
|
||||||
(Type == REG_DWORD && InfHostGetFieldCount (Context) == 5))
|
|
||||||
{
|
|
||||||
PCHAR Str = NULL;
|
|
||||||
|
|
||||||
if (Type == REG_MULTI_SZ)
|
|
||||||
{
|
|
||||||
if (InfHostGetMultiSzField (Context, 5, NULL, 0, &Size) != 0)
|
|
||||||
Size = 0;
|
|
||||||
|
|
||||||
if (Size)
|
|
||||||
{
|
|
||||||
Str = malloc (Size);
|
|
||||||
if (Str == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
InfHostGetMultiSzField (Context, 5, Str, (ULONG)Size, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags & FLG_ADDREG_APPEND)
|
|
||||||
{
|
|
||||||
if (Str == NULL)
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
AppendMultiSzValue (KeyHandle,
|
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
||||||
ValueName,
|
|
||||||
Str,
|
|
||||||
Size);
|
|
||||||
|
|
||||||
free (Str);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
/* else fall through to normal string handling */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (InfHostGetStringField (Context, 5, NULL, 0, &Size) != 0)
|
Error = RegQueryValueExA (
|
||||||
Size = 0;
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if ((Error == ERROR_SUCCESS) &&
|
||||||
|
(Flags & FLG_ADDREG_NOCLOBBER))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (Size)
|
if ((Error != ERROR_SUCCESS) &&
|
||||||
{
|
(Flags & FLG_ADDREG_OVERWRITEONLY))
|
||||||
Str = malloc (Size);
|
return TRUE;
|
||||||
if (Str == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
InfHostGetStringField (Context, 5, Str, (ULONG)Size, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Type == REG_DWORD)
|
switch (Flags & FLG_ADDREG_TYPE_MASK)
|
||||||
{
|
{
|
||||||
ULONG dw = Str ? strtoul (Str, NULL, 0) : 0;
|
case FLG_ADDREG_TYPE_SZ:
|
||||||
|
Type = REG_SZ;
|
||||||
|
break;
|
||||||
|
|
||||||
DPRINT("setting dword %s to %lx\n", ValueName, dw);
|
case FLG_ADDREG_TYPE_MULTI_SZ:
|
||||||
|
Type = REG_MULTI_SZ;
|
||||||
|
break;
|
||||||
|
|
||||||
RegSetValueExA (KeyHandle,
|
case FLG_ADDREG_TYPE_EXPAND_SZ:
|
||||||
ValueName,
|
Type = REG_EXPAND_SZ;
|
||||||
0,
|
break;
|
||||||
Type,
|
|
||||||
(const PUCHAR)&dw,
|
case FLG_ADDREG_TYPE_BINARY:
|
||||||
sizeof(ULONG));
|
Type = REG_BINARY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FLG_ADDREG_TYPE_DWORD:
|
||||||
|
Type = REG_DWORD;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FLG_ADDREG_TYPE_NONE:
|
||||||
|
Type = REG_NONE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Type = Flags >> 16;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
|
||||||
|
(Type == REG_DWORD && InfHostGetFieldCount (Context) == 5))
|
||||||
{
|
{
|
||||||
DPRINT("setting value %s to %s\n", ValueName, Str);
|
PCHAR Str = NULL;
|
||||||
|
|
||||||
if (Str)
|
if (Type == REG_MULTI_SZ)
|
||||||
{
|
{
|
||||||
RegSetValueExA (KeyHandle,
|
if (InfHostGetMultiSzField (Context, 5, NULL, 0, &Size) != 0)
|
||||||
ValueName,
|
Size = 0;
|
||||||
0,
|
|
||||||
Type,
|
if (Size)
|
||||||
(PVOID)Str,
|
{
|
||||||
(ULONG)Size);
|
Str = malloc (Size);
|
||||||
}
|
if (Str == NULL)
|
||||||
else
|
return FALSE;
|
||||||
{
|
|
||||||
RegSetValueExA (KeyHandle,
|
InfHostGetMultiSzField (Context, 5, Str, (ULONG)Size, NULL);
|
||||||
ValueName,
|
}
|
||||||
0,
|
|
||||||
Type,
|
if (Flags & FLG_ADDREG_APPEND)
|
||||||
(PVOID)&EmptyStr,
|
{
|
||||||
(ULONG)sizeof(CHAR));
|
if (Str == NULL)
|
||||||
}
|
return TRUE;
|
||||||
|
|
||||||
|
AppendMultiSzValue (
|
||||||
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
Str,
|
||||||
|
Size);
|
||||||
|
|
||||||
|
free (Str);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/* else fall through to normal string handling */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (InfHostGetStringField (Context, 5, NULL, 0, &Size) != 0)
|
||||||
|
Size = 0;
|
||||||
|
|
||||||
|
if (Size)
|
||||||
|
{
|
||||||
|
Str = malloc (Size);
|
||||||
|
if (Str == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
InfHostGetStringField (Context, 5, Str, (ULONG)Size, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Type == REG_DWORD)
|
||||||
|
{
|
||||||
|
ULONG dw = Str ? strtoul (Str, NULL, 0) : 0;
|
||||||
|
|
||||||
|
DPRINT("setting dword %s to %lx\n", ValueName, dw);
|
||||||
|
|
||||||
|
RegSetValueExA (
|
||||||
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
0,
|
||||||
|
Type,
|
||||||
|
(const PUCHAR)&dw,
|
||||||
|
sizeof(ULONG));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("setting value %s to %s\n", ValueName, Str);
|
||||||
|
|
||||||
|
if (Str)
|
||||||
|
{
|
||||||
|
RegSetValueExA (
|
||||||
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
0,
|
||||||
|
Type,
|
||||||
|
(PVOID)Str,
|
||||||
|
(ULONG)Size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RegSetValueExA (
|
||||||
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
0,
|
||||||
|
Type,
|
||||||
|
(PVOID)&EmptyStr,
|
||||||
|
(ULONG)sizeof(CHAR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (Str);
|
||||||
}
|
}
|
||||||
free (Str);
|
else /* get the binary data */
|
||||||
}
|
|
||||||
else /* get the binary data */
|
|
||||||
{
|
|
||||||
PCHAR Data = NULL;
|
|
||||||
|
|
||||||
if (InfHostGetBinaryField (Context, 5, NULL, 0, &Size) != 0)
|
|
||||||
Size = 0;
|
|
||||||
|
|
||||||
if (Size)
|
|
||||||
{
|
{
|
||||||
Data = malloc (Size);
|
PCHAR Data = NULL;
|
||||||
if (Data == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
DPRINT("setting binary data %s len %lu\n", ValueName, Size);
|
if (InfHostGetBinaryField (Context, 5, NULL, 0, &Size) != 0)
|
||||||
InfHostGetBinaryField (Context, 5, Data, (ULONG)Size, NULL);
|
Size = 0;
|
||||||
|
|
||||||
|
if (Size)
|
||||||
|
{
|
||||||
|
Data = malloc (Size);
|
||||||
|
if (Data == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
DPRINT("setting binary data %s len %lu\n", ValueName, Size);
|
||||||
|
InfHostGetBinaryField (Context, 5, Data, (ULONG)Size, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegSetValueExA (
|
||||||
|
KeyHandle,
|
||||||
|
ValueName,
|
||||||
|
0,
|
||||||
|
Type,
|
||||||
|
(PVOID)Data,
|
||||||
|
(ULONG)Size);
|
||||||
|
|
||||||
|
free (Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegSetValueExA (KeyHandle,
|
return TRUE;
|
||||||
ValueName,
|
|
||||||
0,
|
|
||||||
Type,
|
|
||||||
(PVOID)Data,
|
|
||||||
(ULONG)Size);
|
|
||||||
|
|
||||||
free (Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* registry_callback
|
* registry_callback
|
||||||
*
|
*
|
||||||
|
@ -372,114 +380,114 @@ do_reg_operation(HKEY KeyHandle,
|
||||||
static BOOL
|
static BOOL
|
||||||
registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
registry_callback (HINF hInf, PCHAR Section, BOOL Delete)
|
||||||
{
|
{
|
||||||
CHAR Buffer[MAX_INF_STRING_LENGTH];
|
CHAR Buffer[MAX_INF_STRING_LENGTH];
|
||||||
PCHAR ValuePtr;
|
PCHAR ValuePtr;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
PINFCONTEXT Context = NULL;
|
PINFCONTEXT Context = NULL;
|
||||||
HKEY KeyHandle;
|
HKEY KeyHandle;
|
||||||
BOOL Ok;
|
BOOL Ok;
|
||||||
|
|
||||||
|
|
||||||
Ok = InfHostFindFirstLine (hInf, Section, NULL, &Context) == 0;
|
Ok = InfHostFindFirstLine (hInf, Section, NULL, &Context) == 0;
|
||||||
if (!Ok)
|
if (!Ok)
|
||||||
return TRUE; /* Don't fail if the section isn't present */
|
return TRUE; /* Don't fail if the section isn't present */
|
||||||
|
|
||||||
for (;Ok; Ok = (InfHostFindNextLine (Context, Context) == 0))
|
for (;Ok; Ok = (InfHostFindNextLine (Context, Context) == 0))
|
||||||
{
|
|
||||||
/* get root */
|
|
||||||
if (InfHostGetStringField (Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL) != 0)
|
|
||||||
continue;
|
|
||||||
if (!GetRootKey (Buffer))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* get key */
|
|
||||||
Length = strlen (Buffer);
|
|
||||||
if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - (ULONG)Length, NULL) != 0)
|
|
||||||
*Buffer = 0;
|
|
||||||
|
|
||||||
DPRINT("KeyName: <%s>\n", Buffer);
|
|
||||||
|
|
||||||
if (Delete)
|
|
||||||
{
|
|
||||||
Flags = FLG_ADDREG_DELVAL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* get flags */
|
|
||||||
if (InfHostGetIntField (Context, 4, (PLONG)&Flags) != 0)
|
|
||||||
Flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Flags: %lx\n", Flags);
|
|
||||||
|
|
||||||
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
|
||||||
{
|
{
|
||||||
if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
/* get root */
|
||||||
{
|
if (InfHostGetStringField (Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL) != 0)
|
||||||
DPRINT("RegOpenKey(%s) failed\n", Buffer);
|
continue;
|
||||||
continue; /* ignore if it doesn't exist */
|
if (!GetRootKey (Buffer))
|
||||||
}
|
continue;
|
||||||
}
|
|
||||||
else
|
/* get key */
|
||||||
{
|
Length = strlen (Buffer);
|
||||||
if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - (ULONG)Length, NULL) != 0)
|
||||||
{
|
*Buffer = 0;
|
||||||
DPRINT("RegCreateKey(%s) failed\n", Buffer);
|
|
||||||
continue;
|
DPRINT("KeyName: <%s>\n", Buffer);
|
||||||
}
|
|
||||||
|
if (Delete)
|
||||||
|
{
|
||||||
|
Flags = FLG_ADDREG_DELVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* get flags */
|
||||||
|
if (InfHostGetIntField (Context, 4, (PLONG)&Flags) != 0)
|
||||||
|
Flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Flags: %lx\n", Flags);
|
||||||
|
|
||||||
|
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
||||||
|
{
|
||||||
|
if (RegOpenKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("RegOpenKey(%s) failed\n", Buffer);
|
||||||
|
continue; /* ignore if it doesn't exist */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (RegCreateKeyA (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("RegCreateKey(%s) failed\n", Buffer);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get value name */
|
||||||
|
if (InfHostGetStringField (Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL) == 0)
|
||||||
|
{
|
||||||
|
ValuePtr = Buffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ValuePtr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* and now do it */
|
||||||
|
if (!do_reg_operation (KeyHandle, ValuePtr, Context, Flags))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get value name */
|
InfHostFreeContext(Context);
|
||||||
if (InfHostGetStringField (Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL) == 0)
|
|
||||||
{
|
|
||||||
ValuePtr = Buffer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ValuePtr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and now do it */
|
return TRUE;
|
||||||
if (!do_reg_operation (KeyHandle, ValuePtr, Context, Flags))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
InfHostFreeContext(Context);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ImportRegistryFile(PCHAR FileName)
|
ImportRegistryFile(PCHAR FileName)
|
||||||
{
|
{
|
||||||
HINF hInf;
|
HINF hInf;
|
||||||
ULONG ErrorLine;
|
ULONG ErrorLine;
|
||||||
|
|
||||||
/* Load inf file from install media. */
|
/* Load inf file from install media. */
|
||||||
if (InfHostOpenFile(&hInf, FileName, &ErrorLine) != 0)
|
if (InfHostOpenFile(&hInf, FileName, &ErrorLine) != 0)
|
||||||
{
|
{
|
||||||
DPRINT1 ("InfHostOpenFile() failed\n");
|
DPRINT1 ("InfHostOpenFile() failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registry_callback (hInf, "DelReg", TRUE))
|
if (!registry_callback (hInf, "DelReg", TRUE))
|
||||||
{
|
{
|
||||||
DPRINT1 ("registry_callback() failed\n");
|
DPRINT1 ("registry_callback() failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registry_callback (hInf, "AddReg", FALSE))
|
if (!registry_callback (hInf, "AddReg", FALSE))
|
||||||
{
|
{
|
||||||
DPRINT1 ("registry_callback() failed\n");
|
DPRINT1 ("registry_callback() failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
InfHostCloseFile (hInf);
|
InfHostCloseFile (hInf);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue