Author: ion
Date: Sun Aug 4 18:46:07 2013
New Revision: 59639
URL:
http://svn.reactos.org/svn/reactos?rev=59639&view=rev
Log:
[KERNEL32]: Fix a few bugs in StuffStdHandle. Ironically Windows Server 2003 actually has
a bug here when calling NtDuplicateObject...
Modified:
trunk/reactos/dll/win32/kernel32/client/proc.c
Modified: trunk/reactos/dll/win32/kernel32/client/proc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Sun Aug 4 18:46:07 2013
@@ -62,22 +62,27 @@
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))
- {
- /* Write it */
- NtWriteVirtualMemory(ProcessHandle,
- Address,
- &DuplicatedHandle,
- sizeof(HANDLE),
- &Dummy);
+ /* Is there a handle to duplicate? */
+ if (StandardHandle)
+ {
+ /* 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 @@
/* 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);
}
}
}