diff options
author | Alex <kavsrf@gmail.com> | 2016-08-15 17:11:31 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-08-15 17:14:26 +0200 |
commit | b87fc6b140772ba3017de311c7063c259424264c (patch) | |
tree | 41ad139e7469380704361ae757a155464e8b68e3 /Library/CommonLib/EfiExec.c | |
parent | 68ea2f72cfe6a9b34212ced97882e488c73c8f1d (diff) | |
download | VeraCrypt-DCS-b87fc6b140772ba3017de311c7063c259424264c.tar.gz VeraCrypt-DCS-b87fc6b140772ba3017de311c7063c259424264c.zip |
First public release. Used by VeraCrypt 1.18.VeraCrypt_1.18_PreRelease
Diffstat (limited to 'Library/CommonLib/EfiExec.c')
-rw-r--r-- | Library/CommonLib/EfiExec.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Library/CommonLib/EfiExec.c b/Library/CommonLib/EfiExec.c new file mode 100644 index 0000000..ff0aa95 --- /dev/null +++ b/Library/CommonLib/EfiExec.c @@ -0,0 +1,88 @@ +/** @file
+EFI execute helpers
+
+Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov
+Copyright (c) 2016. VeraCrypt, Mounir IDRASSI
+
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
+
+The full text of the license may be found at
+https://opensource.org/licenses/LGPL-3.0
+**/
+
+#include <Library/CommonLib.h>
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+EFI_STATUS
+EfiExec(
+ IN EFI_HANDLE deviceHandle,
+ IN CHAR16* path
+ )
+{
+ EFI_STATUS res;
+ EFI_DEVICE_PATH* DevicePath;
+ EFI_HANDLE ImageHandle;
+ UINTN ExitDataSize;
+ CHAR16 *ExitData;
+ if (deviceHandle == NULL) {
+ deviceHandle = gFileRootHandle;
+ }
+ if (!path || !deviceHandle) return EFI_INVALID_PARAMETER;
+ DevicePath = FileDevicePath(deviceHandle, path);
+
+ res = gBS->LoadImage(FALSE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);
+ if (EFI_ERROR(res)) {
+ return res;
+ }
+ res = gBS->StartImage(ImageHandle, &ExitDataSize, &ExitData);
+ if (EFI_ERROR(res)) {
+ return res;
+ }
+ return res;
+}
+
+/**
+This function will connect all current system handles recursively. The
+connection will finish until every handle's child handle created if it have.
+
+@retval EFI_SUCCESS All handles and it's child handle have been
+connected
+@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
+
+**/
+EFI_STATUS
+ConnectAllEfi(
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Index;
+
+ Status = gBS->LocateHandleBuffer(
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->ConnectController(HandleBuffer[Index], NULL, NULL, TRUE);
+ }
+
+ if (HandleBuffer != NULL) {
+ FreePool(HandleBuffer);
+ }
+
+ return EFI_SUCCESS;
+}
\ No newline at end of file |