Skip to content

Possible revival of bug W343-3 on Windows prior to version 8 #1675

Open

Description

@chasonr

Commit #19d8ec6 changes this line in sys/windows/consoletty.c

console.has_unicode = ((GetVersion() & 0x80000000) == 0);

to read

console.has_unicode = (IsWindows8OrGreater());

This changes the meaning of the test. GetVersion returns bit 31 set when running on Windows 95, 98 or Me. These versions of Windows do not support WriteConsoleOutputCharacterW, and also do not exhibit bug W343-3. Windows NT and its descendants should call WriteConsoleOutputCharacterW to work around that bug.

As changed, I expect that NetHack won't run at all on Windows 95 and its descendants, and that W343-3 will appear once more on Windows 7 and earlier.

The post to RGRN in which I described the bug is dated 5 November 2005, in the time of Windows XP. So the workaround is both necessary and effective for that version.

NetHack may be broken on Windows 95 for other reasons.

If support for Windows 95 is still desired, this change should be reverted. If not, the test should be removed and WriteConsoleOutputCharacterW should always be alled.

Activity

  1. chasonr commented on Sep 7, 2026

    @chasonr
    ContributorAuthor

    I have a Windows 98 image preserved from a computer that died long ago. It does not have the files bcrypt.dll, dbghelp.dll and userenv.dll, which NetHack.exe and NetHackW.exe both use. I think it's fair to conclude that NetHack is broken on Windows 95 and friends.

  2. chasonr commented on Sep 7, 2026

    @chasonr
    ContributorAuthor

    The MS-DOS version runs natively on Windows 98, with full support for VESA BIOS Extensions.

  3. nhmall commented on Sep 8, 2026

    @nhmall
    Contributor

    Is this what you are recommending?

    • remove the tests for console.has_unicode and just assume that's true.
    • remove all use of WriteConsoleOutputCharacterA() and use WriteConsoleOutputCharacterW() always.
    • publish a stance that states: If you want to play NetHack on Windows 98, consider using the MSDOS version because there isn't a working Windows version.

    I think, generally, there's a desire to maintain support for multiple platforms, as long as there is someone actively providing updates for each platform.

    I don't think, however, it is feasible to try to maintain support for all older operating system versions on every platform that NetHack executes on.

  4. nhmall commented on Sep 8, 2026

    @nhmall
    Contributor

    While the "roadmap" gets discussed, I have placed the following change into the pipeline, to attempt to undo the reported undesirable effect of 19d8ec6.

    diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c
    index 93dd8a966..62b5cf28a 100644
    --- a/sys/windows/consoletty.c
    +++ b/sys/windows/consoletty.c
    @@ -162,6 +162,8 @@ extern void (*ibmgraphics_mode_callback)(void);  /* symbols.c */
     extern void (*utf8graphics_mode_callback)(void); /* symbols.c */
     #endif /* VIRTUAL_TERMINAL_SEQUENCES */
     
    +static boolean OnWindows95_98_Me(void);
    +
     static void init_custom_colors(void);
     static void free_custom_colors(void);
     
    @@ -892,6 +894,12 @@ void buffer_write(cell_t * buffer, cell_t * cell, COORD pos)
             back_buffer_flip();
     }
     
    +static boolean
    +OnWindows95_98_Me(void)
    +{
    +    return ((GetVersion() & 0x80000000) != 0);
    +}
    +
     /*
      * Called after returning from ! or ^Z
      */
    @@ -2525,7 +2533,8 @@ void nethack_enter_consoletty(void)
         buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0);
     
         /* determine whether OS version has unicode support */
    -    console.has_unicode = (IsWindows8OrGreater());
    +    /* console.has_unicode = (IsWindows8OrGreater()); */
    +    console.has_unicode = !OnWindows95_98_Me();
     
     #ifdef VIRTUAL_TERMINAL_SEQUENCES
         /* store the original code page*/
    
    
  5. chasonr commented on Sep 8, 2026

    @chasonr
    ContributorAuthor

    Always calling WriteConsoleOutputCharacterW seems the easiest thing to do.

    It looks like getting the current NetHack running on Windows 95 would require more changes than reverting that one line. These functions, all called from windsys.c, are not supported:

    • BCryptCloseAlgorithmProvider
    • BCryptCreateHash
    • BCryptDestroyHash
    • BCryptFinishHash
    • BCryptGenRandom
    • BCryptGetProperty
    • BCryptHashData
    • BCryptOpenAlgorithmProvider
    • GetUserProfileDirectoryA
    • SymCleanup
    • SymFromAddr
    • SymGetLineFromAddr
    • SymInitialize

    From the Microsoft docs, the BCrypt* functions go back to Windows Vista, GetUserProfileDirectoryA goes back to Windows 2000 and the Sym* functions are available in a redistributable DLL.

  6. chasonr commented on Sep 11, 2026

    @chasonr
    ContributorAuthor

    I set up some VMs with older versions of Windows. I was able to run NetHack as far back as Windows Vista. It does not run on XP, and I didn't expect that it would.

    Without the recent change to the version check, I observed a completely different bug from the one I expected: IBMgraphics did not work at all. It looks like the ANSI code page is being used instead of the OEM one. I also saw that going from one menu to another (as to change symset from the options menu) did not display the second menu correctly. With the version check changed, I saw correct IBMgraphics and menus.

    OTOH, the text-mode NetHack is generating ANSI escape sequences that the older terminal program does not understand. If you've ever run a DOS program that expected ANSI.SYS, and ANSI.SYS wasn't loaded, that's what it looked like. NetHack 3.6.7 does not generate the escape sequences. Cmder runs on Vista, understands the escape sequences, and gives a correct display.

    The graphical-mode NetHackW shows no obvious problems running on Vista.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions