dissect.cstruct 4.3.dev1__tar.gz → 4.3.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dissect_cstruct-4.3.dev1/dissect.cstruct.egg-info → dissect_cstruct-4.3.dev2}/PKG-INFO +1 -1
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/base.py +6 -4
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/char.py +2 -2
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/enum.py +2 -2
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/pointer.py +2 -2
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/structure.py +4 -4
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/wchar.py +2 -2
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2/dissect.cstruct.egg-info}/PKG-INFO +1 -1
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_base.py +1 -1
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_char.py +3 -3
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_custom.py +6 -6
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_enum.py +18 -3
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_flag.py +3 -3
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_int.py +6 -6
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_leb128.py +4 -4
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_packed.py +14 -14
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_pointer.py +5 -5
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_structure.py +9 -9
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_union.py +5 -5
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_void.py +4 -4
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_types_wchar.py +3 -3
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/COPYRIGHT +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/LICENSE +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/MANIFEST.in +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/README.md +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/cstruct.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/expression.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/parser.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/examples/disk.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/examples/mirai.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/examples/pe.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/pyproject.toml +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/setup.cfg +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/__init__.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/conftest.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/data/testdef.txt +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/docs/Makefile +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/docs/conf.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/docs/index.rst +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_align.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_parser.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tests/utils.py +0 -0
- {dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.dev2
|
|
4
4
|
Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -59,7 +59,7 @@ class MetaType(type):
|
|
|
59
59
|
|
|
60
60
|
return cls.size
|
|
61
61
|
|
|
62
|
-
def
|
|
62
|
+
def __default__(cls) -> BaseType:
|
|
63
63
|
"""Return the default value of this type."""
|
|
64
64
|
return cls()
|
|
65
65
|
|
|
@@ -179,7 +179,7 @@ class MetaType(type):
|
|
|
179
179
|
stream: The stream to read from.
|
|
180
180
|
array: The array to write.
|
|
181
181
|
"""
|
|
182
|
-
return cls._write_array(stream, array + [cls.
|
|
182
|
+
return cls._write_array(stream, array + [cls.__default__()])
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
class _overload:
|
|
@@ -225,8 +225,10 @@ class ArrayMetaType(MetaType):
|
|
|
225
225
|
num_entries: int | Expression | None
|
|
226
226
|
null_terminated: bool
|
|
227
227
|
|
|
228
|
-
def
|
|
229
|
-
return type.__call__(
|
|
228
|
+
def __default__(cls) -> BaseType:
|
|
229
|
+
return type.__call__(
|
|
230
|
+
cls, [cls.type.__default__()] * (cls.num_entries if isinstance(cls.num_entries, int) else 0)
|
|
231
|
+
)
|
|
230
232
|
|
|
231
233
|
def _read(cls, stream: BinaryIO, context: dict[str, Any] | None = None) -> Array:
|
|
232
234
|
if cls.null_terminated:
|
|
@@ -25,7 +25,7 @@ class CharArray(bytes, BaseType, metaclass=ArrayMetaType):
|
|
|
25
25
|
return stream.write(data)
|
|
26
26
|
|
|
27
27
|
@classmethod
|
|
28
|
-
def
|
|
28
|
+
def __default__(cls) -> CharArray:
|
|
29
29
|
return type.__call__(cls, b"\x00" * (0 if cls.dynamic or cls.null_terminated else cls.num_entries))
|
|
30
30
|
|
|
31
31
|
|
|
@@ -75,5 +75,5 @@ class Char(bytes, BaseType):
|
|
|
75
75
|
return stream.write(data)
|
|
76
76
|
|
|
77
77
|
@classmethod
|
|
78
|
-
def
|
|
78
|
+
def __default__(cls) -> Char:
|
|
79
79
|
return type.__call__(cls, b"\x00")
|
|
@@ -27,7 +27,7 @@ class EnumMetaType(EnumMeta, MetaType):
|
|
|
27
27
|
) -> EnumMetaType:
|
|
28
28
|
if name is None:
|
|
29
29
|
if value is None:
|
|
30
|
-
value = cls.type.
|
|
30
|
+
value = cls.type.__default__()
|
|
31
31
|
|
|
32
32
|
if not isinstance(value, int):
|
|
33
33
|
# value is a parsable value
|
|
@@ -82,7 +82,7 @@ class EnumMetaType(EnumMeta, MetaType):
|
|
|
82
82
|
|
|
83
83
|
def _write_0(cls, stream: BinaryIO, array: list[BaseType]) -> int:
|
|
84
84
|
data = [entry.value if isinstance(entry, Enum) else entry for entry in array]
|
|
85
|
-
return cls._write_array(stream, data + [cls.type.
|
|
85
|
+
return cls._write_array(stream, data + [cls.type.__default__()])
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
def _fix_alias_members(cls: type[Enum]) -> None:
|
|
@@ -66,8 +66,8 @@ class Pointer(int, BaseType):
|
|
|
66
66
|
return type.__call__(self.__class__, int.__or__(self, other), self._stream, self._context)
|
|
67
67
|
|
|
68
68
|
@classmethod
|
|
69
|
-
def
|
|
70
|
-
return cls.__new__(cls, cls.cs.pointer.
|
|
69
|
+
def __default__(cls) -> Pointer:
|
|
70
|
+
return cls.__new__(cls, cls.cs.pointer.__default__(), None, None)
|
|
71
71
|
|
|
72
72
|
@classmethod
|
|
73
73
|
def _read(cls, stream: BinaryIO, context: dict[str, Any] | None = None) -> Pointer:
|
|
@@ -325,7 +325,7 @@ class StructureMetaType(MetaType):
|
|
|
325
325
|
|
|
326
326
|
value = getattr(data, field.name, None)
|
|
327
327
|
if value is None:
|
|
328
|
-
value = field_type.
|
|
328
|
+
value = field_type.__default__()
|
|
329
329
|
|
|
330
330
|
if field.bits:
|
|
331
331
|
if isinstance(field_type, EnumMetaType):
|
|
@@ -560,7 +560,7 @@ class Union(Structure, metaclass=UnionMetaType):
|
|
|
560
560
|
buf.seek(field.offset)
|
|
561
561
|
|
|
562
562
|
if (value := getattr(self, attr)) is None:
|
|
563
|
-
value = field.type.
|
|
563
|
+
value = field.type.__default__()
|
|
564
564
|
|
|
565
565
|
field.type._write(buf, value)
|
|
566
566
|
|
|
@@ -774,7 +774,7 @@ def _generate_structure__init__(fields: list[Field]) -> FunctionType:
|
|
|
774
774
|
template: FunctionType = _make_structure__init__(len(field_names))
|
|
775
775
|
return type(template)(
|
|
776
776
|
template.__code__.replace(
|
|
777
|
-
co_consts=(None, *[field.type.
|
|
777
|
+
co_consts=(None, *[field.type.__default__() for field in fields]),
|
|
778
778
|
co_names=(*field_names,),
|
|
779
779
|
co_varnames=("self", *field_names),
|
|
780
780
|
),
|
|
@@ -794,7 +794,7 @@ def _generate_union__init__(fields: list[Field]) -> FunctionType:
|
|
|
794
794
|
template: FunctionType = _make_union__init__(len(field_names))
|
|
795
795
|
return type(template)(
|
|
796
796
|
template.__code__.replace(
|
|
797
|
-
co_consts=(None, *sum([(field.name, field.type.
|
|
797
|
+
co_consts=(None, *sum([(field.name, field.type.__default__()) for field in fields], ())),
|
|
798
798
|
co_varnames=("self", *field_names),
|
|
799
799
|
),
|
|
800
800
|
template.__globals__,
|
|
@@ -20,7 +20,7 @@ class WcharArray(str, BaseType, metaclass=ArrayMetaType):
|
|
|
20
20
|
return stream.write(data.encode(Wchar.__encoding_map__[cls.cs.endian]))
|
|
21
21
|
|
|
22
22
|
@classmethod
|
|
23
|
-
def
|
|
23
|
+
def __default__(cls) -> WcharArray:
|
|
24
24
|
return type.__call__(cls, "\x00" * (0 if cls.dynamic or cls.null_terminated else cls.num_entries))
|
|
25
25
|
|
|
26
26
|
|
|
@@ -75,5 +75,5 @@ class Wchar(str, BaseType):
|
|
|
75
75
|
return stream.write(data.encode(cls.__encoding_map__[cls.cs.endian]))
|
|
76
76
|
|
|
77
77
|
@classmethod
|
|
78
|
-
def
|
|
78
|
+
def __default__(cls) -> Wchar:
|
|
79
79
|
return type.__call__(cls, "\x00")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.dev2
|
|
4
4
|
Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -98,7 +98,7 @@ def test_custom_array_type(cs: cstruct, compiled: bool) -> None:
|
|
|
98
98
|
|
|
99
99
|
class ArrayType(BaseType, metaclass=ArrayMetaType):
|
|
100
100
|
@classmethod
|
|
101
|
-
def
|
|
101
|
+
def __default__(cls) -> CustomType:
|
|
102
102
|
return cls.type()
|
|
103
103
|
|
|
104
104
|
@classmethod
|
|
@@ -46,6 +46,6 @@ def test_char_eof(cs: cstruct) -> None:
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def test_char_default(cs: cstruct) -> None:
|
|
49
|
-
assert cs.char.
|
|
50
|
-
assert cs.char[4].
|
|
51
|
-
assert cs.char[None].
|
|
49
|
+
assert cs.char.__default__() == b"\x00"
|
|
50
|
+
assert cs.char[4].__default__() == b"\x00\x00\x00\x00"
|
|
51
|
+
assert cs.char[None].__default__() == b""
|
|
@@ -13,8 +13,8 @@ class EtwPointer(BaseType):
|
|
|
13
13
|
size: int | None
|
|
14
14
|
|
|
15
15
|
@classmethod
|
|
16
|
-
def
|
|
17
|
-
return cls.cs.uint64.
|
|
16
|
+
def __default__(cls) -> int:
|
|
17
|
+
return cls.cs.uint64.__default__()
|
|
18
18
|
|
|
19
19
|
@classmethod
|
|
20
20
|
def _read(cls, stream: BinaryIO, context: dict[str, Any] | None = None) -> BaseType:
|
|
@@ -82,10 +82,10 @@ def test_custom_default(cs: cstruct) -> None:
|
|
|
82
82
|
cs.add_custom_type("EtwPointer", EtwPointer)
|
|
83
83
|
|
|
84
84
|
cs.EtwPointer.as_64bit()
|
|
85
|
-
assert cs.EtwPointer.
|
|
85
|
+
assert cs.EtwPointer.__default__() == 0
|
|
86
86
|
|
|
87
87
|
cs.EtwPointer.as_32bit()
|
|
88
|
-
assert cs.EtwPointer.
|
|
88
|
+
assert cs.EtwPointer.__default__() == 0
|
|
89
89
|
|
|
90
|
-
assert cs.EtwPointer[1].
|
|
91
|
-
assert cs.EtwPointer[None].
|
|
90
|
+
assert cs.EtwPointer[1].__default__() == [0]
|
|
91
|
+
assert cs.EtwPointer[None].__default__() == []
|
|
@@ -418,6 +418,21 @@ def test_enum_default(cs: cstruct) -> None:
|
|
|
418
418
|
"""
|
|
419
419
|
cs.load(cdef)
|
|
420
420
|
|
|
421
|
-
assert cs.test.
|
|
422
|
-
assert cs.test[1].
|
|
423
|
-
assert cs.test[None].
|
|
421
|
+
assert cs.test.__default__() == cs.test.A == cs.test(0)
|
|
422
|
+
assert cs.test[1].__default__() == [cs.test.A]
|
|
423
|
+
assert cs.test[None].__default__() == []
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def test_enum_default_default(cs: cstruct) -> None:
|
|
427
|
+
cdef = """
|
|
428
|
+
enum test {
|
|
429
|
+
default = 0,
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
struct test2 {
|
|
433
|
+
test a;
|
|
434
|
+
};
|
|
435
|
+
"""
|
|
436
|
+
cs.load(cdef)
|
|
437
|
+
|
|
438
|
+
assert cs.test.__default__() == cs.test.default == cs.test(0)
|
|
@@ -266,6 +266,6 @@ def test_flag_default(cs: cstruct) -> None:
|
|
|
266
266
|
"""
|
|
267
267
|
cs.load(cdef)
|
|
268
268
|
|
|
269
|
-
assert cs.test.
|
|
270
|
-
assert cs.test[1].
|
|
271
|
-
assert cs.test[None].
|
|
269
|
+
assert cs.test.__default__() == cs.test(0)
|
|
270
|
+
assert cs.test[1].__default__() == [cs.test(0)]
|
|
271
|
+
assert cs.test[None].__default__() == []
|
|
@@ -403,10 +403,10 @@ def test_int_struct_unsigned_be(cs: cstruct, compiled: bool) -> None:
|
|
|
403
403
|
|
|
404
404
|
|
|
405
405
|
def test_int_default(cs: cstruct) -> None:
|
|
406
|
-
assert cs.int24.
|
|
407
|
-
assert cs.uint24.
|
|
408
|
-
assert cs.int128.
|
|
409
|
-
assert cs.uint128.
|
|
406
|
+
assert cs.int24.__default__() == 0
|
|
407
|
+
assert cs.uint24.__default__() == 0
|
|
408
|
+
assert cs.int128.__default__() == 0
|
|
409
|
+
assert cs.uint128.__default__() == 0
|
|
410
410
|
|
|
411
|
-
assert cs.int24[1].
|
|
412
|
-
assert cs.int24[None].
|
|
411
|
+
assert cs.int24[1].__default__() == [0]
|
|
412
|
+
assert cs.int24[None].__default__() == []
|
|
@@ -192,8 +192,8 @@ def test_leb128_unsigned_write_amount_written(cs: cstruct) -> None:
|
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
def test_leb128_default(cs: cstruct) -> None:
|
|
195
|
-
assert cs.uleb128.
|
|
196
|
-
assert cs.ileb128.
|
|
195
|
+
assert cs.uleb128.__default__() == 0
|
|
196
|
+
assert cs.ileb128.__default__() == 0
|
|
197
197
|
|
|
198
|
-
assert cs.uleb128[1].
|
|
199
|
-
assert cs.uleb128[None].
|
|
198
|
+
assert cs.uleb128[1].__default__() == [0]
|
|
199
|
+
assert cs.uleb128[None].__default__() == []
|
|
@@ -172,17 +172,17 @@ def test_packed_float_struct_be(cs: cstruct, compiled: bool) -> None:
|
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
def test_packed_default(cs: cstruct) -> None:
|
|
175
|
-
assert cs.int8.
|
|
176
|
-
assert cs.uint8.
|
|
177
|
-
assert cs.int16.
|
|
178
|
-
assert cs.uint16.
|
|
179
|
-
assert cs.int32.
|
|
180
|
-
assert cs.uint32.
|
|
181
|
-
assert cs.int64.
|
|
182
|
-
assert cs.uint64.
|
|
183
|
-
assert cs.float16.
|
|
184
|
-
assert cs.float.
|
|
185
|
-
assert cs.double.
|
|
186
|
-
|
|
187
|
-
assert cs.int8[2].
|
|
188
|
-
assert cs.int8[None].
|
|
175
|
+
assert cs.int8.__default__() == 0
|
|
176
|
+
assert cs.uint8.__default__() == 0
|
|
177
|
+
assert cs.int16.__default__() == 0
|
|
178
|
+
assert cs.uint16.__default__() == 0
|
|
179
|
+
assert cs.int32.__default__() == 0
|
|
180
|
+
assert cs.uint32.__default__() == 0
|
|
181
|
+
assert cs.int64.__default__() == 0
|
|
182
|
+
assert cs.uint64.__default__() == 0
|
|
183
|
+
assert cs.float16.__default__() == 0.0
|
|
184
|
+
assert cs.float.__default__() == 0.0
|
|
185
|
+
assert cs.double.__default__() == 0.0
|
|
186
|
+
|
|
187
|
+
assert cs.int8[2].__default__() == [0, 0]
|
|
188
|
+
assert cs.int8[None].__default__() == []
|
|
@@ -242,10 +242,10 @@ def test_pointer_default(cs: cstruct) -> None:
|
|
|
242
242
|
cs.pointer = cs.uint8
|
|
243
243
|
|
|
244
244
|
ptr = cs._make_pointer(cs.uint8)
|
|
245
|
-
assert isinstance(ptr.
|
|
246
|
-
assert ptr.
|
|
247
|
-
assert ptr[1].
|
|
248
|
-
assert ptr[None].
|
|
245
|
+
assert isinstance(ptr.__default__(), Pointer)
|
|
246
|
+
assert ptr.__default__() == 0
|
|
247
|
+
assert ptr[1].__default__() == [0]
|
|
248
|
+
assert ptr[None].__default__() == []
|
|
249
249
|
|
|
250
250
|
with pytest.raises(NullPointerDereference):
|
|
251
|
-
ptr.
|
|
251
|
+
ptr.__default__().dereference()
|
|
@@ -599,9 +599,9 @@ def test_structure_default(cs: cstruct, compiled: bool) -> None:
|
|
|
599
599
|
|
|
600
600
|
assert verify_compiled(cs.test, compiled)
|
|
601
601
|
|
|
602
|
-
assert cs.test() == cs.test.
|
|
602
|
+
assert cs.test() == cs.test.__default__()
|
|
603
603
|
|
|
604
|
-
obj = cs.test.
|
|
604
|
+
obj = cs.test.__default__()
|
|
605
605
|
assert obj.t_int == 0
|
|
606
606
|
assert obj.t_int_array == [0, 0]
|
|
607
607
|
assert obj.t_bytesint == 0
|
|
@@ -625,11 +625,11 @@ def test_structure_default(cs: cstruct, compiled: bool) -> None:
|
|
|
625
625
|
for name in obj.fields.keys():
|
|
626
626
|
assert isinstance(getattr(obj, name), BaseType)
|
|
627
627
|
|
|
628
|
-
assert cs.test_nested() == cs.test_nested.
|
|
628
|
+
assert cs.test_nested() == cs.test_nested.__default__()
|
|
629
629
|
|
|
630
|
-
obj = cs.test_nested.
|
|
631
|
-
assert obj.t_struct == cs.test.
|
|
632
|
-
assert obj.t_struct_array == [cs.test.
|
|
630
|
+
obj = cs.test_nested.__default__()
|
|
631
|
+
assert obj.t_struct == cs.test.__default__()
|
|
632
|
+
assert obj.t_struct_array == [cs.test.__default__(), cs.test.__default__()]
|
|
633
633
|
|
|
634
634
|
assert obj.dumps() == b"\x00" * 171
|
|
635
635
|
|
|
@@ -678,7 +678,7 @@ def test_structure_default_dynamic(cs: cstruct, compiled: bool) -> None:
|
|
|
678
678
|
|
|
679
679
|
assert verify_compiled(cs.test, compiled)
|
|
680
680
|
|
|
681
|
-
assert cs.test() == cs.test.
|
|
681
|
+
assert cs.test() == cs.test.__default__()
|
|
682
682
|
|
|
683
683
|
obj = cs.test()
|
|
684
684
|
assert obj.t_int_array_n == obj.t_int_array_d == []
|
|
@@ -694,9 +694,9 @@ def test_structure_default_dynamic(cs: cstruct, compiled: bool) -> None:
|
|
|
694
694
|
for name in obj.fields.keys():
|
|
695
695
|
assert isinstance(getattr(obj, name), BaseType)
|
|
696
696
|
|
|
697
|
-
assert cs.test_nested() == cs.test_nested.
|
|
697
|
+
assert cs.test_nested() == cs.test_nested.__default__()
|
|
698
698
|
|
|
699
|
-
obj = cs.test_nested.
|
|
699
|
+
obj = cs.test_nested.__default__()
|
|
700
700
|
assert obj.t_struct_n == obj.t_struct_array_d == []
|
|
701
701
|
|
|
702
702
|
assert obj.dumps() == b"\x00" * 21
|
|
@@ -414,7 +414,7 @@ def test_union_default(cs: cstruct) -> None:
|
|
|
414
414
|
"""
|
|
415
415
|
cs.load(cdef)
|
|
416
416
|
|
|
417
|
-
assert cs.test() == cs.test.
|
|
417
|
+
assert cs.test() == cs.test.__default__()
|
|
418
418
|
|
|
419
419
|
obj = cs.test()
|
|
420
420
|
assert obj.a == 0
|
|
@@ -425,11 +425,11 @@ def test_union_default(cs: cstruct) -> None:
|
|
|
425
425
|
for name in obj.fields.keys():
|
|
426
426
|
assert isinstance(getattr(obj, name), BaseType)
|
|
427
427
|
|
|
428
|
-
assert cs.test_nested() == cs.test_nested.
|
|
428
|
+
assert cs.test_nested() == cs.test_nested.__default__()
|
|
429
429
|
|
|
430
|
-
obj = cs.test_nested.
|
|
431
|
-
assert obj.t_union == cs.test.
|
|
432
|
-
assert obj.t_union_array == [cs.test.
|
|
430
|
+
obj = cs.test_nested.__default__()
|
|
431
|
+
assert obj.t_union == cs.test.__default__()
|
|
432
|
+
assert obj.t_union_array == [cs.test.__default__(), cs.test.__default__()]
|
|
433
433
|
|
|
434
434
|
assert obj.dumps() == b"\x00" * 24
|
|
435
435
|
|
|
@@ -33,12 +33,12 @@ def test_void_array_write(cs: cstruct) -> None:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def test_void_default(cs: cstruct) -> None:
|
|
36
|
-
assert cs.void() == cs.void.
|
|
36
|
+
assert cs.void() == cs.void.__default__()
|
|
37
37
|
assert not cs.void()
|
|
38
|
-
assert not cs.void.
|
|
38
|
+
assert not cs.void.__default__()
|
|
39
39
|
|
|
40
|
-
assert cs.void[1].
|
|
41
|
-
assert cs.void[None].
|
|
40
|
+
assert cs.void[1].__default__() == [cs.void()]
|
|
41
|
+
assert cs.void[None].__default__() == []
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def test_void_struct(cs: cstruct, compiled: bool) -> None:
|
|
@@ -78,6 +78,6 @@ def test_wchar_eof(cs: cstruct) -> None:
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
def test_wchar_default(cs: cstruct) -> None:
|
|
81
|
-
assert cs.wchar.
|
|
82
|
-
assert cs.wchar[4].
|
|
83
|
-
assert cs.wchar[None].
|
|
81
|
+
assert cs.wchar.__default__() == "\x00"
|
|
82
|
+
assert cs.wchar[4].__default__() == "\x00\x00\x00\x00"
|
|
83
|
+
assert cs.wchar[None].__default__() == ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.3.dev1 → dissect_cstruct-4.3.dev2}/dissect.cstruct.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|