views:

47

answers:

1

What I would like is to have the process start but have the input and output all be in the same console.

if(CreateProcessWithLogonW(user,domain, pass, LOGON_WITH_PROFILE, NULL, cmd, 0, 0, 0, &sa, &pe))
{
 printf("[~] Process spawned with PID %X\n",  pe.dwProcessId);
}
else
{
 printf("[!] Failed to create process. Error Code: %X\n", GetLastError());
}

When I use this code it creates a whole new window instead of having it in the same window. Is there a way to unset the "CREATE_NEW_CONSOLE" flag because even when I set it to 0 it still creates a new console.

+1  A: 

According to help on this method:

The CREATE_DEFAULT_ERROR_MODE, CREATE_NEW_CONSOLE, and CREATE_NEW_PROCESS_GROUP flags are enabled by default— even if you do not set the flag, the system functions as if it were set.

It looks like Windows API doesn't allow these flags not to be set.

Ashalynd