diff options
Diffstat (limited to 'src/Common/BaseCom.cpp')
-rw-r--r-- | src/Common/BaseCom.cpp | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index e8c75a68..3eaaf809 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -45,12 +45,13 @@ HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) { BOOL r; + HRESULT hr; if (IsUacSupported ()) { while (true) { - r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK; + r = (hr = CreateElevatedComObject (hWnd, clsid, iid, tcServer)) == S_OK; if (r) break; else @@ -64,11 +65,16 @@ BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) } else { - r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK; + r = (hr = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer)) == S_OK; if (!r) Error ("UAC_INIT_ERROR", hWnd); } + if (!r) + { + SetLastError((DWORD) hr); + } + return r; } @@ -130,7 +136,7 @@ DWORD BaseCom::ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *buff { try { - auto_ptr <File> file (device ? new Device (filePath, !write) : new File (filePath, !write)); + unique_ptr <File> file (device ? new Device (filePath, !write) : new File (filePath, !write)); file->CheckOpened (SRC_POS); file->SeekAt (offset); @@ -194,7 +200,7 @@ DWORD BaseCom::DeviceIoControl (BOOL readOnly, BOOL device, BSTR filePath, DWORD { try { - auto_ptr <File> file (device ? new Device (filePath, readOnly == TRUE) : new File (filePath, readOnly == TRUE)); + unique_ptr <File> file (device ? new Device (filePath, readOnly == TRUE) : new File (filePath, readOnly == TRUE)); file->CheckOpened (SRC_POS); if (!file->IoCtl (dwIoControlCode, (BYTE *) input, !(BYTE *) input ? 0 : ((DWORD *) ((BYTE *) input))[-1], (BYTE *) *output, !(BYTE *) *output ? 0 : ((DWORD *) ((BYTE *) *output))[-1])) @@ -336,6 +342,10 @@ DWORD BaseCom::BackupEfiSystemLoader () { return GetLastError(); } + catch (UserAbort&) + { + return ERROR_CANCELLED; + } catch (Exception &e) { e.Show (NULL); @@ -400,6 +410,33 @@ DWORD BaseCom::GetEfiBootDeviceNumber (BSTR* pSdn) return ERROR_SUCCESS; } +DWORD BaseCom::GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) +{ + if (!pSecureBootEnabled || !pVeraCryptKeysLoaded) + return ERROR_INVALID_PARAMETER; + + try + { + BootEncryption bootEnc (NULL); + bootEnc.GetSecureBootConfig (pSecureBootEnabled, pVeraCryptKeysLoaded); + } + catch (SystemException &) + { + return GetLastError(); + } + catch (Exception &e) + { + e.Show (NULL); + return ERROR_EXCEPTION_IN_SERVICE; + } + catch (...) + { + return ERROR_EXCEPTION_IN_SERVICE; + } + + return ERROR_SUCCESS; +} + DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) { if (!customUserMessage) @@ -430,4 +467,38 @@ DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMe } return ERROR_SUCCESS; -}
\ No newline at end of file +} + +DWORD BaseCom::UpdateSetupConfigFile (BOOL bForInstall) +{ + try + { + BootEncryption bootEnc (NULL); + bootEnc.UpdateSetupConfigFile (bForInstall? true : false); + } + catch (SystemException &) + { + return GetLastError(); + } + catch (Exception &e) + { + e.Show (NULL); + return ERROR_EXCEPTION_IN_SERVICE; + } + catch (...) + { + return ERROR_EXCEPTION_IN_SERVICE; + } + + return ERROR_SUCCESS; +} + +DWORD BaseCom::NotifyService(DWORD dwNotifyCode) +{ + return SendServiceNotification(dwNotifyCode); +} + +DWORD BaseCom::FastFileResize (BSTR filePath, __int64 fileSize) +{ + return ::FastResizeFile (filePath, fileSize); +} |