Skip to content

Fix crash caused by stale hNtdllFile handle on NtClose (#172)#174

Open
ali-asly101 wants to merge 2 commits intox64dbg:masterfrom
ali-asly101:fix-stale-ntdll-handle
Open

Fix crash caused by stale hNtdllFile handle on NtClose (#172)#174
ali-asly101 wants to merge 2 commits intox64dbg:masterfrom
ali-asly101:fix-stale-ntdll-handle

Conversation

@ali-asly101
Copy link

Fixes #172

When NtClose is called on the handle saved by HookedNtOpenFile, hNtdllFile was not being reset. This caused HookedNtCreateSection to match against a recycled handle value, mapping the wrong DLL and crashing in DestroyMappedNtApi.

The same issue could occur with hNtdllSection if the section handle was closed before NtMapViewOfSection.

Fix: Clear hNtdllFile and hNtdllSection in HookedNtClose when the tracked handle is closed. Moved both global declarations to the top of the file so they are visible to HookedNtClose.

Tested: Reproduced the crash using a test program that forces handle reuse via NtOpenFile/NtClose loop. After the fix, the test exits cleanly with no access violation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when loading "acgenral.dll"

1 participant