Tutorial Tutorial Icons-plugin loader-widgets 2 of 3(plugin loader with Icon)

Storm Shadow

Administrator
Staff member
Developer
Ida Pro Expert
Elite Cracker
Now we got the icons sorted out in the last tut.
http://www.techbliss.org/threads/tutorial-icons-plugin-loader-widgets-1-of-3-icons.726/

We can continue to the plugin loader.
We in this tut are gonna make a plugin loader that have icons when displayed and important,find the Icons folder, where we have the icons and main widget from within ida pro.
we use the hex-ray method of making python plugins but with some twitched :)
http://www.hexblog.com/?p=120



ill explain in the code with quotes.
Notice we dobt have to free the icons as explained in the virustotal plugin.

tutloader.py
Python:
# Created by: Storm Shadow http://www.techbliss.org
 
# WARNING! All changes made in this file will be lost!
 
import idaapi
from idaapi import *
import sys
sys.path.insert(0 , idaapi.idadir("plugins\\Hellowidget\\icons")) #since ida pro always know its own root folder this will find the icons folder
import icons #import the icons.py file
from icons import * #import the icons from the resource file(icons)
 
class tutclass(idaapi.plugin_t):
	flags = idaapi.PLUGIN_FIX
	comment = "This is a comment"
 
	help = "Hello Widget"
	wanted_name = "Hello Widget"
	wanted_hotkey = ""
 
 
 
	def init(self):
		idaapi.msg("Hello Widget is found \nUse hotkey Ctrl-H \nfind it in the  File Menu \n") #dispplays when ida is started and plugin is found
		return idaapi.PLUGIN_OK
 
 
	def run(self, arg):
		idaapi.msg("run() called with %d!\n" % arg)
 
	def term(self):
		idaapi.msg("")
 
 
 
	def AddMenuElements(self):
		idaapi.add_menu_item("File/", "Hello Widget", "Ctrl-H", 0, self.Loadwidget, ()) #add menu and load the function Loadwidget
		idaapi.set_menu_item_icon("File/Hello Widget", idaapi.load_custom_icon(":/ico/appbar.adobe.prelude.png"))
		#add icon name from icons.py NOTICE the colon in ":/ico/appbar.adobe.prelude.png")
		#colon tells app it from resource
		#also we use the prefix we had when we made the resources file aka /:ico/
 
 
 
 
	def run(self, arg = 0):
		idaapi.msg("Hello Widget Loaded Shortcut Ctrl+H to Load")
		self.AddMenuElements()
 
	def Loadwidget(self):
		g = globals()
		idahome = idaapi.idadir("plugins\\Hellowidget" )#idahome = idaapi.idadir("plugins\\Hellowidget")
		# #we add this so it will find the path for the main plugin
		IDAPython_ExecScript(idahome +  "\\Mainwidget.py", g) )#this is the main PyQt widget
 
 
 
 
def PLUGIN_ENTRY():
	return tutclass()


Breef explainations is we insert path to icons folder so we can import the icons.py file.
We then paint the pluign loader etc code and name messages and hot keys.
Very important is the prefix and the colon where we set the icon.
colon says its from a resource and :/ico
these prefix have to have the same prefix as the resource file in last tut.
rest is pretty selfexplained.but feel free to ask.


if you notice in the file package the __init__.py files
it simply teels python that this folder is part of a package and can be empty.
so if you have a folder add the __init.py file.
but overall notice the folder structure of the plugin, compared with code.
icons folder and have to match the real folders.

Python:
sys.path.insert(0 , idaapi.idadir("plugins\\Hellowidget\\icons"))

Okay we test to see if plugin loader is added to python.
Extract files from project in ida/plugins folder.(download below).
some time you have to go and add the hot keys your self for next run.

Open ida and goto Options and shortcuts.

and add same hotkey as you have in code.

5ZDKcsP.png

Lets test to see if its works.

eYEEAYI.png

Yep
plugin added and it have a icon Yeeehh.

Remember you can add more menus and icons here,
and call functions you added direct here.
example
call command strait from menu.
Code:
def Loadwidget(self):
	help("idaapi")
So you can add alot of menus and icons here.

We wanna add a main PyQt4 widget insteed.
Now for the main plugin.
 

Attachments

  • plugins.zip
    1 MB · Views: 5
Last edited:
Top