-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore.py
35 lines (30 loc) · 861 Bytes
/
score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import triton
import pintool
import pickle
blockList = set()
score = 0
Triton = pintool.getTritonContext()
controlFlow = False
def computeScore(inst):
global score
global controlFlow
if controlFlow:
controlFlow = False
if hex(inst.getAddress()) not in blockList:
score += 1
if inst.isControlFlow():
controlFlow = True
def outputScore():
print(score)
def main():
global blockList
with open("/media/sf_SharedFolder/Generational-Search/blocklist.pkl", "rb") as data:
blockList = pickle.load(data)
Triton.setArchitecture(triton.ARCH.X86_64)
Triton.enableMode(triton.MODE.ALIGNED_MEMORY, True)
pintool.startAnalysisFromSymbol("main")
pintool.insertCall(computeScore, pintool.INSERT_POINT.BEFORE)
pintool.insertCall(outputScore, pintool.INSERT_POINT.FINI)
pintool.runProgram()
if __name__ == "__main__":
main()