You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.1 KiB
C++
68 lines
1.1 KiB
C++
#include "hlapi.h"
|
|
|
|
WinProcessList::iterator WinProcessList::begin()
|
|
{
|
|
return iterator(this);
|
|
}
|
|
|
|
WinProcessList::iterator WinProcessList::end()
|
|
{
|
|
return iterator(this, plist.size);
|
|
}
|
|
|
|
void WinProcessList::Refresh()
|
|
{
|
|
FreeProcessList();
|
|
plist = GenerateProcessList(ctx);
|
|
delete[] list;
|
|
list = new WinProcess[plist.size];
|
|
for (size_t i = 0; i < plist.size; i++)
|
|
list[i] = WinProcess(plist.list[i], ctx);
|
|
}
|
|
|
|
WinProcess* WinProcessList::FindProc(const char* name)
|
|
{
|
|
if (!plist.list)
|
|
Refresh();
|
|
|
|
for (auto& i : *this)
|
|
if (!strcmp(name, i.proc.name))
|
|
return &i;
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
WinProcessList::WinProcessList()
|
|
{
|
|
plist.list = nullptr;
|
|
plist.size = 0;
|
|
list = nullptr;
|
|
ctx = nullptr;
|
|
}
|
|
|
|
WinProcessList::WinProcessList(const WinCtx* pctx)
|
|
: WinProcessList()
|
|
{
|
|
ctx = pctx;
|
|
Refresh();
|
|
}
|
|
|
|
WinProcessList::WinProcessList(WinProcessList&& rhs)
|
|
{
|
|
ctx = rhs.ctx;
|
|
std::swap(plist, rhs.plist);
|
|
std::swap(list, rhs.list);
|
|
}
|
|
|
|
WinProcessList::~WinProcessList()
|
|
{
|
|
FreeProcessList();
|
|
delete[] list;
|
|
}
|
|
|
|
void WinProcessList::FreeProcessList()
|
|
{
|
|
::FreeProcessList(plist);
|
|
plist.list = nullptr;
|
|
}
|