Remove redundant checks in check_procs

This commit is contained in:
Gunnar Beutner 2015-03-02 13:22:37 +01:00
parent 8a062a688b
commit 3087be2567
1 changed files with 2 additions and 12 deletions

View File

@ -297,14 +297,8 @@ int countProcs(const wstring user)
pSIDTokenUser = reinterpret_cast<PTOKEN_USER>(new BYTE[dwReturnLength]); pSIDTokenUser = reinterpret_cast<PTOKEN_USER>(new BYTE[dwReturnLength]);
memset(pSIDTokenUser, 0, dwReturnLength); memset(pSIDTokenUser, 0, dwReturnLength);
if (!pSIDTokenUser) {
if (debug)
wcout << L"Could not recieve token, skiping" << endl;
continue;
}
if (debug) if (debug)
wcout << L"Recieved token, saving information" << endl; wcout << L"Received token, saving information" << endl;
//write Info in pSIDTokenUser //write Info in pSIDTokenUser
if (!GetTokenInformation(hToken, TokenUser, pSIDTokenUser, dwReturnLength, NULL)) if (!GetTokenInformation(hToken, TokenUser, pSIDTokenUser, dwReturnLength, NULL))
@ -327,9 +321,6 @@ int countProcs(const wstring user)
AcctName = reinterpret_cast<LPWSTR>(new WCHAR[dwAcctName]); AcctName = reinterpret_cast<LPWSTR>(new WCHAR[dwAcctName]);
DomainName = reinterpret_cast<LPWSTR>(new WCHAR[dwDomainName]); DomainName = reinterpret_cast<LPWSTR>(new WCHAR[dwDomainName]);
if (!AcctName || !DomainName)
continue;
if (!LookupAccountSid(NULL, pSIDTokenUser->User.Sid, AcctName, if (!LookupAccountSid(NULL, pSIDTokenUser->User.Sid, AcctName,
(LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &sidNameUse)) (LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &sidNameUse))
continue; continue;
@ -347,7 +338,6 @@ int countProcs(const wstring user)
} while (Process32Next(hProcessSnap, &pe32)); } while (Process32Next(hProcessSnap, &pe32));
die: die:
if (hProcessSnap) if (hProcessSnap)
CloseHandle(hProcessSnap); CloseHandle(hProcessSnap);