Mattiwatti / EfiGuard

Disable PatchGuard and Driver Signature Enforcement at boot time
GNU General Public License v3.0
1.78k stars 337 forks source link

Source can't compile on latest EDK because gEfiLegacyBiosProtocolGuid removed #119

Open nProtect opened 5 months ago

nProtect commented 5 months ago

Question description

Hello,

Seem source code can't compile if use with latest EDK because gEfiLegacyBiosProtocolGuid get removed. Ref: https://edk2.groups.io/g/devel/topic/102518665

To temporary fix this, I need to comment this code to make it can compile on latest EDK

EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
Status = gBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid,
    NULL,
    (VOID**)&LegacyBios);
ASSERT_EFI_ERROR(Status);

BootOptions[Index].Status = LegacyBios->LegacyBoot(LegacyBios,
    (BBS_BBS_DEVICE_PATH*)BootOptions[Index].FilePath,
    BootOptions[Index].OptionalDataSize,
    BootOptions[Index].OptionalData);

Is there any issue if I remove this code?

Mattiwatti commented 5 months ago

Indeed, EDK2 has removed all CSM support from OVMF. I actually ran into this issue a while ago, and I have fixed this locally by simply copying the minimum amount of code necessary from OVMF so that the same code in EfiGuard's loader can continue to compile (as the protocol and its GUID are actually used in 'real' PC firmware, not just OVMF, and I do not want to remove the code, as it prevents people from mistakenly thinking EfiGuard is not working when the real issue is the fact that their Windows is installed in BIOS mode.)

My main issue at the moment is actually the fact that I don't wish to encourage compilation using EDK2 master in the first place, but for different reasons: see #112, which is a more serious bug in current edk2 master that I do not currently have a fix or workaround for. Nevertheless, I will probably commit and push a fix for this sometime in the next few days, assuming I find time to test it.

To answer your question:

Is there any issue if I remove this code?

Nope. This code was only added as a way to help out idiots who are trying to use EfiGuard on a legacy (BIOS/MBR) installation of Windows, and point out to them why this is not going to work. Assuming you are using EfiGuard on an EFI installation of Windows as intended, this code will never be executed, and it is safe to remove it.

nProtect commented 5 months ago

Indeed, EDK2 has removed all CSM support from OVMF. I actually ran into this issue a while ago, and I have fixed this locally by simply copying the minimum amount of code necessary from OVMF so that the same code in EfiGuard's loader can continue to compile (as the protocol and its GUID are actually used in 'real' PC firmware, not just OVMF, and I do not want to remove the code, as it prevents people from mistakenly thinking EfiGuard is not working when the real issue is the fact that their Windows is installed in BIOS mode.)

My main issue at the moment is actually the fact that I don't wish to encourage compilation using EDK2 master in the first place, but for different reasons: see #112, which is a more serious bug in current edk2 master that I do not currently have a fix or workaround for. Nevertheless, I will probably commit and push a fix for this sometime in the next few days, assuming I find time to test it.

To answer your question:

Is there any issue if I remove this code?

Nope. This code was only added as a way to help out idiots who are trying to use EfiGuard on a legacy (BIOS/MBR) installation of Windows, and point out to them why this is not going to work. Assuming you are using EfiGuard on an EFI installation of Windows as intended, this code will never be executed, and it is safe to remove it.

Thank you. I only modify some to use only myself and my windows installed as UEFI.