From 32617e814a717af69a03604fceebb0b9693ed4df Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 25 Feb 2018 19:36:43 +0300 Subject: [PATCH] kernel32: Add CreateRemoteThreadEx(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- ...api-ms-win-core-processthreads-l1-1-0.spec | 2 +- ...api-ms-win-core-processthreads-l1-1-1.spec | 2 +- ...api-ms-win-core-processthreads-l1-1-2.spec | 2 +- dlls/kernel32/kernel32.spec | 2 +- dlls/kernel32/thread.c | 20 +++++++++++++++---- dlls/kernelbase/kernelbase.spec | 2 +- include/winbase.h | 1 + 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dlls/api-ms-win-core-processthreads-l1-1-0/api-ms-win-core-processthreads-l1-1-0.spec b/dlls/api-ms-win-core-processthreads-l1-1-0/api-ms-win-core-processthreads-l1-1-0.spec index 77414bc367c..ff13d484f67 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-0/api-ms-win-core-processthreads-l1-1-0.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-0/api-ms-win-core-processthreads-l1-1-0.spec @@ -2,7 +2,7 @@ @ stdcall CreateProcessAsUserW(long wstr wstr ptr ptr long long ptr wstr ptr ptr) advapi32.CreateProcessAsUserW @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) kernel32.CreateProcessW @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) kernel32.CreateRemoteThread -@ stub CreateRemoteThreadEx +@ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) kernel32.CreateRemoteThreadEx @ stdcall CreateThread(ptr long ptr long long ptr) kernel32.CreateThread @ stdcall DeleteProcThreadAttributeList(ptr) kernel32.DeleteProcThreadAttributeList @ stdcall ExitProcess(long) kernel32.ExitProcess diff --git a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec index 149678995cc..381db8aa6ea 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec @@ -2,7 +2,7 @@ @ stdcall CreateProcessAsUserW(long wstr wstr ptr ptr long long ptr wstr ptr ptr) advapi32.CreateProcessAsUserW @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) kernel32.CreateProcessW @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) kernel32.CreateRemoteThread -@ stub CreateRemoteThreadEx +@ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) kernel32.CreateRemoteThreadEx @ stdcall CreateThread(ptr long ptr long long ptr) kernel32.CreateThread @ stdcall DeleteProcThreadAttributeList(ptr) kernel32.DeleteProcThreadAttributeList @ stdcall ExitProcess(long) kernel32.ExitProcess diff --git a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec index 7bfbe72106e..fc2feecdb01 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec @@ -2,7 +2,7 @@ @ stdcall CreateProcessAsUserW(long wstr wstr ptr ptr long long ptr wstr ptr ptr) advapi32.CreateProcessAsUserW @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) kernel32.CreateProcessW @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) kernel32.CreateRemoteThread -@ stub CreateRemoteThreadEx +@ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) kernel32.CreateRemoteThreadEx @ stdcall CreateThread(ptr long ptr long long ptr) kernel32.CreateThread @ stdcall DeleteProcThreadAttributeList(ptr) kernel32.DeleteProcThreadAttributeList @ stdcall ExitProcess(long) kernel32.ExitProcess diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index c431ecbfb79..ee11c421a3d 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -319,7 +319,7 @@ # @ stub CreateProcessInternalWSecure @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) -# @ stub CreateRemoteThreadEx +@ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) @ stdcall CreateSemaphoreA(ptr long long str) @ stdcall CreateSemaphoreExA(ptr long long str long long) @ stdcall CreateSemaphoreExW(ptr long long wstr long long) diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c index 6a89993f926..b6ca9f260f3 100644 --- a/dlls/kernel32/thread.c +++ b/dlls/kernel32/thread.c @@ -55,9 +55,18 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T st sa, stack, start, param, flags, id ); } - /*************************************************************************** * CreateRemoteThread (KERNEL32.@) + */ +HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE_T stack, + LPTHREAD_START_ROUTINE start, LPVOID param, + DWORD flags, DWORD *id ) +{ + return CreateRemoteThreadEx( hProcess, sa, stack, start, param, flags, NULL, id ); +} + +/*************************************************************************** + * CreateRemoteThreadEx (KERNEL32.@) * * Creates a thread that runs in the address space of another process * @@ -73,15 +82,18 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T st * Bad start address for RtlCreateUserThread because the library * may be loaded at different address in other process. */ -HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE_T stack, - LPTHREAD_START_ROUTINE start, LPVOID param, - DWORD flags, LPDWORD id ) +HANDLE WINAPI CreateRemoteThreadEx( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE_T stack, + LPTHREAD_START_ROUTINE start, LPVOID param, DWORD flags, + LPPROC_THREAD_ATTRIBUTE_LIST attributes, DWORD *id ) { HANDLE handle; CLIENT_ID client_id; NTSTATUS status; SIZE_T stack_reserve = 0, stack_commit = 0; + if (attributes) + FIXME("thread attributes ignored\n"); + if (flags & STACK_SIZE_PARAM_IS_A_RESERVATION) stack_reserve = stack; else stack_commit = stack; diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index a834bbeb4d5..1a6f1ff0fb6 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -212,7 +212,7 @@ # @ stub CreateProcessInternalW @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) kernel32.CreateProcessW @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) kernel32.CreateRemoteThread -@ stub CreateRemoteThreadEx +@ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) kernel32.CreateRemoteThreadEx @ stdcall CreateRestrictedToken(long long long ptr long ptr long ptr ptr) advapi32.CreateRestrictedToken @ stdcall CreateSemaphoreExW(ptr long long wstr long long) kernel32.CreateSemaphoreExW @ stdcall CreateSemaphoreW(ptr long long wstr) kernel32.CreateSemaphoreW diff --git a/include/winbase.h b/include/winbase.h index cc719c696cd..e47c87a544e 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1844,6 +1844,7 @@ WINADVAPI BOOL WINAPI CreateProcessAsUserW(HANDLE,LPCWSTR,LPWSTR,LPSECUR #define CreateProcessAsUser WINELIB_NAME_AW(CreateProcessAsUser) WINADVAPI BOOL WINAPI CreateProcessWithLogonW(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,LPCWSTR,LPWSTR,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION); WINBASEAPI HANDLE WINAPI CreateRemoteThread(HANDLE,LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPDWORD); +WINBASEAPI HANDLE WINAPI CreateRemoteThreadEx(HANDLE,LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPPROC_THREAD_ATTRIBUTE_LIST,LPDWORD); WINADVAPI BOOL WINAPI CreateRestrictedToken(HANDLE,DWORD,DWORD,PSID_AND_ATTRIBUTES,DWORD,PLUID_AND_ATTRIBUTES,DWORD,PSID_AND_ATTRIBUTES,PHANDLE); WINBASEAPI HANDLE WINAPI CreateSemaphoreA(LPSECURITY_ATTRIBUTES,LONG,LONG,LPCSTR); WINBASEAPI HANDLE WINAPI CreateSemaphoreW(LPSECURITY_ATTRIBUTES,LONG,LONG,LPCWSTR);