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

NtClose hook improvements: #31

Merged
merged 2 commits into from
Sep 2, 2018
Merged

Conversation

Mattiwatti
Copy link
Collaborator

See #29. (2)

I'm not completely clear on the amount of performance degradation caused by going from a fast mutex to a regular kernel mutex. If this turns out to be an issue, shared pushlocks could be an alternative (this would allow multiple simultaneous readers, but exclusive acquire attempts while there are shared owners will guarantee a deadlock.) Pushlocks are also undocumented of course, but when has that ever stopped anyone?

Mattiwatti and others added 2 commits August 27, 2018 04:37
- Change the fast mutex guarding the NtClose hook to a kernel mutex. This is slower but safer since it prevents a deadlock in the case that NtClose recursively calls itself, which is highly unlikely but possible
- Use ObQueryObjectAuditingByHandle() to test handle validity. This has the advantage of not needing to clear and reset the process debug port each time ObCloseHandle is called. This way other kernel threads will never see a NULL debug port on a process that is actually being debugged
- Remove the DebugPort class, which was mostly a lot of hairy version specific code to find the debug port offset. This is no longer needed due to above change

Also add a bunch of casts (HANDLE to ULONG) to satisfy the VS2017 compiler
@mrexodia mrexodia merged commit 5340a7d into mrexodia:master Sep 2, 2018
@Mattiwatti Mattiwatti deleted the mutex-ntclose branch September 2, 2018 00:21
buldi pushed a commit to buldi/TitanHide that referenced this pull request Apr 24, 2022
- Change the fast mutex guarding the NtClose hook to a kernel mutex. This is slower but safer since it prevents a deadlock in the case that NtClose recursively calls itself, which is highly unlikely but possible
- Use ObQueryObjectAuditingByHandle() to test handle validity. This has the advantage of not needing to clear and reset the process debug port each time ObCloseHandle is called. This way other kernel threads will never see a NULL debug port on a process that is actually being debugged
- Remove the DebugPort class, which was mostly a lot of hairy version specific code to find the debug port offset. This is no longer needed due to above change

Also add a bunch of casts (HANDLE to ULONG) to satisfy the VS2017 compiler
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.

2 participants