Commit 826a9615 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernelbase: Remove no longer needed console handle mapping.

parent 2ecb8713
...@@ -244,7 +244,7 @@ static BOOL init_console_std_handles( BOOL override_all ) ...@@ -244,7 +244,7 @@ static BOOL init_console_std_handles( BOOL override_all )
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 );
if (!set_ntstatus( status )) return FALSE; if (!set_ntstatus( status )) return FALSE;
console_flags |= CONSOLE_INPUT_HANDLE; console_flags |= CONSOLE_INPUT_HANDLE;
SetStdHandle( STD_INPUT_HANDLE, console_handle_map( handle )); SetStdHandle( STD_INPUT_HANDLE, handle );
} }
if (!override_all) if (!override_all)
...@@ -263,7 +263,7 @@ static BOOL init_console_std_handles( BOOL override_all ) ...@@ -263,7 +263,7 @@ static BOOL init_console_std_handles( BOOL override_all )
if (!std_out) if (!std_out)
{ {
console_flags |= CONSOLE_OUTPUT_HANDLE; console_flags |= CONSOLE_OUTPUT_HANDLE;
SetStdHandle( STD_OUTPUT_HANDLE, console_handle_map( handle )); SetStdHandle( STD_OUTPUT_HANDLE, handle );
} }
if (!std_err) if (!std_err)
...@@ -272,7 +272,7 @@ static BOOL init_console_std_handles( BOOL override_all ) ...@@ -272,7 +272,7 @@ static BOOL init_console_std_handles( BOOL override_all )
&handle, 0, TRUE, DUPLICATE_SAME_ACCESS )) &handle, 0, TRUE, DUPLICATE_SAME_ACCESS ))
return FALSE; return FALSE;
console_flags |= CONSOLE_ERROR_HANDLE; console_flags |= CONSOLE_ERROR_HANDLE;
SetStdHandle( STD_ERROR_HANDLE, console_handle_map( handle )); SetStdHandle( STD_ERROR_HANDLE, handle );
} }
return TRUE; return TRUE;
......
...@@ -854,12 +854,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW( LPCWSTR filename, DWORD access, DWO ...@@ -854,12 +854,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW( LPCWSTR filename, DWORD access, DWO
} }
else else
{ {
if (dosdev &&
((LOWORD(dosdev) == 3 * sizeof(WCHAR) && !wcsnicmp( filename + HIWORD(dosdev)/sizeof(WCHAR), L"CON", 3 )) ||
(LOWORD(dosdev) == 6 * sizeof(WCHAR) && !wcsnicmp( filename + HIWORD(dosdev)/sizeof(WCHAR), L"CONIN$", 6 )) ||
(LOWORD(dosdev) == 7 * sizeof(WCHAR) && !wcsnicmp( filename + HIWORD(dosdev)/sizeof(WCHAR), L"CONOUT$", 7 ))))
ret = console_handle_map( ret );
if ((creation == CREATE_ALWAYS && io.Information == FILE_OVERWRITTEN) || if ((creation == CREATE_ALWAYS && io.Information == FILE_OVERWRITTEN) ||
(creation == OPEN_ALWAYS && io.Information == FILE_OPENED)) (creation == OPEN_ALWAYS && io.Information == FILE_OPENED))
SetLastError( ERROR_ALREADY_EXISTS ); SetLastError( ERROR_ALREADY_EXISTS );
......
...@@ -43,17 +43,6 @@ extern const WCHAR system_dir[] DECLSPEC_HIDDEN; ...@@ -43,17 +43,6 @@ extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
extern BOOL is_wow64 DECLSPEC_HIDDEN; extern BOOL is_wow64 DECLSPEC_HIDDEN;
static inline BOOL is_console_handle(HANDLE h)
{
return h != INVALID_HANDLE_VALUE && ((UINT_PTR)h & 3) == 3;
}
/* map between ntdll handle and kernel32 console handle */
static inline HANDLE console_handle_map( HANDLE h )
{
return h != INVALID_HANDLE_VALUE ? (HANDLE)((UINT_PTR)h ^ 3) : INVALID_HANDLE_VALUE;
}
static inline BOOL set_ntstatus( NTSTATUS status ) static inline BOOL set_ntstatus( NTSTATUS status )
{ {
if (status) SetLastError( RtlNtStatusToDosError( status )); if (status) SetLastError( RtlNtStatusToDosError( status ));
......
...@@ -396,7 +396,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH CloseHandle( HANDLE handle ) ...@@ -396,7 +396,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH CloseHandle( HANDLE handle )
else if (handle == (HANDLE)STD_ERROR_HANDLE) else if (handle == (HANDLE)STD_ERROR_HANDLE)
handle = InterlockedExchangePointer( &NtCurrentTeb()->Peb->ProcessParameters->hStdError, 0 ); handle = InterlockedExchangePointer( &NtCurrentTeb()->Peb->ProcessParameters->hStdError, 0 );
if (is_console_handle( handle )) handle = console_handle_map( handle );
return set_ntstatus( NtClose( handle )); return set_ntstatus( NtClose( handle ));
} }
...@@ -658,15 +657,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH DuplicateHandle( HANDLE source_process, HANDLE sou ...@@ -658,15 +657,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH DuplicateHandle( HANDLE source_process, HANDLE sou
HANDLE dest_process, HANDLE *dest, HANDLE dest_process, HANDLE *dest,
DWORD access, BOOL inherit, DWORD options ) DWORD access, BOOL inherit, DWORD options )
{ {
if (is_console_handle( source ))
{
source = console_handle_map( source );
if (!set_ntstatus( NtDuplicateObject( source_process, source, dest_process, dest,
access, inherit ? OBJ_INHERIT : 0, options )))
return FALSE;
*dest = console_handle_map( *dest );
return TRUE;
}
return set_ntstatus( NtDuplicateObject( source_process, source, dest_process, dest, return set_ntstatus( NtDuplicateObject( source_process, source, dest_process, dest,
access, inherit ? OBJ_INHERIT : 0, options )); access, inherit ? OBJ_INHERIT : 0, options ));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment