bugfix: SetRegEx and GetReg were only working with x86 segment registers

This commit is contained in:
elias.bachaalany 2010-01-18 10:55:33 +00:00
parent 277facf240
commit d7c6f94f08

View File

@ -1449,15 +1449,6 @@ def SetFlags(ea, flags):
""" """
return idaapi.setFlags(ea, flags) return idaapi.setFlags(ea, flags)
_REGMAP = {
'es' : idaapi.R_es,
'cs' : idaapi.R_cs,
'ss' : idaapi.R_ss,
'ds' : idaapi.R_ds,
'fs' : idaapi.R_fs,
'gs' : idaapi.R_gs
}
def SetRegEx(ea, reg, value, tag): def SetRegEx(ea, reg, value, tag):
""" """
Set value of a segment register. Set value of a segment register.
@ -1473,8 +1464,9 @@ def SetRegEx(ea, reg, value, tag):
See also SetReg() compatibility macro. See also SetReg() compatibility macro.
""" """
if reg in _REGMAP: reg = idaapi.str2reg(reg);
return idaapi.splitSRarea1(ea, _REGMAP[reg], value, tag) if reg >= 0:
return idaapi.splitSRarea1(ea, reg, value, tag)
else: else:
return False return False
@ -1885,17 +1877,17 @@ def GetReg(ea, reg):
@param ea: linear address @param ea: linear address
@param reg: name of segment register @param reg: name of segment register
@return: the value of the segment register or 0xFFFF on error @return: the value of the segment register or -1 on error
@note: The segment registers in 32bit program usually contain selectors, @note: The segment registers in 32bit program usually contain selectors,
so to get paragraph pointed by the segment register you need to so to get paragraph pointed by the segment register you need to
call AskSelector() function. call AskSelector() function.
""" """
if reg in _REGMAP: reg = idaapi.str2reg(reg);
return idaapi.getSR(ea, _REGMAP[reg]) & 0xFFFF if reg >= 0:
return idaapi.getSR(ea, reg)
else: else:
return False return -1
def NextAddr(ea): def NextAddr(ea):
""" """
@ -3342,8 +3334,9 @@ def SetSegDefReg(ea, reg, value):
""" """
seg = idaapi.getseg(ea) seg = idaapi.getseg(ea)
if seg and reg in _REGMAP: reg = idaapi.str2reg(reg);
return idaapi.SetDefaultRegisterValue(seg, _REGMAP[reg], value) if seg and reg >= 0:
return idaapi.SetDefaultRegisterValue(seg, reg, value)
else: else:
return False return False
@ -5110,7 +5103,7 @@ def AddStrucMember(sid, name, offset, flag, typeid, nbytes, target=-1, tdelta=0,
""" """
if isOff0(flag): if isOff0(flag):
return Eval('AddStrucMember(%d, "%s", %d, %d, %d, %d, %d, %d, %d);' % (sid, name, offset, flag, typeid, nbytes, return Eval('AddStrucMember(%d, "%s", %d, %d, %d, %d, %d, %d, %d);' % (sid, name, offset, flag, typeid, nbytes,
target, tdelta, reftype)) target, tdelta, reftype))
else: else:
return Eval('AddStrucMember(%d, "%s", %d, %d, %d, %d);' % (sid, name, offset, flag, typeid, nbytes)) return Eval('AddStrucMember(%d, "%s", %d, %d, %d, %d);' % (sid, name, offset, flag, typeid, nbytes))
@ -5189,7 +5182,7 @@ def SetMemberType(sid, member_offset, flag, typeid, nitems, target=-1, tdelta=0,
@return: !=0 - ok. @return: !=0 - ok.
""" """
if isOff0(flag): if isOff0(flag):
return Eval('SetMemberType(%d, %d, %d, %d, %d, %d, %d, %d);' % (sid, member_offset, flag, typeid, nitems, return Eval('SetMemberType(%d, %d, %d, %d, %d, %d, %d, %d);' % (sid, member_offset, flag, typeid, nitems,
target, tdelta, reftype)) target, tdelta, reftype))
else: else:
return Eval('SetMemberType(%d, %d, %d, %d, %d);' % (sid, member_offset, flag, typeid, nitems)) return Eval('SetMemberType(%d, %d, %d, %d, %d);' % (sid, member_offset, flag, typeid, nitems))
@ -6441,7 +6434,7 @@ def AttachProcess(pid, event_id):
will interactively ask the user for the process to attach to. will interactively ask the user for the process to attach to.
@param event_id: reserved, must be -1 @param event_id: reserved, must be -1
@return: @return:
- -2: impossible to find a compatible process - -2: impossible to find a compatible process
- -1: impossible to attach to the given process (process died, privilege - -1: impossible to attach to the given process (process died, privilege
needed, not supported by the debugger plugin, ...) needed, not supported by the debugger plugin, ...)