I'd like to be able to create and change global variables at addresses with IDA Python: if variable doesn't exist, create it, if it exists, change it, set its name, undefine it.
There's idc.set_name to set a name at address and ida_bytes.get_flags function to get flags, but I can't find a respective function such as
set_type to change global variable type at address. So to set variable type to dword, I'd do something like
ida_bytes.set_flags(0x14001D01C, ida_bytes.dword_flag()), and to set it to structure type, I'd like to do something like
ida_bytes.set_flags(0x14001D01C, ida_bytes.stru_flag(), ida_struct.get_struc_id("MyStructName"))
I scrolled through idaapi, ida_bytes, idc, ida_struct and ida_typeinf documentation. I also searched for
_type and other in the search box on the hex-rays documentation website, and also manually with Ctrl+F in the pages for namespaces above, but couldn't find functions to set flags at address.