Skip to content

fix decode error #113

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

Closed
wants to merge 1 commit into from
Closed

fix decode error #113

wants to merge 1 commit into from

Conversation

hanul93
Copy link

@hanul93 hanul93 commented Apr 24, 2025

In my execution environment, I get the following error. So I fixed the decoding part.

Traceback (most recent call last):
  File "test\test_idb.py", line 3, in <module>
    with idb.from_file('NetBase.dll.i64') as db:
  File "c:\Python310\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "test\venv\lib\site-packages\idb\__init__.py", line 33, in from_file
    db.vsParse(buf)
  File "test\venv\lib\site-packages\vstruct\__init__.py", line 145, in vsParse
    self._vsFireCallbacks(fname)
  File "test\venv\lib\site-packages\vstruct\__init__.py", line 88, in _vsFireCallbacks
    callback()
  File "test\venv\lib\site-packages\idb\fileformat.py", line 1199, in pcb_header
    s.inf = Root(self).idainfo
  File "test\venv\lib\site-packages\idb\analysis.py", line 365, in __getattr__
    return field.cast(bytes(v), wordsize=self.idb.wordsize)
  File "test\venv\lib\site-packages\idb\analysis.py", line 96, in inner
    return cast(buf, V, wordsize=wordsize)
  File "test\venv\lib\site-packages\idb\analysis.py", line 74, in cast
    v.vsParse(buf)
  File "test\venv\lib\site-packages\idb\analysis.py", line 636, in vsParse
    self.procname = reader.str(16)
  File "test\venv\lib\site-packages\idb\analysis.py", line 427, in str
    return self.read(size).decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 8: invalid start byte

@williballenthin
Copy link
Owner

this exception indicates that the encountered data isn't what we expect (utf-8 string). the proposed fix hides the error, rather than fixing it. i would rather address the underlying bug.

can you share the idb?

@hanul93
Copy link
Author

hanul93 commented Apr 26, 2025

You are right.
Here is the idb file.
360NetBase.dll.zip

@hanul93
Copy link
Author

hanul93 commented May 2, 2025

I have discovered the cause of this problem.
This problem was due to incorrectly interpreting the structure while analyzing idainfo.
However, the source code in your GitHub repository had no issues.
The problem is that the code in version 0.7.1 uploaded to PyPI is different.

[PyPI] ida/analysis.py:625
if self.version == 700 and self.tag == "IDA":
[GitHub] ida/analysis.py:625
if self.version >= 700 and self.tag == "IDA":

The idb file I sent you was analyzed with IDA Pro v7.7.
Therefore, errors were occurring in my project environment installed through PyPI.

@williballenthin
Copy link
Owner

ah great, thanks for the explanation. i'll push another release to PyPI.

@williballenthin
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants