Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression: LF_UNION should be included in $STRUCTS #12

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions drakpdb/type_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def process_structure_member(member):


def process_structure(struct):
if struct.leaf_type != "LF_STRUCTURE":
if struct.leaf_type not in ["LF_STRUCTURE", "LF_UNION"]:
# Unhandled type of structure
return [0, {}]
if not hasattr(struct.fieldlist, "substructs"):
Expand All @@ -129,7 +129,8 @@ def process_tpi(pdb):
"""
return {
"$STRUCTS": {
name: process_structure(structure)
for name, structure in pdb.STREAM_TPI.structures.items()
type_info.name: process_structure(type_info)
for type_info in pdb.STREAM_TPI.types.values()
if hasattr(type_info, "name")
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "drakpdb"
version = "0.2.1"
version = "0.2.2"
description = "Helper library to generate DRAKVUF profiles."
readme = "README.md"
classifiers = [
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ def pytest_generate_tests(metafunc):
if 'pdb_file' in metafunc.fixturenames:
pdbs_files = list(pdbs_dir.glob("*.pdb"))
metafunc.parametrize('pdb_file', pdbs_files)
if 'nt_kernel_pdb_file' in metafunc.fixturenames:
pdbs_files = list(pdbs_dir.glob("ntkrnlmp*.pdb"))
metafunc.parametrize('nt_kernel_pdb_file', pdbs_files)
11 changes: 11 additions & 0 deletions tests/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ def test_pdb_profile(pdb_file):
assert profile["$FUNCTIONS"]
assert profile["$CONSTANTS"]
assert profile["$METADATA"]


def test_kernel_types(nt_kernel_pdb_file):
profile = make_pdb_profile(nt_kernel_pdb_file)
structs = profile["$STRUCTS"]
# There are parsed structs
assert structs
# including unions like _HANDLE_TABLE_ENTRY
assert "_HANDLE_TABLE_ENTRY" in structs
# Size of structure is more than 0
assert structs["_HANDLE_TABLE_ENTRY"][0] > 0
Loading