Click here to Skip to main content
15,896,557 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 457.9K   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 _API_MGR_H_
#define _API_MGR_H_

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

#include <afxtempl.h>
#include "TypedefsInclude.h"

class APIMgr  
{
    public:
	    APIMgr();
	    virtual ~APIMgr();

        // Loads and free's any modules
        HMODULE LoadModule( LPCTSTR lpctszModuleName_i );
        void FreeModules();

        // Return procedure address of a procedure
        FARPROC GetProcAddress( LPCSTR lpcszProcName_i, LPCTSTR lpctszModuleName_i );

        //************************************
        // Method:    FindProcPtrByName
        // FullName:  APIMgr::FindProcPtrByName
        // Access:    public 
        // Returns:   FARPROC
        // Qualifier:
        // Parameter: LPCTSTR lpctszProcName_i
        //************************************
        FARPROC FindProcPtrByName( LPCTSTR lpctszProcName_i )
        {
            // First search whether we have this function pointer with us
            FARPROC ProcAddr = 0;
            m_FuncPtrMap.Lookup( lpctszProcName_i, ProcAddr );

            return ProcAddr;
        }

        //************************************
        // Method:    FindModuleByName
        // FullName:  APIMgr::FindModuleByName
        // Access:    public 
        // Returns:   HMODULE
        // Qualifier:
        // Parameter: LPCTSTR lpctszModuleName_i
        //************************************
        HMODULE FindModuleByName( LPCTSTR lpctszModuleName_i )
        {
            // Get module pointer from map if there is any
            HMODULE hMod = 0;
            m_ModuleHandleMap.Lookup( lpctszModuleName_i, hMod );
            return hMod;
        }

    private:

        // Map variables
        typedef CMap<CString, LPCTSTR, HMODULE, HMODULE&> ModuleHandleMap;
        typedef CMap<CString, LPCTSTR, FARPROC, FARPROC&> ModuleProcMap;

        ModuleProcMap m_FuncPtrMap;
        ModuleHandleMap m_ModuleHandleMap;
};// End APIMgr

extern APIMgr g_APIMgr;

#endif // _API_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