Skip to content

Commit

Permalink
Merge pull request #26 from jptomoya/fix-elf-parser
Browse files Browse the repository at this point in the history
Fix ELF Parser size bug and Re-enable test_elf_*.py tests for Windows
  • Loading branch information
ptr-yudai authored Feb 21, 2024
2 parents 50bf0c6 + df6de88 commit 4fc35fe
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 52 deletions.
32 changes: 16 additions & 16 deletions ptrlib/filestruct/bunkai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_7.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions tests/filestruct/elf/test_elf_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
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

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):
Expand Down

0 comments on commit 4fc35fe

Please sign in to comment.