From cf6a8f1453bed5aca0ac32b4038c83ce62b77327 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Thu, 13 Oct 2011 23:05:08 +0000 Subject: ShellPkg: Set CRC value whenever changing a system table. This adds a function (from DxeMain.c) that calculates and sets a CRC into a system table header and then calls the function in the 2 places where the shell changes the system table. signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12536 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Application/Shell/ShellParametersProtocol.c | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'ShellPkg') diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 02606d615b..5beaadab2e 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -470,6 +470,31 @@ StripQuotes ( } } +/** + Calcualte the 32-bit CRC in a EFI table using the service provided by the + gRuntime service. + + @param Hdr Pointer to an EFI standard header + +**/ +VOID +CalculateEfiHdrCrc ( + IN OUT EFI_TABLE_HEADER *Hdr + ) +{ + UINT32 Crc; + + Hdr->CRC32 = 0; + + // + // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then + // Crc will come back as zero if we set it to zero here + // + Crc = 0; + gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc); + Hdr->CRC32 = Crc; +} + /** Funcion will replace the current StdIn and StdOut in the ShellParameters protocol structure by parsing NewCommandLine. The current values are returned to the @@ -1039,6 +1064,8 @@ UpdateStdInStdOutStdErr( } FreePool(CommandLineCopy); + CalculateEfiHdrCrc(&gST->Hdr); + if (gST->ConIn == NULL ||gST->ConOut == NULL) { return (EFI_OUT_OF_RESOURCES); } @@ -1112,6 +1139,8 @@ RestoreStdInStdOutStdErr ( gST->StandardErrorHandle = SystemTableInfo->ConErrHandle; } + CalculateEfiHdrCrc(&gST->Hdr); + return (EFI_SUCCESS); } /** -- cgit v1.2.3