Click here to Skip to main content
15,881,588 members
Articles / Desktop Programming / MFC

Process viewer

Rate me:
Please Sign up or sign in to vote.
4.94/5 (104 votes)
9 Mar 2008CPOL9 min read 454.8K   22K   294  
Lists out the details of running processes in a system, loaded drivers, loaded dlls, version of each dll and process, process times, command line, owner, priority, GDI resource usage, privileges, loaded symbols, window heirarchy, autostart app finding and more.
#ifndef _PROCESS_PRIVILEGE_MGR_H_
#define _PROCESS_PRIVILEGE_MGR_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Privilege.h"
#include "TypedefsInclude.h"

typedef enum
{
    Ps_Success      = 0,
    Ps_Error        = 1,
    Ps_SomeFailed   = 2,
}PrivilegeStatus;

class CProcessPrivilegeMgr  
{
    public:
		// Constructor
        CProcessPrivilegeMgr();

		// Destructor
        virtual ~CProcessPrivilegeMgr();

		bool OpenKeepProcessToken( const HANDLE hProcess_i );
		HANDLE GetToken() const { return m_ahmProcessToken; }
    
        PTOKEN_PRIVILEGES LoadPrivileges();

        int EnableAllPrivileges( const bool Enable );
        int RemoveAllPrivileges();
        bool EnablePrivilege( LPCTSTR lpctszPrivilege_i, const bool Enable );

        bool IsPrivilegeEnabled( LPCTSTR lpctszPrivName_i ) const
        {
            const PrivilegeMap::CPair* pPair = GetPrivilegeMap().PLookup( lpctszPrivName_i );
            return pPair && pPair->value.GetPrivilegeEnabled();
        }

        const PrivilegeMap& GetPrivilegeMap() const
        {
            return m_ProcessPrivileges;
        }
        PrivilegeMap& GetPrivilegeMap()
        {
            return m_ProcessPrivileges;
        }

        void InitPrivilegeMap();

    protected:

		LPCTSTR* GetPrivilegeNameArray();

        // Returns true if privilege given is enabled
        bool IsPrivilegeEnabled( const DWORD dwAttributes_i ) const
        {
            return ( Utils::IsValidMask( dwAttributes_i, SE_PRIVILEGE_ENABLED ) ||
                     Utils::IsValidMask( dwAttributes_i, SE_PRIVILEGE_ENABLED_BY_DEFAULT ) ||
                     Utils::IsValidMask( dwAttributes_i, SE_PRIVILEGE_USED_FOR_ACCESS ));
        }

        void AddPrivilege( const CPrivilege& Privilege )
        {
            GetPrivilegeMap()[Privilege.GetPrivilegeName()] = Privilege;
        }
    
    private:

        PrivilegeMap m_ProcessPrivileges;
		Utils::AutoHandleMgr m_ahmProcessToken;
};// End CProcessPrivilegeMgr

#endif // _PROCESS_PRIVILEGE_MGR_H_

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)


Written By
Software Developer Microsoft
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions