-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess ID Nabok.cpp
More file actions
34 lines (31 loc) · 1.05 KB
/
Process ID Nabok.cpp
File metadata and controls
34 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <functional>
#include <iostream>
#include <windows.h>
#include <psapi.h>
using PIDVector=vector<DWORD>;
using HMODULEVector=vector<HMODULE>;
template<typename T> bool autoFill(T& vec,std::function<WINBOOL(typename T::value_type*, DWORD, DWORD*)> filler)
{
//вычисляем размер одного элемента массива
constexpr auto itmSize=sizeof(typename T::value_type);
while(true)
{
DWORD cnt;
const auto status=filler(vec.data(), vec.size()*itmSize, &cnt);
if(!status)
{
//в случае ошибки, выходим
return false;
}
//нам приходит размер данных в байтах, а нужно - в штуках
const auto nItems=cnt/itmSize;
if(nItems>=vec.size())
{
//если буфер мал - увеличить
vec.resize( nItems + 1024);
}
else
{
vec.resize( nItems );
return true;
}