dissect.cstruct 4.6.dev7__tar.gz → 4.6.dev8__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.6.dev7 → dissect_cstruct-4.6.dev8}/PKG-INFO +1 -1
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/parser.py +13 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/PKG-INFO +1 -1
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_parser.py +13 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/.git-blame-ignore-revs +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/.gitattributes +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/CHANGELOG.md +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/COPYRIGHT +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/LICENSE +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/MANIFEST.in +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/README.md +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/cstruct.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/expression.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/tools/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/tools/stubgen.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/base.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/enum.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/structure.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/entry_points.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/requires.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/examples/disk.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/examples/mirai.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/examples/pe.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/pyproject.toml +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/setup.cfg +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/_data/testdef.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/_docs/Makefile +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/_docs/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/_docs/conf.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/_docs/index.rst +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/conftest.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_align.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_annotations.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_tools_stubgen.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_enum.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tests/utils.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.dev8
|
|
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
|
|
@@ -57,6 +57,7 @@ class TokenParser(Parser):
|
|
|
57
57
|
TOK = TokenCollection()
|
|
58
58
|
TOK.add(r"#\[(?P<values>[^\]]+)\](?=\s*)", "CONFIG_FLAG")
|
|
59
59
|
TOK.add(r"#define\s+(?P<name>[^\s]+)(?P<value>[^\r\n]*)", "DEFINE")
|
|
60
|
+
TOK.add(r"#undef\s+(?P<name>[^\s]+)\s*", "UNDEF")
|
|
60
61
|
TOK.add(r"#ifdef\s+(?P<name>[^\s]+)\s*", "IFDEF")
|
|
61
62
|
TOK.add(r"#ifndef\s+(?P<name>[^\s]+)\s*", "IFNDEF")
|
|
62
63
|
TOK.add(r"#else\s*", "ELSE")
|
|
@@ -154,6 +155,16 @@ class TokenParser(Parser):
|
|
|
154
155
|
|
|
155
156
|
self.cstruct.consts[match["name"]] = value
|
|
156
157
|
|
|
158
|
+
def _undef(self, tokens: TokenConsumer) -> None:
|
|
159
|
+
const = tokens.consume()
|
|
160
|
+
pattern = self.TOK.patterns[self.TOK.UNDEF]
|
|
161
|
+
match = pattern.match(const.value).groupdict()
|
|
162
|
+
|
|
163
|
+
if match["name"] in self.cstruct.consts:
|
|
164
|
+
del self.cstruct.consts[match["name"]]
|
|
165
|
+
else:
|
|
166
|
+
raise ParserError(f"line {self._lineno(const)}: constant {match['name']!r} not defined")
|
|
167
|
+
|
|
157
168
|
def _enum(self, tokens: TokenConsumer) -> None:
|
|
158
169
|
# We cheat with enums because the entire enum is in the token
|
|
159
170
|
etok = tokens.consume()
|
|
@@ -443,6 +454,8 @@ class TokenParser(Parser):
|
|
|
443
454
|
self._config_flag(tokens)
|
|
444
455
|
elif token == self.TOK.DEFINE:
|
|
445
456
|
self._constant(tokens)
|
|
457
|
+
elif token == self.TOK.UNDEF:
|
|
458
|
+
self._undef(tokens)
|
|
446
459
|
elif token == self.TOK.TYPEDEF:
|
|
447
460
|
self._typedef(tokens)
|
|
448
461
|
elif token == self.TOK.STRUCT:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.dev8
|
|
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
|
|
@@ -163,6 +163,19 @@ def test_typedef_pointer(cs: cstruct) -> None:
|
|
|
163
163
|
assert cs.PIMAGE_DATA_DIRECTORY.type == cs._IMAGE_DATA_DIRECTORY
|
|
164
164
|
|
|
165
165
|
|
|
166
|
+
def test_undef(cs: cstruct) -> None:
|
|
167
|
+
cdef = """
|
|
168
|
+
#define MY_CONST 42
|
|
169
|
+
#undef MY_CONST
|
|
170
|
+
"""
|
|
171
|
+
cs.load(cdef)
|
|
172
|
+
|
|
173
|
+
assert "MY_CONST" not in cs.consts
|
|
174
|
+
|
|
175
|
+
with pytest.raises(ParserError, match="line 1: constant 'MY_CONST' not defined"):
|
|
176
|
+
cs.load("#undef MY_CONST") # This should raise an error since MY_CONST is not defined
|
|
177
|
+
|
|
178
|
+
|
|
166
179
|
def test_conditional_ifdef(cs: cstruct) -> None:
|
|
167
180
|
cdef = """
|
|
168
181
|
#define MY_CONST 42
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/dissect.cstruct.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.6.dev8}/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
|
|
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
|