Skip to content

Commit

Permalink
1.26 - fixes -s option on non-English systems
Browse files Browse the repository at this point in the history
Using the well-known SID for Local System instead of the name to find
the system session.
poweradminllc committed Feb 25, 2015
1 parent 722d18b commit 80ea3b2
Showing 2 changed files with 17 additions and 26 deletions.
10 changes: 5 additions & 5 deletions PAExec.rc
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,25,0,0
PRODUCTVERSION 1,25,0,0
FILEVERSION 1,26,0,0
PRODUCTVERSION 1,26,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Power Admin LLC"
VALUE "FileDescription", "PAExec Application"
VALUE "FileVersion", "1.25.0.0"
VALUE "FileVersion", "1.26.0.0"
VALUE "InternalName", "PAExec"
VALUE "LegalCopyright", "Copyright (c) 2012-2014 Power Admin LLC"
VALUE "LegalCopyright", "Copyright (c) 2012-2015 Power Admin LLC"
VALUE "OriginalFilename", "PAExec.exe"
VALUE "ProductName", "PAExec Application"
VALUE "ProductVersion", "1.25.0.0"
VALUE "ProductVersion", "1.26.0.0"
END
END
BLOCK "VarFileInfo"
33 changes: 12 additions & 21 deletions Process.cpp
Original file line number Diff line number Diff line change
@@ -449,7 +449,7 @@ bool StartProcess(Settings& settings, HANDLE hCmdPipe)



CString GetTokenUser(HANDLE hToken)
CString GetTokenUserSID(HANDLE hToken)
{
DWORD tmp = 0;
CString userName;
@@ -469,23 +469,11 @@ CString GetTokenUser(HANDLE hToken)

if(GetTokenInformation(hToken, TokenUser, userToken, userTokenSize, &tmp))
{
SID_NAME_USE snUse;
if( LookupAccountSidW(NULL, userToken->User.Sid,
&sidName.front(), &--sidNameSize, &sidDomain.front(),
&--sidDomainSize, &snUse ))
{
userName = &sidDomain.front();
userName += L"\\";
userName += &sidName.front();
}
else
{
WCHAR *pSidString = NULL;
if(ConvertSidToStringSid(userToken->User.Sid, &pSidString))
userName = pSidString;
if(NULL != pSidString)
LocalFree(pSidString);
}
WCHAR *pSidString = NULL;
if(ConvertSidToStringSid(userToken->User.Sid, &pSidString))
userName = pSidString;
if(NULL != pSidString)
LocalFree(pSidString);
}
else
_ASSERT(0);
@@ -517,9 +505,12 @@ HANDLE GetLocalSystemProcessToken()
{
try
{
CString name = GetTokenUser(hToken);
const wchar_t arg[] = L"NT AUTHORITY\\";
if(0 == _wcsnicmp(name, arg, sizeof(arg)/sizeof(arg[0])-1))
CString name = GetTokenUserSID(hToken);

//const wchar_t arg[] = L"NT AUTHORITY\\";
//if(0 == _wcsnicmp(name, arg, sizeof(arg)/sizeof(arg[0])-1))

if(name == L"S-1-5-18") //Well known SID for Local System
{
CloseHandle(hProcess);
return hToken;

0 comments on commit 80ea3b2

Please sign in to comment.