[PATCH 1/2] msvcrt: Lazily initialize console handles.

Piotr Caban piotr.caban at gmail.com
Fri Mar 12 06:27:50 CST 2021


Hi Rémi,

On 3/12/21 11:02 AM, Rémi Bernon wrote:
> +static HANDLE msvcrt_input_console(void)
>   {

> +  HANDLE console;
> +  LOCK_CONSOLE;
> +  if (!MSVCRT_console_in)
> +  {
> +    MSVCRT_console_in = CreateFileA("CONIN$", GENERIC_WRITE|GENERIC_READ,
> +                                    FILE_SHARE_WRITE|FILE_SHARE_READ,
> +                                    NULL, OPEN_EXISTING, 0, NULL);
> +    if (MSVCRT_console_in == INVALID_HANDLE_VALUE)
> +      WARN("Input console handle initialization failed!\n");
> +  }
> +  console = MSVCRT_console_in;
> +  UNLOCK_CONSOLE;
> +  return console;
> +}
I think that the caller should be responsible for locking. It's 
especially important for the _nolock functions that shouldn't lock at all.

Thanks,
Piotr



More information about the wine-devel mailing list