diff options
| author | serpilliere <devnull@localhost> | 2012-06-29 09:04:58 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-06-29 09:04:58 +0200 |
| commit | 9447ee34926461b933cd7eb915a8318aa3a777ea (patch) | |
| tree | 855c54985d98878e5c643a1b45458475e3834937 | |
| parent | 04821c88e1c582b831ae24b408c996292680c545 (diff) | |
| download | miasm-9447ee34926461b933cd7eb915a8318aa3a777ea.tar.gz miasm-9447ee34926461b933cd7eb915a8318aa3a777ea.zip | |
modint: fix int bug
| -rw-r--r-- | miasm/arch/ia32_arch.py | 13 | ||||
| -rw-r--r-- | miasm/core/asmbloc.py | 6 | ||||
| -rw-r--r-- | miasm/core/parse_ad.py | 2 | ||||
| -rw-r--r-- | miasm/core/parse_asm.py | 2 | ||||
| -rw-r--r-- | miasm/tools/modint.py | 2 |
5 files changed, 19 insertions, 6 deletions
diff --git a/miasm/arch/ia32_arch.py b/miasm/arch/ia32_arch.py index 39e47781..84ab02cd 100644 --- a/miasm/arch/ia32_arch.py +++ b/miasm/arch/ia32_arch.py @@ -15,7 +15,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -from miasm.tools.modint import uint1, uint8, uint16, uint32, uint64 +from miasm.tools.modint import uint1, uint8, uint16, uint32, uint64, int8, int16, int32, int64 import struct import logging from miasm.core.parse_ad import parse_ad, ad_to_generic @@ -30,14 +30,21 @@ log.addHandler(console_handler) log.setLevel(logging.WARN) -tab_int_size = {uint8:8, +tab_int_size = {int8:8, + uint8:8, + int16:16, uint16:16, + int32:32, uint32:32, + int64:64, uint64:64 } -tab_size2int = {x86_afs.u08:uint8, +tab_size2int = {x86_afs.s08:int8, + x86_afs.u08:uint8, + x86_afs.s16:int16, x86_afs.u16:uint16, + x86_afs.s32:int32, x86_afs.u32:uint32, } diff --git a/miasm/core/asmbloc.py b/miasm/core/asmbloc.py index ddf3816c..b18c331a 100644 --- a/miasm/core/asmbloc.py +++ b/miasm/core/asmbloc.py @@ -28,9 +28,13 @@ console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s")) log_asmbloc.addHandler(console_handler) log_asmbloc.setLevel(logging.WARN) -tab_int_size = {uint8:8, +tab_int_size = {int8:8, + uint8:8, + int16:16, uint16:16, + int32:32, uint32:32, + int64:64, uint64:64 } diff --git a/miasm/core/parse_ad.py b/miasm/core/parse_ad.py index 3de0a3b2..3c1868ac 100644 --- a/miasm/core/parse_ad.py +++ b/miasm/core/parse_ad.py @@ -16,7 +16,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # from miasm.arch.ia32_reg import x86_afs -from miasm.tools.modint import uint1, uint8, uint16, uint32, uint64 +from miasm.tools.modint import uint1, uint8, uint16, uint32, uint64, int8, int16, int32, int64 def dict_add(a, b): tmp = dict(a) diff --git a/miasm/core/parse_asm.py b/miasm/core/parse_asm.py index 64618626..430df537 100644 --- a/miasm/core/parse_asm.py +++ b/miasm/core/parse_asm.py @@ -89,7 +89,7 @@ def parse_txt(mnemo, txt, symbol_pool = None, gen_label_index = 0): lines.append(asm_raw(line.strip())) continue - raise "unknown directive %s"%str(directive) + raise ValueError("unknown directive %s"%str(directive)) #label r = re.match(r'\s*(\S+)\s*:', line) diff --git a/miasm/tools/modint.py b/miasm/tools/modint.py index 3bd3ea3e..b1e5f0f6 100644 --- a/miasm/tools/modint.py +++ b/miasm/tools/modint.py @@ -141,6 +141,8 @@ class moduint(object): class modint(moduint): def __init__(self, arg): + if isinstance(arg, moduint): + arg = arg.arg a = arg%self.__class__.limit if a >= self.__class__.limit/2: a -= self.__class__.limit |