[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);