wbenny / pdbex

pdbex is a utility for reconstructing structures and unions from the PDB into compilable C headers
MIT License
814 stars 160 forks source link

Silent failure, incorrect LoadDiaViaLoadLibrary return value #17

Closed m417z closed 4 years ago

m417z commented 4 years ago

On my computer, both LoadDiaViaCoCreateInstance and LoadDiaViaLoadLibrary fail. It took me a while to understand that, had to debug a bit. That's because LoadDiaViaLoadLibrary returns FALSE on an error, but the return type is HRESULT, so it essentially returns S_OK.

m417z commented 4 years ago

I see it was already reported: https://github.com/wbenny/pdbex/issues/7 https://github.com/wbenny/pdbex/issues/11

Sorry for reporting it again. But at least it's fixed now due to my reminder :)

I'd also join to @hfiref0x's comment about having a descriptive diagnostic if the DIA library can't be loaded:

I would additionally add more diagnostic messages in case if required dlls are missing of having diffrent machine type (Result = HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT) : %1 is not a valid Win32 application. ).

Right now it'll say "file not found" (instead of crashing), but it's quite confusing because the PDB file path is not the culprit in this case.