1
1
import os
2
- import sys
3
- import locale
4
2
import subprocess
5
3
import pythoncom
6
4
import idaapi
7
5
import idautils
8
6
import idc
7
+ import ida_nalt
9
8
10
9
invokekinds = {
11
10
pythoncom .INVOKE_FUNC : "func" ,
68
67
p_initialized = False
69
68
70
69
71
- class ComHelperResultChooser (idaapi .Choose2 ):
70
+ class ComHelperResultChooser (idaapi .Choose ):
72
71
def __init__ (self ,
73
72
title ,
74
73
items ,
@@ -77,13 +76,13 @@ def __init__(self,
77
76
height = None ,
78
77
embedded = False ,
79
78
modal = False ):
80
- idaapi .Choose2 .__init__ (
79
+ idaapi .Choose .__init__ (
81
80
self ,
82
81
title , [
83
- ["Address" , idaapi .Choose2 . CHCOL_HEX | 10 ],
84
- ["Function" , idaapi .Choose2 . CHCOL_PLAIN | 25 ],
85
- ["Parent" , idaapi .Choose2 . CHCOL_PLAIN | 25 ],
86
- ["Desc" , idaapi .Choose2 . CHCOL_PLAIN | 40 ],
82
+ ["Address" , idaapi .CHCOL_HEX | 10 ],
83
+ ["Function" , idaapi .CHCOL_PLAIN | 25 ],
84
+ ["Parent" , idaapi .CHCOL_PLAIN | 25 ],
85
+ ["Desc" , idaapi .CHCOL_PLAIN | 40 ],
87
86
],
88
87
flags = flags ,
89
88
width = width ,
@@ -98,7 +97,7 @@ def OnClose(self):
98
97
99
98
def OnSelectLine (self , n ):
100
99
self .selcount += 1
101
- idc .Jump (self .items [n ][0 ])
100
+ idc .jumpto (self .items [n ][0 ])
102
101
103
102
def OnGetLine (self , n ):
104
103
res = self .items [n ]
@@ -113,9 +112,9 @@ def show(self):
113
112
return self .Show () >= 0
114
113
115
114
116
- #--------------------------------------------------------------------------
115
+ # --------------------------------------------------------------------------
117
116
# Plugin
118
- #--------------------------------------------------------------------------
117
+ # --------------------------------------------------------------------------
119
118
class Comhelper_Plugin_t (idaapi .plugin_t ):
120
119
comment = "Comhelper plugin for IDA Pro"
121
120
help = "Comhelper"
@@ -147,15 +146,14 @@ def get_com_vas(self, dllpath, clsid, iid, count):
147
146
toolpath = os .path .join (BASE_DIR , toolname )
148
147
try :
149
148
ret = subprocess .check_output (
150
- [toolpath , dllpath , clsid , iid , count ], shell = True )
151
- except subprocess .CalledProcessError , e :
149
+ [toolpath , dllpath , clsid , iid , count ], shell = True ). decode ( 'ascii' )
150
+ except subprocess .CalledProcessError as e :
152
151
return [
153
152
'LoadDll fail' , 'GetProc fail' , 'GetClass fail' ,
154
153
'CreateInstance fail'
155
- ][e .returncode - 1 ] + ' for clsid:{} iid:{}' .format (clsid ,iid )
154
+ ][e .returncode - 1 ] + ' for clsid:{} iid:{}' .format (clsid , iid )
156
155
vas = []
157
156
imagebase = ida_nalt .get_imagebase ()
158
-
159
157
for rvahex in ret .split ('\n ' ):
160
158
rvahex = rvahex .strip ()
161
159
if rvahex :
@@ -169,7 +167,7 @@ def search(self):
169
167
'DllUnregisterServer' , 'DllEntryPoint' , 'DllGetClassObject' ,
170
168
'DllCanUnloadNow' , 'DllRegisterServer'
171
169
])
172
- dllpath = ida_nalt .get_input_file_path (). decode ( 'utf-8' )
170
+ dllpath = ida_nalt .get_input_file_path ()
173
171
if not comexports .issubset (exports ):
174
172
print ('{} is not COM! exports mismatching' .format (dllpath ))
175
173
return
@@ -178,7 +176,6 @@ def search(self):
178
176
except :
179
177
print ('{} is not COM! LoadTypeLib fail' .format (dllpath ))
180
178
return
181
- classes = {}
182
179
values = []
183
180
for i in range (tlb .GetTypeInfoCount ()):
184
181
if tlb .GetTypeInfoType (i ) == pythoncom .TKIND_COCLASS :
@@ -191,8 +188,8 @@ def search(self):
191
188
name = tlb .GetDocumentation (i )[0 ]
192
189
iid = str (attr .iid )
193
190
vas = self .get_com_vas (
194
- dllpath . encode ( locale . getdefaultlocale ()[ 1 ]) , clsid ,
195
- iid , str ( attr . cFuncs ) )
191
+ dllpath , clsid , iid , str ( attr . cFuncs )
192
+ )
196
193
if isinstance (vas , str ):
197
194
print (vas )
198
195
else :
0 commit comments