Skip to content

Commit

Permalink
Revert "try fix when lsass not running"
Browse files Browse the repository at this point in the history
This reverts commit d7b3f38.
  • Loading branch information
fcharlie committed Apr 3, 2023
1 parent 1ba130e commit 4f7df36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ endif()
#
set(PRIVEXEC_VERSION_MAJOR 5)
set(PRIVEXEC_VERSION_MINOR 0)
set(PRIVEXEC_VERSION_PATCH 4)
set(PRIVEXEC_VERSION_PATCH 3)
set(PACKAGE_VERSION "${PRIVEXEC_VERSION_MAJOR}.${PRIVEXEC_VERSION_MINOR}.${PRIVEXEC_VERSION_PATCH}")

string(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" COMPILER_ARCH_ID)
Expand Down
14 changes: 3 additions & 11 deletions lib/exec/elevator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ bool InitializeAsSystem(bela::error_code &ec) {

// bela::EqualsIgnoreCase
[[maybe_unused]] constexpr std::wstring_view LsassName = L"lsass.exe";
[[maybe_unused]] constexpr std::wstring_view WinLogonName = L"winlogon.exe";

inline auto IsSystemProcessName(std::wstring_view name) {
return bela::EqualsIgnoreCase(name, LsassName) || bela::EqualsIgnoreCase(name, WinLogonName);
}

constexpr DWORD INVALID_PROCESS_ID = 0xFFFFFFFF;
DWORD LookupSystemProcess() {
PWTS_PROCESS_INFOW pi{nullptr};
Expand All @@ -113,7 +107,7 @@ DWORD LookupSystemProcess() {
});
auto end = pi + count;
for (auto it = pi; it != end; it++) {
if (it->SessionId == 0 && IsSystemProcessName(it->pProcessName) &&
if (it->SessionId == 0 && bela::EqualsIgnoreCase(LsassName, it->pProcessName) &&
IsWellKnownSid(it->pUserSid, WinLocalSystemSid) == TRUE) {
return it->ProcessId;
}
Expand Down Expand Up @@ -218,14 +212,12 @@ bool Elavator::impersonation_system_token(bela::error_code &ec) {
HANDLE hExistingToken = INVALID_HANDLE_VALUE;
auto hProcess = ::OpenProcess(MAXIMUM_ALLOWED, FALSE, systemProcessId);
if (hProcess == INVALID_HANDLE_VALUE) {
ec = bela::make_system_error_code(
bela::StringCat(L"Elavator::impersonation_system_token<OpenProcess> ", systemProcessId, L" "));
ec = bela::make_system_error_code(L"Elavator::impersonation_system_token<OpenProcess> ");
return false;
}
auto hpdeleter = bela::finally([&] { CloseHandle(hProcess); });
if (OpenProcessToken(hProcess, MAXIMUM_ALLOWED, &hExistingToken) != TRUE) {
ec = bela::make_system_error_code(
bela::StringCat(L"Elavator::impersonation_system_token<OpenProcessToken> ", systemProcessId, L" "));
ec = bela::make_system_error_code(L"Elavator::impersonation_system_token<OpenProcessToken> ");
return false;
}
auto htdeleter = bela::finally([&] { CloseHandle(hExistingToken); });
Expand Down

0 comments on commit 4f7df36

Please sign in to comment.