Esempio n. 1
0
    def encode_section(self, elf):
        """
        Generate the contents of the notes section.
        """
        note = section.UnpreparedElfNote(elffile=elf,
                                         name='elfweaver.notes')
        note.note_name = "Memstats Details"
        note.note_type = 1
        encoded = self.encode()
        note._desc_data = ByteArray.ByteArray(encoded)

        return note
Esempio n. 2
0
 def test_get_data(self):
     a = ByteArray("12345678qwerty")
     # Note: There should be more extensive testing of the return
     # value.
     a.get_data(0, 8, '<')
Esempio n. 3
0
 def test_array_set_data(self):
     b = ByteArray()
     for bytes, fmt in [(1, "B"), (2, "H"), (4, "L"), (8, "Q")]:
         b.set_data(0, 10, bytes, '<')
         self.assertEqual(len(b), bytes)
         self.assertEqual(struct.unpack("<" + fmt, b)[0], 10)
Esempio n. 4
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
Esempio n. 5
0
 def test_init_data(self):
     ByteArray("foo")
Esempio n. 6
0
 def test_init(self):
     ByteArray()
Esempio n. 7
0
 def test_get_data(self):
     a = ByteArray("12345678qwerty")
     # Note: There should be more extensive testing of the return
     # value.
     a.get_data(0, 8, '<')
Esempio n. 8
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
Esempio n. 9
0
 def test_array_set_data(self):
     b = ByteArray()
     for bytes, fmt in [(1, "B"), (2, "H"), (4, "L"), (8, "Q")]:
         b.set_data(0, 10, bytes, '<')
         self.assertEqual(len(b), bytes)
         self.assertEqual(struct.unpack("<" + fmt, b)[0], 10)