Running Baldur's Gate 2 in windowed mode at high resolutions

Problem: You want to run the original Baldur's Gate 2: Throne of Bhall in windowed mode, but at your monitor's native resolution. However, the game contains logic which force-enables fullscreen mode if the configured horizontal resolution is greater than or equal to your monitor's horizontal resolution.

I'm talking about the original BG2 release here, not any remaster such as the Enhanced Edition. I'm assuming you have ToB with the official patch installed. These instructions are also likely to be compatible with any unofficial code patches applied to the game executable.

Solution: You can disable this logic by hex-editing BGMain.exe:

  • Make a backup of BGMain.exe.

  • Open BGMain.exe in a hex editor such as frhed.

  • At offset 0x327b7, you should find the byte sequence C7 81 E4 00 00 00 01 00 00 00; replace all the bytes with 0x90.

  • At offset 0x327c7, you should find the byte sequence C6 82 E2 00 00 00 01; replace all the bytes with 0x90.

  • At offset 0x327d4, you should find the byte sequence C6 80 E1 00 00 00 01; replace all the bytes with 0x90.

  • Save and run.

The first of these disables a mov which sets a flag indicating not to allow fullscreen mode to be disabled. The second and third of these disable movs which set flags indicating fullscreen mode is enabled.

Background: I had to do this to run BG2 with “3D Acceleration” (OpenGL mode) enabled on Linux under Wine, as its OpenGL mode doesn't run well in fullscreen mode under Wine; the screen flickers, as though every other frame is drawn from an uninitialised framebuffer. Possibly some issue with double buffering. This is with the unofficial widescreen mod applied to set the game's resolution to my display's native resolution.

Running in windowed mode at your native resolution will require you to have some way of disabling window chrome, of course. In my case, I use i3, and can put the window into a borderless fullscreen mode by pressing Mod+f. This is distinct from “OpenGL” fullscreen mode.