Don't fail attach to pid if 'ProgramFiles' env var is not available. Fixes #1144 (#1515)

This commit is contained in:
Fabio Zadrozny 2019-06-13 14:23:04 -03:00 committed by Karthik Nadig
parent 7c33548f6a
commit 7f76c4b284

View file

@ -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