VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/Library
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2017-02-05 23:45:29 +0300
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-06-05 17:36:54 +0200
commitfdfe9f849c15dc4b864a72fcbc5266edb68171c1 (patch)
treeec625901931928af079611f8af9cc3dc5d6ed3f9 /Library
parentabf3adcd2f37f4e278fc9ef7634ca0c8f5171893 (diff)
downloadVeraCrypt-DCS-fdfe9f849c15dc4b864a72fcbc5266edb68171c1.tar.gz
VeraCrypt-DCS-fdfe9f849c15dc4b864a72fcbc5266edb68171c1.zip
DcsCfg dumps of secregion and tables
Diffstat (limited to 'Library')
-rw-r--r--Library/DcsCfgLib/GptEdit.c45
1 files changed, 45 insertions, 0 deletions
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 <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/PrintLib.h>
#include <Uefi/UefiGpt.h>
#include <Guid/Gpt.h>
@@ -815,6 +816,50 @@ err:
}
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,
IN CONST CHAR16* dataFileName