Author: hbelusca
Date: Fri Jun 2 00:00:37 2017
New Revision: 74739
URL:
http://svn.reactos.org/svn/reactos?rev=74739&view=rev
Log:
[MKHIVE]: Formatting changes only + sync back the names of the reg-inf functions with the
ones where they are coming from (aka. Wine's setupapi/install.c).
Modified:
trunk/reactos/sdk/tools/mkhive/binhive.c
trunk/reactos/sdk/tools/mkhive/reginf.c
Modified: trunk/reactos/sdk/tools/mkhive/binhive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/binhive.c…
==============================================================================
--- trunk/reactos/sdk/tools/mkhive/binhive.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/tools/mkhive/binhive.c [iso-8859-1] Fri Jun 2 00:00:37 2017
@@ -33,26 +33,26 @@
BOOL
ExportBinaryHive(
IN PCSTR FileName,
- IN PCMHIVE Hive)
+ IN PCMHIVE CmHive)
{
FILE *File;
BOOL ret;
- printf (" Creating binary hive: %s\n", FileName);
+ printf(" Creating binary hive: %s\n", FileName);
/* Create new hive file */
- File = fopen (FileName, "w+b");
+ File = fopen(FileName, "w+b");
if (File == NULL)
{
printf(" Error creating/opening file\n");
return FALSE;
}
- fseek (File, 0, SEEK_SET);
+ fseek(File, 0, SEEK_SET);
- Hive->FileHandles[HFILE_TYPE_PRIMARY] = (HANDLE)File;
- ret = HvWriteHive(&Hive->Hive);
- fclose (File);
+ CmHive->FileHandles[HFILE_TYPE_PRIMARY] = (HANDLE)File;
+ ret = HvWriteHive(&CmHive->Hive);
+ fclose(File);
return ret;
}
Modified: trunk/reactos/sdk/tools/mkhive/reginf.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/tools/mkhive/reginf.c?…
==============================================================================
--- trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/tools/mkhive/reginf.c [iso-8859-1] Fri Jun 2 00:00:37 2017
@@ -21,7 +21,7 @@
* PROJECT: ReactOS hive maker
* FILE: tools/mkhive/reginf.c
* PURPOSE: Inf file import code
- * PROGRAMMER: Eric Kohl
+ * PROGRAMMERS: Eric Kohl
* Hervé Poussineau
*/
@@ -68,40 +68,40 @@
/* FUNCTIONS ****************************************************************/
static BOOL
-GetRootKey (PWCHAR Name)
+get_root_key(PWCHAR Name)
{
- if (!strcmpiW (Name, HKCR))
- {
- strcpyW (Name, HKCRPath);
- return TRUE;
- }
-
- if (!strcmpiW (Name, HKCU))
- {
- strcpyW (Name, HKCUPath);
- return TRUE;
- }
-
- if (!strcmpiW (Name, HKLM))
- {
- strcpyW (Name, HKLMPath);
- return TRUE;
- }
-
- if (!strcmpiW (Name, HKU))
- {
- strcpyW (Name, HKUPath);
- return TRUE;
- }
-
- if (!strcmpiW (Name, BCD))
- {
- strcpyW (Name, BCDPath);
+ if (!strcmpiW(Name, HKCR))
+ {
+ strcpyW(Name, HKCRPath);
+ return TRUE;
+ }
+
+ if (!strcmpiW(Name, HKCU))
+ {
+ strcpyW(Name, HKCUPath);
+ return TRUE;
+ }
+
+ if (!strcmpiW(Name, HKLM))
+ {
+ strcpyW(Name, HKLMPath);
+ return TRUE;
+ }
+
+ if (!strcmpiW(Name, HKU))
+ {
+ strcpyW(Name, HKUPath);
+ return TRUE;
+ }
+
+ if (!strcmpiW(Name, BCD))
+ {
+ strcpyW(Name, BCDPath);
return TRUE;
}
#if 0
- if (!strcmpiW (Name, HKR))
+ if (!strcmpiW(Name, HKR))
return FALSE;
#endif
@@ -110,12 +110,13 @@
/***********************************************************************
- * AppendMultiSzValue
+ * append_multi_sz_value
*
* Append a multisz string to a multisz registry value.
*/
+// NOTE: Synced with setupapi/install.c ; see also usetup/registry.c
static VOID
-AppendMultiSzValue (
+append_multi_sz_value(
IN HKEY KeyHandle,
IN PWCHAR ValueName,
IN PWCHAR Strings,
@@ -129,28 +130,25 @@
size_t len;
LONG Error;
- Error = RegQueryValueExW (
- KeyHandle,
- ValueName,
- NULL,
- &Type,
- NULL,
- &Size);
- if ((Error != ERROR_SUCCESS) ||
- (Type != REG_MULTI_SZ))
+ Error = RegQueryValueExW(KeyHandle,
+ ValueName,
+ NULL,
+ &Type,
+ NULL,
+ &Size);
+ if ((Error != ERROR_SUCCESS) || (Type != REG_MULTI_SZ))
return;
Buffer = malloc ((Size + StringSize) * sizeof(WCHAR));
if (Buffer == NULL)
return;
- Error = RegQueryValueExW (
- KeyHandle,
- ValueName,
- NULL,
- NULL,
- (PUCHAR)Buffer,
- &Size);
+ Error = RegQueryValueExW(KeyHandle,
+ ValueName,
+ NULL,
+ NULL,
+ (PUCHAR)Buffer,
+ &Size);
if (Error != ERROR_SUCCESS)
goto done;
@@ -175,18 +173,17 @@
if (Total != Size)
{
- DPRINT ("setting value %S to %S\n", ValueName, Buffer);
- RegSetValueExW (
- KeyHandle,
- ValueName,
- 0,
- REG_MULTI_SZ,
- (PUCHAR)Buffer,
- Total * sizeof(WCHAR));
+ DPRINT("setting value %S to %S\n", ValueName, Buffer);
+ RegSetValueExW(KeyHandle,
+ ValueName,
+ 0,
+ REG_MULTI_SZ,
+ (PUCHAR)Buffer,
+ Total * sizeof(WCHAR));
}
done:
- free (Buffer);
+ free(Buffer);
}
@@ -202,7 +199,7 @@
IN PINFCONTEXT Context,
IN ULONG Flags)
{
- WCHAR EmptyStr = (CHAR)0;
+ WCHAR EmptyStr = 0;
ULONG Type;
ULONG Size;
LONG Error;
@@ -211,11 +208,11 @@
{
if (ValueName)
{
- RegDeleteValueW (KeyHandle, ValueName);
+ RegDeleteValueW(KeyHandle, ValueName);
}
else
{
- RegDeleteKeyW (KeyHandle, NULL);
+ RegDeleteKeyW(KeyHandle, NULL);
}
return TRUE;
@@ -226,19 +223,16 @@
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
{
- Error = RegQueryValueExW (
- KeyHandle,
- ValueName,
- NULL,
- NULL,
- NULL,
- NULL);
- if ((Error == ERROR_SUCCESS) &&
- (Flags & FLG_ADDREG_NOCLOBBER))
+ Error = RegQueryValueExW(KeyHandle,
+ ValueName,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if ((Error == ERROR_SUCCESS) && (Flags & FLG_ADDREG_NOCLOBBER))
return TRUE;
- if ((Error != ERROR_SUCCESS) &&
- (Flags & FLG_ADDREG_OVERWRITEONLY))
+ if ((Error != ERROR_SUCCESS) && (Flags & FLG_ADDREG_OVERWRITEONLY))
return TRUE;
}
@@ -274,22 +268,22 @@
}
if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
- (Type == REG_DWORD && InfHostGetFieldCount (Context) == 5))
+ (Type == REG_DWORD && InfHostGetFieldCount(Context) == 5))
{
PWCHAR Str = NULL;
if (Type == REG_MULTI_SZ)
{
- if (InfHostGetMultiSzField (Context, 5, NULL, 0, &Size) != 0)
+ if (InfHostGetMultiSzField(Context, 5, NULL, 0, &Size) != 0)
Size = 0;
if (Size)
{
- Str = malloc (Size * sizeof(WCHAR));
+ Str = malloc(Size * sizeof(WCHAR));
if (Str == NULL)
return FALSE;
- InfHostGetMultiSzField (Context, 5, Str, Size, NULL);
+ InfHostGetMultiSzField(Context, 5, Str, Size, NULL);
}
if (Flags & FLG_ADDREG_APPEND)
@@ -297,45 +291,43 @@
if (Str == NULL)
return TRUE;
- AppendMultiSzValue (
- KeyHandle,
- ValueName,
- Str,
- Size);
-
- free (Str);
+ append_multi_sz_value(KeyHandle,
+ ValueName,
+ Str,
+ Size);
+
+ free(Str);
return TRUE;
}
/* else fall through to normal string handling */
}
else
{
- if (InfHostGetStringField (Context, 5, NULL, 0, &Size) != 0)
+ if (InfHostGetStringField(Context, 5, NULL, 0, &Size) != 0)
Size = 0;
if (Size)
{
- Str = malloc (Size * sizeof(WCHAR));
+ Str = malloc(Size * sizeof(WCHAR));
if (Str == NULL)
return FALSE;
- InfHostGetStringField (Context, 5, Str, Size, NULL);
+ InfHostGetStringField(Context, 5, Str, Size, NULL);
}
}
if (Type == REG_DWORD)
{
- ULONG dw = Str ? strtoulW (Str, NULL, 0) : 0;
+ ULONG dw = Str ? strtoulW(Str, NULL, 0) : 0;
DPRINT("setting dword %S to %x\n", ValueName, dw);
- RegSetValueExW (
- KeyHandle,
- ValueName,
- 0,
- Type,
- (const PUCHAR)&dw,
- sizeof(ULONG));
+ RegSetValueExW(KeyHandle,
+ ValueName,
+ 0,
+ Type,
+ (const PUCHAR)&dw,
+ sizeof(ULONG));
}
else
{
@@ -343,53 +335,50 @@
if (Str)
{
- RegSetValueExW (
- KeyHandle,
- ValueName,
- 0,
- Type,
- (PVOID)Str,
- Size * sizeof(WCHAR));
+ RegSetValueExW(KeyHandle,
+ ValueName,
+ 0,
+ Type,
+ (PVOID)Str,
+ Size * sizeof(WCHAR));
}
else
{
- RegSetValueExW (
- KeyHandle,
- ValueName,
- 0,
- Type,
- (PVOID)&EmptyStr,
- sizeof(WCHAR));
- }
- }
- free (Str);
+ RegSetValueExW(KeyHandle,
+ ValueName,
+ 0,
+ Type,
+ (PVOID)&EmptyStr,
+ sizeof(WCHAR));
+ }
+ }
+ free(Str);
}
else /* get the binary data */
{
PUCHAR Data = NULL;
- if (InfHostGetBinaryField (Context, 5, NULL, 0, &Size) != 0)
+ if (InfHostGetBinaryField(Context, 5, NULL, 0, &Size) != 0)
Size = 0;
if (Size)
{
- Data = malloc (Size);
+ Data = malloc(Size);
if (Data == NULL)
return FALSE;
DPRINT("setting binary data %S len %d\n", ValueName, Size);
- InfHostGetBinaryField (Context, 5, Data, Size, NULL);
- }
-
- RegSetValueExW (
- KeyHandle,
- ValueName,
- 0,
- Type,
- (PVOID)Data,
- Size);
-
- free (Data);
+ InfHostGetBinaryField(Context, 5, Data, Size, NULL);
+ }
+
+ RegSetValueExW(KeyHandle,
+ ValueName,
+ 0,
+ Type,
+ (PVOID)Data,
+ Size);
+
+ free(Data);
}
return TRUE;
@@ -401,7 +390,7 @@
* Called once for each AddReg and DelReg entry in a given section.
*/
static BOOL
-registry_callback (HINF hInf, PWCHAR Section, BOOL Delete)
+registry_callback(HINF hInf, PWCHAR Section, BOOL Delete)
{
WCHAR Buffer[MAX_INF_STRING_LENGTH];
PWCHAR ValuePtr;
@@ -413,21 +402,21 @@
BOOL Ok;
- Ok = InfHostFindFirstLine (hInf, Section, NULL, &Context) == 0;
+ Ok = InfHostFindFirstLine(hInf, Section, NULL, &Context) == 0;
if (!Ok)
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)
+ if (InfHostGetStringField(Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)
!= 0)
continue;
- if (!GetRootKey (Buffer))
+ if (!get_root_key(Buffer))
continue;
/* get key */
- Length = strlenW (Buffer);
- if (InfHostGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH -
(ULONG)Length, NULL) != 0)
+ Length = strlenW(Buffer);
+ if (InfHostGetStringField(Context, 2, Buffer + Length,
sizeof(Buffer)/sizeof(WCHAR) - (ULONG)Length, NULL) != 0)
*Buffer = 0;
DPRINT("KeyName: <%S>\n", Buffer);
@@ -439,7 +428,7 @@
else
{
/* get flags */
- if (InfHostGetIntField (Context, 4, (INT *)&Flags) != 0)
+ if (InfHostGetIntField(Context, 4, (INT *)&Flags) != 0)
Flags = 0;
}
@@ -447,7 +436,7 @@
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
{
- if (RegOpenKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
+ if (RegOpenKeyW(NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
{
DPRINT("RegOpenKey(%S) failed\n", Buffer);
continue; /* ignore if it doesn't exist */
@@ -455,7 +444,7 @@
}
else
{
- if (RegCreateKeyW (NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
+ if (RegCreateKeyW(NULL, Buffer, &KeyHandle) != ERROR_SUCCESS)
{
DPRINT("RegCreateKey(%S) failed\n", Buffer);
continue;
@@ -463,7 +452,7 @@
}
/* get value name */
- if (InfHostGetStringField (Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL) ==
0)
+ if (InfHostGetStringField(Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL)
== 0)
{
ValuePtr = Buffer;
}
@@ -473,7 +462,7 @@
}
/* and now do it */
- if (!do_reg_operation (KeyHandle, ValuePtr, Context, Flags))
+ if (!do_reg_operation(KeyHandle, ValuePtr, Context, Flags))
{
return FALSE;
}
@@ -494,25 +483,25 @@
/* Load inf file from install media. */
if (InfHostOpenFile(&hInf, FileName, 0, &ErrorLine) != 0)
{
- DPRINT1 ("InfHostOpenFile(%s) failed\n", FileName);
+ DPRINT1("InfHostOpenFile(%s) failed\n", FileName);
return FALSE;
}
- if (!registry_callback (hInf, (PWCHAR)DelReg, TRUE))
- {
- DPRINT1 ("registry_callback() for DelReg failed\n");
- InfHostCloseFile (hInf);
+ if (!registry_callback(hInf, (PWCHAR)DelReg, TRUE))
+ {
+ DPRINT1("registry_callback() for DelReg failed\n");
+ InfHostCloseFile(hInf);
return FALSE;
}
- if (!registry_callback (hInf, (PWCHAR)AddReg, FALSE))
- {
- DPRINT1 ("registry_callback() for AddReg failed\n");
- InfHostCloseFile (hInf);
+ if (!registry_callback(hInf, (PWCHAR)AddReg, FALSE))
+ {
+ DPRINT1("registry_callback() for AddReg failed\n");
+ InfHostCloseFile(hInf);
return FALSE;
}
- InfHostCloseFile (hInf);
+ InfHostCloseFile(hInf);
return TRUE;
}