Don't use CSRSS handles if we alreay have some (so we can inherit file
handles, etc)
Modified: trunk/reactos/lib/kernel32/misc/dllmain.c
Modified: trunk/reactos/lib/kernel32/process/create.c
Modified: trunk/reactos/ntoskrnl/ke/kthread.c
_____
Modified: trunk/reactos/lib/kernel32/misc/dllmain.c
--- trunk/reactos/lib/kernel32/misc/dllmain.c 2005-07-30 23:43:45 UTC
(rev 16907)
+++ trunk/reactos/lib/kernel32/misc/dllmain.c 2005-07-30 23:57:14 UTC
(rev 16908)
@@ -167,18 +167,28 @@
/* We got the handles, let's set them */
Parameters->ConsoleHandle =
Request.Data.AllocConsoleRequest.Console;
- SetStdHandle(STD_INPUT_HANDLE,
Request.Data.AllocConsoleRequest.InputHandle);
- SetStdHandle(STD_OUTPUT_HANDLE,
Request.Data.AllocConsoleRequest.OutputHandle);
- SetStdHandle(STD_ERROR_HANDLE,
-
DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle,
- 0,
- TRUE,
- DUPLICATE_SAME_ACCESS));
+ /* If we already had some, don't use the new ones */
+ if (!Parameters->StandardInput)
+ {
+ Parameters->StandardInput =
Request.Data.AllocConsoleRequest.InputHandle;
+ }
+ if (!Parameters->StandardOutput)
+ {
+ Parameters->StandardOutput =
Request.Data.AllocConsoleRequest.OutputHandle;
+ }
+ if (!Parameters->StandardError)
+ {
+ Parameters->StandardError =
DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle,
+ 0,
+ TRUE,
+
DUPLICATE_SAME_ACCESS);
+ }
+
DPRINT1("Console setup: %lx, %lx, %lx\n",
- Request.Data.AllocConsoleRequest.Console,
- Request.Data.AllocConsoleRequest.InputHandle,
- Request.Data.AllocConsoleRequest.OutputHandle);
+ Parameters->ConsoleHandle,
+ Parameters->StandardInput,
+ Parameters->StandardOutput);
return TRUE;
}
_____
Modified: trunk/reactos/lib/kernel32/process/create.c
--- trunk/reactos/lib/kernel32/process/create.c 2005-07-30 23:43:45 UTC
(rev 16907)
+++ trunk/reactos/lib/kernel32/process/create.c 2005-07-30 23:57:14 UTC
(rev 16908)
@@ -308,10 +308,13 @@
IN PRTL_USER_PROCESS_PARAMETERS PebParams,
IN BOOL InheritHandles)
{
+ DPRINT1("BasepCopyHandles %p %p, %d\n", Params, PebParams,
InheritHandles);
+
/* Copy the handle if we are inheriting or if it's a console handle
*/
if (InheritHandles || IsConsoleHandle(PebParams->StandardInput))
{
Params->StandardInput = PebParams->StandardInput;
+ DPRINT1("Standard Input: %x\n", Params->StandardInput);
}
if (InheritHandles || IsConsoleHandle(PebParams->StandardOutput))
{
@@ -349,7 +352,7 @@
UNICODE_STRING Desktop, Shell, Runtime, Title;
PPEB OurPeb = NtCurrentPeb();
- DPRINT("BasepInitializeEnvironment\n");
+ DPRINT1("BasepInitializeEnvironment\n");
/* Get the full path name */
RetVal = GetFullPathNameW(ApplicationPathName,
@@ -478,6 +481,7 @@
/* Write the handles only if we have to */
if (StartupInfo->dwFlags & STARTF_USESTDHANDLES)
{
+ DPRINT1("Using Standard Handles\n");
ProcessParameters->StandardInput = StartupInfo->hStdInput;
ProcessParameters->StandardOutput = StartupInfo->hStdOutput;
ProcessParameters->StandardError = StartupInfo->hStdError;
@@ -506,6 +510,7 @@
(STARTF_USESTDHANDLES | STARTF_USEHOTKEY |
STARTF_SHELLPRIVATE)))
{
/* Use handles from PEB, if inheriting or they are console
*/
+ DPRINT1("Copying handles from parent\n");
BasepCopyHandles(ProcessParameters,
OurPeb->ProcessParameters,
InheritHandles);
_____
Modified: trunk/reactos/ntoskrnl/ke/kthread.c
--- trunk/reactos/ntoskrnl/ke/kthread.c 2005-07-30 23:43:45 UTC (rev
16907)
+++ trunk/reactos/ntoskrnl/ke/kthread.c 2005-07-30 23:57:14 UTC (rev
16908)
@@ -342,11 +342,7 @@
Priority = Thread->Priority - (Thread->PriorityDecrement +
1);
/* Normalize it if we've gone too low */
- if (Priority < Thread->BasePriority)
- {
- /* Normalize it if we've gone too low */
- Priority = Thread->BasePriority;
- }
+ if (Priority < Thread->BasePriority) Priority =
Thread->BasePriority;
/* Reset the priority decrement, we've done it */
Thread->PriorityDecrement = 0;
@@ -354,12 +350,15 @@
/* Set the new priority, if needed */
if (Priority != Thread->Priority)
{
- /* HACK HACK This isn't nice, but it's the only way
with our current codebase */
+ /*
+ * HACK HACK This isn't nice, but it's the only way
with our
+ * current codebase
+ */
Thread->Priority = Priority;
}
else
{
- /* Priority hasn't changed, find a new thread */
+ /* FIXME: Priority hasn't changed, find a new thread */
}
}
}