diff options
Diffstat (limited to 'DcsBoot')
-rw-r--r-- | DcsBoot/DcsBoot.c | 104 | ||||
-rw-r--r-- | DcsBoot/DcsBoot.inf | 64 |
2 files changed, 168 insertions, 0 deletions
diff --git a/DcsBoot/DcsBoot.c b/DcsBoot/DcsBoot.c new file mode 100644 index 0000000..bccf216 --- /dev/null +++ b/DcsBoot/DcsBoot.c @@ -0,0 +1,104 @@ +/** @file
+ This is DCS boot loader application
+
+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 <Uefi.h>
+#include <Library/CommonLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
+
+EFI_GUID ImagePartGuid;
+EFI_GUID *gEfiExecPartGuid = &ImagePartGuid;
+CHAR16 *gEfiExecCmdDefault = L"\\EFI\\Microsoft\\Boot\\Bootmgfw.efi";
+CHAR16 *gEfiExecCmd = NULL;
+/**
+The actual entry point for the application.
+
+@param[in] ImageHandle The firmware allocated handle for the EFI image.
+@param[in] SystemTable A pointer to the EFI System Table.
+
+@retval EFI_SUCCESS The entry point executed successfully.
+@retval other Some error occur when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+DcsBootMain(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS res;
+ UINTN len;
+ UINT32 attr;
+ InitBio();
+ res = InitFS();
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"InitFS %r\n", res);
+ }
+
+ // Load all drivers
+ res = EfiExec(NULL, L"\\EFI\\VeraCrypt\\LegacySpeaker.dcs");
+
+ res = EfiGetPartGUID(gFileRootHandle, &ImagePartGuid);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"\nStart partition %r\n", res);
+ return res;
+ }
+
+ EfiSetVar(L"DcsExecPartGuid", NULL, &ImagePartGuid, sizeof(EFI_GUID), EFI_VARIABLE_BOOTSERVICE_ACCESS);
+ EfiSetVar(L"DcsExecCmd", NULL, gEfiExecCmdDefault, (StrLen(gEfiExecCmdDefault) + 1) * 2, EFI_VARIABLE_BOOTSERVICE_ACCESS);
+ // Authorize
+ res = EfiExec(NULL, L"\\EFI\\VeraCrypt\\DcsInt.dcs");
+ if (EFI_ERROR(res)) {
+ // ERR_PRINT(L"\nDcsInt.efi %r\n",res);
+ return res;
+ }
+
+ res = EfiGetVar(L"DcsExecPartGuid", NULL, &gEfiExecPartGuid, &len, &attr);
+ if (EFI_ERROR(res)) {
+ gEfiExecPartGuid = &ImagePartGuid;
+ }
+
+ res = EfiGetVar(L"DcsExecCmd", NULL, &gEfiExecCmd, &len, &attr);
+ if (EFI_ERROR(res)) {
+ gEfiExecCmd = gEfiExecCmdDefault;
+ }
+
+ // Find new start partition
+ ConnectAllEfi();
+ InitBio();
+ res = InitFS();
+// OUT_PRINT(L".");
+ res = EfiFindPartByGUID(gEfiExecPartGuid, &gFileRootHandle);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"\nCan't find start partition %g\n", gEfiExecPartGuid);
+ EfiCpuHalt();
+ }
+// OUT_PRINT(L".");
+ res = FileOpenRoot(gFileRootHandle, &gFileRoot);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"\nCan't open start partition\n");
+ EfiCpuHalt();
+ }
+// OUT_PRINT(L".");
+ // Try to exec windows loader...
+ res = EfiExec(NULL, gEfiExecCmd);
+ if (EFI_ERROR(res)) {
+ ERR_PRINT(L"\nStart %s - %r\n", gEfiExecCmd, res);
+ EfiCpuHalt();
+ }
+ ERR_PRINT(L"???%r");
+ EfiCpuHalt();
+ return EFI_INVALID_PARAMETER;
+}
diff --git a/DcsBoot/DcsBoot.inf b/DcsBoot/DcsBoot.inf new file mode 100644 index 0000000..9459e92 --- /dev/null +++ b/DcsBoot/DcsBoot.inf @@ -0,0 +1,64 @@ +## @file
+# This is DCS boot loader application
+#
+# 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
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = DcsBoot
+ FILE_GUID = DE8AB4B2-EB47-44E1-A4D7-1001E5E9F0A5
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = DcsBootMain
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DcsBoot.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ DcsPkg/DcsPkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+ BaseLib
+ MemoryAllocationLib
+ CommonLib
+
+[Guids]
+ gEfiGlobalVariableGuid
+ gEfiDcsVariableGuid
+ gEfiFileInfoGuid
+
+[Protocols]
+ gEfiBlockIoProtocolGuid
+
+[BuildOptions.IA32]
+RELEASE_VS2010x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+DEBUG_VS2010x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+NOOPT_VS2010x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+
+RELEASE_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+DEBUG_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+NOOPT_VS2015x86_IA32_CC_FLAGS = /arch:IA32 /FAcs
+[FeaturePcd]
+
+[Pcd]
+
|