""" Usage
Copies those files from VC first:
DUMPBIN.EXE
LIB.EXE
LINK.EXE
MSPDB60.DLL(your symbol version)
Use following command to get the lib file for debug
python dlltolib.py xxx.dll
"""
import sys, os, re
if len(sys.argv) < 2:
print "** Plz spcecifies a dll file"
sys.exit()
cwdpath = os.getcwd()
os.chdir(cwdpath)
dllfile = sys.argv.pop()
deffile = dllfile[0:-3] + 'def'
print '** Will create %s, %s after done, del manually' % (dllfile, deffile)
#dumpbin.exe /exports /out:g:\tool\ws2_32.def ws2_32.dll
dumpcom = r'dumpbin.exe '
param = r'/exports /out:%s %s' % (deffile, dllfile)
print '** Begin to dump dll to def'
print dumpcom + param
os.system(dumpcom + param)
print '** Dump dll file to def file Done'
opendef = file(deffile, 'r')
startsign = re.compile(r'^\s*ordinal\s+hint\s+RVA\s+name', re.IGNORECASE)
endsign = re.compile(r'^\s*Summary\s*$', re.IGNORECASE)
fromflag = True # flag for checking whether has found function table
tempfunc = []
# read the fucntion from orignal def
exportfunc = opendef.readlines()
for line in exportfunc:
if fromflag:
if startsign.search(line):
fromflag = False
else:
if endsign.search(line):
break
tempfunc.append(line.replace('\n', ''))
exportfunc = tempfunc[1:-1]
opendef.close()
# then produce to what I want to define def file
writefile = file(deffile, 'w')
heard = 'LIBRARY "%s"\n\n' % dllfile
section = 'EXPORTS\n'
# exportfunc[1] = ' 22 73 00010BDE shutdown'
funcs = []
funcs.append(heard)
funcs.append(section)
for line in exportfunc:
func = line.split()
funcs.append('\t' + func[-1] + ' @' + func[0] + '\n')
writefile.writelines(funcs)
writefile.close()
libcmd = r'lib.exe '
param = r'/MACHINE:IX86 /def:%s' % deffile
print '** Begin to create lib file'
os.system(libcmd + param)
print '** Generate lib file for %s done' % dllfile
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
来源: http://lavixu.livejournal.com/14738.html 压缩包中除上述网址的dll2lib.py外还含有 VC 6 的如下几个文件: DUMPBIN.EXE LIB.EXE LINK.EXE MSPDB60.DLL 该python脚本对一个 A.dll 文件会生成如下三个文件: A.lib A.def A.exp 因为是 python 写的,所以需要下载 python (目前为 2.7 ,不要使用 3.X 版的,因为 3.X 版认为 print "string" 是语法错误的) ------------------- 传说中的分隔线 ------------------- 你可能对下面的内容也感兴趣: 标题: How can an MSVC program call an MinGW DLL, and vice versa? 网址: http://wyw.dcweb.cn/dllfaq.htm ------------------- 下面是传说中价格为$999的 DLL to Lib (d2l) 它能把 dll 转为静态库 :) DLL to Lib 3.0 (Free to try; $999.00 to buy) http://download.cnet.com/DLL-to-Lib/3000-18487_4-10064902.html
资源推荐
资源详情
资源评论
收起资源包目录
dll2lib.rar (5个子文件)
DUMPBIN.EXE 16KB
dll2lib.py 2KB
LIB.EXE 16KB
MSPDB60.DLL 176KB
LINK.EXE 452KB
共 5 条
- 1
资源评论
- maxware2015-02-03不是我想要的
- x76732013-03-02需要安装 python
- leevale2014-08-27很不错的说
- futiem2014-01-08是 python 写的
hloveloveu
- 粉丝: 15
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功