Duplicate stdin/stdout handles to avoid closing them when library is

unloaded.
This commit is contained in:
Ulrich Czekalla 2003-10-31 04:17:45 +00:00 committed by Alexandre Julliard
parent 84ad10bfcd
commit 736d96b5b3
2 changed files with 8 additions and 4 deletions

View File

@ -47,7 +47,8 @@ void msvcrt_init_console(void)
{ {
TRACE(":Opening console handles\n"); TRACE(":Opening console handles\n");
MSVCRT_console_in = GetStdHandle(STD_INPUT_HANDLE); DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE),
GetCurrentProcess(), &MSVCRT_console_in, 0, FALSE, DUPLICATE_SAME_ACCESS);
/* FIXME: Should be initialised with: /* FIXME: Should be initialised with:
* CreateFileA("CONIN$", GENERIC_READ, FILE_SHARE_READ, * CreateFileA("CONIN$", GENERIC_READ, FILE_SHARE_READ,

View File

@ -204,11 +204,14 @@ void msvcrt_init_io(void)
{ {
int i; int i;
memset(MSVCRT__iob,0,3*sizeof(MSVCRT_FILE)); memset(MSVCRT__iob,0,3*sizeof(MSVCRT_FILE));
MSVCRT_handles[0] = GetStdHandle(STD_INPUT_HANDLE); DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE),
GetCurrentProcess(), &MSVCRT_handles[0], 0, FALSE, DUPLICATE_SAME_ACCESS);
MSVCRT_flags[0] = MSVCRT__iob[0]._flag = MSVCRT__IOREAD; MSVCRT_flags[0] = MSVCRT__iob[0]._flag = MSVCRT__IOREAD;
MSVCRT_handles[1] = GetStdHandle(STD_OUTPUT_HANDLE); DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE),
GetCurrentProcess(), &MSVCRT_handles[1], 0, FALSE, DUPLICATE_SAME_ACCESS);
MSVCRT_flags[1] = MSVCRT__iob[1]._flag = MSVCRT__IOWRT; MSVCRT_flags[1] = MSVCRT__iob[1]._flag = MSVCRT__IOWRT;
MSVCRT_handles[2] = GetStdHandle(STD_ERROR_HANDLE); DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_ERROR_HANDLE),
GetCurrentProcess(), &MSVCRT_handles[2], 0, FALSE, DUPLICATE_SAME_ACCESS);
MSVCRT_flags[2] = MSVCRT__iob[2]._flag = MSVCRT__IOWRT; MSVCRT_flags[2] = MSVCRT__iob[2]._flag = MSVCRT__IOWRT;
TRACE(":handles (%p)(%p)(%p)\n",MSVCRT_handles[0], TRACE(":handles (%p)(%p)(%p)\n",MSVCRT_handles[0],