mirror of
https://github.com/reactos/reactos.git
synced 2025-04-05 13:11:22 +00:00
Fixed an off-by-one error in CmiPopulateHive().
Removed dead code from NtFlushKey(). Changed some debugging messages. svn path=/trunk/; revision=4340
This commit is contained in:
parent
c306d43c24
commit
1b53680503
3 changed files with 19 additions and 213 deletions
|
@ -690,18 +690,8 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
NTSTATUS Status;
|
||||
PKEY_OBJECT KeyObject;
|
||||
PREGISTRY_HIVE RegistryHive;
|
||||
#if 0
|
||||
WCHAR LogName[MAX_PATH];
|
||||
UNICODE_STRING TmpFileName;
|
||||
HANDLE FileHandle;
|
||||
// HANDLE FileHandleLog;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
LARGE_INTEGER fileOffset;
|
||||
DWORD * pEntDword;
|
||||
ULONG i;
|
||||
#endif
|
||||
|
||||
DPRINT("KeyHandle %x\n", KeyHandle);
|
||||
DPRINT("NtFlushKey (KeyHandle %lx) called\n", KeyHandle);
|
||||
|
||||
/* Verify that the handle is valid and is a registry key */
|
||||
Status = ObReferenceObjectByHandle(KeyHandle,
|
||||
|
@ -733,192 +723,6 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* Then write changed blocks in .log */
|
||||
wcscpy(LogName,RegistryHive->Filename.Buffer);
|
||||
wcscat(LogName,L".log");
|
||||
RtlInitUnicodeString (&TmpFileName, LogName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&TmpFileName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* BEGIN FIXME : actually (26 November 200) vfatfs.sys can't create new files
|
||||
so we can't create log file
|
||||
Status = ZwCreateFile(&FileHandleLog,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0,
|
||||
FILE_SUPERSEDE,
|
||||
0,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ZwWriteFile(FileHandleLog,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
RegistryHive->HiveHeader,
|
||||
sizeof(HIVE_HEADER),
|
||||
0,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(FileHandleLog);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (i = 0; i < RegistryHive->BlockListSize ; i++)
|
||||
{
|
||||
if ( RegistryHive->BlockList[i]->DateModified.dwHighDateTime
|
||||
> RegistryHive->HiveHeader->DateModified.dwHighDateTime
|
||||
|| (RegistryHive->BlockList[i]->DateModified.dwHighDateTime
|
||||
== RegistryHive->HiveHeader->DateModified.dwHighDateTime
|
||||
&& RegistryHive->BlockList[i]->DateModified.dwLowDateTime
|
||||
> RegistryHive->HiveHeader->DateModified.dwLowDateTime
|
||||
)
|
||||
)
|
||||
|
||||
Status = ZwWriteFile(FileHandleLog,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
RegistryHive->BlockList[i],
|
||||
RegistryHive->BlockList[i]->BlockSize ,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(FileHandleLog);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
ZwClose(FileHandleLog);
|
||||
END FIXME*/
|
||||
|
||||
/* Update header of RegistryHive with Version >VersionOld */
|
||||
/* this allow recover if system crash while updating hove file */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->Filename,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RegistryHive->HiveHeader->Version++;
|
||||
|
||||
Status = ZwWriteFile(FileHandle,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
RegistryHive->HiveHeader,
|
||||
sizeof(HIVE_HEADER),
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(FileHandle);
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Update changed blocks in file */
|
||||
fileOffset.u.HighPart = 0;
|
||||
for (i = 0; i < RegistryHive->BlockListSize ; i++)
|
||||
{
|
||||
if (RegistryHive->BlockList[i]->DateModified.dwHighDateTime
|
||||
> RegistryHive->HiveHeader->DateModified.dwHighDateTime
|
||||
|| (RegistryHive->BlockList[i]->DateModified.dwHighDateTime
|
||||
== RegistryHive->HiveHeader->DateModified.dwHighDateTime
|
||||
&& RegistryHive->BlockList[i]->DateModified.dwLowDateTime
|
||||
> RegistryHive->HiveHeader->DateModified.dwLowDateTime))
|
||||
{
|
||||
fileOffset.u.LowPart = RegistryHive->BlockList[i]->BlockOffset+4096;
|
||||
Status = NtWriteFile(FileHandle,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
RegistryHive->BlockList[i],
|
||||
RegistryHive->BlockList[i]->BlockSize,
|
||||
&fileOffset,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(FileHandle);
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Change version in header */
|
||||
RegistryHive->HiveHeader->VersionOld = RegistryHive->HiveHeader->Version;
|
||||
ZwQuerySystemTime((PTIME) &RegistryHive->HiveHeader->DateModified);
|
||||
|
||||
/* Calculate checksum */
|
||||
RegistryHive->HiveHeader->Checksum = 0;
|
||||
pEntDword = (DWORD *) RegistryHive->HiveHeader;
|
||||
for (i = 0; i < 127 ; i++)
|
||||
{
|
||||
RegistryHive->HiveHeader->Checksum ^= pEntDword[i];
|
||||
}
|
||||
|
||||
/* Write new header */
|
||||
fileOffset.u.LowPart = 0;
|
||||
Status = ZwWriteFile(FileHandle,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
RegistryHive->HiveHeader,
|
||||
sizeof(HIVE_HEADER),
|
||||
&fileOffset,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(FileHandle);
|
||||
ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource);
|
||||
ObDereferenceObject(KeyObject);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ZwClose(FileHandle);
|
||||
#endif
|
||||
|
||||
ExReleaseResourceLite(&RegistryHive->HiveResource);
|
||||
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
|
|
@ -394,13 +394,13 @@ CmiPopulateHive(HANDLE FileHandle)
|
|||
|
||||
// Add free blocks so we don't need to expand
|
||||
// the file for a while
|
||||
for (i = 0; i < 50; i++)
|
||||
for (i = 1; i < 50; i++)
|
||||
{
|
||||
// Block offset of this bin
|
||||
BinCell->BlockOffset = (2 + i) * REG_BLOCK_SIZE;
|
||||
BinCell->BlockOffset = i * REG_BLOCK_SIZE;
|
||||
|
||||
FileOffset.u.HighPart = 0;
|
||||
FileOffset.u.LowPart = (2 + i) * REG_BLOCK_SIZE;
|
||||
FileOffset.u.LowPart = (i + 1) * REG_BLOCK_SIZE;
|
||||
|
||||
Status = NtWriteFile(FileHandle,
|
||||
NULL,
|
||||
|
@ -1194,7 +1194,7 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
PVOID BlockPtr;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT1("CmiStartLogUpdate() called\n");
|
||||
DPRINT("CmiStartLogUpdate() called\n");
|
||||
|
||||
BitmapSize = ROUND_UP(RegistryHive->BlockListSize, sizeof(ULONG) * 8) / 8;
|
||||
BufferSize = sizeof(HIVE_HEADER) +
|
||||
|
@ -3276,7 +3276,7 @@ CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
|
|||
if (IsVolatileHive(RegistryHive))
|
||||
return;
|
||||
|
||||
DPRINT1("CmiMarkBlockDirty(Offset 0x%lx)\n", (ULONG)BlockOffset);
|
||||
DPRINT("CmiMarkBlockDirty(Offset 0x%lx)\n", (ULONG)BlockOffset);
|
||||
|
||||
BlockNumber = (ULONG)BlockOffset / 4096;
|
||||
|
||||
|
@ -3290,11 +3290,11 @@ CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
|
|||
|
||||
BlockCount = (ROUND_UP(BlockOffset + CellSize, 4096) - ROUND_DOWN(BlockOffset, 4096)) / 4096;
|
||||
|
||||
DPRINT1(" BlockNumber %lu Size %lu (%s) BlockCount %lu\n",
|
||||
BlockNumber,
|
||||
CellSize,
|
||||
(Cell->CellSize < 0) ? "used" : "free",
|
||||
BlockCount);
|
||||
DPRINT(" BlockNumber %lu Size %lu (%s) BlockCount %lu\n",
|
||||
BlockNumber,
|
||||
CellSize,
|
||||
(Cell->CellSize < 0) ? "used" : "free",
|
||||
BlockCount);
|
||||
|
||||
RegistryHive->HiveDirty = TRUE;
|
||||
RtlSetBits(&RegistryHive->DirtyBitMap,
|
||||
|
@ -3314,7 +3314,7 @@ CmiMarkBinDirty(PREGISTRY_HIVE RegistryHive,
|
|||
if (IsVolatileHive(RegistryHive))
|
||||
return;
|
||||
|
||||
DPRINT1("CmiMarkBinDirty(Offset 0x%lx)\n", (ULONG)BinOffset);
|
||||
DPRINT("CmiMarkBinDirty(Offset 0x%lx)\n", (ULONG)BinOffset);
|
||||
|
||||
BlockNumber = (ULONG)BinOffset / 4096;
|
||||
|
||||
|
@ -3322,10 +3322,10 @@ CmiMarkBinDirty(PREGISTRY_HIVE RegistryHive,
|
|||
|
||||
BlockCount = Bin->BlockSize / 4096;
|
||||
|
||||
DPRINT1(" BlockNumber %lu Size %lu BlockCount %lu\n",
|
||||
BlockNumber,
|
||||
Bin->BlockSize,
|
||||
BlockCount);
|
||||
DPRINT(" BlockNumber %lu Size %lu BlockCount %lu\n",
|
||||
BlockNumber,
|
||||
Bin->BlockSize,
|
||||
BlockCount);
|
||||
|
||||
RegistryHive->HiveDirty = TRUE;
|
||||
RtlSetBits(&RegistryHive->DirtyBitMap,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: registry.c,v 1.86 2003/03/08 19:26:12 ekohl Exp $
|
||||
/* $Id: registry.c,v 1.87 2003/03/18 20:36:17 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -1106,6 +1106,8 @@ CmiHiveSyncRoutine(PVOID DeferredContext)
|
|||
|
||||
DPRINT("DeferredContext %x\n", DeferredContext);
|
||||
ExFreePool(DeferredContext);
|
||||
|
||||
DPRINT1("CmiHiveSyncRoutine() done\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue