krnl386: Invalid console handles should translate into real handles when creating a new process.
This commit is contained in:
parent
3d9693fa61
commit
bc68b30d20
|
@ -53,21 +53,26 @@ static HANDLE dos_handles[DOS_TABLE_SIZE];
|
||||||
*/
|
*/
|
||||||
static void FILE_InitProcessDosHandles( void )
|
static void FILE_InitProcessDosHandles( void )
|
||||||
{
|
{
|
||||||
|
HANDLE hStdInput, hStdOutput, hStdError, hNull;
|
||||||
static BOOL init_done /* = FALSE */;
|
static BOOL init_done /* = FALSE */;
|
||||||
HANDLE cp = GetCurrentProcess();
|
HANDLE cp = GetCurrentProcess();
|
||||||
|
|
||||||
if (init_done) return;
|
if (init_done) return;
|
||||||
init_done = TRUE;
|
init_done = TRUE;
|
||||||
DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &dos_handles[0],
|
hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
DuplicateHandle(cp, GetStdHandle(STD_OUTPUT_HANDLE), cp, &dos_handles[1],
|
hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
hNull = CreateFileA("NUL", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||||
DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[2],
|
/* Invalid console handles need to translate to real DOS handles in a new process */
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
if (!hStdInput) hStdInput = hNull;
|
||||||
DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[3],
|
if (!hStdOutput) hStdOutput = hNull;
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
if (!hStdError) hStdError = hNull;
|
||||||
DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[4],
|
DuplicateHandle(cp, hStdInput, cp, &dos_handles[0], 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS);
|
DuplicateHandle(cp, hStdOutput, cp, &dos_handles[1], 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
|
DuplicateHandle(cp, hStdError, cp, &dos_handles[2], 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
|
DuplicateHandle(cp, hStdError, cp, &dos_handles[3], 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
|
DuplicateHandle(cp, hStdError, cp, &dos_handles[4], 0, TRUE, DUPLICATE_SAME_ACCESS);
|
||||||
|
CloseHandle(hNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
Loading…
Reference in New Issue