Don't use CSRSS handles if we alreay have some (so we can inherit file handles, etc)

svn path=/trunk/; revision=16908
This commit is contained in:
Alex Ionescu 2005-07-30 23:57:14 +00:00
parent eb86553bed
commit 7cf9ad08e3
3 changed files with 32 additions and 18 deletions

View file

@ -167,18 +167,28 @@ BasepInitConsole(VOID)
/* We got the handles, let's set them */ /* We got the handles, let's set them */
Parameters->ConsoleHandle = Request.Data.AllocConsoleRequest.Console; Parameters->ConsoleHandle = Request.Data.AllocConsoleRequest.Console;
SetStdHandle(STD_INPUT_HANDLE, Request.Data.AllocConsoleRequest.InputHandle);
SetStdHandle(STD_OUTPUT_HANDLE, Request.Data.AllocConsoleRequest.OutputHandle); /* If we already had some, don't use the new ones */
SetStdHandle(STD_ERROR_HANDLE, if (!Parameters->StandardInput)
DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle, {
0, Parameters->StandardInput = Request.Data.AllocConsoleRequest.InputHandle;
TRUE, }
DUPLICATE_SAME_ACCESS)); 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", DPRINT1("Console setup: %lx, %lx, %lx\n",
Request.Data.AllocConsoleRequest.Console, Parameters->ConsoleHandle,
Request.Data.AllocConsoleRequest.InputHandle, Parameters->StandardInput,
Request.Data.AllocConsoleRequest.OutputHandle); Parameters->StandardOutput);
return TRUE; return TRUE;
} }

View file

@ -308,10 +308,13 @@ BasepCopyHandles(IN PRTL_USER_PROCESS_PARAMETERS Params,
IN PRTL_USER_PROCESS_PARAMETERS PebParams, IN PRTL_USER_PROCESS_PARAMETERS PebParams,
IN BOOL InheritHandles) 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 */ /* Copy the handle if we are inheriting or if it's a console handle */
if (InheritHandles || IsConsoleHandle(PebParams->StandardInput)) if (InheritHandles || IsConsoleHandle(PebParams->StandardInput))
{ {
Params->StandardInput = PebParams->StandardInput; Params->StandardInput = PebParams->StandardInput;
DPRINT1("Standard Input: %x\n", Params->StandardInput);
} }
if (InheritHandles || IsConsoleHandle(PebParams->StandardOutput)) if (InheritHandles || IsConsoleHandle(PebParams->StandardOutput))
{ {
@ -349,7 +352,7 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
UNICODE_STRING Desktop, Shell, Runtime, Title; UNICODE_STRING Desktop, Shell, Runtime, Title;
PPEB OurPeb = NtCurrentPeb(); PPEB OurPeb = NtCurrentPeb();
DPRINT("BasepInitializeEnvironment\n"); DPRINT1("BasepInitializeEnvironment\n");
/* Get the full path name */ /* Get the full path name */
RetVal = GetFullPathNameW(ApplicationPathName, RetVal = GetFullPathNameW(ApplicationPathName,
@ -478,6 +481,7 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
/* Write the handles only if we have to */ /* Write the handles only if we have to */
if (StartupInfo->dwFlags & STARTF_USESTDHANDLES) if (StartupInfo->dwFlags & STARTF_USESTDHANDLES)
{ {
DPRINT1("Using Standard Handles\n");
ProcessParameters->StandardInput = StartupInfo->hStdInput; ProcessParameters->StandardInput = StartupInfo->hStdInput;
ProcessParameters->StandardOutput = StartupInfo->hStdOutput; ProcessParameters->StandardOutput = StartupInfo->hStdOutput;
ProcessParameters->StandardError = StartupInfo->hStdError; ProcessParameters->StandardError = StartupInfo->hStdError;
@ -506,6 +510,7 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
(STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE))) (STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE)))
{ {
/* Use handles from PEB, if inheriting or they are console */ /* Use handles from PEB, if inheriting or they are console */
DPRINT1("Copying handles from parent\n");
BasepCopyHandles(ProcessParameters, BasepCopyHandles(ProcessParameters,
OurPeb->ProcessParameters, OurPeb->ProcessParameters,
InheritHandles); InheritHandles);

View file

@ -342,11 +342,7 @@ KiAdjustQuantumThread(IN PKTHREAD Thread)
Priority = Thread->Priority - (Thread->PriorityDecrement + 1); Priority = Thread->Priority - (Thread->PriorityDecrement + 1);
/* Normalize it if we've gone too low */ /* Normalize it if we've gone too low */
if (Priority < Thread->BasePriority) if (Priority < Thread->BasePriority) Priority = Thread->BasePriority;
{
/* Normalize it if we've gone too low */
Priority = Thread->BasePriority;
}
/* Reset the priority decrement, we've done it */ /* Reset the priority decrement, we've done it */
Thread->PriorityDecrement = 0; Thread->PriorityDecrement = 0;
@ -354,12 +350,15 @@ KiAdjustQuantumThread(IN PKTHREAD Thread)
/* Set the new priority, if needed */ /* Set the new priority, if needed */
if (Priority != Thread->Priority) 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; Thread->Priority = Priority;
} }
else else
{ {
/* Priority hasn't changed, find a new thread */ /* FIXME: Priority hasn't changed, find a new thread */
} }
} }
} }