i have searched on so many websites after "how i get the conhost process"
, and nothing is really what i'm looking for.
i have searched on.
superuser/stackoverflow
when-is-conhost-exe-actually-necessarystackoverflow
how-can-a-win32-process-get-the-pid-of-its-parentstackoverflow
c-how-to-fetch-parent-process-idstackoverflow
c-how-to-determine-if-a-windows-process-is-runningstackoverflow
get-full-running-process-list-visual-cstackoverflow
ms-c-get-pid-of-current-processstackoverflow
get-list-of-dlls-loaded-in-current-process-with-their-reference-countscodeproject
Get-Parent-Process-PIDcplusplus
Getting list of running processesmsdn.microsoft
GetModuleFileNameExmsdn.microsoft
GetModuleFileNamemsdn.microsoft
GetCurrentProcessIdmsdn.microsoft
GetProcessIdmsdn.microsoft
GetModuleHandlemsdn.microsoft
GetConsoleWindowmsdn.microsoft
Tool Helpmsdn.microsoft
CreateToolhelp32Snapshotmsdn.microsoft
NextModule32msdn.microsoft
DebugActiveProcessmsdn.microsoft
Enumerating All Modules For a Process
and i can't find anything about "how to get the conhost process"
.
i have some code that works for the current "cmd.exe / program.exe"
and that gives me the "PID, NAME, PATH, READ/WRITE ADDRESS"
.
i can get the parent
process but that is not conhost.exe
.
code "need to link library 'psapi' first"
:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <psapi.h>
#include <iostream>
#include <tlhelp32.h>
int PrintModules(DWORD processID) {
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
unsigned int i;
printf( "\nProcess ID: %u\n", processID);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
if(NULL == hProcess) return 1;
if(EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
for(i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
TCHAR szModName[MAX_PATH];
if(GetModuleFileNameEx(hProcess, hMods[i], szModName,sizeof(szModName) / sizeof(TCHAR))) {
_tprintf( TEXT(" %s (0x%08X)\n"), szModName, hMods[i]);
}
}
}
CloseHandle(hProcess);
return 0;
}
int main(void) {
DWORD cpid = GetCurrentProcessId();
PrintModules(cpid);
int ppid = -1;
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = { 0 };
pe.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(h, &pe)) {
do {
if(pe.th32ProcessID == cpid) {
printf("PID: %i; PPID: %i\n", cpid, pe.th32ParentProcessID);
ppid = pe.th32ParentProcessID;
}
} while(Process32Next(h, &pe));
}
PrintModules(ppid);
CloseHandle(h);
std::cin.get();
return 0;
}
and i can't figure out a way to get the current conhost
process.
when you open a program
that uses the console, a conhost.exe
process is created.
and my question is how do i get that conhost.exe
process...
Thanks! :)