Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jpbandroid/reactos-pulls
Browse files Browse the repository at this point in the history
…into windivs8
  • Loading branch information
errortek committed Feb 20, 2024
2 parents 4874c4f + f053454 commit 1af55df
Show file tree
Hide file tree
Showing 42 changed files with 3,851 additions and 3,703 deletions.
6 changes: 0 additions & 6 deletions base/applications/ctfmon/ctfmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ InitApp(
g_bOnWow64 = cicIsWow64(); // Is the current process on WoW64?
cicGetOSInfo(&g_uACP, &g_dwOsInfo); // Get OS info

// Initialize Cicero
TFInitLib();

// Create a mutex for Cicero
g_hCicMutex = TF_CreateCicLoadMutex(&g_fWinLogon);
if (!g_hCicMutex)
Expand Down Expand Up @@ -251,9 +248,6 @@ UninitApp(VOID)
// Close Tipbar Popup
ClosePopupTipbar();

// Release Cicero
TFUninitLib();

// Close the mutex
::CloseHandle(g_hCicMutex);
g_hCicMutex = NULL;
Expand Down
6 changes: 2 additions & 4 deletions base/setup/lib/utils/osdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,12 +806,11 @@ CreateNTOSInstallationsList(

ASSERT(PartEntry->DiskEntry == DiskEntry);

DPRINT(" Primary Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n",
DPRINT(" Primary Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, FormatState = %lu -- Should I check it? %s\n",
PartEntry->PartitionNumber, PartEntry->PartitionIndex,
PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE",
PartEntry->IsPartitioned ? "TRUE" : "FALSE",
PartEntry->New ? "Yes" : "No",
PartEntry->AutoCreate ? "Yes" : "No",
PartEntry->FormatState,
ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!");

Expand All @@ -828,12 +827,11 @@ CreateNTOSInstallationsList(

ASSERT(PartEntry->DiskEntry == DiskEntry);

DPRINT(" Logical Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n",
DPRINT(" Logical Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, FormatState = %lu -- Should I check it? %s\n",
PartEntry->PartitionNumber, PartEntry->PartitionIndex,
PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE",
PartEntry->IsPartitioned ? "TRUE" : "FALSE",
PartEntry->New ? "Yes" : "No",
PartEntry->AutoCreate ? "Yes" : "No",
PartEntry->FormatState,
ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!");

Expand Down
104 changes: 55 additions & 49 deletions base/setup/lib/utils/partlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ IsSuperFloppy(
}

/* The partition lengths should agree */
PartitionLengthEstimate = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
PartitionLengthEstimate = GetDiskSizeInBytes(DiskEntry);
if (PartitionInfo->PartitionLength.QuadPart != PartitionLengthEstimate)
{
DPRINT1("PartitionLength = %I64u is different from PartitionLengthEstimate = %I64u\n",
Expand Down Expand Up @@ -676,34 +676,55 @@ CreateInsertBlankRegion(
static
BOOLEAN
InitializePartitionEntry(
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate)
_Inout_ PPARTENTRY PartEntry,
_In_opt_ ULONGLONG SizeBytes)
{
PDISKENTRY DiskEntry = PartEntry->DiskEntry;
ULONGLONG SectorCount;

DPRINT1("Current entry sector count: %I64u\n", PartEntry->SectorCount.QuadPart);

DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
/* The entry must not be already partitioned and not be void */
ASSERT(!PartEntry->IsPartitioned);
ASSERT(PartEntry->SectorCount.QuadPart);

/* Convert the size in bytes to sector count. SizeBytes being
* zero means the caller wants to use all the empty space. */
if ((SizeBytes == 0) || (SizeBytes == GetPartEntrySizeInBytes(PartEntry)))
{
/* Use all of the unpartitioned disk space */
SectorCount = PartEntry->SectorCount.QuadPart;
}
else
{
SectorCount = SizeBytes / DiskEntry->BytesPerSector;
if (SectorCount == 0)
{
/* SizeBytes was certainly less than the minimal size, so fail */
DPRINT1("Partition size %I64u too small\n", SizeBytes);
return FALSE;
}
}
DPRINT1(" New sector count: %I64u\n", SectorCount);

/* Fail if we try to initialize this partition entry with more sectors than what it actually contains */
/* Fail if we request more sectors than what the entry actually contains */
if (SectorCount > PartEntry->SectorCount.QuadPart)
return FALSE;

/* Fail if the partition is already in use */
ASSERT(!PartEntry->IsPartitioned);

if ((AutoCreate != FALSE) ||
if ((SectorCount == 0) ||
(AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) -
PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart))
{
PartEntry->AutoCreate = AutoCreate;
/* Reuse the whole current entry */
}
else
{
ULONGLONG StartSector;
ULONGLONG SectorCount2;
PPARTENTRY NewPartEntry;

/* Create a partition entry that represents the remaining space after the partition to be initialized */
/* Create a partition entry that represents the remaining space
* after the partition to be initialized */

StartSector = AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment);
SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector;
Expand Down Expand Up @@ -735,7 +756,6 @@ InitializePartitionEntry(

PartEntry->FormatState = Unformatted;
PartEntry->FileSystem[0] = L'\0';
// PartEntry->AutoCreate = AutoCreate;
PartEntry->BootIndicator = FALSE;

DPRINT1("First Sector : %I64u\n", PartEntry->StartSector.QuadPart);
Expand Down Expand Up @@ -2390,37 +2410,24 @@ GetPrevPartition(
return NULL;
}

// static
FORCEINLINE
static inline
BOOLEAN
IsEmptyLayoutEntry(
IN PPARTITION_INFORMATION PartitionInfo)
_In_ PPARTITION_INFORMATION PartitionInfo)
{
if (PartitionInfo->StartingOffset.QuadPart == 0 &&
PartitionInfo->PartitionLength.QuadPart == 0)
{
return TRUE;
}

return FALSE;
return (PartitionInfo->StartingOffset.QuadPart == 0 &&
PartitionInfo->PartitionLength.QuadPart == 0);
}

// static
FORCEINLINE
static inline
BOOLEAN
IsSamePrimaryLayoutEntry(
IN PPARTITION_INFORMATION PartitionInfo,
IN PDISKENTRY DiskEntry,
IN PPARTENTRY PartEntry)
_In_ PPARTITION_INFORMATION PartitionInfo,
_In_ PPARTENTRY PartEntry)
{
if (PartitionInfo->StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector &&
PartitionInfo->PartitionLength.QuadPart == PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector)
return ((PartitionInfo->StartingOffset.QuadPart == GetPartEntryOffsetInBytes(PartEntry)) &&
(PartitionInfo->PartitionLength.QuadPart == GetPartEntrySizeInBytes(PartEntry)));
// PartitionInfo->PartitionType == PartEntry->PartitionType
{
return TRUE;
}

return FALSE;
}

static
Expand Down Expand Up @@ -2578,12 +2585,12 @@ UpdateDiskLayout(

PartEntry->OnDiskPartitionNumber = (!IsContainerPartition(PartEntry->PartitionType) ? PartitionNumber : 0);

if (!IsSamePrimaryLayoutEntry(PartitionInfo, DiskEntry, PartEntry))
if (!IsSamePrimaryLayoutEntry(PartitionInfo, PartEntry))
{
DPRINT1("Updating primary partition entry %lu\n", Index);

PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry);
PartitionInfo->PartitionLength.QuadPart = GetPartEntrySizeInBytes(PartEntry);
PartitionInfo->HiddenSectors = PartEntry->StartSector.LowPart;
PartitionInfo->PartitionNumber = PartEntry->PartitionNumber;
PartitionInfo->PartitionType = PartEntry->PartitionType;
Expand Down Expand Up @@ -2624,8 +2631,8 @@ UpdateDiskLayout(

DPRINT1("Updating logical partition entry %lu\n", Index);

PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry);
PartitionInfo->PartitionLength.QuadPart = GetPartEntrySizeInBytes(PartEntry);
PartitionInfo->HiddenSectors = DiskEntry->SectorAlignment;
PartitionInfo->PartitionNumber = PartEntry->PartitionNumber;
PartitionInfo->PartitionType = PartEntry->PartitionType;
Expand Down Expand Up @@ -2862,12 +2869,11 @@ BOOLEAN
CreatePartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
_In_ ULONGLONG SectorCount,
_In_ BOOLEAN AutoCreate)
_In_opt_ ULONGLONG SizeBytes)
{
ERROR_NUMBER Error;

DPRINT1("CreatePartition(%I64u)\n", SectorCount);
DPRINT1("CreatePartition(%I64u bytes)\n", SizeBytes);

if (List == NULL || PartEntry == NULL ||
PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned)
Expand All @@ -2883,7 +2889,7 @@ CreatePartition(
}

/* Initialize the partition entry, inserting a new blank region if needed */
if (!InitializePartitionEntry(PartEntry, SectorCount, AutoCreate))
if (!InitializePartitionEntry(PartEntry, SizeBytes))
return FALSE;

UpdateDiskLayout(PartEntry->DiskEntry);
Expand Down Expand Up @@ -2924,11 +2930,11 @@ BOOLEAN
CreateExtendedPartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
_In_ ULONGLONG SectorCount)
_In_opt_ ULONGLONG SizeBytes)
{
ERROR_NUMBER Error;

DPRINT1("CreateExtendedPartition(%I64u)\n", SectorCount);
DPRINT1("CreateExtendedPartition(%I64u bytes)\n", SizeBytes);

if (List == NULL || PartEntry == NULL ||
PartEntry->DiskEntry == NULL || PartEntry->IsPartitioned)
Expand All @@ -2944,7 +2950,7 @@ CreateExtendedPartition(
}

/* Initialize the partition entry, inserting a new blank region if needed */
if (!InitializePartitionEntry(PartEntry, SectorCount, FALSE))
if (!InitializePartitionEntry(PartEntry, SizeBytes))
return FALSE;

ASSERT(PartEntry->LogicalPartition == FALSE);
Expand Down Expand Up @@ -3933,7 +3939,7 @@ SetMountedDeviceValues(
/* Assign a "\DosDevices\#:" mount point to this partition */
if (PartEntry->DriveLetter)
{
StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry);
if (!SetMountedDeviceValue(PartEntry->DriveLetter,
DiskEntry->LayoutBuffer->Signature,
StartingOffset))
Expand All @@ -3956,7 +3962,7 @@ SetMountedDeviceValues(
/* Assign a "\DosDevices\#:" mount point to this partition */
if (PartEntry->DriveLetter)
{
StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
StartingOffset.QuadPart = GetPartEntryOffsetInBytes(PartEntry);
if (!SetMountedDeviceValue(PartEntry->DriveLetter,
DiskEntry->LayoutBuffer->Signature,
StartingOffset))
Expand Down
18 changes: 12 additions & 6 deletions base/setup/lib/utils/partlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ typedef struct _PARTENTRY
/* Partition is new, table does not exist on disk yet */
BOOLEAN New;

/* Partition was created automatically */
BOOLEAN AutoCreate;

/* Partition must be checked */
BOOLEAN NeedsCheck;

Expand Down Expand Up @@ -227,6 +224,16 @@ RoundingDivide(
IN ULONGLONG Divisor);


#define GetPartEntryOffsetInBytes(PartEntry) \
((PartEntry)->StartSector.QuadPart * (PartEntry)->DiskEntry->BytesPerSector)

#define GetPartEntrySizeInBytes(PartEntry) \
((PartEntry)->SectorCount.QuadPart * (PartEntry)->DiskEntry->BytesPerSector)

#define GetDiskSizeInBytes(DiskEntry) \
((DiskEntry)->SectorCount.QuadPart * (DiskEntry)->BytesPerSector)


BOOLEAN
IsSuperFloppy(
IN PDISKENTRY DiskEntry);
Expand Down Expand Up @@ -306,14 +313,13 @@ BOOLEAN
CreatePartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
_In_ ULONGLONG SectorCount,
_In_ BOOLEAN AutoCreate);
_In_opt_ ULONGLONG SizeBytes);

BOOLEAN
CreateExtendedPartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
_In_ ULONGLONG SectorCount);
_In_opt_ ULONGLONG SizeBytes);

NTSTATUS
DismountVolume(
Expand Down
4 changes: 2 additions & 2 deletions base/setup/usetup/partlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PartitionDescription(
PCSTR Unit;

/* Get the partition size */
PartSize = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
PartSize = GetPartEntrySizeInBytes(PartEntry);
PrettifySize2(&PartSize, &Unit);

if (PartEntry->IsPartitioned == FALSE)
Expand Down Expand Up @@ -307,7 +307,7 @@ DiskDescription(
PCSTR Unit;

/* Get the disk size */
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
DiskSize = GetDiskSizeInBytes(DiskEntry);
PrettifySize1(&DiskSize, &Unit);

//
Expand Down
Loading

0 comments on commit 1af55df

Please sign in to comment.