From 33dccf7012673882bef35b9afd9fb986881a8168 Mon Sep 17 00:00:00 2001 From: Adrien Guinet Date: Tue, 31 Oct 2017 08:16:17 +0100 Subject: Various Win32 API additions/fixes (#616) Various Win32 API additions/fixes * add a get_size method to Miasm heap object, which allows the implementation of mscvrt_realloc * add the concept of "current directory", with the default value being arbitrary set to "c:\tmp", which allows the implementation of {Get,Set}CurrentDirecrtory * various other methods implemented: - advapi32_RegCloseKey - advapi32_RegCreateKeyW - advapi32_RegSetValueExA - advapi32_RegSetValueExW - kernel32_GetProcessHeap - msvcrt_delete - msvcrt_fprintf - msvcrt_fwrite - msvcrt__mbscpy - msvcrt_new - msvcrt_realloc - msvcrt_sprintf - msvcrt_srand - msvcrt_strrchr - msvcrt_swprintf - msvcrt_wcscat - msvcrt_wcscmp - msvcrt_wcscpy - msvcrt__wcsicmp - msvcrt_wcslen - msvcrt_wcsncpy - msvcrt__wcsnicmp - msvcrt_wcsrchr --- test/os_dep/common.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 test/os_dep/common.py (limited to 'test/os_dep/common.py') diff --git a/test/os_dep/common.py b/test/os_dep/common.py new file mode 100755 index 00000000..5d525e32 --- /dev/null +++ b/test/os_dep/common.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python2 +#-*- coding:utf-8 -*- + +import unittest +import logging +from miasm2.analysis.machine import Machine +import miasm2.os_dep.common as commonapi +from miasm2.core.utils import pck32 +from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE + +machine = Machine("x86_32") + +jit = machine.jitter() +jit.init_stack() + +class TestCommonAPI(unittest.TestCase): + + def test_get_size(self): + heap = commonapi.heap() + with self.assertRaises(AssertionError): + heap.get_size(jit.vm, 0) + heap.alloc(jit, 20) + heap.alloc(jit, 40) + heap.alloc(jit, 50) + heap.alloc(jit, 60) + ptr = heap.alloc(jit, 10) + heap.alloc(jit, 80) + for i in xrange(10): + self.assertEqual(heap.get_size(jit.vm, ptr+i), 10) + +if __name__ == '__main__': + testsuite = unittest.TestLoader().loadTestsFromTestCase(TestCommonAPI) + report = unittest.TextTestRunner(verbosity=2).run(testsuite) + exit(len(report.errors + report.failures)) + -- cgit 1.4.1