We are on legacy BIOS if GetFirmwareEnvironmentVariable fails (returns zero) *and* extended error information is ERROR_INVALID_FUNCTION. Cf. http://msdn.microsoft.com/en-us/library/windows/desktop/ms724325%28v=vs.85%29.aspx
Fix potential crash caused by signed vs. unsigned comparison. Negative length compares as very large unsigned number causing subsequent NULL access. Make exhaustive search for all BootNNNN variables to find one matching requested efi_distributor.