Click here to Skip to main content
12,759,875 members (31,824 online)
Click here to Skip to main content

Stats

77K views
1.9K downloads
171 bookmarked
Posted 12 Aug 2008

ProSysLib: Dissecting the Process

, 22 Nov 2010 CPOL
Access detailed information about the current process the easiest way.
ProcessInfo.exe
ProSysLib.dll
Interop.ProSysLib.dll
Interop.ProSysLib.dll
ProcessInfo.exe
ProSysLib.dll
PSL64v0.9.dll
Interop.ProSysLib.dll
ProcessInfo.exe
PSL32v0.9.dll
ProSysLib_v0.9
Bin
PSL32v0.9.dll
PSL64v0.9.dll
Help
Samples
C#2008
ProcessInfo
Properties
ProcessViewer
Properties
VB6
CPUInfo.exe
CPUInfo.frm
CPUInfo.frx
CPUInfo.vbp
CPUInfo.vbw
VC2008
Deployment
Src
mssccprj.scc
ProSysLib.def
ProSysLib.rgs
ProSysLib.vcproj.vspscc
ProSysLib.vssscc
PSLSystem.rgs
PSLv0.5Setup.exe
PSLv0.7Setup.exe
// PSLSecurity.cpp : Implementation of CPSLSecurity

#include "stdafx.h"
#include "PSLSecurity.h"
#include <Aclapi.h>

CPSLSecurity::CPSLSecurity()
{
}

HRESULT CPSLSecurity::FinalConstruct()
{
	return S_OK;
}

void CPSLSecurity::FinalRelease()
{
}

////////////////////////////////////////////////////////////////////////
// Interface Implementation;
////////////////////////////////////////////////////////////////////////

STDMETHODIMP CPSLSecurity::get_User(IPSLUser ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_User;
	
	PSL_END
}

STDMETHODIMP CPSLSecurity::get_Accounts(IPSLAccounts ** ppValue)
{
	PSL_BEGIN

	SetException(exNotImplemented);
	//*ppValue = m_Accounts;
	
	PSL_END
}

STDMETHODIMP CPSLSecurity::get_Privileges(IPSLPrivileges ** ppValue)
{
	PSL_BEGIN

	*ppValue = m_Privileges;
	
	PSL_END
}

STDMETHODIMP CPSLSecurity::GetNamedObjectAccess(PSLNamedType nt, BSTR sObjectName, long * pErrorCode, long * pValue)
{
	PSL_BEGIN

	*pValue = 0; // Mask Value;

	PACL pDacl;
	_bstr_t sObject = sObjectName;
	DWORD dwError = ::GetNamedSecurityInfo((LPTSTR)sObject, (SE_OBJECT_TYPE)nt, DACL_SECURITY_INFORMATION, NULL, NULL, &pDacl, NULL, NULL);
	if(dwError == ERROR_SUCCESS)
	{
		HANDLE hToken = NULL;
		if(::OpenProcessToken(::GetCurrentProcess(), TOKEN_READ, &hToken))
		{
			DWORD dwLength = 0;
			::GetTokenInformation(hToken, TokenUser, NULL, 0, &dwLength);
			LPBYTE pBuffer = new BYTE[dwLength];
			if(::GetTokenInformation(hToken, TokenUser, pBuffer, dwLength, &dwLength))
			{
				TOKEN_USER * pUser = (TOKEN_USER*)(LPVOID)pBuffer;
				TRUSTEE trustee;
				::BuildTrusteeWithSid(&trustee, pUser->User.Sid);
				ACCESS_MASK mask;
				dwError = ::GetEffectiveRightsFromAcl(pDacl, &trustee, &mask);
				if(dwError == ERROR_SUCCESS)
					*pValue = mask;
			}
			else
				dwError = ::GetLastError();

			delete []pBuffer;
			::CloseHandle(hToken);
		}
		else
			dwError = ::GetLastError();
	}

	if(pErrorCode)
		*pErrorCode = dwError;

	PSL_END
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Vitaly Tomilov
Software Developer (Senior) Sibedge IT
Ireland Ireland
My online CV: cv.vitalytomilov.com

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 22 Nov 2010
Article Copyright 2008 by Vitaly Tomilov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid