From b338e29fd3eaf700f8c8360aa0310048ba941d54 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:12:46 +0200 Subject: 3.19 --- shared/privilege.cpp | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'shared/privilege.cpp') diff --git a/shared/privilege.cpp b/shared/privilege.cpp index c854ad4e..eaeac866 100644 --- a/shared/privilege.cpp +++ b/shared/privilege.cpp @@ -19,10 +19,8 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_QUERY, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); + Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); (void)dummy; //silence warning "unused variable" @@ -32,10 +30,7 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) NULL, //__in_opt LPCTSTR lpSystemName, privilege, //__in LPCTSTR lpName, &luid )) //__out PLUID lpLuid - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); PRIVILEGE_SET priv = {}; priv.PrivilegeCount = 1; @@ -48,10 +43,7 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) hToken, //__in HANDLE ClientToken, &priv, //__inout PPRIVILEGE_SET RequiredPrivileges, &alreadyGranted)) //__out LPBOOL pfResult - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); return alreadyGranted == TRUE; } @@ -63,10 +55,8 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_ADJUST_PRIVILEGES, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); + Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); (void)dummy; //silence warning "unused variable" @@ -75,10 +65,7 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError NULL, //__in_opt LPCTSTR lpSystemName, privilege, //__in LPCTSTR lpName, &luid )) //__out PLUID lpLuid - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); TOKEN_PRIVILEGES tp = {}; tp.PrivilegeCount = 1; @@ -92,14 +79,8 @@ void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError 0, //__in DWORD BufferLength, NULL, //__out_opt PTOKEN_PRIVILEGES PreviousState, NULL)) //__out_opt PDWORD ReturnLength - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); if (::GetLastError() == ERROR_NOT_ALL_ASSIGNED) //check although previous function returned with success! - { - const wxString errorMessage = wxString(_("Error setting privilege:")) + wxT(" \"") + privilege + wxT("\""); - throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted()); - } + throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); } -- cgit