@@ -93,12 +93,6 @@ bool InitializeAsSystem(bela::error_code &ec) {
9393
9494// bela::EqualsIgnoreCase
9595[[maybe_unused]] constexpr std::wstring_view LsassName = L" lsass.exe" ;
96- [[maybe_unused]] constexpr std::wstring_view WinLogonName = L" winlogon.exe" ;
97-
98- inline auto IsSystemProcessName (std::wstring_view name) {
99- return bela::EqualsIgnoreCase (name, LsassName) || bela::EqualsIgnoreCase (name, WinLogonName);
100- }
101-
10296constexpr DWORD INVALID_PROCESS_ID = 0xFFFFFFFF ;
10397DWORD LookupSystemProcess () {
10498 PWTS_PROCESS_INFOW pi{nullptr };
@@ -113,7 +107,7 @@ DWORD LookupSystemProcess() {
113107 });
114108 auto end = pi + count;
115109 for (auto it = pi; it != end; it++) {
116- if (it->SessionId == 0 && IsSystemProcessName ( it->pProcessName ) &&
110+ if (it->SessionId == 0 && bela::EqualsIgnoreCase (LsassName, it->pProcessName ) &&
117111 IsWellKnownSid (it->pUserSid , WinLocalSystemSid) == TRUE ) {
118112 return it->ProcessId ;
119113 }
@@ -218,14 +212,12 @@ bool Elavator::impersonation_system_token(bela::error_code &ec) {
218212 HANDLE hExistingToken = INVALID_HANDLE_VALUE;
219213 auto hProcess = ::OpenProcess (MAXIMUM_ALLOWED, FALSE , systemProcessId);
220214 if (hProcess == INVALID_HANDLE_VALUE) {
221- ec = bela::make_system_error_code (
222- bela::StringCat (L" Elavator::impersonation_system_token<OpenProcess> " , systemProcessId, L" " ));
215+ ec = bela::make_system_error_code (L" Elavator::impersonation_system_token<OpenProcess> " );
223216 return false ;
224217 }
225218 auto hpdeleter = bela::finally ([&] { CloseHandle (hProcess); });
226219 if (OpenProcessToken (hProcess, MAXIMUM_ALLOWED, &hExistingToken) != TRUE ) {
227- ec = bela::make_system_error_code (
228- bela::StringCat (L" Elavator::impersonation_system_token<OpenProcessToken> " , systemProcessId, L" " ));
220+ ec = bela::make_system_error_code (L" Elavator::impersonation_system_token<OpenProcessToken> " );
229221 return false ;
230222 }
231223 auto htdeleter = bela::finally ([&] { CloseHandle (hExistingToken); });
0 commit comments