From 03a99b0fd2b61cc47bbcfe6fb7d62ebbb741faeb Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Thu, 19 Oct 2023 18:03:41 +0800 Subject: [PATCH] Update parsedump.py --- contrib/windows/parsedump/parsedump.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/contrib/windows/parsedump/parsedump.py b/contrib/windows/parsedump/parsedump.py index 86541cf76a49..c3754e62c5c6 100644 --- a/contrib/windows/parsedump/parsedump.py +++ b/contrib/windows/parsedump/parsedump.py @@ -5,28 +5,32 @@ import re import subprocess +import pathlib import os +pf64 = pathlib.WindowsPath(os.environ["ProgramFiles"]) +pf86 = pathlib.WindowsPath(os.environ["ProgramFiles(x86)"]) + def find_first_existing_file(file_paths): for file_path in file_paths: - if os.path.exists(file_path): + if file_path.exists(): return file_path return None # Return None if no file is found # List of file paths to check cdb_file_paths_to_check = [ - "%ProgramFiles%\\Windows Kits\\10\\Debuggers\\x64\\cdb.exe", - "%ProgramFiles(x86)%\\Windows Kits\\10\\Debuggers\\x64\\cdb.exe", - "%ProgramFiles%\\Windows Kits\\10\\Debuggers\\x86\\cdb.exe", - "%ProgramFiles(x86)%\\Windows Kits\\10\\Debuggers\\x86\\cdb.exe" + pf64 / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe", + pf86 / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe", + pf64 / "Windows Kits" / "10" / "Debuggers" / "x86" / "cdb.exe", + pf86 / "Windows Kits" / "10" / "Debuggers" / "x86" / "cdb.exe" ] -cdbstr = find_first_existing_file(cdb_file_paths_to_check) +cdb = find_first_existing_file(cdb_file_paths_to_check) -if cdbstr: - print(cdbstr) +if cdb: + print(cdb) else: print("cdb not found.") exit() @@ -37,7 +41,7 @@ def find_first_existing_file(file_paths): def run(arg): result = subprocess.run( - [cdbstr, "-z", dumpfilestr, "-c", arg, "-y", symbolstr], + [str(cdb), "-z", dumpfilestr, "-c", arg, "-y", symbolstr], stdout=subprocess.PIPE, stderr=subprocess.PIPE, )