Skip to content

Commit

Permalink
read ZFS install location from registry
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Innes <andrew.c12@gmail.com>
  • Loading branch information
andrewc12 committed Oct 21, 2023
1 parent 71ff7f5 commit 555aa4e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion contrib/windows/parsedump/parsedump.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import subprocess
import pathlib
import os
import winreg

pf64 = pathlib.WindowsPath(os.environ["ProgramFiles"])
pf86 = pathlib.WindowsPath(os.environ["ProgramFiles(x86)"])
Expand All @@ -19,6 +20,32 @@ def find_first_existing_file(file_paths):
return None # Return None if no file is found



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_zfs():
zfs_reg_path = (
pathlib.Path("SOFTWARE")
/ "OpenZFS"
/ "OpenZFS On Windows"
/ "InstallLocation"
)

res = read_reg(zfs_reg_path)
if not res:
return None

zfs_install_path = pathlib.WindowsPath(res)

return zfs_install_path


# List of file paths to check
cdb_file_paths_to_check = [
pf64 / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe",
Expand All @@ -35,8 +62,10 @@ def find_first_existing_file(file_paths):
print("cdb not found.")
exit()

zfs = find_zfs()

dumpfilestr = "C:\\Windows\\MEMORY.DMP"
symbolstr = "srv*;C:\\Program Files\\OpenZFS On Windows\\symbols\\;"
symbolstr = "srv*;" + str(zfs / "symbols") + "\\;"


def run(arg):
Expand Down

0 comments on commit 555aa4e

Please sign in to comment.