[FREELDR][HACK] Temporarily disable registry recovery code for AMD64

The newly implemented code for registry recovery makes the FreeLdr binary to grow
in size, to the point that it would BSOD because the PE image is too big.

For now we have to temporarily disable any of the newly added code, until
either FreeLdr is split into a basic PE bootloader image itself and a
"FreeLdrlib" that is used by the PE image to access various bootloader APIs
or another proper solution is found.
This commit is contained in:
George Bișoc 2023-10-22 21:28:39 +02:00
parent 7983b65e10
commit fa80176a62
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
2 changed files with 43 additions and 1 deletions

View file

@ -99,7 +99,14 @@ RegInitializeHive(
_In_ BOOLEAN LoadAlternate)
{
NTSTATUS Status;
/*
* FIXME: Disable compilation of some parts of code for AMD64 for now,
* since it makes the FreeLdr binary size so large that it prevents
* x64 ROS from booting.
*/
#if !defined(_M_AMD64)
CM_CHECK_REGISTRY_STATUS CmStatusCode;
#endif
/* Initialize the hive */
Status = HvInitialize(GET_HHIVE(CmHive),
@ -121,6 +128,8 @@ RegInitializeHive(
return FALSE;
}
/* FIXME: See the comment above */
#if !defined(_M_AMD64)
/* Now check the hive and purge volatile data */
CmStatusCode = CmCheckRegistry(CmHive, CM_CHECK_REGISTRY_BOOTLOADER_PURGE_VOLATILES | CM_CHECK_REGISTRY_VALIDATE_HIVE);
if (!CM_CHECK_REGISTRY_SUCCESS(CmStatusCode))
@ -128,10 +137,13 @@ RegInitializeHive(
ERR("CmCheckRegistry detected problems with the loaded flat hive (check code %lu)\n", CmStatusCode);
return FALSE;
}
#endif
return TRUE;
}
/* FIXME: See the comment above */
#if !defined(_M_AMD64)
/**
* @brief
* Loads and reads a hive log at specified
@ -406,6 +418,7 @@ RegRecoverDataHive(
HiveBaseBlock->CheckSum = HvpHiveHeaderChecksum(HiveBaseBlock);
return TRUE;
}
#endif
/**
* @brief
@ -451,6 +464,14 @@ RegImportBinaryHive(
CmSystemHive = FrLdrTempAlloc(sizeof(CMHIVE), 'eviH');
Success = RegInitializeHive(CmSystemHive, ChunkBase, LoadAlternate);
if (!Success)
/* FIXME: See the comment above */
#if defined(_M_AMD64)
{
ERR("Corrupted hive %p!\n", ChunkBase);
FrLdrTempFree(CmSystemHive, 'eviH');
return FALSE;
}
#else
{
/* Free the buffer and retry again */
FrLdrTempFree(CmSystemHive, 'eviH');
@ -484,6 +505,7 @@ RegImportBinaryHive(
*/
((PHBASE_BLOCK)ChunkBase)->BootRecover = HBOOT_BOOT_RECOVERED_BY_HIVE_LOG;
}
#endif
/* Save the root key node */
SystemHive = GET_HHIVE(CmSystemHive);

View file

@ -619,6 +619,11 @@ HvpGetHiveHeader(
return HiveSuccess;
}
/*
* FIXME: Disable compilation for AMD64 for now since it makes
* the FreeLdr binary size so large it makes booting impossible.
*/
#if !defined(_M_AMD64)
/**
* @brief
* Computes the hive space size by querying
@ -960,6 +965,7 @@ HvpRecoverDataFromLog(
return HiveSuccess;
}
#endif
/**
* @brief
@ -998,7 +1004,12 @@ HvLoadHive(
NTSTATUS Status;
BOOLEAN Success;
PHBASE_BLOCK BaseBlock = NULL;
/* FIXME: See the comment above (near HvpQueryHiveSize) */
#if defined(_M_AMD64)
ULONG Result;
#else
ULONG Result, Result2;
#endif
LARGE_INTEGER TimeStamp;
ULONG Offset = 0;
PVOID HiveData;
@ -1044,6 +1055,12 @@ HvLoadHive(
/* Hive header needs a repair */
case RecoverHeader:
/* FIXME: See the comment above (near HvpQueryHiveSize) */
#if defined(_M_AMD64)
{
return STATUS_REGISTRY_CORRUPT;
}
#else
{
/* Check if this hive has a log at hand to begin with */
#if (NTDDI_VERSION < NTDDI_VISTA)
@ -1092,6 +1109,7 @@ HvLoadHive(
break;
}
#endif
}
/* Set the boot type */
@ -1384,6 +1402,8 @@ HvInitialize(
return Status;
}
/* FIXME: See the comment above (near HvpQueryHiveSize) */
#if !defined(_M_AMD64)
/*
* Check if we have recovered this hive. We are responsible to
* flush the primary hive back to backing storage afterwards.
@ -1418,7 +1438,7 @@ HvInitialize(
*/
Status = STATUS_SUCCESS;
}
#endif
break;
}