Check for correct funtion entry address in munge_threadfunc

* init.cc (munge_threadfunc): Check that we're actually replacing
	the correct original function address on the stack.
	* ntdll.h (enum _THREADINFOCLASS): Add ThreadQuerySetWin32StartAddress.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Qian Hong
2015-10-29 09:17:46 +01:00
committed by Corinna Vinschen
parent e30d78d685
commit ff3c4a7d2f
4 changed files with 18 additions and 3 deletions

View File

@ -55,12 +55,17 @@ munge_threadfunc ()
if (threadfunc_ix[0])
{
char *threadfunc = ebp[threadfunc_ix[0]];
char *threadfunc = NULL;
NtQueryInformationThread (NtCurrentThread (),
ThreadQuerySetWin32StartAddress,
&threadfunc, sizeof threadfunc, NULL);
if (!search_for || threadfunc == search_for)
{
search_for = NULL;
for (i = 0; threadfunc_ix[i]; i++)
ebp[threadfunc_ix[i]] = (char *) threadfunc_fe;
if (!threadfunc || ebp[threadfunc_ix[i]] == threadfunc)
ebp[threadfunc_ix[i]] = (char *) threadfunc_fe;
TlsSetValue (_my_oldfunc, threadfunc);
}
}