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

Ghidra TTD fails with "NameError: name 'dbgmodel' is not defined" #7940

Closed
MichaelEbert opened this issue Mar 22, 2025 · 9 comments
Closed
Assignees
Milestone

Comments

@MichaelEbert
Copy link

MichaelEbert commented Mar 22, 2025

Describe the bug
dbgmodel is not defined.

To Reproduce
Open debugger.
File->Open->xyz.exe
Debugger->Configure and launch xyz using...->ttd

python command: python
Trace(.run): H:\reverse eng\xyz\dumps\xyz.run
Arguments:
use dbgmodel: [x]
path to dbgeng: H:\reverse eng\ttd

Loading dbgeng and friends from H:\reverse eng\ttd
Traceback (most recent call last):
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debu
g\Debugger-agent-dbgeng\pypkg\src\ghidrattd\libraries.py", line 73, in <module> 
    from comtypes.gen import DbgMod
ImportError: cannot import name 'DbgMod' from 'comtypes.gen' (unknown location) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debu
g\Debugger-agent-dbgeng\data\support\local-ttd.py", line 58, in <module>        
    main()
    ~~~~^^
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debu
g\Debugger-agent-dbgeng\data\support\local-ttd.py", line 41, in main
    ~~~~^^
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debug\Debugger-agent-dbgeng\data\support\local-ttd.py", line 41, in main
    from ghidrattd import commands as cmd
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debug\Debugger-agent-dbgeng\pypkg\src\ghidrattd\__init__.py", line 19, in <module>
    from . import libraries, util, commands, methods, hooks
  File "H:\altBin\ghidra_11.3.1_PUBLIC_20250219\ghidra_11.3.1_PUBLIC\Ghidra\Debug\Debugger-agent-dbgeng\pypkg\src\ghidrattd\libraries.py", line 75, in <module>
    tlb = os.path.join(dbgmodel.module_locator(), 'tlb', 'dbgmodel.tlb')
                       ^^^^^^^^
NameError: name 'dbgmodel' is not defined
>>>

Expected behavior
no errors

Screenshots
If applicable, add screenshots to help explain your problem.

Attachments

Environment (please complete the following information):

  • OS: Windows 10
  • Java Version: 21.0.6
  • Ghidra Version: 11.3.1
  • Ghidra Origin: official GitHub distro
  • H:\reverse eng\ttd contains files copied from C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2502.25002.0_x64__8wekyb3d8bbwe\amd64

Additional context
dlls in H:\reverse eng\ttd:
H:\reverse eng\ttd\CredentialProviders\GCMW\DbgCredentialProvider_gcmw.dll
H:\reverse eng\ttd\ttd\wow64\TTDAnalyze.dll
H:\reverse eng\ttd\ttd\wow64\TtdExt.dll
H:\reverse eng\ttd\ttd\wow64\TTDLoader.dll
H:\reverse eng\ttd\ttd\wow64\TTDRecord.dll
H:\reverse eng\ttd\ttd\wow64\TTDRecordCPU.dll
H:\reverse eng\ttd\ttd\wow64\TTDReplay.dll
H:\reverse eng\ttd\ttd\wow64\TTDReplayCPU.dll
H:\reverse eng\ttd\ttd\TTDAnalyze.dll
H:\reverse eng\ttd\ttd\TtdExt.dll
H:\reverse eng\ttd\ttd\TTDLoader.dll
H:\reverse eng\ttd\ttd\TTDRecord.dll
H:\reverse eng\ttd\ttd\TTDRecordCPU.dll
H:\reverse eng\ttd\ttd\TTDReplay.dll
H:\reverse eng\ttd\ttd\TTDReplayCPU.dll
H:\reverse eng\ttd\winext\chakra\ChakraCore.dll
H:\reverse eng\ttd\winext\chakra\JsProvider.dll
H:\reverse eng\ttd\winext\sos\extensions\Microsoft.Diagnostics.DataContractReader.dll
H:\reverse eng\ttd\winext\sos\extensions\Microsoft.Diagnostics.DataContractReader.Extension.dll
H:\reverse eng\ttd\winext\sos\extensions\Microsoft.Diagnostics.DebuggerCommands.dll
H:\reverse eng\ttd\winext\sos\Azure.Core.dll
H:\reverse eng\ttd\winext\sos\Azure.Identity.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Bcl.AsyncInterfaces.dll
H:\reverse eng\ttd\winext\sos\Microsoft.CSharp.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Diagnostics.DebugServices.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Diagnostics.DebugServices.Implementation.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Diagnostics.ExtensionCommands.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Diagnostics.NETCore.Client.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Diagnostics.Runtime.dll
H:\reverse eng\ttd\winext\sos\Microsoft.DiaSymReader.Native.amd64.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.DependencyInjection.Abstractions.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.DependencyInjection.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.Logging.Abstractions.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.Logging.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.Options.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Extensions.Primitives.dll
H:\reverse eng\ttd\winext\sos\Microsoft.FileFormats.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Identity.Client.dll
H:\reverse eng\ttd\winext\sos\Microsoft.Identity.Client.Extensions.Msal.dll
H:\reverse eng\ttd\winext\sos\Microsoft.IdentityModel.Abstractions.dll
H:\reverse eng\ttd\winext\sos\Microsoft.SymbolStore.dll
H:\reverse eng\ttd\winext\sos\sos.dll
H:\reverse eng\ttd\winext\sos\SOS.Extensions.dll
H:\reverse eng\ttd\winext\sos\SOS.Hosting.dll
H:\reverse eng\ttd\winext\sos\SOS.InstallHelper.dll
H:\reverse eng\ttd\winext\sos\System.Buffers.dll
H:\reverse eng\ttd\winext\sos\System.ClientModel.dll
H:\reverse eng\ttd\winext\sos\System.Collections.Immutable.dll
H:\reverse eng\ttd\winext\sos\System.CommandLine.dll
H:\reverse eng\ttd\winext\sos\System.ComponentModel.Annotations.dll
H:\reverse eng\ttd\winext\sos\System.Diagnostics.DiagnosticSource.dll
H:\reverse eng\ttd\winext\sos\System.IO.FileSystem.AccessControl.dll
H:\reverse eng\ttd\winext\sos\System.Memory.Data.dll
H:\reverse eng\ttd\winext\sos\System.Memory.dll
H:\reverse eng\ttd\winext\sos\System.Numerics.Vectors.dll
H:\reverse eng\ttd\winext\sos\System.Reflection.Metadata.dll
H:\reverse eng\ttd\winext\sos\System.Runtime.CompilerServices.Unsafe.dll
H:\reverse eng\ttd\winext\sos\System.Runtime.Loader.dll
H:\reverse eng\ttd\winext\sos\System.Security.AccessControl.dll
H:\reverse eng\ttd\winext\sos\System.Security.Cryptography.ProtectedData.dll
H:\reverse eng\ttd\winext\sos\System.Security.Principal.Windows.dll
H:\reverse eng\ttd\winext\sos\System.Text.Encodings.Web.dll
H:\reverse eng\ttd\winext\sos\System.Text.Json.dll
H:\reverse eng\ttd\winext\sos\System.Threading.Tasks.Extensions.dll
H:\reverse eng\ttd\winext\acxkd.dll
H:\reverse eng\ttd\winext\bthkd.dll
H:\reverse eng\ttd\winext\CLRComposition.dll
H:\reverse eng\ttd\winext\CrashpadComposition.dll
H:\reverse eng\ttd\winext\DbgEngCoreDMExt.dll
H:\reverse eng\ttd\winext\DbgModelApiXtn.dll
H:\reverse eng\ttd\winext\DbgShim.dll
H:\reverse eng\ttd\winext\dwarf.dll
H:\reverse eng\ttd\winext\ELFBinComposition.dll
H:\reverse eng\ttd\winext\ext.dll
H:\reverse eng\ttd\winext\GDBServerComposition.dll
H:\reverse eng\ttd\winext\gpiokd.dll
H:\reverse eng\ttd\winext\hidkd.dll
H:\reverse eng\ttd\winext\i3ckd.dll
H:\reverse eng\ttd\winext\jscript9diagdump.dll
H:\reverse eng\ttd\winext\JsProvider.dll
H:\reverse eng\ttd\winext\kext.dll
H:\reverse eng\ttd\winext\LinuxUserXtn.dll
H:\reverse eng\ttd\winext\MachOBinComposition.dll
H:\reverse eng\ttd\winext\Microsoft.Diagnostics.Analysis.Utilities.dll
H:\reverse eng\ttd\winext\NTSnapshotComposition.dll
H:\reverse eng\ttd\winext\OpenEnclaveComposition.dll
H:\reverse eng\ttd\winext\PEBinComposition.dll
H:\reverse eng\ttd\winext\rcdrkd.dll
H:\reverse eng\ttd\winext\RemoteSourceComposition.dll
H:\reverse eng\ttd\winext\SmFxDbg.dll
H:\reverse eng\ttd\winext\storagekd.dll
H:\reverse eng\ttd\winext\uext.dll
H:\reverse eng\ttd\winext\usb3kd.dll
H:\reverse eng\ttd\winext\usb4kd.dll
H:\reverse eng\ttd\winext\usbkd.dll
H:\reverse eng\ttd\winext\wdfkd.dll
H:\reverse eng\ttd\winxp\acpikd.dll
H:\reverse eng\ttd\winxp\exts.dll
H:\reverse eng\ttd\winxp\fltkd.dll
H:\reverse eng\ttd\winxp\kdexts.dll
H:\reverse eng\ttd\winxp\ks.dll
H:\reverse eng\ttd\winxp\minipkd.dll
H:\reverse eng\ttd\winxp\ndiskd.dll
H:\reverse eng\ttd\winxp\ntsdexts.dll
H:\reverse eng\ttd\winxp\nvkd.dll
H:\reverse eng\ttd\winxp\rpcexts.dll
H:\reverse eng\ttd\winxp\scsikd.dll
H:\reverse eng\ttd\winxp\wmiTrace.dll
H:\reverse eng\ttd\winxp\wow64exts.dll
H:\reverse eng\ttd\winxp\WudfExt.dll
H:\reverse eng\ttd\dbgcore.dll
H:\reverse eng\ttd\DbgCredentialProvider.dll
H:\reverse eng\ttd\dbgeng.dll
H:\reverse eng\ttd\dbghelp.dll
H:\reverse eng\ttd\dbgmodel.dll
H:\reverse eng\ttd\ExdiGdbSrv.dll
H:\reverse eng\ttd\msdia140.dll
H:\reverse eng\ttd\srcsrv.dll
H:\reverse eng\ttd\symsrv.dll

@MichaelEbert
Copy link
Author

sys.version
'3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)]'

@d-millar
Copy link
Collaborator

@MichaelEbert Do you have the latest version of pybag installed?

@MichaelEbert
Copy link
Author

I have tried with pybag Version: 2.2.13 and pybag 2.2.15. Same error with both.

@d-millar
Copy link
Collaborator

Actually, I guess that might not be relevant - apologies. This logic has recently changed, and bouncing between the two means I’m frequently adled.

There are better(-ish) directions here:

https://github.com/d-millar/ghidra-debugger-how-to/blob/main/tips/using_pyttd.md

Let me know if these don’t help. You may also want to consider downloading and building the latest from master, as the dependency on pyttd has been removed, and the newer code is cleaner. New launcher is local-dbgeng-trace.

Still bear in mind this code is under active development.

@MichaelEbert
Copy link
Author

I will try building master.

@d-millar
Copy link
Collaborator

Cool - let us know if you have issues. I will take a stab at running your exact setup tomorrow to see if I can recreate your error. It does certainly look like dbgmodel is undefined. Possibly untested, given it’s in the exception block, but I would have expected that to have been hit after least once.

@d-millar
Copy link
Collaborator

@MichaelEbert So, re-running with 11.3.1, there does appear to be a bug in the code, but I'm not sure it relates directly to what you're seeing. In particular, the file Ghidra\Debug\Debugger-agent-dbgeng\pypkg\src\ghidrattd\methods.py has a half dozen of so references to "@util.dbg.eng_thread" copied from ghidradbg\methods.py that should not be in there. (ghidrattd's util.py has no dbg.) Those lines, all of which appear as annotations on method definitions, can be deleted.

After deleting them, I was able to run successfully. That said, this seems unrelated to the undefined "dbgmodel" reference. If you have moved successfully to the version in master, I would stick with that, but, if you still are looking to get the 11.3.1 version working, I would (a) check the pyttd install per the reference above, and (b) see if the 'normal' dbgeng agent it working correctly with "dbgmodel" selected in the the dialog. Also, what version of python are you running and is that a match for the version used in pyttd?

@MichaelEbert
Copy link
Author

Looks like 11.4 solved the issue!

@d-millar
Copy link
Collaborator

Excellent - glad to hear!

@ryanmkurtz ryanmkurtz removed the Status: Waiting on customer Waiting for customer feedback label Mar 25, 2025
@ryanmkurtz ryanmkurtz added this to the 11.4 milestone Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants