你好,我运行脚本时遇到“ AttributeError:'tuple”对象没有属性“ ImplFlags”。我正在使用ironpython,并且该脚本仅打算在ironpython上运行。
我已经尝试将“ row.ImplFlags”更改为“ row [ImplFlags]”,但这只是抛出了这个:“ NameError:全局名称'ImplFlags'未定义”
import clr
clr.AddReferenceToFileAndPath("System.Reflection.dll")
from System.Reflection import MethodAttributes, MethodImplAttributes
def main():
mod = dnlib.DotNet.ModuleDefMD.Load('CrackME.exe')
ss = mod.Assembly.Modules[0].Metadata.StringsStream # Strings stream
ts = mod.Assembly.Modules[0].Metadata.TablesStream # mod.Assembly.Modules[0].TablesStream
size = ts.MethodTable.Rows
for mod in mod.Assembly.Modules:
for typ in mod.Types:
for method in typ.Methods:
for i in xrange(1, size+1):
row = ts.TryReadMethodRow(i)
if row.ImplFlags == int(MethodImplAttributes.IL): # Show only methods having CodeType IL
print 'Name: {0}\tIsSpecial: {1}'.format(ss.Read(row.Name), int(MethodAttributes.SpecialName) & row.Flags != 0)
if __name__ == '__main__':
try:
clr.AddReferenceToFileAndPath('dnlib.dll')
import dnlib
except Exception, ex:
print ex
else:
main()
老实说,我不知道为什么要这么做。它通常应该可以正常打印,但是每次我尝试修复元组错误时,它都会不断抛出新错误。注意:如果有区别,此脚本应在Ironpython上运行