GregoryMorse / GhidraDec

Ghidra Decompiler Plugin for IDA Pro
MIT License
163 stars 29 forks source link

Decompilation error: Read pipe is bad #7

Open greenozon opened 2 years ago

greenozon commented 2 years ago

During usage of the plugin ver 0.4 and Ghidra ver ghidra_10.1.5_PUBLIC I"ve got the following error:

Caught decompilation error: Read pipe is bad

OS: W7 x64 file: x86 coff

full ogs:

[GhidraDec info]   :    Working on input file "c:\tmp\t1.obj".
Conflicting shortcut: Ctrl+G; Candidate actions:
    Edit/Plugins/Ghidra Decompiler Plugin (Ghidra Decompiler Plugin)
    JumpSegmentRegister (Jump to se&gment register...)
Executing action: Edit/Plugins/Ghidra Decompiler Plugin (Ghidra Decompiler Plugin)
[GhidraDec info]   :    Found decompile.exe at C:\ghidra_10.1.5_PUBLIC/Ghidra/Features/Decompiler/os/win_x86_64/ -> plugin is properly configured.
[GhidraDec info]   :    Working on input file "c:\tmp\t1.obj".
[GhidraDec info]   :    Running Ghidra decompiler plugin:
[GhidraDec info]   :    Saving IDA database ...
Flushing buffers, please wait...ok
[GhidraDec info]   :    IDA database saved into :  c:\tmp\t1.obj.dec-backup.idb
[GhidraDec info]   :    Generating retargetable decompilation DB ...
[GhidraDec info]   :    Decompile input ...
[GhidraDec info]   :    Decompilation command: C:\ghidra_10.1.5_PUBLIC/Ghidra/Features/Decompiler/os/win_x86_64/decompile.exe
[GhidraDec info]   :    Running the decompilation command ...
[GhidraDec info]   :    Detected Processor spec: C:\ghidra_10.1.5_PUBLIC/Ghidra/Processors\x86/data/languages/x86.pspec Compiler spec: C:\ghidra_10.1.5_PUBLIC/Ghidra/Processors\x86/data/languages/x86win.cspec Sleigh file: C:\ghidra_10.1.5_PUBLIC/Ghidra/Processors\x86/data/languages/x86.sla
[GhidraDec info]   :    Local decompilation ...
[GhidraDec info]   :    Decompiling function:  @ 0
[GhidraDec info]   :    Caught decompilation error: Read pipe is bad
[GhidraDec info]   :    Decompilation completed:  in 17 seconds
GregoryMorse commented 2 years ago

It has not been tested with 10.1.5 but if anything in the protocol changed, or if any bug in handling various complicated parts of the protocol between the decompiler and the plugin occurs, this is exactly what would happen. Have you tried with 10.1.2? If it doesnt work with the older version, probably need a sample. There is a debug mode which logs all the details of protocol communication. I think in a future release, this should be an option on the GUI, so the debug logs can be submitted here as often just seeing the textual view of the protocol makes it quite obvious what the bug is and how to fix it.

greenozon commented 2 years ago

Just gave it a try for 10.1.2 - same error How could I enable debug mode?

GregoryMorse commented 2 years ago

It requires PRINT_DEBUG to be defined when compiling due to the logging to fixed paths in: https://github.com/GregoryMorse/GhidraDec/blob/master/decompiler.cpp

Really the path for the logfiles should be on the GUI, and if it's a non-empty path, it should just always log there. It prints a detailed but human readable file of all protocol activity between the plugin and the decompiler. This should be fixed for next version, as the bug you are reporting is the most common - namely that some part of the protocol is not handled correctly, so far these have been minor and easy to fix.

greenozon commented 2 years ago

Thanks Looks like building the final bits is not that straightforward as I was expecting :)

Some show stoppers (not all) that I'd like to ask about (Using MSVC 2019 x64 build)

1) image

2) image

Build started...
1>------ Build started: Project: GhidraDecIface, Configuration: Debug x64 ------
1>GhidraDecIface.cpp
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620): error C2259: 'MyCallback': cannot instantiate abstract class
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(371): message : see declaration of 'MyCallback'
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620): message : due to following members:
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620): message : 'std::vector<uchar,std::allocator<uchar>> DecompileCallback::getStringData(AddrInfo)': is abstract
1>c:\Dev\re\GhidraDec-master\sleighinterface.h(260): message : see declaration of 'DecompileCallback::getStringData'
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620,33): error C2259: 'MyCallback': cannot instantiate abstract class
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(371): message : see declaration of 'MyCallback'
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620,33): message : due to following members:
1>c:\Dev\re\GhidraDec-master\GhidraDecIface.cpp(620,33): message : 'std::vector<uchar,std::allocator<uchar>> DecompileCallback::getStringData(AddrInfo)': is abstract
1>c:\Dev\re\GhidraDec-master\sleighinterface.h(260): message : see declaration of 'DecompileCallback::getStringData'
1>Done building project "GhidraDecIface.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
greenozon commented 2 years ago

I've got another question (besidse above errors) - how to build the x32 IDA plugin in VisualStudio? looks like it builds only x64 one?

greenozon commented 2 years ago

@GregoryMorse any news on the topic please...

Ideally, add support for new 10.2.x branch