MCPcopy Create free account
hub / github.com/CheckPointSW/Karta / analyzeFile

Function analyzeFile

src/analyze_src_file.py:8–29  ·  view source on GitHub ↗

Analyzes all of the (source) functions for a single compiled file.

()

Source from the content-addressed store, hash-verified

6import traceback
7
8def analyzeFile():
9 """Analyzes all of the (source) functions for a single compiled file."""
10 disas = getDisas()
11 logger.info("Started the Script")
12 contexts = []
13 # check for windows binary
14 if disas.inputFile().endswith(".obj"):
15 logger.debug("Activating Windows mode")
16 setWindowsMode()
17 # build the list of exported (non-static) functions
18 exported = disas.exports()
19 for segment_idx in range(disas.numSegments()):
20 if ".text" not in disas.segmentName(segment_idx):
21 continue
22 for function_ea in disas.segmentFunctions(segment_idx):
23 src_ctx = disas.analyzeFunction(function_ea, True)
24 # check if static or not
25 if src_ctx.name not in exported:
26 src_ctx.markStatic()
27 contexts.append(src_ctx)
28 functionsToFile(disas.inputFile(), contexts)
29 logger.info("Finished Successfully")
30
31
32# Create a basic logger for the init phase

Callers 1

Calls 10

getDisasFunction · 0.85
setWindowsModeFunction · 0.85
functionsToFileFunction · 0.85
exportsMethod · 0.80
markStaticMethod · 0.80
inputFileMethod · 0.45
numSegmentsMethod · 0.45
segmentNameMethod · 0.45
segmentFunctionsMethod · 0.45
analyzeFunctionMethod · 0.45

Tested by

no test coverage detected