author Ryan C. Gordon <>
Thu, 28 May 2015 01:54:52 -0400
changeset 9671 0e1f57b051f4
parent 9507 b1e690e9c5b3
child 10890 a2ec89f77e6b
permissions -rw-r--r--
Windows GetBasePath should use GetModuleFileNameExW() and check for overflows.

Apparently you might get strange paths from GetModuleFileName(), such as
short path names or UNC filenames, so this avoids that problem. Since you have
to tapdance with linking different libraries and defining macros depending on
what Windows you plan to target, we dynamically load the API we need, which
works on all versions of Windows (on Win7, it'll load a compatibility wrapper
for the newer API location).

What a mess.

This also now does the right thing if there isn't enough space to store the
path, looping with a larger allocated buffer each try.

Fixes Bugzilla #2435.
     2                          Simple DirectMedia Layer
     4                                   (SDL)
     6                                 Version 2.0
     8 ---
    11 Simple DirectMedia Layer is a cross-platform development library designed
    12 to provide low level access to audio, keyboard, mouse, joystick, and graphics
    13 hardware via OpenGL and Direct3D. It is used by video playback software,
    14 emulators, and popular games including Valve's award winning catalog
    15 and many Humble Bundle games.
    17 More extensive documentation is available in the docs directory, starting
    18 with
    20 Enjoy!
    21 	Sam Lantinga				(