mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge branch 'GP-5873_ryanmkurtz_PR-8450_ZERO-A-ONE_ida9' (Closes #8450)
This commit is contained in:
commit
09e625f5fe
4 changed files with 63 additions and 67 deletions
|
@ -1,17 +1,17 @@
|
|||
## ###
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#---------------------------------------------------------------------
|
||||
# xmlldr.py - IDA XML loader
|
||||
|
@ -31,11 +31,6 @@ import idaxml
|
|||
import idc
|
||||
import sys
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
from idaxml import _exc_info
|
||||
sys.exc_value = lambda: _exc_info()[1]
|
||||
sys.exc_type = lambda: _exc_info()[0]
|
||||
|
||||
"""
|
||||
Loader functions
|
||||
"""
|
||||
|
@ -96,10 +91,10 @@ def load_file(li, neflags, format):
|
|||
msg += "\nimporting multiple address spaces."
|
||||
print("\n" + msg)
|
||||
idc.warning(msg)
|
||||
except:
|
||||
except Exception as e:
|
||||
print("\nHouston, we have a problem!")
|
||||
msg = "***** Exception occurred: XML loader failed! *****"
|
||||
print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
|
||||
print(f"\n{msg}\n{type(e).__name__}: {e}")
|
||||
print(event, element.tag, element.attrib)
|
||||
idc.warning(msg)
|
||||
finally:
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
## ###
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#---------------------------------------------------------------------
|
||||
# xmlexp.py - IDA XML Exporter plugin
|
||||
|
@ -30,10 +30,6 @@ import idaxml
|
|||
import idc
|
||||
import sys
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
from idaxml import _exc_info
|
||||
sys.exc_value = lambda: _exc_info()[1]
|
||||
sys.exc_type = lambda: _exc_info()[0]
|
||||
|
||||
class XmlExporterPlugin(ida_idaapi.plugin_t):
|
||||
"""
|
||||
|
@ -79,10 +75,10 @@ class XmlExporterPlugin(ida_idaapi.plugin_t):
|
|||
msg = "XML Export cancelled!"
|
||||
print("\n" + msg)
|
||||
idc.warning(msg)
|
||||
except:
|
||||
except Exception as e:
|
||||
ida_kernwin.hide_wait_box()
|
||||
msg = "***** Exception occurred: XML Exporter failed! *****"
|
||||
print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
|
||||
print(f"\n{msg}\n {type(e).__name__}: {e}")
|
||||
idc.warning(msg)
|
||||
finally:
|
||||
xml.cleanup()
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
## ###
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# IP: GHIDRA
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
#---------------------------------------------------------------------
|
||||
# xmlimp.py - IDA XML Importer plugin
|
||||
|
@ -24,16 +24,12 @@ The file idaxml.py must be placed in the IDA python directory.
|
|||
|
||||
from __future__ import print_function
|
||||
import ida_idaapi
|
||||
import ida_kernwin
|
||||
import ida_pro
|
||||
import idaxml
|
||||
import idc
|
||||
import sys
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
from idaxml import _exc_info
|
||||
sys.exc_value = lambda: _exc_info()[1]
|
||||
sys.exc_type = lambda: _exc_info()[0]
|
||||
|
||||
class XmlImporterPlugin(ida_idaapi.plugin_t):
|
||||
"""
|
||||
XML Importer plugin class
|
||||
|
@ -82,9 +78,10 @@ class XmlImporterPlugin(ida_idaapi.plugin_t):
|
|||
msg += "\nimporting multiple address spaces."
|
||||
print("\n" + msg)
|
||||
idc.warning(msg)
|
||||
except:
|
||||
except Exception as e:
|
||||
ida_kernwin.hide_wait_box()
|
||||
msg = "***** Exception occurred: XML Importer failed! *****"
|
||||
print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
|
||||
print(f"\n{msg}\n{type(e).__name__}: {e}")
|
||||
idc.warning(msg)
|
||||
finally:
|
||||
xml.cleanup()
|
||||
|
|
|
@ -90,7 +90,8 @@ def is_ida_version_supported():
|
|||
|
||||
def get_struc(sid: int) -> Optional[ida_typeinf.tinfo_t]:
|
||||
try:
|
||||
tif = ida_typeinf.tinfo_t(tid=sid)
|
||||
tif = ida_typeinf.tinfo_t()
|
||||
tif.get_type_by_tid(tid=sid)
|
||||
return tif if tif.is_udt() else None
|
||||
except ValueError:
|
||||
return None
|
||||
|
@ -139,7 +140,8 @@ def get_struc_qty():
|
|||
|
||||
def get_enum_member_tid(eid: int, i: int) -> int:
|
||||
try:
|
||||
tif = ida_typeinf.tinfo_t(tid=eid)
|
||||
tif = ida_typeinf.tinfo_t()
|
||||
tif.get_type_by_tid(tid=eid)
|
||||
except ValueError:
|
||||
return BADADDR
|
||||
edm = ida_typeinf.edm_t()
|
||||
|
@ -152,7 +154,8 @@ def find_enum_member_serial(enum_id: int, member_value: int, member_name: str):
|
|||
Returns -1 on failure.
|
||||
"""
|
||||
try:
|
||||
tif = ida_typeinf.tinfo_t(tid=enum_id)
|
||||
tif = ida_typeinf.tinfo_t()
|
||||
tif.get_type_by_tid(tid=enum_id)
|
||||
except ValueError:
|
||||
return -1
|
||||
ei = ida_typeinf.enum_type_data_t()
|
||||
|
@ -980,7 +983,9 @@ class XmlExporter(IdaXml):
|
|||
#if bf:
|
||||
# self.write_attribute(BIT_FIELD, "yes")
|
||||
regcmt = idc.get_enum_cmt(eid)
|
||||
rptcmt = ida_typeinf.tinfo_t(tid=eid).get_type_rptcmt()
|
||||
tif = ida_typeinf.tinfo_t()
|
||||
tif.get_type_by_tid(tid=eid)
|
||||
rptcmt = tif.get_type_rptcmt()
|
||||
has_children = ((idc.get_enum_size(eid) > 0) or
|
||||
(regcmt is not None) or (rptcmt is not None) or
|
||||
(ida_bytes.get_radix(eflags, 0) != 16) or
|
||||
|
@ -2201,6 +2206,9 @@ class XmlExporter(IdaXml):
|
|||
signedhex: Boolean indicating if hex representation of
|
||||
value is signed.
|
||||
"""
|
||||
# Check if value is None and handle it gracefully
|
||||
if value is None:
|
||||
return
|
||||
if base == 10:
|
||||
temp = "%d" % value
|
||||
else:
|
||||
|
@ -2721,9 +2729,9 @@ class XmlImporter(IdaXml):
|
|||
if ea == BADADDR:
|
||||
idc.put_bookmark(addr, 0, 0, 0, slot, description)
|
||||
break
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
msg = "** Exception occurred in import_bookmark **"
|
||||
print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
|
||||
print(f"\n{msg}\n{type(e).__name__}: {e}")
|
||||
|
||||
|
||||
def import_cmts(self, element, sid, typ):
|
||||
|
@ -3055,9 +3063,9 @@ class XmlImporter(IdaXml):
|
|||
register_vars = function.findall(REGISTER_VAR)
|
||||
for register_var in register_vars:
|
||||
self.import_register_var(register_var, func)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
msg = "** Exception occurred in import_function **"
|
||||
print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
|
||||
print(f"\n{msg}\n{type(e).__name__}: {e}")
|
||||
|
||||
|
||||
def import_function_def(self, function_def):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue