From df6de88b1e883d66a0122362919d255230fdc023 Mon Sep 17 00:00:00 2001 From: jptomoya <4786564+jptomoya@users.noreply.github.com> Date: Wed, 21 Feb 2024 02:33:45 +0900 Subject: [PATCH] Use implementation independent integer types in BunkaiPrimitive --- ptrlib/filestruct/bunkai.py | 32 +++++++++++++++--------------- tests/filestruct/elf/test_elf_1.py | 4 ---- tests/filestruct/elf/test_elf_2.py | 4 ---- tests/filestruct/elf/test_elf_3.py | 4 ---- tests/filestruct/elf/test_elf_4.py | 4 ---- tests/filestruct/elf/test_elf_5.py | 4 ---- tests/filestruct/elf/test_elf_6.py | 4 ---- tests/filestruct/elf/test_elf_7.py | 4 ---- tests/filestruct/elf/test_elf_8.py | 4 ---- tests/filestruct/elf/test_elf_9.py | 4 ---- 10 files changed, 16 insertions(+), 52 deletions(-) diff --git a/ptrlib/filestruct/bunkai.py b/ptrlib/filestruct/bunkai.py index 099f913..5890825 100644 --- a/ptrlib/filestruct/bunkai.py +++ b/ptrlib/filestruct/bunkai.py @@ -230,22 +230,22 @@ def _parse_stream(self, stream): else: return self._ty.from_buffer_copy(buf).value -u8 = BunkaiPrimitive(ctypes.c_ubyte) -u16 = BunkaiPrimitive(ctypes.c_ushort) -u32 = BunkaiPrimitive(ctypes.c_uint) -u64 = BunkaiPrimitive(ctypes.c_ulong) -s8 = BunkaiPrimitive(ctypes.c_byte) -s16 = BunkaiPrimitive(ctypes.c_short) -s32 = BunkaiPrimitive(ctypes.c_int) -s64 = BunkaiPrimitive(ctypes.c_long) -u8be = BunkaiPrimitive(ctypes.c_ubyte, True) -u16be = BunkaiPrimitive(ctypes.c_ushort, True) -u32be = BunkaiPrimitive(ctypes.c_uint, True) -u64be = BunkaiPrimitive(ctypes.c_ulong, True) -s8be = BunkaiPrimitive(ctypes.c_byte, True) -s16be = BunkaiPrimitive(ctypes.c_short, True) -s32be = BunkaiPrimitive(ctypes.c_int, True) -s64be = BunkaiPrimitive(ctypes.c_long, True) +u8 = BunkaiPrimitive(ctypes.c_uint8) +u16 = BunkaiPrimitive(ctypes.c_uint16) +u32 = BunkaiPrimitive(ctypes.c_uint32) +u64 = BunkaiPrimitive(ctypes.c_uint64) +s8 = BunkaiPrimitive(ctypes.c_int8) +s16 = BunkaiPrimitive(ctypes.c_int16) +s32 = BunkaiPrimitive(ctypes.c_int32) +s64 = BunkaiPrimitive(ctypes.c_int64) +u8be = BunkaiPrimitive(ctypes.c_uint8, True) +u16be = BunkaiPrimitive(ctypes.c_uint16, True) +u32be = BunkaiPrimitive(ctypes.c_uint32, True) +u64be = BunkaiPrimitive(ctypes.c_uint64, True) +s8be = BunkaiPrimitive(ctypes.c_int8, True) +s16be = BunkaiPrimitive(ctypes.c_int16, True) +s32be = BunkaiPrimitive(ctypes.c_int32, True) +s64be = BunkaiPrimitive(ctypes.c_int64, True) if __name__ == '__main__': data = b'\xde\xad\xbe\xef' # magic diff --git a/tests/filestruct/elf/test_elf_1.py b/tests/filestruct/elf/test_elf_1.py index 9f49887..f40a664 100644 --- a/tests/filestruct/elf/test_elf_1.py +++ b/tests/filestruct/elf/test_elf_1.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/libc-2.27.so" BASE = 0x7fffdeadb000 @@ -12,8 +10,6 @@ class TestELF1(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_symbol(self): diff --git a/tests/filestruct/elf/test_elf_2.py b/tests/filestruct/elf/test_elf_2.py index 467887a..772adb1 100644 --- a/tests/filestruct/elf/test_elf_2.py +++ b/tests/filestruct/elf/test_elf_2.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/libc-2.31.so" BASE = 0x7fffdeadb000 @@ -12,8 +10,6 @@ class TestELF2(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_symbol(self): diff --git a/tests/filestruct/elf/test_elf_3.py b/tests/filestruct/elf/test_elf_3.py index 72adba0..826ee38 100644 --- a/tests/filestruct/elf/test_elf_3.py +++ b/tests/filestruct/elf/test_elf_3.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/libc-2.34.so" BASE = 0x7fffdeadb000 @@ -12,8 +10,6 @@ class TestELF3(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_symbol(self): diff --git a/tests/filestruct/elf/test_elf_4.py b/tests/filestruct/elf/test_elf_4.py index cca08ee..8251323 100644 --- a/tests/filestruct/elf/test_elf_4.py +++ b/tests/filestruct/elf/test_elf_4.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/test_echo.x86" BASE = 0x7fdea000 @@ -12,8 +10,6 @@ class TestELF4(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_plt(self): diff --git a/tests/filestruct/elf/test_elf_5.py b/tests/filestruct/elf/test_elf_5.py index 0180fcd..ae80ca2 100644 --- a/tests/filestruct/elf/test_elf_5.py +++ b/tests/filestruct/elf/test_elf_5.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/test_echo.x64" BASE = 0x555555554000 @@ -12,8 +10,6 @@ class TestELF5(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_plt(self): diff --git a/tests/filestruct/elf/test_elf_6.py b/tests/filestruct/elf/test_elf_6.py index d3bdf4e..2d70021 100644 --- a/tests/filestruct/elf/test_elf_6.py +++ b/tests/filestruct/elf/test_elf_6.py @@ -3,16 +3,12 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/test_fsb.x86" class TestELF6(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_plt(self): diff --git a/tests/filestruct/elf/test_elf_7.py b/tests/filestruct/elf/test_elf_7.py index ee26f58..95ed6a5 100644 --- a/tests/filestruct/elf/test_elf_7.py +++ b/tests/filestruct/elf/test_elf_7.py @@ -3,16 +3,12 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/test_fsb.x64" class TestELF7(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_plt(self): diff --git a/tests/filestruct/elf/test_elf_8.py b/tests/filestruct/elf/test_elf_8.py index 1dca844..0d3dd05 100644 --- a/tests/filestruct/elf/test_elf_8.py +++ b/tests/filestruct/elf/test_elf_8.py @@ -3,16 +3,12 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/test_plt.x64" class TestELF8(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_plt(self): diff --git a/tests/filestruct/elf/test_elf_9.py b/tests/filestruct/elf/test_elf_9.py index 56f8919..f7b3cd1 100644 --- a/tests/filestruct/elf/test_elf_9.py +++ b/tests/filestruct/elf/test_elf_9.py @@ -3,8 +3,6 @@ from ptrlib.filestruct.elf import ELF from logging import getLogger, FATAL -_is_windows = os.name == 'nt' - PATH_ELF = "./tests/test.bin/libc-2.35.so" BASE = 0x7fffdeadb000 @@ -12,8 +10,6 @@ class TestELF9(unittest.TestCase): def setUp(self): getLogger("ptrlib").setLevel(FATAL) - if _is_windows: - self.skipTest("This test is intended for the Linux platform") self.elf = ELF(PATH_ELF) def test_symbol(self):