From 46cd09ef50bb63fa2b30b9c4f9fd284e130a46d4 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Thu, 9 Feb 2017 00:28:02 +0300 Subject: PlatformInfo read. (via ReadEfiConfig) It is displayed in System settings --- src/Common/BaseCom.cpp | 4 ++-- src/Common/BaseCom.h | 2 +- src/Common/BootEncryption.cpp | 18 +++++++++--------- src/Common/BootEncryption.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/Common') diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index 26e2650a..a73e472d 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -400,7 +400,7 @@ DWORD BaseCom::GetEfiBootDeviceNumber (BSTR* pSdn) return ERROR_SUCCESS; } -DWORD BaseCom::ReadEfiConfig (BSTR* pContent, DWORD *pcbRead) +DWORD BaseCom::ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead) { if (!pContent || !(*pContent)) return ERROR_INVALID_PARAMETER; @@ -409,7 +409,7 @@ DWORD BaseCom::ReadEfiConfig (BSTR* pContent, DWORD *pcbRead) { DWORD maxSize = ((DWORD *) ((BYTE *) *pContent))[-1]; BootEncryption bootEnc (NULL); - bootEnc.ReadEfiConfig ((byte*) *pContent, maxSize, pcbRead); + bootEnc.ReadEfiConfig (filename, (byte*) *pContent, maxSize, pcbRead); } catch (SystemException &) { diff --git a/src/Common/BaseCom.h b/src/Common/BaseCom.h index b103ad59..1ec9012a 100644 --- a/src/Common/BaseCom.h +++ b/src/Common/BaseCom.h @@ -116,7 +116,7 @@ public: static DWORD BackupEfiSystemLoader (); static DWORD RestoreEfiSystemLoader (); static DWORD GetEfiBootDeviceNumber (BSTR* pSdn); - static DWORD ReadEfiConfig (BSTR* pContent, DWORD *pcbRead); + static DWORD ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead); static DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); }; diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 45ba53d4..6dc2c979 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -372,7 +372,7 @@ namespace VeraCrypt } } - static void ReadEfiConfig (byte* confContent, DWORD maxSize, DWORD* pcbRead) + static void ReadEfiConfig (const wchar_t *filename, byte* confContent, DWORD maxSize, DWORD* pcbRead) { Elevate(); @@ -382,8 +382,8 @@ namespace VeraCrypt SetLastError (ERROR_INVALID_PARAMETER); throw SystemException(SRC_POS); } - - DWORD result = ElevatedComInstance->ReadEfiConfig (&outputBstr, pcbRead); + BSTR bstrfn = W2BSTR(filename); + DWORD result = ElevatedComInstance->ReadEfiConfig (bstrfn, &outputBstr, pcbRead); if (confContent) memcpy (confContent, *(void **) &outputBstr, maxSize); @@ -492,7 +492,7 @@ namespace VeraCrypt static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); } - static void ReadEfiConfig (byte* confContent, DWORD maxSize, DWORD* pcbRead) { throw ParameterIncorrect (SRC_POS); } + static void ReadEfiConfig (const wchar_t *filename, byte* confContent, DWORD maxSize, DWORD* pcbRead) { throw ParameterIncorrect (SRC_POS); } static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); } }; @@ -1530,14 +1530,14 @@ namespace VeraCrypt } } - void BootEncryption::ReadEfiConfig (byte* confContent, DWORD maxSize, DWORD* pcbRead) + void BootEncryption::ReadEfiConfig (const wchar_t* fileName, byte* confContent, DWORD maxSize, DWORD* pcbRead) { if (!pcbRead) throw ParameterIncorrect (SRC_POS); if (!IsAdmin() && IsUacSupported()) { - Elevator::ReadEfiConfig (confContent, maxSize, pcbRead); + Elevator::ReadEfiConfig (fileName, confContent, maxSize, pcbRead); } else { @@ -1546,14 +1546,14 @@ namespace VeraCrypt finally_do ({ EfiBootInst.DismountBootPartition(); }); EfiBootInst.MountBootPartition(0); - EfiBootInst.GetFileSize(L"\\EFI\\VeraCrypt\\DcsProp", ui64Size); + EfiBootInst.GetFileSize(fileName, ui64Size); *pcbRead = (DWORD) ui64Size; if (*pcbRead > maxSize) throw ParameterIncorrect (SRC_POS); - EfiBootInst.ReadFile (L"\\EFI\\VeraCrypt\\DcsProp", confContent, *pcbRead); + EfiBootInst.ReadFile (fileName, confContent, *pcbRead); } } @@ -1575,7 +1575,7 @@ namespace VeraCrypt // call ReadEfiConfig only when needed since it requires elevation if (userConfig || customUserMessage || bootLoaderVersion) { - ReadEfiConfig (confContent, sizeof (confContent) - 1, &dwSize); + ReadEfiConfig (L"\\EFI\\VeraCrypt\\DcsProp", confContent, sizeof (confContent) - 1, &dwSize); confContent[dwSize] = 0; diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index 4071a7f5..c63aa80e 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -270,7 +270,7 @@ namespace VeraCrypt void ProbeRealSystemDriveSize (); bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr); uint32 ReadDriverConfigurationFlags (); - void ReadEfiConfig (byte* confContent, DWORD maxSize, DWORD* pcbRead); + void ReadEfiConfig (const wchar_t* filename, byte* confContent, DWORD maxSize, DWORD* pcbRead); void RegisterBootDriver (bool hiddenSystem); void RegisterFilterDriver (bool registerDriver, FilterType filterType); void RegisterSystemFavoritesService (BOOL registerService); -- cgit v1.2.3