mirror of
https://github.com/mandiant/capa.git
synced 2026-02-04 11:07:53 -08:00
make read consistent with file object behavior (#1281)
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
- generator: refactor caching and matching #1251 @mike-hunhoff
|
||||
- fix: improve exception handling to prevent IDA from locking up when errors occur #1262 @mike-hunhoff
|
||||
- verify rule metadata using Pydantic #1167 @mr-tz
|
||||
- extractor: make read consistent with file object behavior #1254 @mr-tz
|
||||
|
||||
### Development
|
||||
|
||||
|
||||
@@ -181,11 +181,13 @@ class IDAIO:
|
||||
def read(self, size):
|
||||
ea = ida_loader.get_fileregion_ea(self.offset)
|
||||
if ea == idc.BADADDR:
|
||||
# best guess, such as if file is mapped at address 0x0.
|
||||
ea = self.offset
|
||||
logger.debug("cannot read 0x%x bytes at 0x%x (ea: BADADDR)", size, self.offset)
|
||||
return b""
|
||||
|
||||
logger.debug("reading 0x%x bytes at 0x%x (ea: 0x%x)", size, self.offset, ea)
|
||||
return ida_bytes.get_bytes(ea, size)
|
||||
|
||||
# get_bytes returns None on error, for consistency with read always return bytes
|
||||
return ida_bytes.get_bytes(ea, size) or b""
|
||||
|
||||
def close(self):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user