I am looking to return an array of all current running process ID's from a function using C++.
I am enumerating the list with the following function:
DWORD* xEnumProcs(){
PROCESSENTRY32 pe32;
HANDLE snapshot = NULL;
DWORD pid[1024];
DWORD* pointer;
pointer = pid;
int I = 0;
snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot != INVALID_HANDLE_VALUE) {
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(snapshot, &pe32)) {
do {
pid[I] = pe32.th32ProcessID;
I++;
} while (Process32Next(snapshot, &pe32));
}
CloseHandle(snapshot);
}
return pointer;
}
I am unsure if this is done properly. I am trying to utilize this array inside of another function like so:
void HandleProcs(){
DWORD* xNewProcs = xEnumProcs;
}
And this is the error I am receiving on the one line in the body of the last function:
'initializing' : cannot convert from 'DWORD *(__cdecl *)(void)' to 'DWORD *'
1> There is no context in which this conversion is possible