in scripts/symcryptasm_processor.py [0:0]
def process_start_function(self, match, line, line_num):
# Entering a new function
self.function_start_match = match
self.function_start_line = line_num
self.is_nested_function = (match.group(1) == "NESTED_")
self.is_mul_function = (match.group(2) == "MUL_")
self.function_name = match.groups()[-3]
self.arg_count = int(match.groups()[-2])
self.reg_count = int(match.groups()[-1])
if self.is_nested_function and self.nested_calling_convention is None:
logging.error(
"symcryptasm nested functions are not currently supported with assembler (%s) and architecture (%s)!\n\t"
"%s (line %d)"
% (self.assembler, self.normal_calling_convention.architecture, line, line_num))
exit(1)
if self.is_mul_function and self.mul_calling_convention is None:
logging.error(
"symcryptasm mul functions are not supported with assembler (%s) and architecture (%s)!\n\t"
"%s (line %d)"
% (self.assembler, self.normal_calling_convention.architecture, line, line_num))
exit(1)
if self.is_nested_function and self.is_mul_function:
logging.error(
"Too many prefixes for symcryptasm function - currently only 1 of prefix, MUL_ or NESTED_, is supported!\n\t"
"%s (line %d)"
% (line, line_num))
exit(1)
if self.arg_count > self.normal_calling_convention.max_arguments:
logging.error(
"Too many (%d) arguments for symcryptasm function - only %d arguments are supported by calling convention (%s)\n\t"
"%s (line %d)"
% (self.arg_count, self.normal_calling_convention.max_arguments, self.normal_calling_convention.name, match.group(0), line_num))
exit(1)
if self.reg_count > len(self.normal_calling_convention.mapping):
logging.error(
"Too many (%d) registers required for symcryptasm function - only %d registers are mapped by calling convention (%s)\n\t"
"%s (line %d)"
% (self.reg_count, len(self.normal_calling_convention.mapping), self.normal_calling_convention.name, match.group(0), line_num))
exit(1)
if self.is_mul_function and self.reg_count > len(self.mul_calling_convention.mapping)-1:
logging.error(
"Too many (%d) registers required for symcryptasm mul function - only %d registers are mapped by calling convention (%s)\n\t"
"%s (line %d)"
% (self.reg_count, len(self.mul_calling_convention.mapping)-1, self.mul_calling_convention.name, match.group(0), line_num))
exit(1)
logging.info("%d: function start %s, %d, %d" % (line_num, self.function_name, self.arg_count, self.reg_count))
if self.is_nested_function:
self.calling_convention = self.nested_calling_convention
elif self.is_mul_function:
self.calling_convention = self.mul_calling_convention
else:
self.calling_convention = self.normal_calling_convention
return generate_prologue(self.assembler, self.calling_convention, self.function_name, self.arg_count, self.reg_count, self.is_nested_function)