mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
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:
parent
eb86553bed
commit
7cf9ad08e3
3 changed files with 32 additions and 18 deletions
|
@ -167,18 +167,28 @@ BasepInitConsole(VOID)
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -308,10 +308,13 @@ BasepCopyHandles(IN PRTL_USER_PROCESS_PARAMETERS Params,
|
|||
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 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
|
|||
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 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
|
|||
/* 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 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
|
|||
(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);
|
||||
|
|
|
@ -342,11 +342,7 @@ KiAdjustQuantumThread(IN PKTHREAD Thread)
|
|||
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 @@ KiAdjustQuantumThread(IN PKTHREAD Thread)
|
|||
/* 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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue