Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions plugins/cvutils-getoffset.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

major, minor = map(int, idaapi.get_kernel_version().split("."))
using_ida7api = (major > 6)
using_pyqt5 = using_ida7api or (major == 6 and minor >= 9)

idaver_74newer = (major == 7 and minor >= 4)
idaver_8newer = (major >= 8)
IDA_9_2_PLUS = (major > 9) or (major == 9 and minor >= 2)

if idaver_74newer or idaver_8newer:
newer_version_compatible = True
Expand All @@ -29,6 +29,13 @@

IDA_9 = (major >= 9)

if IDA_9_2_PLUS:
using_pyside6 = True
using_pyqt5 = False
else:
using_pyside6 = False
using_pyqt5 = using_ida7api or (major == 6 and minor >= 9)

if newer_version_compatible:
# IDA 7.4+
# https://hex-rays.com/products/ida/support/ida74_idapython_no_bc695_porting_guide.shtml
Expand All @@ -46,12 +53,16 @@
BWN_PSEUDOCODE = idaapi.BWN_PSEUDOCODE
SETMENU_APP = idaapi.SETMENU_APP

if using_pyqt5:
if using_pyside6:
import PySide6.QtGui as QtGui
import PySide6.QtCore as QtCore
import PySide6.QtWidgets as QtWidgets
from PySide6.QtWidgets import QApplication
elif using_pyqt5:
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from PyQt5.Qt import QApplication

else:
import PySide.QtGui as QtGui
import PySide.QtCore as QtCore
Expand All @@ -63,8 +74,12 @@

def setClipboardText(data):
cb = QApplication.clipboard()
cb.clear(mode=cb.Clipboard)
cb.setText(data, mode=cb.Clipboard)
if using_pyside6:
cb.clear(mode=QtGui.QClipboard.Mode.Clipboard)
cb.setText(data, mode=QtGui.QClipboard.Mode.Clipboard)
else:
cb.clear(mode=cb.Clipboard)
cb.setText(data, mode=cb.Clipboard)


def PLUGIN_ENTRY():
Expand Down
33 changes: 16 additions & 17 deletions plugins/cvutils-gotooffset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# IDA Plugin to jump to an offset from the Imagebase.
# Copy the 'cvutils-getoffset.py' into the plugins directory of IDA
# Copy the 'cvutils-gotooffset.py' into the plugins directory of IDA
#------------------------------------------------------------------------------

VERSION = '1.1.0'
Expand All @@ -9,48 +9,55 @@
PLUGIN_NAME = "Go To Offset"
PLUGIN_HOTKEY = "Shift+G"



import os
import sys
import idc
import idaapi
import idautils
import string


major, minor = map(int, idaapi.get_kernel_version().split("."))
using_ida7api = (major > 6)
using_pyqt5 = using_ida7api or (major == 6 and minor >= 9)

idaver_74newer = (major == 7 and minor >= 4)
idaver_8newer = (major >= 8)
IDA_9_2_PLUS = (major > 9) or (major == 9 and minor >= 2)

if idaver_74newer or idaver_8newer:
newer_version_compatible = True
else:
newer_version_compatible = False

if IDA_9_2_PLUS:
using_pyside6 = True
using_pyqt5 = False
else:
using_pyside6 = False
using_pyqt5 = using_ida7api or (major == 6 and minor >= 9)

if newer_version_compatible:
#IDA 7.4+
#https://hex-rays.com/products/ida/support/ida74_idapython_no_bc695_porting_guide.shtml
import ida_ida
import ida_kernwin

if using_pyqt5:
if using_pyside6:
import PySide6.QtGui as QtGui
import PySide6.QtCore as QtCore
import PySide6.QtWidgets as QtWidgets
from PySide6.QtWidgets import QApplication
elif using_pyqt5:
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from PyQt5.Qt import QApplication

else:
import PySide.QtGui as QtGui
import PySide.QtCore as QtCore
QtWidgets = QtGui
QtCore.pyqtSignal = QtCore.Signal
QtCore.pyqtSlot = QtCore.Slot
from PySide.QtGui import QApplication



def PLUGIN_ENTRY():
Expand Down Expand Up @@ -94,22 +101,18 @@ def term(self):
This is called by IDA when it is unloading the plugin.
"""


# unregister our actions & free their resources
self._del_action_goto_offset()


# done
idaapi.msg("%s terminated...\n" % self.wanted_name)


#--------------------------------------------------------------------------
# IDA Actions
#--------------------------------------------------------------------------

ACTION_GET_OFFSET = "prefix:goto_offset"


def _init_action_goto_offset(self):
"""
Register the copy bytes action with IDA.
Expand All @@ -136,11 +139,9 @@ def _init_action_goto_offset(self):
31 # Copy icon
)


# register the action with IDA
assert idaapi.register_action(action_desc), "Action registration failed"


def _del_action_goto_offset(self):
"""
Delete the bulk prefix action from IDA.
Expand All @@ -165,7 +166,6 @@ def jump_to_address(jump_address):
else:
idc.Jump(jump_address)


#------------------------------------------------------------------------------
# Image Min EA
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -213,7 +213,6 @@ def isvalid_address(ea):

return 1


#------------------------------------------------------------------------------
# Go to offset
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -268,4 +267,4 @@ def activate(self, ctx):
return 1

def update(self, ctx):
return idaapi.AST_ENABLE_ALWAYS
return idaapi.AST_ENABLE_ALWAYS