From fdfe9f849c15dc4b864a72fcbc5266edb68171c1 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Sun, 5 Feb 2017 23:45:29 +0300 Subject: DcsCfg dumps of secregion and tables --- Library/DcsCfgLib/GptEdit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'Library') diff --git a/Library/DcsCfgLib/GptEdit.c b/Library/DcsCfgLib/GptEdit.c index d486909..5545791 100644 --- a/Library/DcsCfgLib/GptEdit.c +++ b/Library/DcsCfgLib/GptEdit.c @@ -14,6 +14,7 @@ https://opensource.org/licenses/LGPL-3.0 #include #include #include +#include #include #include @@ -814,6 +815,50 @@ err: return res; } +EFI_STATUS +TablesDump( + IN CHAR16 *prefix + ) { + EFI_TABLE_HEADER *mhdr = NULL; + EFI_STATUS res = EFI_SUCCESS; + CHAR16 name[128]; + + if (gDcsTables == NULL) { + CE(TablesLoad()); + } + + mhdr = (EFI_TABLE_HEADER *)gDcsTables; + if (gDcsTables != NULL && + mhdr->Signature == EFITABLE_HEADER_SIGN && + GptHeaderCheckCrc(gDcsTablesSize, mhdr)) { + UINT8* raw = (UINT8*)gDcsTables; + UINTN rawSize = mhdr->HeaderSize; + UINTN tpos = sizeof(EFI_TABLE_HEADER); + while (tpos < rawSize) { + EFI_TABLE_HEADER *hdr = (EFI_TABLE_HEADER *)(raw + tpos); + CHAR8 asc_sign[sizeof(hdr->Signature) + 1] = { 0 }; + CopyMem(asc_sign, &hdr->Signature, sizeof(hdr->Signature)); + asc_sign[sizeof(hdr->Signature)] = 0; + UnicodeSPrint(name, sizeof(name), L"%s%a", prefix, asc_sign); + OUT_PRINT(L"%s, SZ=%d", name, hdr->HeaderSize); + if (!GptHeaderCheckCrc(rawSize - tpos, hdr)) { + ERR_PRINT(L" - wrong crc\n"); + return EFI_CRC_ERROR; // wrong crc + } + CE(FileSave(NULL, name, raw + tpos + sizeof(EFI_TABLE_HEADER), hdr->HeaderSize - sizeof(EFI_TABLE_HEADER))); + OUT_PRINT(L" - saved\n"); + tpos += hdr->HeaderSize; + } + return EFI_SUCCESS; + } + +err: + if (EFI_ERROR(res)) { + ERR_PRINT(L"Tables load error %r\n", res); + } + return res; +} + EFI_STATUS TablesNew( IN CONST CHAR16* signStr, -- cgit v1.2.3