[2/2] ntdll: Improve check_atl_thunk to prevent passing exceptions to the usermode application.

Sebastian Lackner sebastian at fds-team.de
Tue Oct 14 01:26:27 CDT 2014

This patch fixes the issue described in patch 1/2.

This patch adds some new functions to ntdll/virtual.c, which can be used to access memory of the local process without triggering any exceptions. So far these functions are only used for the ATL thunk check, but it might also make sense to use them in the future for other parts, for example the check for privileged instructions. In contrary to NtReadVirtualMemory / NtWriteVirtualMemory those functions do not have the wineserver call overhead.

This solution is the best at my opinion, but if an alternative method is preferred, we still have the following options:

* Call NtQueryVirtualMemory before the actual ATL thunk check - this should work most of the time, but could lead to race-conditions when multithreaded apps modify permissions in one thread, and execute code in a second one.

* Introducing some new kind of exception handler type, which can be safely used within the "kernel" part of ntdll, so that exceptions are not passed to debuggers / vectored handlers. Thats probably a bit overkill, at least when its only used at a single place.

* Use NtQueryVirtualMemory for the permissions and Nt{Read,Write}VirtualMemory for accessing the data. This should be relatively safe, but is probably the slowest possible solution ;)

 dlls/kernel32/tests/virtual.c |  1 -
 dlls/ntdll/ntdll_misc.h       |  2 ++
 dlls/ntdll/signal_i386.c      | 20 +++++------
 dlls/ntdll/virtual.c          | 78 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 12 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ntdll-Improve-check_atl_thunk-to-prevent-passing-exc.patch
Type: text/x-patch
Size: 6775 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20141014/665f4860/attachment.bin>

More information about the wine-patches mailing list