IDA has this nifty habit that when it doesn't know what a special purpose register is, it just drops in the number of the register instead. While this is all well and fine, I'd like to be able to correct these items in my database. I know I can just adjust the [arch].cfg file; however, that applies the changes to ALL processors of that architecture, which isn't always the correct behavior. Instead, I'd like to only change the registers per database that I'm working on.
So I started down the IDAPython path and I can easily get the unnamed registers:
for r in range(220,240): uknName = get_reg_name(r,0) print("Got: '%s' for register %d ") % (unkName,r) if unkName is None: # I'd like to fix this but I can't # set_reg_name(r,<something I read from a file>)
Where I've run into issues is that I can't seem to find the IDAPython idc/idaapi/idautils function that I can use to rename the it. Do you know what the magic python sauce is that would allow me to rename these items? I've been trying to find something in the official docs here but haven't had any luck.
UPDATE: Equivalent Functionality
As mentioned below, this isn't "possible" with the IDA API (as is also noted in my original implied statement of "I read all of this and can't find a way to do it." The following code will provide you an equvilent bit of information ... but I've not found an efficient way to implement it so I just keep this snip-it around and hack it up as needed. It provides the same as the "RightClick->Rename" that you can use to rename a given register per function ... sadly, not a good way to do an entire database. Mucked up for x86 since it was the only image I had available:
ea = ScreenEA() func = idaapi.get_func(ea) regvar = idaapi.find_regvar(func, ea, "eax") # print(var_dump(regvar)) # associated "rename variable" magic idaapi.rename_regvar(func, idaapi.find_regvar(func, ea, "eax"), "asdfd")