mustangV / yara-project

Automatically exported from code.google.com/p/yara-project
Apache License 2.0
0 stars 0 forks source link

[yara python]match() method does not accept variable as parameter #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
#python 2.7, yara-python1.6
import yara
rules = yara.compile("definitions.yara")
result = rules.match(pid=1234)
if result != []:
    print "got it."
The above code is ok, but if I want to pass a variable instead of an immediate 
number to the method match(), it says: "TypeError: match() takes 1 argument".
My code is loke the following,

for x in ProcessIds:
    rules.match(pid = x)

ProcessIds is an array of c_ulong type values.

Original issue reported on code.google.com by zhangke1...@gmail.com on 23 Apr 2013 at 8:54

GoogleCodeExporter commented 8 years ago
The issue here is that c_ulong is not a really a Python integer, and the match 
function doesn't recognize it. You could use:

for x in ProcessIds:
rules.match(pid = x.value)

Original comment by plus...@gmail.com on 6 Dec 2013 at 1:47