mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +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;
|
HANDLE DuplicatedHandle;
|
||||||
SIZE_T Dummy;
|
SIZE_T Dummy;
|
||||||
|
|
||||||
/* Duplicate the handle */
|
/* Is there a handle to duplicate? */
|
||||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
if (StandardHandle)
|
||||||
StandardHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
&DuplicatedHandle,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
/* Write it */
|
/* Duplicate it */
|
||||||
NtWriteVirtualMemory(ProcessHandle,
|
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||||
Address,
|
StandardHandle,
|
||||||
&DuplicatedHandle,
|
ProcessHandle,
|
||||||
sizeof(HANDLE),
|
&DuplicatedHandle,
|
||||||
&Dummy);
|
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 */
|
/* Duplicate standard input unless it's a console handle */
|
||||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardInput))
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardInput))
|
||||||
{
|
{
|
||||||
StuffStdHandle(&ProcessParameters->StandardInput,
|
StuffStdHandle(ProcessHandle,
|
||||||
ProcessHandle,
|
Peb->ProcessParameters->StandardInput,
|
||||||
Peb->ProcessParameters->StandardInput);
|
&ProcessParameters->StandardInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Duplicate standard output unless it's a console handle */
|
/* Duplicate standard output unless it's a console handle */
|
||||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardOutput))
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardOutput))
|
||||||
{
|
{
|
||||||
StuffStdHandle(&ProcessParameters->StandardOutput,
|
StuffStdHandle(ProcessHandle,
|
||||||
ProcessHandle,
|
Peb->ProcessParameters->StandardOutput,
|
||||||
Peb->ProcessParameters->StandardOutput);
|
&ProcessParameters->StandardOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Duplicate standard error unless it's a console handle */
|
/* Duplicate standard error unless it's a console handle */
|
||||||
if (!IsConsoleHandle(Peb->ProcessParameters->StandardError))
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardError))
|
||||||
{
|
{
|
||||||
StuffStdHandle(&ProcessParameters->StandardError,
|
StuffStdHandle(ProcessHandle,
|
||||||
ProcessHandle,
|
Peb->ProcessParameters->StandardError,
|
||||||
Peb->ProcessParameters->StandardError);
|
&ProcessParameters->StandardError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue