mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[USETUP] Code formatting, making also the code closer to mkhive's one. Also, definitely remove the SetInstallPathValue() hack.
svn path=/branches/setup_improvements/; revision=74763
This commit is contained in:
parent
8269478385
commit
cd89e5b797
1 changed files with 180 additions and 214 deletions
|
@ -102,6 +102,7 @@ GetRootKey(
|
||||||
*
|
*
|
||||||
* Append a multisz string to a multisz registry value.
|
* Append a multisz string to a multisz registry value.
|
||||||
*/
|
*/
|
||||||
|
// NOTE: Synced with setupapi/install.c ; see also mkhive/reginf.c
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
append_multi_sz_value (HANDLE hkey,
|
append_multi_sz_value (HANDLE hkey,
|
||||||
|
@ -115,7 +116,7 @@ append_multi_sz_value (HANDLE hkey,
|
||||||
if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
|
if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
|
||||||
if (type != REG_MULTI_SZ) return;
|
if (type != REG_MULTI_SZ) return;
|
||||||
|
|
||||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (size + str_size) * sizeof(WCHAR) ))) return;
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size + str_size * sizeof(WCHAR) ))) return;
|
||||||
if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
|
if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
|
||||||
|
|
||||||
/* compare each string against all the existing ones */
|
/* compare each string against all the existing ones */
|
||||||
|
@ -196,7 +197,7 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
PINFCONTEXT Context,
|
PINFCONTEXT Context,
|
||||||
ULONG Flags)
|
ULONG Flags)
|
||||||
{
|
{
|
||||||
WCHAR EmptyStr = (WCHAR)0;
|
WCHAR EmptyStr = 0;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
|
|
||||||
|
@ -221,7 +222,7 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
#if 0
|
#if 0
|
||||||
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
if (Flags & (FLG_ADDREG_NOCLOBBER | FLG_ADDREG_OVERWRITEONLY))
|
||||||
{
|
{
|
||||||
BOOL exists = !RegQueryValueExW( hkey, value, NULL, NULL, NULL, NULL );
|
BOOL exists = !RegQueryValueExW( hkey, ValueName, NULL, NULL, NULL, NULL );
|
||||||
if (exists && (flags & FLG_ADDREG_NOCLOBBER))
|
if (exists && (flags & FLG_ADDREG_NOCLOBBER))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (!exists & (flags & FLG_ADDREG_OVERWRITEONLY))
|
if (!exists & (flags & FLG_ADDREG_OVERWRITEONLY))
|
||||||
|
@ -272,7 +273,7 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
|
|
||||||
if (Size)
|
if (Size)
|
||||||
{
|
{
|
||||||
Str = (WCHAR*) RtlAllocateHeap (ProcessHeap, 0, Size * sizeof(WCHAR));
|
Str = (WCHAR*) RtlAllocateHeap(ProcessHeap, 0, Size * sizeof(WCHAR));
|
||||||
if (Str == NULL)
|
if (Str == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -284,6 +285,7 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
if (Str == NULL)
|
if (Str == NULL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
DPRINT1("append_multi_sz_value '%S' commented out, WHY??\n", ValueName);
|
||||||
// append_multi_sz_value( hkey, value, str, size );
|
// append_multi_sz_value( hkey, value, str, size );
|
||||||
|
|
||||||
RtlFreeHeap (ProcessHeap, 0, Str);
|
RtlFreeHeap (ProcessHeap, 0, Str);
|
||||||
|
@ -293,16 +295,16 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!SetupGetStringFieldW (Context, 5, NULL, 0, &Size))
|
if (!SetupGetStringFieldW(Context, 5, NULL, 0, &Size))
|
||||||
Size = 0;
|
Size = 0;
|
||||||
|
|
||||||
if (Size)
|
if (Size)
|
||||||
{
|
{
|
||||||
Str = (WCHAR*) RtlAllocateHeap (ProcessHeap, 0, Size * sizeof(WCHAR));
|
Str = (WCHAR*)RtlAllocateHeap(ProcessHeap, 0, Size * sizeof(WCHAR));
|
||||||
if (Str == NULL)
|
if (Str == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
SetupGetStringFieldW (Context, 5, Str, Size, NULL);
|
SetupGetStringFieldW(Context, 5, Str, Size, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +355,7 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
|
|
||||||
if (Size)
|
if (Size)
|
||||||
{
|
{
|
||||||
Data = (unsigned char*) RtlAllocateHeap (ProcessHeap, 0, Size);
|
Data = (unsigned char*) RtlAllocateHeap(ProcessHeap, 0, Size);
|
||||||
if (Data == NULL)
|
if (Data == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -375,95 +377,95 @@ do_reg_operation(HANDLE KeyHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CreateNestedKey (PHANDLE KeyHandle,
|
CreateNestedKey(PHANDLE KeyHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES LocalObjectAttributes;
|
OBJECT_ATTRIBUTES LocalObjectAttributes;
|
||||||
UNICODE_STRING LocalKeyName;
|
UNICODE_STRING LocalKeyName;
|
||||||
ULONG Disposition;
|
ULONG Disposition;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
USHORT FullNameLength;
|
USHORT FullNameLength;
|
||||||
PWCHAR Ptr;
|
PWCHAR Ptr;
|
||||||
HANDLE LocalKeyHandle;
|
HANDLE LocalKeyHandle;
|
||||||
|
|
||||||
|
Status = NtCreateKey(KeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
ObjectAttributes,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&Disposition);
|
||||||
|
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
|
||||||
|
if (Status != STATUS_OBJECT_NAME_NOT_FOUND)
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
/* Copy object attributes */
|
||||||
|
RtlCopyMemory(&LocalObjectAttributes,
|
||||||
|
ObjectAttributes,
|
||||||
|
sizeof(OBJECT_ATTRIBUTES));
|
||||||
|
RtlCreateUnicodeString(&LocalKeyName,
|
||||||
|
ObjectAttributes->ObjectName->Buffer);
|
||||||
|
LocalObjectAttributes.ObjectName = &LocalKeyName;
|
||||||
|
FullNameLength = LocalKeyName.Length;
|
||||||
|
|
||||||
|
/* Remove the last part of the key name and try to create the key again. */
|
||||||
|
while (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||||
|
{
|
||||||
|
Ptr = wcsrchr (LocalKeyName.Buffer, '\\');
|
||||||
|
if (Ptr == NULL || Ptr == LocalKeyName.Buffer)
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*Ptr = (WCHAR)0;
|
||||||
|
LocalKeyName.Length = wcslen (LocalKeyName.Buffer) * sizeof(WCHAR);
|
||||||
|
|
||||||
|
Status = NtCreateKey(&LocalKeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&LocalObjectAttributes,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&Disposition);
|
||||||
|
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString (&LocalKeyName);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add removed parts of the key name and create them too. */
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
if (LocalKeyName.Length == FullNameLength)
|
||||||
|
{
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
*KeyHandle = LocalKeyHandle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
NtClose(LocalKeyHandle);
|
||||||
|
|
||||||
|
LocalKeyName.Buffer[LocalKeyName.Length / sizeof(WCHAR)] = L'\\';
|
||||||
|
LocalKeyName.Length = wcslen (LocalKeyName.Buffer) * sizeof(WCHAR);
|
||||||
|
|
||||||
|
Status = NtCreateKey(&LocalKeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&LocalObjectAttributes,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&Disposition);
|
||||||
|
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&LocalKeyName);
|
||||||
|
|
||||||
Status = NtCreateKey (KeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
ObjectAttributes,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&Disposition);
|
|
||||||
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
|
|
||||||
if (Status != STATUS_OBJECT_NAME_NOT_FOUND)
|
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
/* Copy object attributes */
|
|
||||||
RtlCopyMemory (&LocalObjectAttributes,
|
|
||||||
ObjectAttributes,
|
|
||||||
sizeof(OBJECT_ATTRIBUTES));
|
|
||||||
RtlCreateUnicodeString (&LocalKeyName,
|
|
||||||
ObjectAttributes->ObjectName->Buffer);
|
|
||||||
LocalObjectAttributes.ObjectName = &LocalKeyName;
|
|
||||||
FullNameLength = LocalKeyName.Length;
|
|
||||||
|
|
||||||
/* Remove the last part of the key name and try to create the key again. */
|
|
||||||
while (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
Ptr = wcsrchr (LocalKeyName.Buffer, '\\');
|
|
||||||
if (Ptr == NULL || Ptr == LocalKeyName.Buffer)
|
|
||||||
{
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*Ptr = (WCHAR)0;
|
|
||||||
LocalKeyName.Length = wcslen (LocalKeyName.Buffer) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
Status = NtCreateKey (&LocalKeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&LocalObjectAttributes,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&Disposition);
|
|
||||||
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
RtlFreeUnicodeString (&LocalKeyName);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add removed parts of the key name and create them too. */
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
if (LocalKeyName.Length == FullNameLength)
|
|
||||||
{
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
*KeyHandle = LocalKeyHandle;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
NtClose (LocalKeyHandle);
|
|
||||||
|
|
||||||
LocalKeyName.Buffer[LocalKeyName.Length / sizeof(WCHAR)] = L'\\';
|
|
||||||
LocalKeyName.Length = wcslen (LocalKeyName.Buffer) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
Status = NtCreateKey (&LocalKeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&LocalObjectAttributes,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&Disposition);
|
|
||||||
DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlFreeUnicodeString (&LocalKeyName);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -474,101 +476,95 @@ CreateNestedKey (PHANDLE KeyHandle,
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
|
registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
NTSTATUS Status;
|
||||||
WCHAR Buffer[MAX_INF_STRING_LENGTH];
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING Name;
|
UNICODE_STRING Name, Value;
|
||||||
UNICODE_STRING Value;
|
PUNICODE_STRING ValuePtr;
|
||||||
PUNICODE_STRING ValuePtr;
|
UINT Flags;
|
||||||
NTSTATUS Status;
|
ULONG Length;
|
||||||
UINT Flags;
|
WCHAR Buffer[MAX_INF_STRING_LENGTH];
|
||||||
ULONG Length;
|
|
||||||
|
|
||||||
INFCONTEXT Context;
|
INFCONTEXT Context;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
BOOLEAN Ok;
|
BOOLEAN Ok;
|
||||||
|
|
||||||
|
Ok = SetupFindFirstLineW(hInf, Section, NULL, &Context);
|
||||||
|
if (!Ok)
|
||||||
|
return TRUE; /* Don't fail if the section isn't present */
|
||||||
|
|
||||||
Ok = SetupFindFirstLineW (hInf, Section, NULL, &Context);
|
for (;Ok; Ok = SetupFindNextLine (&Context, &Context))
|
||||||
|
|
||||||
if (Ok)
|
|
||||||
{
|
{
|
||||||
for (;Ok; Ok = SetupFindNextLine (&Context, &Context))
|
/* get root */
|
||||||
{
|
if (!SetupGetStringFieldW(&Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL))
|
||||||
/* get root */
|
continue;
|
||||||
if (!SetupGetStringFieldW (&Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL))
|
if (!GetRootKey (Buffer))
|
||||||
continue;
|
|
||||||
if (!GetRootKey (Buffer))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* get key */
|
/* get key */
|
||||||
Length = wcslen (Buffer);
|
Length = wcslen(Buffer);
|
||||||
if (!SetupGetStringFieldW (&Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL))
|
if (!SetupGetStringFieldW(&Context, 2, Buffer + Length, sizeof(Buffer)/sizeof(WCHAR) - Length, NULL))
|
||||||
*Buffer = 0;
|
*Buffer = 0;
|
||||||
|
|
||||||
DPRINT("KeyName: <%S>\n", Buffer);
|
DPRINT("KeyName: <%S>\n", Buffer);
|
||||||
|
|
||||||
/* get flags */
|
/* get flags */
|
||||||
if (!SetupGetIntField (&Context, 4, (PINT)&Flags))
|
if (!SetupGetIntField(&Context, 4, (PINT)&Flags))
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
|
|
||||||
DPRINT("Flags: %lx\n", Flags);
|
DPRINT("Flags: %lx\n", Flags);
|
||||||
|
|
||||||
RtlInitUnicodeString (&Name,
|
RtlInitUnicodeString(&Name, Buffer);
|
||||||
Buffer);
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&Name,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
InitializeObjectAttributes (&ObjectAttributes,
|
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
||||||
&Name,
|
{
|
||||||
OBJ_CASE_INSENSITIVE,
|
Status = NtOpenKey(&KeyHandle,
|
||||||
NULL,
|
KEY_ALL_ACCESS,
|
||||||
NULL);
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
|
|
||||||
{
|
{
|
||||||
Status = NtOpenKey (&KeyHandle,
|
DPRINT1("NtOpenKey(%wZ) failed (Status %lx)\n", &Name, Status);
|
||||||
KEY_ALL_ACCESS,
|
continue; /* ignore if it doesn't exist */
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("NtOpenKey(%wZ) failed (Status %lx)\n", &Name, Status);
|
|
||||||
continue; /* ignore if it doesn't exist */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = CreateNestedKey (&KeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("CreateNestedKey(%wZ) failed (Status %lx)\n", &Name, Status);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get value name */
|
|
||||||
if (SetupGetStringFieldW (&Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL))
|
|
||||||
{
|
|
||||||
RtlInitUnicodeString (&Value,
|
|
||||||
Buffer);
|
|
||||||
ValuePtr = &Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ValuePtr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and now do it */
|
|
||||||
if (!do_reg_operation (KeyHandle, ValuePtr, &Context, Flags))
|
|
||||||
{
|
|
||||||
NtClose (KeyHandle);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NtClose (KeyHandle);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = CreateNestedKey(&KeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("CreateNestedKey(%wZ) failed (Status %lx)\n", &Name, Status);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get value name */
|
||||||
|
if (SetupGetStringFieldW(&Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR), NULL))
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&Value, Buffer);
|
||||||
|
ValuePtr = &Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ValuePtr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* and now do it */
|
||||||
|
if (!do_reg_operation(KeyHandle, ValuePtr, &Context, Flags))
|
||||||
|
{
|
||||||
|
NtClose(KeyHandle);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtClose(KeyHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -598,60 +594,30 @@ ImportRegistryFile(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!registry_callback(hInf, L"DelReg", FALSE))
|
||||||
|
{
|
||||||
|
DPRINT1("registry_callback() failed\n");
|
||||||
|
InfCloseFile(hInf);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!registry_callback(hInf, L"AddReg", FALSE))
|
if (!registry_callback(hInf, L"AddReg", FALSE))
|
||||||
{
|
{
|
||||||
DPRINT1("registry_callback() failed\n");
|
DPRINT1("registry_callback() failed\n");
|
||||||
|
InfCloseFile(hInf);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registry_callback(hInf, L"AddReg.NT" Architecture, FALSE))
|
if (!registry_callback(hInf, L"AddReg.NT" Architecture, FALSE))
|
||||||
{
|
{
|
||||||
DPRINT1("registry_callback() failed\n");
|
DPRINT1("registry_callback() failed\n");
|
||||||
|
InfCloseFile(hInf);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
InfCloseFile(hInf);
|
InfCloseFile(hInf);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
SetInstallPathValue(
|
|
||||||
PUNICODE_STRING InstallPath)
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\HARDWARE");
|
|
||||||
UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"InstallPath");
|
|
||||||
HANDLE KeyHandle;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Create the 'secret' InstallPath key */
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&KeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = NtOpenKey(&KeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtSetValueKey(KeyHandle,
|
|
||||||
&ValueName,
|
|
||||||
0,
|
|
||||||
REG_SZ,
|
|
||||||
(PVOID)InstallPath->Buffer,
|
|
||||||
InstallPath->Length + sizeof(WCHAR));
|
|
||||||
NtClose(KeyHandle);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue