255 lines
5.9 KiB
C++
255 lines
5.9 KiB
C++
#ifndef _COMMON_PROCESSENTRY_HPP_
|
|
#define _COMMON_PROCESSENTRY_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_TOOLHELP32_HPP_
|
|
#include <common/tlhelp32.hpp>
|
|
#endif
|
|
|
|
class ProcessEntry : private PROCESSENTRY32
|
|
{
|
|
public:
|
|
ProcessEntry(void);
|
|
ProcessEntry(const ProcessEntry &processEntry);
|
|
ProcessEntry(const PROCESSENTRY32 &processEntry32);
|
|
virtual ~ProcessEntry();
|
|
ProcessEntry &operator=(const ProcessEntry &processEntry);
|
|
ProcessEntry &operator=(const PROCESSENTRY32 &processEntry32);
|
|
BOOL operator==(const ProcessEntry &processEntry)const;
|
|
BOOL operator==(const PROCESSENTRY32 &processEntry32)const;
|
|
DWORD referenceCount(void)const;
|
|
DWORD processID(void)const;
|
|
DWORD heapID(void)const;
|
|
DWORD moduleID(void)const;
|
|
DWORD threads(void)const;
|
|
DWORD parentProcessID(void)const;
|
|
LONG priorityClassBase(void)const;
|
|
DWORD flags(void)const;
|
|
String strExeFile(void)const;
|
|
PROCESSENTRY32 &getProcessEntry(void);
|
|
private:
|
|
void referenceCount(DWORD referenceCount);
|
|
void processID(DWORD processID);
|
|
void heapID(DWORD heapID);
|
|
void moduleID(DWORD moduleID);
|
|
void threads(DWORD threads);
|
|
void parentProcessID(DWORD parentProcessID);
|
|
void priorityClassBase(LONG priorityClassBase);
|
|
void flags(DWORD flags);
|
|
void strExeFile(const String &strExeFile);
|
|
void setZero(void);
|
|
};
|
|
|
|
inline
|
|
ProcessEntry::ProcessEntry(void)
|
|
{
|
|
setZero();
|
|
}
|
|
|
|
inline
|
|
ProcessEntry::ProcessEntry(const ProcessEntry &processEntry)
|
|
{
|
|
*this=processEntry;
|
|
}
|
|
|
|
inline
|
|
ProcessEntry::ProcessEntry(const PROCESSENTRY32 &processEntry32)
|
|
{
|
|
*this=processEntry32;
|
|
}
|
|
|
|
inline
|
|
ProcessEntry::~ProcessEntry()
|
|
{
|
|
}
|
|
|
|
inline
|
|
ProcessEntry &ProcessEntry::operator=(const ProcessEntry &processEntry)
|
|
{
|
|
referenceCount(processEntry.referenceCount());
|
|
processID(processEntry.processID());
|
|
heapID(processEntry.heapID());
|
|
moduleID(processEntry.moduleID());
|
|
threads(processEntry.threads());
|
|
parentProcessID(processEntry.parentProcessID());
|
|
priorityClassBase(processEntry.priorityClassBase());
|
|
flags(processEntry.flags());
|
|
strExeFile(processEntry.strExeFile());
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
ProcessEntry &ProcessEntry::operator=(const PROCESSENTRY32 &processEntry32)
|
|
{
|
|
referenceCount(processEntry32.cntUsage);
|
|
processID(processEntry32.th32ProcessID);
|
|
heapID(processEntry32.th32DefaultHeapID);
|
|
moduleID(processEntry32.th32ModuleID);
|
|
threads(processEntry32.cntThreads);
|
|
parentProcessID(processEntry32.th32ParentProcessID);
|
|
priorityClassBase(processEntry32.pcPriClassBase);
|
|
flags(processEntry32.dwFlags);
|
|
strExeFile(processEntry32.szExeFile);
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
BOOL ProcessEntry::operator==(const ProcessEntry &processEntry)const
|
|
{
|
|
return (referenceCount()==processEntry.referenceCount()&&
|
|
processID()==processEntry.processID()&&
|
|
heapID()==processEntry.heapID()&&
|
|
moduleID()==processEntry.moduleID()&&
|
|
threads()==processEntry.threads()&&
|
|
parentProcessID()==processEntry.parentProcessID()&&
|
|
priorityClassBase()==processEntry.priorityClassBase()&&
|
|
flags()==processEntry.flags()&&
|
|
strExeFile()==processEntry.strExeFile());
|
|
}
|
|
|
|
inline
|
|
BOOL ProcessEntry::operator==(const PROCESSENTRY32 &processEntry32)const
|
|
{
|
|
return (referenceCount()==processEntry32.cntUsage&&
|
|
processID()==processEntry32.th32ProcessID&&
|
|
heapID()==processEntry32.th32DefaultHeapID&&
|
|
moduleID()==processEntry32.th32ModuleID&&
|
|
threads()==processEntry32.cntThreads&&
|
|
parentProcessID()==processEntry32.th32ParentProcessID&&
|
|
priorityClassBase()==processEntry32.pcPriClassBase&&
|
|
flags()==processEntry32.dwFlags&&
|
|
strExeFile()==processEntry32.szExeFile);
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::referenceCount(void)const
|
|
{
|
|
return PROCESSENTRY32::cntUsage;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::referenceCount(DWORD referenceCount)
|
|
{
|
|
PROCESSENTRY32::cntUsage=referenceCount;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::processID(void)const
|
|
{
|
|
return PROCESSENTRY32::th32ProcessID;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::processID(DWORD processID)
|
|
{
|
|
PROCESSENTRY32::th32ProcessID=processID;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::heapID(void)const
|
|
{
|
|
return PROCESSENTRY32::th32DefaultHeapID;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::heapID(DWORD heapID)
|
|
{
|
|
PROCESSENTRY32::th32DefaultHeapID=heapID;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::moduleID(void)const
|
|
{
|
|
return PROCESSENTRY32::th32ModuleID;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::moduleID(DWORD moduleID)
|
|
{
|
|
PROCESSENTRY32::th32ModuleID=moduleID;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::threads(void)const
|
|
{
|
|
return PROCESSENTRY32::cntThreads;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::threads(DWORD threads)
|
|
{
|
|
PROCESSENTRY32::cntThreads=threads;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::parentProcessID(void)const
|
|
{
|
|
return PROCESSENTRY32::th32ParentProcessID;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::parentProcessID(DWORD parentProcessID)
|
|
{
|
|
PROCESSENTRY32::th32ParentProcessID=parentProcessID;
|
|
}
|
|
|
|
inline
|
|
LONG ProcessEntry::priorityClassBase(void)const
|
|
{
|
|
return PROCESSENTRY32::pcPriClassBase;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::priorityClassBase(LONG priorityClassBase)
|
|
{
|
|
PROCESSENTRY32::pcPriClassBase=priorityClassBase;
|
|
}
|
|
|
|
inline
|
|
DWORD ProcessEntry::flags(void)const
|
|
{
|
|
return PROCESSENTRY32::dwFlags;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::flags(DWORD flags)
|
|
{
|
|
PROCESSENTRY32::dwFlags=flags;
|
|
}
|
|
|
|
inline
|
|
String ProcessEntry::strExeFile(void)const
|
|
{
|
|
return PROCESSENTRY32::szExeFile;
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::strExeFile(const String &strExeFile)
|
|
{
|
|
if(strExeFile.length()>=sizeof(PROCESSENTRY32::szExeFile))return;
|
|
::strcpy(PROCESSENTRY32::szExeFile,(char*)(String&)strExeFile);
|
|
}
|
|
|
|
inline
|
|
void ProcessEntry::setZero(void)
|
|
{
|
|
PROCESSENTRY32::dwSize=sizeof(PROCESSENTRY32);
|
|
PROCESSENTRY32::cntUsage=0;
|
|
PROCESSENTRY32::th32ProcessID=0;
|
|
PROCESSENTRY32::th32DefaultHeapID=0;
|
|
PROCESSENTRY32::th32ModuleID=0;
|
|
PROCESSENTRY32::cntThreads=0;
|
|
PROCESSENTRY32::th32ParentProcessID=0;
|
|
PROCESSENTRY32::pcPriClassBase=0;
|
|
PROCESSENTRY32::dwFlags=0;
|
|
PROCESSENTRY32::szExeFile[0]=0;
|
|
}
|
|
|
|
inline
|
|
PROCESSENTRY32 &ProcessEntry::getProcessEntry(void)
|
|
{
|
|
return (PROCESSENTRY32&)*this;
|
|
}
|
|
#endif
|