- c un peu long pour metre ici tout le code je met que le début pour donner une idée
- void main()
- {
-
- PWSTR PathBuf;
- char BinPath[MAX_PATH];
- int i;
-
- if(!LoadPrivilege(SE_DEBUG_NAME))
- return;
-
-
-
- if(OpenPort())
- {
- printf("Pid Port Proto Path\n\n");
-
- for(i=0; i < 65534; i++)
- {
- //disable idle process
- if(ResultPorts[0][i].pid != 0)
- {
- PathBuf=GetProcessPathByPID(ResultPorts[0][i].pid);
- memset(BinPath,0,MAX_PATH);
- wcstombs(BinPath,PathBuf,MAX_PATH);
- LocalFree(PathBuf);
- printf("%-6d %-6d Tcp %s\n",ResultPorts[0][i].pid,i,BinPath);
- }
- }
-
- for(i=0; i < 65534; i++)
- {
- if(ResultPorts[1][i].pid != 0)
- {
- PathBuf=GetProcessPathByPID(ResultPorts[1][i].pid);
- memset(BinPath,0,MAX_PATH);
- wcstombs(BinPath,PathBuf,MAX_PATH);
- LocalFree(PathBuf);
- printf("%-6d %-6d Udp %s\n",ResultPorts[1][i].pid,i,BinPath);
- }
- }
- }
-
- return;
- }
c un peu long pour metre ici tout le code je met que le début pour donner une idée
void main()
{
PWSTR PathBuf;
char BinPath[MAX_PATH];
int i;
if(!LoadPrivilege(SE_DEBUG_NAME))
return;
if(OpenPort())
{
printf("Pid Port Proto Path\n\n");
for(i=0; i < 65534; i++)
{
//disable idle process
if(ResultPorts[0][i].pid != 0)
{
PathBuf=GetProcessPathByPID(ResultPorts[0][i].pid);
memset(BinPath,0,MAX_PATH);
wcstombs(BinPath,PathBuf,MAX_PATH);
LocalFree(PathBuf);
printf("%-6d %-6d Tcp %s\n",ResultPorts[0][i].pid,i,BinPath);
}
}
for(i=0; i < 65534; i++)
{
if(ResultPorts[1][i].pid != 0)
{
PathBuf=GetProcessPathByPID(ResultPorts[1][i].pid);
memset(BinPath,0,MAX_PATH);
wcstombs(BinPath,PathBuf,MAX_PATH);
LocalFree(PathBuf);
printf("%-6d %-6d Udp %s\n",ResultPorts[1][i].pid,i,BinPath);
}
}
}
return;
}