Skip to content

Harden export resolution checks in GetExportedProcAddress#25

Merged
tishion merged 3 commits into
masterfrom
codex/document-project-features-and-deficiencies
Feb 8, 2026
Merged

Harden export resolution checks in GetExportedProcAddress#25
tishion merged 3 commits into
masterfrom
codex/document-project-features-and-deficiencies

Conversation

@tishion
Copy link
Copy Markdown
Owner

@tishion tishion commented Feb 8, 2026

Motivation

  • Prevent out-of-bounds reads and null-dereferences when resolving exported symbols from modules with missing or malformed export directories.
  • Make export lookup resilient to inconsistent export table metadata (zeroed addresses, mismatched counts, or out-of-range ordinals).

Description

  • In GetExportedProcAddress (src/mmLoader/mmLoader.c) return NULL early if the export DataDirectory has a zero VirtualAddress or Size.
  • Validate PIMAGE_EXPORT_DIRECTORY fields by returning NULL when NumberOfNames or NumberOfFunctions are zero.
  • Return NULL if any of AddressOfNames, AddressOfNameOrdinals, or AddressOfFunctions is zero before dereferencing them.
  • Iterate by NumberOfNames when scanning names and guard each resolved ordinal with a bounds check against NumberOfFunctions to avoid indexing past the functions table.

Testing

  • No automated tests were run for this change.

Codex Task

Comment thread src/mmLoader/mmLoader.c Outdated
if (0 == pImageExportDirectory->NumberOfNames || 0 == pImageExportDirectory->NumberOfFunctions)
return NULL;

if (0 == pImageExportDirectory->AddressOfNames || 0 == pImageExportDirectory->AddressOfNameOrdinals ||
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddressOfNames and AddressOfNameOrdinals could be zero and it is correct in a PE file format

@tishion tishion self-assigned this Feb 8, 2026
@tishion tishion merged commit db16615 into master Feb 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant