Skip to content

Commit

Permalink
FIX #2
Browse files Browse the repository at this point in the history
  • Loading branch information
howmp committed Sep 30, 2022
1 parent 0835a43 commit 64bcddb
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 140 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@

1. 安装IDA的时候,要勾选IDAPython

1. 用IDAPython的pip,安装pywin32

默认情况下,使用命令:`C:\python27-x64\Scripts\pip.exe install pywin32`
1. 安装pywin32`pip install pywin32`

1. 将bin目录三个文件复制到插件目录

默认情况下,在这个目录:`C:\Program Files\IDA 7.0\plugins`
默认情况下,在这个目录:`C:\Program Files\IDA 7.6\plugins`

1. 删除或备份插件目录原始的`comhelper.dll``comhelper64.dll`文件

## 更新记录

1. 2022-9-30

1. 支持IDA7.6,支持Python3

1. 2020-4-8

1. 重新编译去除运行库依赖,解决丢失MSVCR90.dll等问题
Expand Down
35 changes: 16 additions & 19 deletions bin/comhelper.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import os
import sys
import locale
import subprocess
import pythoncom
import idaapi
import idautils
import idc
import ida_nalt

invokekinds = {
pythoncom.INVOKE_FUNC: "func",
Expand Down Expand Up @@ -68,7 +67,7 @@
p_initialized = False


class ComHelperResultChooser(idaapi.Choose2):
class ComHelperResultChooser(idaapi.Choose):
def __init__(self,
title,
items,
Expand All @@ -77,13 +76,13 @@ def __init__(self,
height=None,
embedded=False,
modal=False):
idaapi.Choose2.__init__(
idaapi.Choose.__init__(
self,
title, [
["Address", idaapi.Choose2.CHCOL_HEX | 10],
["Function", idaapi.Choose2.CHCOL_PLAIN | 25],
["Parent", idaapi.Choose2.CHCOL_PLAIN | 25],
["Desc", idaapi.Choose2.CHCOL_PLAIN | 40],
["Address", idaapi.CHCOL_HEX | 10],
["Function", idaapi.CHCOL_PLAIN | 25],
["Parent", idaapi.CHCOL_PLAIN | 25],
["Desc", idaapi.CHCOL_PLAIN | 40],
],
flags=flags,
width=width,
Expand All @@ -98,7 +97,7 @@ def OnClose(self):

def OnSelectLine(self, n):
self.selcount += 1
idc.Jump(self.items[n][0])
idc.jumpto(self.items[n][0])

def OnGetLine(self, n):
res = self.items[n]
Expand All @@ -113,9 +112,9 @@ def show(self):
return self.Show() >= 0


#--------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Plugin
#--------------------------------------------------------------------------
# --------------------------------------------------------------------------
class Comhelper_Plugin_t(idaapi.plugin_t):
comment = "Comhelper plugin for IDA Pro"
help = "Comhelper"
Expand Down Expand Up @@ -147,15 +146,14 @@ def get_com_vas(self, dllpath, clsid, iid, count):
toolpath = os.path.join(BASE_DIR, toolname)
try:
ret = subprocess.check_output(
[toolpath, dllpath, clsid, iid, count], shell=True)
except subprocess.CalledProcessError, e:
[toolpath, dllpath, clsid, iid, count], shell=True).decode('ascii')
except subprocess.CalledProcessError as e:
return [
'LoadDll fail', 'GetProc fail', 'GetClass fail',
'CreateInstance fail'
][e.returncode - 1] + ' for clsid:{} iid:{}'.format(clsid,iid)
][e.returncode - 1] + ' for clsid:{} iid:{}'.format(clsid, iid)
vas = []
imagebase = ida_nalt.get_imagebase()

for rvahex in ret.split('\n'):
rvahex = rvahex.strip()
if rvahex:
Expand All @@ -169,7 +167,7 @@ def search(self):
'DllUnregisterServer', 'DllEntryPoint', 'DllGetClassObject',
'DllCanUnloadNow', 'DllRegisterServer'
])
dllpath = ida_nalt.get_input_file_path().decode('utf-8')
dllpath = ida_nalt.get_input_file_path()
if not comexports.issubset(exports):
print('{} is not COM! exports mismatching'.format(dllpath))
return
Expand All @@ -178,7 +176,6 @@ def search(self):
except:
print('{} is not COM! LoadTypeLib fail'.format(dllpath))
return
classes = {}
values = []
for i in range(tlb.GetTypeInfoCount()):
if tlb.GetTypeInfoType(i) == pythoncom.TKIND_COCLASS:
Expand All @@ -191,8 +188,8 @@ def search(self):
name = tlb.GetDocumentation(i)[0]
iid = str(attr.iid)
vas = self.get_com_vas(
dllpath.encode(locale.getdefaultlocale()[1]), clsid,
iid, str(attr.cFuncs))
dllpath, clsid, iid, str(attr.cFuncs)
)
if isinstance(vas, str):
print(vas)
else:
Expand Down
10 changes: 5 additions & 5 deletions comfinder/comfinder.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@
<ProjectGuid>{54F62D4B-EB14-4B38-8211-A880FD39040C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>comfinder</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 64bcddb

Please sign in to comment.