mirror of https://github.com/acidanthera/audk.git
Use ReadUnaligned16 function to access the buffer which is pointed by a possible unaligned pointer.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13879 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
151304d96d
commit
e6fa789014
|
@ -1262,6 +1262,7 @@ BiosVideoCheckForVbe (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_IA32_REGISTER_SET Regs;
|
EFI_IA32_REGISTER_SET Regs;
|
||||||
UINT16 *ModeNumberPtr;
|
UINT16 *ModeNumberPtr;
|
||||||
|
UINT16 VbeModeNumber;
|
||||||
BOOLEAN ModeFound;
|
BOOLEAN ModeFound;
|
||||||
BOOLEAN EdidFound;
|
BOOLEAN EdidFound;
|
||||||
BIOS_VIDEO_MODE_DATA *ModeBuffer;
|
BIOS_VIDEO_MODE_DATA *ModeBuffer;
|
||||||
|
@ -1478,11 +1479,16 @@ BiosVideoCheckForVbe (
|
||||||
PreferMode = 0;
|
PreferMode = 0;
|
||||||
ModeNumber = 0;
|
ModeNumber = 0;
|
||||||
|
|
||||||
for (; *ModeNumberPtr != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST; ModeNumberPtr++) {
|
//
|
||||||
|
// ModeNumberPtr may be not 16-byte aligned, so ReadUnaligned16 is used to access the buffer pointed by ModeNumberPtr.
|
||||||
|
//
|
||||||
|
for (VbeModeNumber = ReadUnaligned16 (ModeNumberPtr);
|
||||||
|
VbeModeNumber != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST;
|
||||||
|
VbeModeNumber = ReadUnaligned16 (++ModeNumberPtr)) {
|
||||||
//
|
//
|
||||||
// Make sure this is a mode number defined by the VESA VBE specification. If it isn'tm then skip this mode number.
|
// Make sure this is a mode number defined by the VESA VBE specification. If it isn'tm then skip this mode number.
|
||||||
//
|
//
|
||||||
if ((*ModeNumberPtr & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {
|
if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -1490,7 +1496,7 @@ BiosVideoCheckForVbe (
|
||||||
//
|
//
|
||||||
gBS->SetMem (&Regs, sizeof (Regs), 0);
|
gBS->SetMem (&Regs, sizeof (Regs), 0);
|
||||||
Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION;
|
Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION;
|
||||||
Regs.X.CX = *ModeNumberPtr;
|
Regs.X.CX = VbeModeNumber;
|
||||||
gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0);
|
gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0);
|
||||||
Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);
|
Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);
|
||||||
Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);
|
Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);
|
||||||
|
@ -1619,7 +1625,7 @@ BiosVideoCheckForVbe (
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentModeData = &ModeBuffer[ModeNumber - 1];
|
CurrentModeData = &ModeBuffer[ModeNumber - 1];
|
||||||
CurrentModeData->VbeModeNumber = *ModeNumberPtr;
|
CurrentModeData->VbeModeNumber = VbeModeNumber;
|
||||||
if (BiosVideoPrivate->VbeInformationBlock->VESAVersion >= VESA_BIOS_EXTENSIONS_VERSION_3_0) {
|
if (BiosVideoPrivate->VbeInformationBlock->VESAVersion >= VESA_BIOS_EXTENSIONS_VERSION_3_0) {
|
||||||
CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->LinBytesPerScanLine;
|
CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->LinBytesPerScanLine;
|
||||||
CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRedFieldPosition;
|
CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRedFieldPosition;
|
||||||
|
|
Loading…
Reference in New Issue