From cdddf02d0cc180ba5eacee7b1f5774bdebfae02b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 26 Oct 2018 13:24:41 +0200 Subject: [PATCH] kernel32: Implement CreateProcessInternalA/W. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a patch by Michael Müller. Signed-off-by: Alexandre Julliard --- dlls/kernel32/kernel32.spec | 4 +-- dlls/kernel32/process.c | 49 +++++++++++++++++++++++---------- dlls/kernelbase/kernelbase.spec | 4 +-- include/winbase.h | 3 ++ 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index afd44dfe1c5..80da9c8e2e2 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -314,8 +314,8 @@ # @ stub CreatePrivateNamespaceW @ stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr) # @ stub CreateProcessAsUserW -# @ stub CreateProcessInternalA -# @ stub CreateProcessInternalW +@ stdcall CreateProcessInternalA(long str str ptr ptr long long ptr str ptr ptr ptr) +@ stdcall CreateProcessInternalW(long wstr wstr ptr ptr long long ptr wstr ptr ptr ptr) # @ stub CreateProcessInternalWSecure @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 1490f6dadbd..4d30f3a4fd3 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -2660,12 +2660,14 @@ static LPWSTR get_file_name( LPCWSTR appname, LPWSTR cmdline, LPWSTR buffer, return ret; } - -/* Steam hotpatches CreateProcessA and W, so to prevent it from crashing use an internal function */ -static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIBUTES process_attr, - LPSECURITY_ATTRIBUTES thread_attr, BOOL inherit, DWORD flags, - LPVOID env, LPCWSTR cur_dir, LPSTARTUPINFOW startup_info, - LPPROCESS_INFORMATION info ) +/********************************************************************** + * CreateProcessInternalW (KERNEL32.@) + */ +BOOL WINAPI CreateProcessInternalW( HANDLE token, LPCWSTR app_name, LPWSTR cmd_line, + LPSECURITY_ATTRIBUTES process_attr, LPSECURITY_ATTRIBUTES thread_attr, + BOOL inherit, DWORD flags, LPVOID env, LPCWSTR cur_dir, + LPSTARTUPINFOW startup_info, LPPROCESS_INFORMATION info, + HANDLE *new_token ) { BOOL retv = FALSE; HANDLE hFile = 0; @@ -2681,6 +2683,9 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A TRACE("app %s cmdline %s\n", debugstr_w(app_name), debugstr_w(cmd_line) ); + if (token) FIXME("Creating a process with a token is not yet implemented\n"); + if (new_token) FIXME("No support for returning created process token\n"); + if (!(tidy_cmdline = get_file_name( app_name, cmd_line, name, ARRAY_SIZE( name ), &hFile, &is_64bit ))) return FALSE; if (hFile == INVALID_HANDLE_VALUE) goto done; @@ -2798,12 +2803,13 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A /********************************************************************** - * CreateProcessA (KERNEL32.@) + * CreateProcessInternalA (KERNEL32.@) */ -BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUTES process_attr, - LPSECURITY_ATTRIBUTES thread_attr, BOOL inherit, - DWORD flags, LPVOID env, LPCSTR cur_dir, - LPSTARTUPINFOA startup_info, LPPROCESS_INFORMATION info ) +BOOL WINAPI CreateProcessInternalA( HANDLE token, LPCSTR app_name, LPSTR cmd_line, + LPSECURITY_ATTRIBUTES process_attr, LPSECURITY_ATTRIBUTES thread_attr, + BOOL inherit, DWORD flags, LPVOID env, LPCSTR cur_dir, + LPSTARTUPINFOA startup_info, LPPROCESS_INFORMATION info, + HANDLE *new_token ) { BOOL ret = FALSE; WCHAR *app_nameW = NULL, *cmd_lineW = NULL, *cur_dirW = NULL; @@ -2827,8 +2833,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA( LPCSTR app_name, LPSTR cmd_line, L FIXME("StartupInfo.lpReserved is used, please report (%s)\n", debugstr_a(startup_info->lpReserved)); - ret = create_process_impl( app_nameW, cmd_lineW, process_attr, thread_attr, - inherit, flags, env, cur_dirW, &infoW, info ); + ret = CreateProcessInternalW( token, app_nameW, cmd_lineW, process_attr, thread_attr, + inherit, flags, env, cur_dirW, &infoW, info, new_token ); done: HeapFree( GetProcessHeap(), 0, app_nameW ); HeapFree( GetProcessHeap(), 0, cmd_lineW ); @@ -2839,6 +2845,19 @@ done: } +/********************************************************************** + * CreateProcessA (KERNEL32.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA( LPCSTR app_name, LPSTR cmd_line, LPSECURITY_ATTRIBUTES process_attr, + LPSECURITY_ATTRIBUTES thread_attr, BOOL inherit, + DWORD flags, LPVOID env, LPCSTR cur_dir, + LPSTARTUPINFOA startup_info, LPPROCESS_INFORMATION info ) +{ + return CreateProcessInternalA( NULL, app_name, cmd_line, process_attr, thread_attr, + inherit, flags, env, cur_dir, startup_info, info, NULL ); +} + + /********************************************************************** * CreateProcessW (KERNEL32.@) */ @@ -2847,8 +2866,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPVOID env, LPCWSTR cur_dir, LPSTARTUPINFOW startup_info, LPPROCESS_INFORMATION info ) { - return create_process_impl( app_name, cmd_line, process_attr, thread_attr, - inherit, flags, env, cur_dir, startup_info, info); + return CreateProcessInternalW( NULL, app_name, cmd_line, process_attr, thread_attr, + inherit, flags, env, cur_dir, startup_info, info, NULL ); } diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index e01f1098238..d79957193a9 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -208,8 +208,8 @@ @ stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr) kernel32.CreateProcessA @ stdcall CreateProcessAsUserA(long str str ptr ptr long long ptr str ptr ptr) advapi32.CreateProcessAsUserA @ stdcall CreateProcessAsUserW(long wstr wstr ptr ptr long long ptr wstr ptr ptr) advapi32.CreateProcessAsUserW -# @ stub CreateProcessInternalA -# @ stub CreateProcessInternalW +@ stdcall CreateProcessInternalA(long str str ptr ptr long long ptr str ptr ptr ptr) kernel32.CreateProcessInternalA +@ stdcall CreateProcessInternalW(long wstr wstr ptr ptr long long ptr wstr ptr ptr ptr) kernel32.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 @ stdcall CreateRemoteThreadEx(long ptr long ptr ptr long ptr ptr) kernel32.CreateRemoteThreadEx diff --git a/include/winbase.h b/include/winbase.h index d4fc108534a..20c73af3194 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1865,6 +1865,9 @@ WINBASEAPI BOOL WINAPI CreateProcessW(LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTE WINADVAPI BOOL WINAPI CreateProcessAsUserA(HANDLE,LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION); WINADVAPI BOOL WINAPI CreateProcessAsUserW(HANDLE,LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION); #define CreateProcessAsUser WINELIB_NAME_AW(CreateProcessAsUser) +WINBASEAPI BOOL WINAPI CreateProcessInternalA(HANDLE,LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION,HANDLE*); +WINBASEAPI BOOL WINAPI CreateProcessInternalW(HANDLE,LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION,HANDLE*); +#define CreateProcessInternal WINELIB_NAME_AW(CreateProcessInternal) 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);