IDA has the idc.SetType
method that would accept a function start offset and a function prototype string and will set that function's prototype, although it will not set the function's name.
The idc.SetType
function is actually a convenience function around ida_typeinf.idc_parse_decl
and ida_typeinf.apply_type
, through a couple of other methods defined in the idc
module. If you wanna set both function name and prototype, you could use idc.parse_decl
to parse the prototype and then call idc.apply_type
and idc.set_name
to set the prototype and name.
Reading the code I linked to around idc.SetType
really makes the API clear.
An example code could look something like this:
prototype_details = idc.parse_decl(PROTOTYPE, idc.PT_SILENT)
if prototype_details:
idc.set_name(FUNCTION_ADDRESS, prototype_details[0])
idc.apply_type(FUNCTION_ADDRESS, prototype_details)
Naturally, you'll need to replace PROTOTYPE
and FUNCTION_ADDRESS
with the function's prototype and address, as well as implement this inside a loop. I'll leave this an an exercise for the reader.