MCPcopy
hub / github.com/keystone-engine/keypatch / init

Method init

keypatch.py:1477–1534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1475 self.opts['c_opt_chk'] = self.opts['c_opt_padding'] | self.opts['c_opt_comment']
1476
1477 def init(self):
1478 global kp_initialized
1479
1480 # register popup menu handlers
1481 try:
1482 Kp_MC_Patcher.register(self, "Patcher (Ctrl-Alt-K)")
1483 Kp_MC_Fill_Range.register(self, "Fill Range")
1484 Kp_MC_Undo.register(self, "Undo last patching")
1485 Kp_MC_Search.register(self, "Search")
1486 Kp_MC_Updater.register(self, "Check for update")
1487 Kp_MC_About.register(self, "About")
1488 except:
1489 pass
1490
1491 # setup popup menu
1492 self.hooks = Hooks()
1493 self.hooks.hook()
1494
1495 self.opts = None
1496 if kp_initialized == False:
1497 kp_initialized = True
1498 # add Keypatch menu
1499 menu = idaapi.add_menu_item("Edit/Keypatch/", "Patcher (Ctrl-Alt-K)", "", 1, self.patcher, None)
1500 if menu is not None:
1501 idaapi.add_menu_item("Edit/Keypatch/", "About", "", 1, self.about, None)
1502 idaapi.add_menu_item("Edit/Keypatch/", "Check for update", "", 1, self.updater, None)
1503 idaapi.add_menu_item("Edit/Keypatch/", "-", "", 1, self.menu_null, None)
1504 idaapi.add_menu_item("Edit/Keypatch/", "Search", "", 1, self.search, None)
1505 idaapi.add_menu_item("Edit/Keypatch/", "-", "", 1, self.menu_null, None)
1506 idaapi.add_menu_item("Edit/Keypatch/", "Undo last patching", "", 1, self.undo, None)
1507 idaapi.add_menu_item("Edit/Keypatch/", "Fill Range", "", 1, self.fill_range, None)
1508 elif idaapi.IDA_SDK_VERSION < 680:
1509 # older IDAPython (such as in IDAPro 6.6) does add new submenu.
1510 # in this case, put Keypatch menu in menu Edit \ Patch program
1511 # not sure about v6.7, so to be safe we just check against v6.8
1512 idaapi.add_menu_item("Edit/Patch program/", "-", "", 0, self.menu_null, None)
1513 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: About", "", 0, self.about, None)
1514 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: Check for update", "", 0, self.updater, None)
1515 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: Search", "", 0, self.search, None)
1516 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: Undo last patching", "", 0, self.undo, None)
1517 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: Fill Range", "", 0, self.fill_range, None)
1518 idaapi.add_menu_item("Edit/Patch program/", "Keypatch:: Patcher (Ctrl-Alt-K)", "", 0, self.patcher, None)
1519
1520 print("=" * 80)
1521 print("Keypatch v{0} (c) Nguyen Anh Quynh & Thanh Nguyen, 2016".format(VERSION))
1522 print("Keypatch is using Keystone v{0}".format(keystone.__version__))
1523 print("Keypatch Patcher's shortcut key is Ctrl-Alt-K")
1524 print("Use the same hotkey Ctrl-Alt-K to open 'Fill Range' window on a selected range of code")
1525 print("To revert (undo) the last patching, choose menu Edit | Keypatch | Undo last patching")
1526 print("Keypatch Search is available from menu Edit | Keypatch | Search")
1527 print("Find more information about Keypatch at http://keystone-engine.org/keypatch")
1528
1529 self.load_configuration()
1530
1531 print("=" * 80)
1532 self.kp_asm = Keypatch_Asm()
1533
1534 return idaapi.PLUGIN_KEEP

Callers

nothing calls this directly

Calls 4

load_configurationMethod · 0.95
HooksClass · 0.85
Keypatch_AsmClass · 0.85
registerMethod · 0.80

Tested by

no test coverage detected