PlatformInfo read. (via ReadEfiConfig)

It is displayed in System settings
This commit is contained in:
kavsrf 2017-02-09 00:28:02 +03:00 committed by Mounir IDRASSI
parent a075d45a99
commit 46cd09ef50
No known key found for this signature in database
GPG Key ID: DD0C382D5FCFB8FC
11 changed files with 38 additions and 24 deletions

View File

@ -400,7 +400,7 @@ DWORD BaseCom::GetEfiBootDeviceNumber (BSTR* pSdn)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
DWORD BaseCom::ReadEfiConfig (BSTR* pContent, DWORD *pcbRead) DWORD BaseCom::ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead)
{ {
if (!pContent || !(*pContent)) if (!pContent || !(*pContent))
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
@ -409,7 +409,7 @@ DWORD BaseCom::ReadEfiConfig (BSTR* pContent, DWORD *pcbRead)
{ {
DWORD maxSize = ((DWORD *) ((BYTE *) *pContent))[-1]; DWORD maxSize = ((DWORD *) ((BYTE *) *pContent))[-1];
BootEncryption bootEnc (NULL); BootEncryption bootEnc (NULL);
bootEnc.ReadEfiConfig ((byte*) *pContent, maxSize, pcbRead); bootEnc.ReadEfiConfig (filename, (byte*) *pContent, maxSize, pcbRead);
} }
catch (SystemException &) catch (SystemException &)
{ {

View File

@ -116,7 +116,7 @@ class BaseCom
static DWORD BackupEfiSystemLoader (); static DWORD BackupEfiSystemLoader ();
static DWORD RestoreEfiSystemLoader (); static DWORD RestoreEfiSystemLoader ();
static DWORD GetEfiBootDeviceNumber (BSTR* pSdn); 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); static DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
}; };

View File

@ -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(); Elevate();
@ -382,8 +382,8 @@ namespace VeraCrypt
SetLastError (ERROR_INVALID_PARAMETER); SetLastError (ERROR_INVALID_PARAMETER);
throw SystemException(SRC_POS); throw SystemException(SRC_POS);
} }
BSTR bstrfn = W2BSTR(filename);
DWORD result = ElevatedComInstance->ReadEfiConfig (&outputBstr, pcbRead); DWORD result = ElevatedComInstance->ReadEfiConfig (bstrfn, &outputBstr, pcbRead);
if (confContent) if (confContent)
memcpy (confContent, *(void **) &outputBstr, maxSize); memcpy (confContent, *(void **) &outputBstr, maxSize);
@ -492,7 +492,7 @@ namespace VeraCrypt
static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { 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); } 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) if (!pcbRead)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
if (!IsAdmin() && IsUacSupported()) if (!IsAdmin() && IsUacSupported())
{ {
Elevator::ReadEfiConfig (confContent, maxSize, pcbRead); Elevator::ReadEfiConfig (fileName, confContent, maxSize, pcbRead);
} }
else else
{ {
@ -1546,14 +1546,14 @@ namespace VeraCrypt
finally_do ({ EfiBootInst.DismountBootPartition(); }); finally_do ({ EfiBootInst.DismountBootPartition(); });
EfiBootInst.MountBootPartition(0); EfiBootInst.MountBootPartition(0);
EfiBootInst.GetFileSize(L"\\EFI\\VeraCrypt\\DcsProp", ui64Size); EfiBootInst.GetFileSize(fileName, ui64Size);
*pcbRead = (DWORD) ui64Size; *pcbRead = (DWORD) ui64Size;
if (*pcbRead > maxSize) if (*pcbRead > maxSize)
throw ParameterIncorrect (SRC_POS); 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 // call ReadEfiConfig only when needed since it requires elevation
if (userConfig || customUserMessage || bootLoaderVersion) if (userConfig || customUserMessage || bootLoaderVersion)
{ {
ReadEfiConfig (confContent, sizeof (confContent) - 1, &dwSize); ReadEfiConfig (L"\\EFI\\VeraCrypt\\DcsProp", confContent, sizeof (confContent) - 1, &dwSize);
confContent[dwSize] = 0; confContent[dwSize] = 0;

View File

@ -270,7 +270,7 @@ namespace VeraCrypt
void ProbeRealSystemDriveSize (); void ProbeRealSystemDriveSize ();
bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr); bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
uint32 ReadDriverConfigurationFlags (); 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 RegisterBootDriver (bool hiddenSystem);
void RegisterFilterDriver (bool registerDriver, FilterType filterType); void RegisterFilterDriver (bool registerDriver, FilterType filterType);
void RegisterSystemFavoritesService (BOOL registerService); void RegisterSystemFavoritesService (BOOL registerService);

View File

@ -167,9 +167,9 @@ class TrueCryptFormatCom : public ITrueCryptFormatCom
return BaseCom::GetEfiBootDeviceNumber (pSdn); return BaseCom::GetEfiBootDeviceNumber (pSdn);
} }
virtual DWORD STDMETHODCALLTYPE ReadEfiConfig (BSTR* pContent, DWORD *pcbRead) virtual DWORD STDMETHODCALLTYPE ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead)
{ {
return BaseCom::ReadEfiConfig (pContent, pcbRead); return BaseCom::ReadEfiConfig (filename, pContent, pcbRead);
} }
virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg)

View File

@ -46,7 +46,7 @@ library TrueCryptFormatCom
DWORD BackupEfiSystemLoader (); DWORD BackupEfiSystemLoader ();
DWORD RestoreEfiSystemLoader (); DWORD RestoreEfiSystemLoader ();
DWORD GetEfiBootDeviceNumber (BSTR* pSdn); DWORD GetEfiBootDeviceNumber (BSTR* pSdn);
DWORD ReadEfiConfig (BSTR* pContent, DWORD *pcbRead); DWORD ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead);
DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
}; };

View File

@ -188,9 +188,9 @@ class TrueCryptMainCom : public ITrueCryptMainCom
return BaseCom::GetEfiBootDeviceNumber (pSdn); return BaseCom::GetEfiBootDeviceNumber (pSdn);
} }
virtual DWORD STDMETHODCALLTYPE ReadEfiConfig (BSTR* pContent, DWORD *pcbRead) virtual DWORD STDMETHODCALLTYPE ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead)
{ {
return BaseCom::ReadEfiConfig (pContent, pcbRead); return BaseCom::ReadEfiConfig (filename, pContent, pcbRead);
} }
virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg)

View File

@ -50,7 +50,7 @@ library TrueCryptMainCom
DWORD BackupEfiSystemLoader (); DWORD BackupEfiSystemLoader ();
DWORD RestoreEfiSystemLoader (); DWORD RestoreEfiSystemLoader ();
DWORD GetEfiBootDeviceNumber (BSTR* pSdn); DWORD GetEfiBootDeviceNumber (BSTR* pSdn);
DWORD ReadEfiConfig (BSTR* pContent, DWORD *pcbRead); DWORD ReadEfiConfig (BSTR filename, BSTR* pContent, DWORD *pcbRead);
DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
}; };

View File

@ -10916,6 +10916,17 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA
return 1; return 1;
} }
byte platforminfo[10*1024];
platforminfo[0] = 0;
DWORD cbread;
try
{
BootEncObj->ReadEfiConfig(L"\\EFI\\VeraCrypt\\PlatformInfo", platforminfo, 10*1024 - 1, &cbread);
platforminfo[cbread - 1] = 0;
}
catch (Exception &e) { }
SetDlgItemTextA (hwndDlg, IDC_PLATFORMINFO, (char*)platforminfo);
try try
{ {
LocalizeDialog (hwndDlg, "IDD_SYSENC_SETTINGS"); LocalizeDialog (hwndDlg, "IDD_SYSENC_SETTINGS");

View File

@ -285,15 +285,15 @@ BEGIN
LTEXT "",IDT_PKCS11_LIB_HELP,16,63,286,65 LTEXT "",IDT_PKCS11_LIB_HELP,16,63,286,65
END END
IDD_EFI_SYSENC_SETTINGS DIALOGEX 0, 0, 370, 139 IDD_EFI_SYSENC_SETTINGS DIALOGEX 0, 0, 370, 245
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "VeraCrypt - System Encryption Settings" CAPTION "VeraCrypt - System Encryption Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
CONTROL "&Cache pre-boot authentication password in driver memory (for mounting of non-system volumes)",IDC_BOOT_LOADER_CACHE_PASSWORD, CONTROL "&Cache pre-boot authentication password in driver memory (for mounting of non-system volumes)",IDC_BOOT_LOADER_CACHE_PASSWORD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,79,339,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,79,339,10
DEFPUSHBUTTON "OK",IDOK,257,115,50,14 DEFPUSHBUTTON "OK",IDOK,267,225,50,14
PUSHBUTTON "Cancel",IDCANCEL,313,115,50,14 PUSHBUTTON "Cancel",IDCANCEL,318,225,50,14
GROUPBOX "Boot Loader Screen Options",IDT_BOOT_LOADER_SCREEN_OPTIONS,8,7,355,53 GROUPBOX "Boot Loader Screen Options",IDT_BOOT_LOADER_SCREEN_OPTIONS,8,7,355,53
GROUPBOX "Security Options",IDT_SECURITY_OPTIONS,8,64,355,44 GROUPBOX "Security Options",IDT_SECURITY_OPTIONS,8,64,355,44
CONTROL "Include PIM when caching pre-boot authentication password",IDC_BOOT_LOADER_CACHE_PIM, CONTROL "Include PIM when caching pre-boot authentication password",IDC_BOOT_LOADER_CACHE_PIM,
@ -302,6 +302,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,20,339,9 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,20,339,9
CONTROL "Do not request Hash algorithm in the pre-boot authentication screen",IDC_DISABLE_BOOT_LOADER_HASH_PROMPT, CONTROL "Do not request Hash algorithm in the pre-boot authentication screen",IDC_DISABLE_BOOT_LOADER_HASH_PROMPT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,35,339,9 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,35,339,9
EDITTEXT IDC_PLATFORMINFO,9,111,351,111,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_VSCROLL | WS_HSCROLL
END END
IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 370, 248 IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 370, 248
@ -483,7 +484,7 @@ BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 363 RIGHTMARGIN, 363
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 129 BOTTOMMARGIN, 235
END END
IDD_PERFORMANCE_SETTINGS, DIALOG IDD_PERFORMANCE_SETTINGS, DIALOG

View File

@ -184,6 +184,8 @@
#define IDC_HIDE_WAITING_DIALOG 1161 #define IDC_HIDE_WAITING_DIALOG 1161
#define IDC_DISABLE_BOOT_LOADER_HASH_PROMPT 1162 #define IDC_DISABLE_BOOT_LOADER_HASH_PROMPT 1162
#define IDC_SECURE_DESKTOP_PASSWORD_ENTRY 1163 #define IDC_SECURE_DESKTOP_PASSWORD_ENTRY 1163
#define IDB_PLATFORMINFO 1164
#define IDC_PLATFORMINFO 1165
#define IDM_HELP 40001 #define IDM_HELP 40001
#define IDM_ABOUT 40002 #define IDM_ABOUT 40002
#define IDM_UNMOUNT_VOLUME 40003 #define IDM_UNMOUNT_VOLUME 40003
@ -260,7 +262,7 @@
#define _APS_NO_MFC 1 #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 120 #define _APS_NEXT_RESOURCE_VALUE 120
#define _APS_NEXT_COMMAND_VALUE 40069 #define _APS_NEXT_COMMAND_VALUE 40069
#define _APS_NEXT_CONTROL_VALUE 1164 #define _APS_NEXT_CONTROL_VALUE 1166
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif