krnl386.exe16: Do not reassign default handles after they got closed.

Alexandre Julliard julliard at
Wed Apr 6 03:39:20 CDT 2016

Sebastian Lackner <sebastian at> writes:

> As far as I remember it basically solves two bugs at once:
> * First of all, apps interpret a returned HFILE of 0 from file APIs as failure.
>   This can happen when apps call _lclose(0) before, or when FILE_InitProcessDosHandles
>   does not properly initialize them. The second case, failure to
>   initialize dos_handles[*] during init, will be fixed in a separate patch.
> * I also remember that Michael ran various tests to verify the return value
>   of _lclose(*), and it showed that Windows returns 0 when trying to close
>   such handle multiple times. I am aware that we still call CloseHandle() on
>   INVALID_HANDLE_VALUE in Wine, but this is probably well-defined enough to
>   avoid additional checks.

I'm concerned that using two different markers for invalid handles is
confusing. There are already more than enough 0 vs. INVALID_HANDLE_VALUE
mismatches ;-)

I think it would be better to set them to 0 on close, and handle that
case explicitly in all functions.

Alexandre Julliard
julliard at

More information about the wine-devel mailing list