Skip to content

Pybag fails to load with Windows SDK installed via Visual Studio #34

Description

@joelspadin

When you install the Windows SDK as part of Visual Studio (either because it is a dependency for an enabled workload or by explicitly selecting it from the "individual components" tab in the installer), it only seems to install some parts of the SDK which do not include the full debugger features. It will create a "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64" directory, but this will only contain a few DLLs like dbghelp.dll.

Pybag seems to prioritize using the Windows SDK over using WinDbg installed from the app store, and it only cares whether the directory exists instead of checking whether the necessary files are present as well, so it will fail to load with an error like this if you have this partial Windows SDK installed, even if dbgeng is available from a WinDbg install.

>>> import pybag
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import pybag
  File "C:\Users\Joel\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pybag\__init__.py", line 128, in <module>
    ctypes.windll.LoadLibrary(os.path.join(dbgdir, 'dbgeng.dll'))
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Joel\AppData\Local\Python\pythoncore-3.14-64\Lib\ctypes\__init__.py", line 552, in LoadLibrary
    return self._dlltype(name)
           ~~~~~~~~~~~~~^^^^^^
  File "C:\Users\Joel\AppData\Local\Python\pythoncore-3.14-64\Lib\ctypes\__init__.py", line 433, in __init__
    self._handle = self._load_library(name, mode, handle, winmode)
                   ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Joel\AppData\Local\Python\pythoncore-3.14-64\Lib\ctypes\__init__.py", line 451, in _load_library
    return _LoadLibrary(self._name, winmode)
FileNotFoundError: Could not find module 'C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbgeng.dll' (or one of its dependencies). Try using the full path with constructor syntax.

This could probably be handled by having

def find_dbgdir():
check whether the directory contains dbgeng.dll instead of just whether the directory exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions