mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[0.4.10] [ADVAPI32] Avoid regression CORE-14874 "Java 7u80 fails to install"
by reverting "[ADVAPI32] Additions for CreateProcessAsUserA/W()."
This reverts commit 0.4.10-dev-260-g
d4b4da5385
Afterwards I could install Java 7u80 again
and the Java-dependent app "pdfSam 2.2.4" did install and run.
This commit is contained in:
parent
bb4c55d650
commit
32ce3885d5
2 changed files with 94 additions and 180 deletions
|
@ -23,14 +23,12 @@
|
|||
#define _WMI_SOURCE_
|
||||
#include <aclapi.h>
|
||||
#include <winsafer.h>
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/iofuncs.h>
|
||||
#include <ndk/obfuncs.h>
|
||||
#include <ndk/psfuncs.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <ndk/sefuncs.h>
|
||||
#include <ndk/setypes.h>
|
||||
|
||||
/* this has to go after the NDK when being used with the NDK */
|
||||
#include <ntsecapi.h>
|
||||
|
|
|
@ -86,132 +86,58 @@ CloseLogonLsaHandle(VOID)
|
|||
}
|
||||
|
||||
|
||||
static
|
||||
BOOL
|
||||
CreateProcessAsUserCommon(
|
||||
_In_ BOOL bUnicode,
|
||||
_In_opt_ HANDLE hToken,
|
||||
_In_opt_ LPCVOID lpApplicationName,
|
||||
_Inout_opt_ LPVOID lpCommandLine,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
_In_ BOOL bInheritHandles,
|
||||
_In_ DWORD dwCreationFlags,
|
||||
_In_opt_ LPVOID lpEnvironment,
|
||||
_In_opt_ LPCVOID lpCurrentDirectory,
|
||||
_In_ LPVOID lpStartupInfo,
|
||||
_Out_ LPPROCESS_INFORMATION lpProcessInformation)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH
|
||||
CreateProcessAsUserA(HANDLE hToken,
|
||||
LPCSTR lpApplicationName,
|
||||
LPSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
BOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFOA lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PROCESS_ACCESS_TOKEN AccessToken;
|
||||
NTSTATUS Status;
|
||||
|
||||
TRACE("%p %s %s %p %p %d 0x%08x %p %s %p %p\n", hToken, debugstr_a(lpApplicationName),
|
||||
debugstr_a(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles,
|
||||
dwCreationFlags, lpEnvironment, debugstr_a(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
|
||||
|
||||
/* Create the process with a suspended main thread */
|
||||
if (bUnicode)
|
||||
if (!CreateProcessA(lpApplicationName,
|
||||
lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags | CREATE_SUSPENDED,
|
||||
lpEnvironment,
|
||||
lpCurrentDirectory,
|
||||
lpStartupInfo,
|
||||
lpProcessInformation))
|
||||
{
|
||||
/* Call the UNICODE version */
|
||||
if (!CreateProcessW((LPCWSTR)lpApplicationName,
|
||||
(LPWSTR)lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags | CREATE_SUSPENDED,
|
||||
lpEnvironment,
|
||||
(LPCWSTR)lpCurrentDirectory,
|
||||
(LPSTARTUPINFOW)lpStartupInfo,
|
||||
lpProcessInformation))
|
||||
{
|
||||
ERR("CreateProcessW failed, last error: %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the ANSI version */
|
||||
if (!CreateProcessA((LPCSTR)lpApplicationName,
|
||||
(LPSTR)lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags | CREATE_SUSPENDED,
|
||||
lpEnvironment,
|
||||
(LPCSTR)lpCurrentDirectory,
|
||||
(LPSTARTUPINFOA)lpStartupInfo,
|
||||
lpProcessInformation))
|
||||
{
|
||||
ERR("CreateProcessA failed, last error: %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
ERR("CreateProcessA failed! GLE: %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (hToken != NULL)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hTokenDup;
|
||||
BOOLEAN PrivilegeSet = FALSE;
|
||||
|
||||
/* Duplicate the token for this new process */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL); // FIXME: Use a valid SecurityDescriptor!
|
||||
Status = NtDuplicateToken(hToken,
|
||||
0,
|
||||
&ObjectAttributes,
|
||||
FALSE,
|
||||
TokenPrimary,
|
||||
&hTokenDup);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("NtDuplicateToken failed, Status 0x%08x\n", Status);
|
||||
TerminateProcess(lpProcessInformation->hProcess, Status);
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// FIXME: Do we always need SecurityImpersonation?
|
||||
if (!ImpersonateSelf(SecurityImpersonation))
|
||||
{
|
||||
ERR("ImpersonateSelf(SecurityImpersonation) failed, last error: %d\n", GetLastError());
|
||||
NtClose(hTokenDup);
|
||||
TerminateProcess(lpProcessInformation->hProcess, RtlGetLastNtStatus());
|
||||
// SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Acquire the process primary token assignment privilege */
|
||||
Status = RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, TRUE, &PrivilegeSet);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE) failed, Status 0x%08lx\n", Status);
|
||||
RevertToSelf();
|
||||
NtClose(hTokenDup);
|
||||
TerminateProcess(lpProcessInformation->hProcess, Status);
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AccessToken.Token = hTokenDup;
|
||||
AccessToken.Thread = lpProcessInformation->hThread;
|
||||
AccessToken.Token = hToken;
|
||||
AccessToken.Thread = NULL;
|
||||
|
||||
/* Set the new process token */
|
||||
Status = NtSetInformationProcess(lpProcessInformation->hProcess,
|
||||
ProcessAccessToken,
|
||||
(PVOID)&AccessToken,
|
||||
sizeof(AccessToken));
|
||||
|
||||
/* Restore the privileges */
|
||||
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, PrivilegeSet, TRUE, &PrivilegeSet);
|
||||
|
||||
RevertToSelf();
|
||||
|
||||
/* Close the duplicated token */
|
||||
NtClose(hTokenDup);
|
||||
|
||||
/* Check whether NtSetInformationProcess() failed */
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
ERR("NtSetInformationProcess failed, Status 0x%08x\n", Status);
|
||||
ERR("NtSetInformationProcess failed: 0x%08x\n", Status);
|
||||
TerminateProcess(lpProcessInformation->hProcess, Status);
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
|
@ -231,78 +157,68 @@ CreateProcessAsUserCommon(
|
|||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
DECLSPEC_HOTPATCH
|
||||
CreateProcessAsUserA(
|
||||
_In_opt_ HANDLE hToken,
|
||||
_In_opt_ LPCSTR lpApplicationName,
|
||||
_Inout_opt_ LPSTR lpCommandLine,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
_In_ BOOL bInheritHandles,
|
||||
_In_ DWORD dwCreationFlags,
|
||||
_In_opt_ LPVOID lpEnvironment,
|
||||
_In_opt_ LPCSTR lpCurrentDirectory,
|
||||
_In_ LPSTARTUPINFOA lpStartupInfo,
|
||||
_Out_ LPPROCESS_INFORMATION lpProcessInformation)
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH
|
||||
CreateProcessAsUserW(HANDLE hToken,
|
||||
LPCWSTR lpApplicationName,
|
||||
LPWSTR lpCommandLine,
|
||||
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
BOOL bInheritHandles,
|
||||
DWORD dwCreationFlags,
|
||||
LPVOID lpEnvironment,
|
||||
LPCWSTR lpCurrentDirectory,
|
||||
LPSTARTUPINFOW lpStartupInfo,
|
||||
LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
TRACE("%p %s %s %p %p %d 0x%08x %p %s %p %p\n", hToken, debugstr_a(lpApplicationName),
|
||||
debugstr_a(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles,
|
||||
dwCreationFlags, lpEnvironment, debugstr_a(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
|
||||
PROCESS_ACCESS_TOKEN AccessToken;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Call the helper function */
|
||||
return CreateProcessAsUserCommon(FALSE,
|
||||
hToken,
|
||||
lpApplicationName,
|
||||
lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags,
|
||||
lpEnvironment,
|
||||
lpCurrentDirectory,
|
||||
lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
DECLSPEC_HOTPATCH
|
||||
CreateProcessAsUserW(
|
||||
_In_opt_ HANDLE hToken,
|
||||
_In_opt_ LPCWSTR lpApplicationName,
|
||||
_Inout_opt_ LPWSTR lpCommandLine,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
||||
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
_In_ BOOL bInheritHandles,
|
||||
_In_ DWORD dwCreationFlags,
|
||||
_In_opt_ LPVOID lpEnvironment,
|
||||
_In_opt_ LPCWSTR lpCurrentDirectory,
|
||||
_In_ LPSTARTUPINFOW lpStartupInfo,
|
||||
_Out_ LPPROCESS_INFORMATION lpProcessInformation)
|
||||
{
|
||||
TRACE("%p %s %s %p %p %d 0x%08x %p %s %p %p\n", hToken, debugstr_w(lpApplicationName),
|
||||
debugstr_w(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles,
|
||||
dwCreationFlags, lpEnvironment, debugstr_w(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
|
||||
|
||||
/* Call the helper function */
|
||||
return CreateProcessAsUserCommon(TRUE,
|
||||
hToken,
|
||||
lpApplicationName,
|
||||
lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags,
|
||||
lpEnvironment,
|
||||
lpCurrentDirectory,
|
||||
lpStartupInfo,
|
||||
lpProcessInformation);
|
||||
/* Create the process with a suspended main thread */
|
||||
if (!CreateProcessW(lpApplicationName,
|
||||
lpCommandLine,
|
||||
lpProcessAttributes,
|
||||
lpThreadAttributes,
|
||||
bInheritHandles,
|
||||
dwCreationFlags | CREATE_SUSPENDED,
|
||||
lpEnvironment,
|
||||
lpCurrentDirectory,
|
||||
lpStartupInfo,
|
||||
lpProcessInformation))
|
||||
{
|
||||
ERR("CreateProcessW failed! GLE: %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (hToken != NULL)
|
||||
{
|
||||
AccessToken.Token = hToken;
|
||||
AccessToken.Thread = NULL;
|
||||
|
||||
/* Set the new process token */
|
||||
Status = NtSetInformationProcess(lpProcessInformation->hProcess,
|
||||
ProcessAccessToken,
|
||||
(PVOID)&AccessToken,
|
||||
sizeof(AccessToken));
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
ERR("NtSetInformationProcess failed: 0x%08x\n", Status);
|
||||
TerminateProcess(lpProcessInformation->hProcess, Status);
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resume the main thread */
|
||||
if (!(dwCreationFlags & CREATE_SUSPENDED))
|
||||
{
|
||||
ResumeThread(lpProcessInformation->hThread);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -576,7 +492,7 @@ LogonUserExW(
|
|||
Password.Buffer,
|
||||
Password.MaximumLength);
|
||||
|
||||
/* Create the Logon SID */
|
||||
/* Create the Logon SID*/
|
||||
AllocateLocallyUniqueId(&LogonId);
|
||||
Status = RtlAllocateAndInitializeSid(&SystemAuthority,
|
||||
SECURITY_LOGON_IDS_RID_COUNT,
|
||||
|
@ -592,7 +508,7 @@ LogonUserExW(
|
|||
if (!NT_SUCCESS(Status))
|
||||
goto done;
|
||||
|
||||
/* Create the Local SID */
|
||||
/* Create the Local SID*/
|
||||
Status = RtlAllocateAndInitializeSid(&LocalAuthority,
|
||||
1,
|
||||
SECURITY_LOCAL_RID,
|
||||
|
|
Loading…
Reference in a new issue