dissect.cstruct 4.6.dev1__tar.gz → 4.6.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.6.dev1 → dissect_cstruct-4.6.dev2}/PKG-INFO +1 -1
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/cstruct.py +1 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/parser.py +10 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/PKG-INFO +1 -1
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_parser.py +21 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/.git-blame-ignore-revs +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/.gitattributes +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/CHANGELOG.md +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/COPYRIGHT +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/LICENSE +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/MANIFEST.in +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/README.md +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/expression.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/tools/__init__.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/tools/stubgen.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/base.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/enum.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/structure.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/entry_points.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/requires.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/examples/disk.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/examples/mirai.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/examples/pe.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/pyproject.toml +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/setup.cfg +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/__init__.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/_data/testdef.txt +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/_docs/Makefile +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/_docs/__init__.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/_docs/conf.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/_docs/index.rst +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/conftest.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_align.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_annotations.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_tools_stubgen.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_enum.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/tests/utils.py +0 -0
- {dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/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.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
|
|
@@ -64,6 +64,7 @@ class TokenParser(Parser):
|
|
|
64
64
|
)
|
|
65
65
|
TOK.add(r"(?<=})\s*(?P<defs>(?:[a-zA-Z0-9_]+\s*,\s*)+[a-zA-Z0-9_]+)\s*(?=;)", "DEFS")
|
|
66
66
|
TOK.add(r"(?P<name>\**?\s*[a-zA-Z0-9_]+)(?:\s*:\s*(?P<bits>\d+))?(?:\[(?P<count>[^;\n]*)\])?\s*(?=;)", "NAME")
|
|
67
|
+
TOK.add(r"#include\s+(?P<name>[^\s]+)\s*", "INCLUDE")
|
|
67
68
|
TOK.add(r"[a-zA-Z_][a-zA-Z0-9_]*", "IDENTIFIER")
|
|
68
69
|
TOK.add(r"[{}]", "BLOCK")
|
|
69
70
|
TOK.add(r"\$(?P<name>[^\s]+) = (?P<value>{[^}]+})\w*[\r\n]+", "LOOKUP")
|
|
@@ -324,6 +325,13 @@ class TokenParser(Parser):
|
|
|
324
325
|
|
|
325
326
|
return names
|
|
326
327
|
|
|
328
|
+
def _include(self, tokens: TokenConsumer) -> None:
|
|
329
|
+
include = tokens.consume()
|
|
330
|
+
pattern = self.TOK.patterns[self.TOK.INCLUDE]
|
|
331
|
+
match = pattern.match(include.value).groupdict()
|
|
332
|
+
|
|
333
|
+
self.cstruct.includes.append(match["name"].strip().strip("'\""))
|
|
334
|
+
|
|
327
335
|
@staticmethod
|
|
328
336
|
def _remove_comments(string: str) -> str:
|
|
329
337
|
# https://stackoverflow.com/a/18381470
|
|
@@ -382,6 +390,8 @@ class TokenParser(Parser):
|
|
|
382
390
|
self._enum(tokens)
|
|
383
391
|
elif token == self.TOK.LOOKUP:
|
|
384
392
|
self._lookup(tokens)
|
|
393
|
+
elif token == self.TOK.INCLUDE:
|
|
394
|
+
self._include(tokens)
|
|
385
395
|
else:
|
|
386
396
|
raise ParserError(f"line {self._lineno(token)}: unexpected token {token!r}")
|
|
387
397
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.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
|
|
@@ -129,3 +129,24 @@ def test_structure_names(cs: cstruct) -> None:
|
|
|
129
129
|
assert cs.c.__name__ == "c"
|
|
130
130
|
assert cs.d.__name__ == "c"
|
|
131
131
|
assert cs.e.__name__ == "e"
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def test_includes(cs: cstruct) -> None:
|
|
135
|
+
cdef = """
|
|
136
|
+
/* Standard libs */
|
|
137
|
+
#include <stdint.h> // defines fixed data types: int8_t...
|
|
138
|
+
/* user libs */
|
|
139
|
+
#include "myLib.h" // my own header
|
|
140
|
+
|
|
141
|
+
typedef struct myStruct
|
|
142
|
+
{
|
|
143
|
+
char charVal[16];
|
|
144
|
+
}
|
|
145
|
+
"""
|
|
146
|
+
cs.load(cdef)
|
|
147
|
+
|
|
148
|
+
assert cs.includes == ["<stdint.h>", "myLib.h"]
|
|
149
|
+
assert cs.myStruct.__name__ == "myStruct"
|
|
150
|
+
assert len(cs.myStruct.fields) == 1
|
|
151
|
+
assert cs.myStruct.fields.get("charVal")
|
|
152
|
+
|
|
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.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.dev2}/dissect.cstruct.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.6.dev1 → dissect_cstruct-4.6.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
|
|
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
|