Package IDAscope :: Package idascope :: Package core :: Package structures :: Module ParameterContext
[hide private]
[frames] | no frames]

Source Code for Module IDAscope.idascope.core.structures.ParameterContext

 1  #!/usr/bin/python 
 2  ######################################################################## 
 3  # Copyright (c) 2012 
 4  # Daniel Plohmann <daniel.plohmann<at>gmail<dot>com> 
 5  # Alexander Hanel <alexander.hanel<at>gmail<dot>com> 
 6  # All rights reserved. 
 7  ######################################################################## 
 8  # 
 9  #  This file is part of IDAscope 
10  # 
11  #  IDAscope is free software: you can redistribute it and/or modify it 
12  #  under the terms of the GNU General Public License as published by 
13  #  the Free Software Foundation, either version 3 of the License, or 
14  #  (at your option) any later version. 
15  # 
16  #  This program is distributed in the hope that it will be useful, but 
17  #  WITHOUT ANY WARRANTY; without even the implied warranty of 
18  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
19  #  General Public License for more details. 
20  # 
21  #  You should have received a copy of the GNU General Public License 
22  #  along with this program.  If not, see 
23  #  <http://www.gnu.org/licenses/>. 
24  # 
25  ######################################################################## 
26   
27  # operand types defined by IDA 
28  # o_void  =      0  # No Operand 
29  # o_reg  =       1  # General Register (al,ax,es,ds...)                reg 
30  # o_mem  =       2  # Direct Memory Reference  (DATA)                  addr 
31  # o_phrase  =    3  # Memory Ref [Base Reg + Index Reg]                phrase 
32  # o_displ  =     4  # Memory Reg [Base Reg + Index Reg + Displacement] phrase+addr 
33  # o_imm  =       5  # Immediate Value                                  value 
34  # o_far  =       6  # Immediate Far Address  (CODE)                    addr 
35  # o_near  =      7  # Immediate Near Address (CODE)                    addr 
36   
37   
38 -class ParameterContext():
39 """ 40 This class is an information container for parameters that are handed over during function calls. 41 """ 42
43 - def __init__(self):
44 self.parameter_type = "" 45 self.parameter_name = "" 46 self.push_address = -1 47 self.ida_operand_type = -1 48 self.ida_operand_value = -1 49 self.value = -1 50 self.valid = True 51 pass
52
54 """ 55 Get the address of this parameter in hex string form. 56 @return: the parameter address in hex string form or "unresolved" if it has not been assigned. 57 """ 58 if self.push_address != -1: 59 return "0x%x" % self.push_address 60 else: 61 return "unresolved"
62
63 - def get_rendered_value(self):
64 """ 65 Get the value of this parameter in hex string form. 66 @return: the value in hex string form or "unresolved" if it has not been assigned. 67 """ 68 if self.value != -1: 69 return "0x%x" % self.value 70 else: 71 return "unresolved"
72
73 - def __str__(self):
74 """ 75 Convenience function. 76 @return: a nice string representation for this object 77 """ 78 return "0x%x - %s %s: %s (%d, %d)" % (self.push_address, self.parameter_type, self.parameter_name, \ 79 self.value, self.ida_operand_type, self.ida_operand_value)
80