diff --git a/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/dbghelp.py b/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/dbghelp.py index 0add047d..ce14ff9f 100644 --- a/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/dbghelp.py +++ b/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/dbghelp.py @@ -47,29 +47,34 @@ from winappdbg.win32.kernel32 import * def _load_latest_dbghelp_dll(): from os import getenv - from os.path import join + from os.path import join, exists + program_files_location = getenv("ProgramFiles") + if not program_files_location: + program_files_location = "C:\Program Files" + + program_files_x86_location = getenv("ProgramFiles(x86)") + if arch == ARCH_AMD64: if wow64: pathname = join( - getenv("ProgramFiles(x86)", - getenv("ProgramFiles")), + program_files_x86_location or program_files_location, "Debugging Tools for Windows (x86)", "dbghelp.dll") else: pathname = join( - getenv("ProgramFiles"), + program_files_location, "Debugging Tools for Windows (x64)", "dbghelp.dll") elif arch == ARCH_I386: pathname = join( - getenv("ProgramFiles"), + program_files_location, "Debugging Tools for Windows (x86)", "dbghelp.dll") else: pathname = None - if pathname: + if pathname and exists(pathname): try: _dbghelp = ctypes.windll.LoadLibrary(pathname) ctypes.windll.dbghelp = _dbghelp