mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[KERNEL32]: Fix a few bugs in StuffStdHandle. Ironically Windows Server 2003 actually has a bug here when calling NtDuplicateObject...
svn path=/trunk/; revision=59639
This commit is contained in:
parent
53d4f6c6a3
commit
110bbab440
1 changed files with 29 additions and 24 deletions
|
@ -62,22 +62,27 @@ StuffStdHandle(IN HANDLE ProcessHandle,
|
|||
HANDLE DuplicatedHandle;
|
||||
SIZE_T Dummy;
|
||||
|
||||
/* Duplicate the handle */
|
||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||
StandardHandle,
|
||||
ProcessHandle,
|
||||
&DuplicatedHandle,
|
||||
0,
|
||||
0,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
|
||||
if (NT_SUCCESS(Status))
|
||||
/* Is there a handle to duplicate? */
|
||||
if (StandardHandle)
|
||||
{
|
||||
/* Write it */
|
||||
NtWriteVirtualMemory(ProcessHandle,
|
||||
Address,
|
||||
&DuplicatedHandle,
|
||||
sizeof(HANDLE),
|
||||
&Dummy);
|
||||
/* Duplicate it */
|
||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||
StandardHandle,
|
||||
ProcessHandle,
|
||||
&DuplicatedHandle,
|
||||
0,
|
||||
0,
|
||||
DUPLICATE_SAME_ACCESS |
|
||||
DUPLICATE_SAME_ATTRIBUTES);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Write it */
|
||||
NtWriteVirtualMemory(ProcessHandle,
|
||||
Address,
|
||||
&DuplicatedHandle,
|
||||
sizeof(HANDLE),
|
||||
&Dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4139,25 +4144,25 @@ StartScan:
|
|||
/* Duplicate standard input unless it's a console handle */
|
||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardInput))
|
||||
{
|
||||
StuffStdHandle(&ProcessParameters->StandardInput,
|
||||
ProcessHandle,
|
||||
Peb->ProcessParameters->StandardInput);
|
||||
StuffStdHandle(ProcessHandle,
|
||||
Peb->ProcessParameters->StandardInput,
|
||||
&ProcessParameters->StandardInput);
|
||||
}
|
||||
|
||||
/* Duplicate standard output unless it's a console handle */
|
||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardOutput))
|
||||
{
|
||||
StuffStdHandle(&ProcessParameters->StandardOutput,
|
||||
ProcessHandle,
|
||||
Peb->ProcessParameters->StandardOutput);
|
||||
StuffStdHandle(ProcessHandle,
|
||||
Peb->ProcessParameters->StandardOutput,
|
||||
&ProcessParameters->StandardOutput);
|
||||
}
|
||||
|
||||
/* Duplicate standard error unless it's a console handle */
|
||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardError))
|
||||
{
|
||||
StuffStdHandle(&ProcessParameters->StandardError,
|
||||
ProcessHandle,
|
||||
Peb->ProcessParameters->StandardError);
|
||||
StuffStdHandle(ProcessHandle,
|
||||
Peb->ProcessParameters->StandardError,
|
||||
&ProcessParameters->StandardError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue