Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for debugger #300

Merged

Conversation

andrewc12
Copy link

Add more locations the debugger might be in
Signed-off-by: Andrew Innes [email protected]

Motivation and Context

Description

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@andrewc12
Copy link
Author

@EchterAgo any thoughts?

@EchterAgo
Copy link

Yes, I think we should substitute env vars and use %ProgramFiles% / %ProgramFiles(x86)%. I'll also check if there is a registry key for the location

@EchterAgo
Copy link

>>> import pathlib
>>> import os           
>>> pf = pathlib.Path(os.environ["ProgramFiles"])
>>> cdb = pf / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe" 
>>> cdb
WindowsPath('C:/Program Files/Windows Kits/10/Debuggers/x64/cdb.exe')

@EchterAgo
Copy link

EchterAgo commented Oct 19, 2023

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\KitsRoot10 is probably what we should try first.

Maybe even HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10 first

@EchterAgo
Copy link

EchterAgo commented Oct 19, 2023

There is also WindowsDebuggersRoot10 (C:\Program Files (x86)\Windows Kits\10\Debuggers\ on my system)

Edit: This only exists under WOW6432Node here.

@EchterAgo
Copy link

EchterAgo commented Oct 19, 2023

def read_reg(path: pathlib.Path, hive=winreg.HKEY_LOCAL_MACHINE):
    try:
        with winreg.OpenKey(hive, str(path.parent)) as key:
            value, _ = winreg.QueryValueEx(key, path.name)
            return value
    except (OSError, FileNotFoundError):
        return None


def find_kits():
    kit_value_names = ["KitsRoot10", "KitsRoot81", "KitsRoot"]
    kit_install_path: pathlib.Path = None

    for kit_value_name in kit_value_names:
        kit_reg_path = (
            pathlib.Path("SOFTWARE")
            / "WOW6432Node"
            / "Microsoft"
            / "Windows Kits"
            / "Installed Roots"
            / kit_value_name
        )

        res = read_reg(kit_reg_path)
        if not res:
            continue

        kit_install_path = pathlib.Path(res)
        break

    return kit_install_path

@andrewc12
Copy link
Author

andrewc12 commented Oct 19, 2023

def find_kits():
    kit_value_names = ["KitsRoot10", "KitsRoot81", "KitsRoot"]
    kit_install_path: pathlib.Path = None

    for kit_value_name in kit_value_names:
        kit_reg_path = (
            pathlib.Path("SOFTWARE")
            / "WOW6432Node"
            / "Microsoft"
            / "Windows Kits"
            / "Installed Roots"
            / kit_value_name
        )

        res = read_reg(kit_reg_path)
        if not res:
            continue

        kit_install_path = pathlib.Path(res)
        break

    return kit_install_path

Probably a good idea but I wont be able to recreate the %ProgramFiles%\Windows Kits\10\Debuggers\x64\cdb.exe scenario for testing without a clean windows install (I think)

I'll still probably use the rego key from #301

Add more locations the debugger might be in
Signed-off-by: Andrew Innes <[email protected]>
@andrewc12 andrewc12 merged commit 555aa4e into openzfsonwindows:zfs-Windows-2.2.0-release Oct 21, 2023
6 of 7 checks passed
@andrewc12
Copy link
Author

Thanks for the registry code @EchterAgo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants