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:
		
				
					committed by
					
						 Corinna Vinschen
						Corinna Vinschen
					
				
			
			
				
	
			
			
			
						parent
						
							e30d78d685
						
					
				
				
					commit
					ff3c4a7d2f
				
			| @@ -1,3 +1,9 @@ | |||||||
|  | 2015-10-29  Qian Hong  <qhong@codeweavers.com> | ||||||
|  |  | ||||||
|  | 	* init.cc (munge_threadfunc): Check that we're actually replacing | ||||||
|  | 	the correct original function address on the stack. | ||||||
|  | 	* ntdll.h (enum _THREADINFOCLASS): Add ThreadQuerySetWin32StartAddress. | ||||||
|  |  | ||||||
| 2015-08-21  Jon Turney  <jon.turney@dronecode.org.uk> | 2015-08-21  Jon Turney  <jon.turney@dronecode.org.uk> | ||||||
|  |  | ||||||
| 	* cygwin-cxx.h: Remove execute permissions. | 	* cygwin-cxx.h: Remove execute permissions. | ||||||
|   | |||||||
| @@ -55,11 +55,16 @@ munge_threadfunc () | |||||||
|  |  | ||||||
|   if (threadfunc_ix[0]) |   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) |       if (!search_for || threadfunc == search_for) | ||||||
| 	{ | 	{ | ||||||
| 	  search_for = NULL; | 	  search_for = NULL; | ||||||
| 	  for (i = 0; threadfunc_ix[i]; i++) | 	  for (i = 0; threadfunc_ix[i]; i++) | ||||||
|  | 	    if (!threadfunc || ebp[threadfunc_ix[i]] == threadfunc) | ||||||
| 	       ebp[threadfunc_ix[i]] = (char *) threadfunc_fe; | 	       ebp[threadfunc_ix[i]] = (char *) threadfunc_fe; | ||||||
| 	  TlsSetValue (_my_oldfunc, threadfunc); | 	  TlsSetValue (_my_oldfunc, threadfunc); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1162,7 +1162,8 @@ typedef enum _THREADINFOCLASS | |||||||
| { | { | ||||||
|   ThreadBasicInformation = 0, |   ThreadBasicInformation = 0, | ||||||
|   ThreadTimes = 1, |   ThreadTimes = 1, | ||||||
|   ThreadImpersonationToken = 5 |   ThreadImpersonationToken = 5, | ||||||
|  |   ThreadQuerySetWin32StartAddress = 9 | ||||||
| } THREADINFOCLASS, *PTHREADINFOCLASS; | } THREADINFOCLASS, *PTHREADINFOCLASS; | ||||||
|  |  | ||||||
| /* Checked on 64 bit. */ | /* Checked on 64 bit. */ | ||||||
|   | |||||||
| @@ -50,3 +50,6 @@ Bug Fixes | |||||||
|  |  | ||||||
| - Avoid SEGV when handling SIDs with 0 subauthorities. | - Avoid SEGV when handling SIDs with 0 subauthorities. | ||||||
|   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00141.html |   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00141.html | ||||||
|  |  | ||||||
|  | - Fix a potential SEGV on (at least) Wine. | ||||||
|  |   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00018.html | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user