diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-11-02 22:24:23 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-11-12 15:10:44 +0100 |
| commit | 4dc802e3544e669cfea1d6be8a01ca2a2600dfef (patch) | |
| tree | 96a79b40469c1db9201ca46b210503d4dcf378c5 /test/os_dep/win_api_x86_32.py | |
| parent | 83e54bd2de945a36ab5ccd4cc5b94817d7cb0112 (diff) | |
| download | miasm-4dc802e3544e669cfea1d6be8a01ca2a2600dfef.tar.gz miasm-4dc802e3544e669cfea1d6be8a01ca2a2600dfef.zip | |
Clear get_str_* API
get_str_ansi decoded strings using utf8 and was blindly used for pure windows function (LoadLibraryA) and for stdlib functions (printf, strlen, ...) even if strlen does not use utf8... New API is: get_win_str_a/get_win_str_w and set_win_str_a/set_win_str_w for windows (respectively codepage1252/windows utf16) .Those functions should only be used in windows strings manipulations, so there are taken out of the jitter. get_c_str/set_c_str: as those functions are "classic" in OSes, they are keeped in the jitter.
Diffstat (limited to 'test/os_dep/win_api_x86_32.py')
| -rwxr-xr-x | test/os_dep/win_api_x86_32.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/os_dep/win_api_x86_32.py b/test/os_dep/win_api_x86_32.py index f759c6af..66a4e628 100755 --- a/test/os_dep/win_api_x86_32.py +++ b/test/os_dep/win_api_x86_32.py @@ -6,6 +6,7 @@ import unittest import logging from miasm.analysis.machine import Machine import miasm.os_dep.win_api_x86_32 as winapi +from miasm.os_dep.win_api_x86_32 import get_win_str_a, get_win_str_w from miasm.core.utils import pck32 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE @@ -42,7 +43,7 @@ class TestWinAPI(unittest.TestCase): jit.push_uint32_t(buf) jit.push_uint32_t(0) # ret_ad winapi.msvcrt_sprintf(jit) - ret = jit.get_str_ansi(buf) + ret = get_win_str_a(jit, buf) self.assertEqual(ret, "'coucou' 1111") @@ -63,7 +64,7 @@ class TestWinAPI(unittest.TestCase): jit.push_uint32_t(buf) jit.push_uint32_t(0) # ret_ad winapi.msvcrt_swprintf(jit) - ret = jit.get_str_unic(buf) + ret = get_win_str_w(jit, buf) self.assertEqual(ret, u"'coucou' 1111") @@ -94,7 +95,7 @@ class TestWinAPI(unittest.TestCase): jit.push_uint32_t(size) # size jit.push_uint32_t(0) # @return winapi.kernel32_GetCurrentDirectoryA(jit) - dir_ = jit.get_str_ansi(addr) + dir_ = get_win_str_a(jit, addr) size_ret = jit.cpu.EAX self.assertEqual(len(dir_), size_ret) @@ -106,7 +107,7 @@ class TestWinAPI(unittest.TestCase): winapi.kernel32_GetCurrentDirectoryA(jit) size_ret = jit.cpu.EAX self.assertEqual(len(dir_)+1, size_ret) - dir_short = jit.get_str_ansi(addr) + dir_short = get_win_str_a(jit, addr) self.assertEqual(dir_short, dir_[:4]) def test_MemoryManagementFunctions(self): |