From 5fb01149ef1cecc36b261094b304ff0654bb7ae3 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Sat, 17 Sep 2016 01:00:44 +0300 Subject: DcsRe select volume is added to boot from usb Notes (7.2, 7.4) --- DcsInt/DcsInt.c | 31 +++++++++++++++---------------- DcsRe/DcsRe.c | 4 +++- Library/CommonLib/EfiBio.c | 3 ++- Library/GraphLib/EfiGraph.c | 1 + Library/VeraCryptLib/DcsVeraCrypt.c | 7 +++++-- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/DcsInt/DcsInt.c b/DcsInt/DcsInt.c index ced318c..3fe90d6 100644 --- a/DcsInt/DcsInt.c +++ b/DcsInt/DcsInt.c @@ -262,7 +262,7 @@ IntBlockIO_Write( writeCrypted = MEM_ALLOC(BufferSize); if (writeCrypted == NULL) { Status = EFI_BAD_BUFFER_SIZE; - + return Status; } CopyMem(writeCrypted, Buffer, BufferSize); // Print(L"*"); @@ -354,18 +354,7 @@ IntBlockIo_Hook( DcsIntBlockIo->Controller = DeviceHandle; DcsIntBlockIo->BlockIo = BlockIo; DcsIntBlockIo->IsReinstalled = 0; - - if (EFI_ERROR(Status)) { - gBS->CloseProtocol( - DeviceHandle, - &gEfiBlockIoProtocolGuid, - This->DriverBindingHandle, - DeviceHandle - ); - MEM_FREE(DcsIntBlockIo); - return EFI_UNSUPPORTED; - } - // Block +// Block // Tpl = gBS->RaiseTPL(TPL_NOTIFY); // Install new routines DcsIntBlockIo->CryptInfo = SecRegionCryptInfo; @@ -579,24 +568,30 @@ SecRegionChangePwd() { if (vcres != 0) { ERR_PRINT(L"header create error(%x)\n", vcres); - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto ret; } // get BlockIo protocol bio = EfiGetBlockIO(SecRegionHandle); if (bio == NULL) { ERR_PRINT(L"Block io not supported\n,"); - return EFI_NOT_FOUND; + Status = EFI_NOT_FOUND; + goto ret; } Status = bio->WriteBlocks(bio, bio->Media->MediaId, SecRegionSector, 512, Header); if (EFI_ERROR(Status)) { ERR_PRINT(L"Write: %r\n", Status); - return Status; + goto ret; } CopyMem(&gAuthPassword, &newPassword, sizeof(gAuthPassword)); CopyMem(SecRegionData + SecRegionOffset, Header, 512); ERR_PRINT(L"Update (%r)\n", Status); + +ret: + burn(&newPassword, sizeof(newPassword)); + burn(&confirmPassword, sizeof(confirmPassword)); return Status; } @@ -1017,6 +1012,10 @@ UefiMain( DetectX86Features(); res = SecRegionTryDecrypt(); + + // Reset Console buffer + gST->ConIn->Reset(gST->ConIn, FALSE); + if (EFI_ERROR(res)) { return OnExit(gOnExitFailed, OnExitAuthFaild, res); } diff --git a/DcsRe/DcsRe.c b/DcsRe/DcsRe.c index 9c59dfc..7d08d50 100644 --- a/DcsRe/DcsRe.c +++ b/DcsRe/DcsRe.c @@ -151,7 +151,9 @@ ActionShell() { EFI_STATUS ActionDcsBoot() { - return EfiExec(NULL, L"EFI\\VeraCrypt\\DcsBoot.efi"); + SelectEfiVolume(); + if (EfiBootVolume == NULL) return EFI_NOT_READY; + return EfiExec(gFSHandles[EfiBootVolumeIndex], L"EFI\\VeraCrypt\\DcsBoot.efi"); } CHAR16* DcsBootBins[] = { diff --git a/Library/CommonLib/EfiBio.c b/Library/CommonLib/EfiBio.c index 9577c08..e6509f9 100644 --- a/Library/CommonLib/EfiBio.c +++ b/Library/CommonLib/EfiBio.c @@ -71,6 +71,7 @@ EfiGetHandles( { EFI_STATUS res = EFI_BUFFER_TOO_SMALL; UINTN BufferSize; + if ((Buffer == NULL) || (Count == NULL)) return EFI_INVALID_PARAMETER; if(*Buffer != NULL) MEM_FREE(*Buffer); *Count = 0; *Buffer = (EFI_HANDLE*) MEM_ALLOC(sizeof(EFI_HANDLE)); @@ -80,7 +81,7 @@ EfiGetHandles( if (res == RETURN_BUFFER_TOO_SMALL) { MEM_FREE(*Buffer); *Buffer = (EFI_HANDLE*)MEM_ALLOC(BufferSize); - if (!Buffer) { + if (*Buffer == NULL) { return EFI_OUT_OF_RESOURCES; } res = gBS->LocateHandle(SearchType, Protocol, SearchKey, &BufferSize, *Buffer); diff --git a/Library/GraphLib/EfiGraph.c b/Library/GraphLib/EfiGraph.c index b8e8e2e..3e90646 100644 --- a/Library/GraphLib/EfiGraph.c +++ b/Library/GraphLib/EfiGraph.c @@ -235,6 +235,7 @@ BltPoint( IN UINTN x, IN UINTN y ) { + if (!draw) draw = &gDrawContext; if (draw->Brush == NULL) return BltPointSingle(blt, draw, x, y); else { diff --git a/Library/VeraCryptLib/DcsVeraCrypt.c b/Library/VeraCryptLib/DcsVeraCrypt.c index 9cf57ce..ba92931 100644 --- a/Library/VeraCryptLib/DcsVeraCrypt.c +++ b/Library/VeraCryptLib/DcsVeraCrypt.c @@ -37,8 +37,11 @@ BOOL ConfigRead(char *configKey, char *configValue, int maxValueSize) { char *xml; - if (ConfigBuffer == NULL) - FileLoad(NULL, L"\\EFI\\VeraCrypt\\DcsProp", &ConfigBuffer, &ConfigBufferSize); + if (ConfigBuffer == NULL) { + if (FileLoad(NULL, L"\\EFI\\VeraCrypt\\DcsProp", &ConfigBuffer, &ConfigBufferSize) != EFI_SUCCESS) { + return FALSE; + } + } xml = ConfigBuffer; if (xml != NULL) -- cgit v1.2.3