2012-11-02 18:00:47 +00:00
|
|
|
/*
|
1998-12-04 18:28:13 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-11-14 14:57:11 +00:00
|
|
|
* FILE: dll/win32/kernel32/client/proc.c
|
1998-12-04 18:28:13 +00:00
|
|
|
* PURPOSE: Process functions
|
2012-11-02 18:00:47 +00:00
|
|
|
* PROGRAMMERS: Ariadne (ariadne@xs4all.nl)
|
1998-12-04 18:28:13 +00:00
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
1996-01-23 01:02:17 +00:00
|
|
|
*/
|
1999-01-16 21:03:00 +00:00
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
|
2013-01-03 17:42:27 +00:00
|
|
|
#define NDEBUG
|
2007-09-02 19:42:22 +00:00
|
|
|
#include <debug.h>
|
1999-01-16 02:11:45 +00:00
|
|
|
|
1999-05-29 00:15:17 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
1999-01-01 22:03:17 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
WaitForInputIdleType UserWaitForInputIdleRoutine;
|
|
|
|
UNICODE_STRING BaseUnicodeCommandLine;
|
|
|
|
ANSI_STRING BaseAnsiCommandLine;
|
2011-12-04 16:34:58 +00:00
|
|
|
UNICODE_STRING BasePathVariableName = RTL_CONSTANT_STRING(L"PATH");
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
LPSTARTUPINFOA BaseAnsiStartupInfo = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry;
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
BOOLEAN g_AppCertInitialized;
|
|
|
|
BOOLEAN g_HaveAppCerts;
|
|
|
|
LIST_ENTRY BasepAppCertDllsList;
|
|
|
|
RTL_CRITICAL_SECTION gcsAppCert;
|
|
|
|
PBASEP_APPCERT_EMBEDDED_FUNC fEmbeddedCertFunc;
|
|
|
|
NTSTATUS g_AppCertStatus;
|
|
|
|
RTL_QUERY_REGISTRY_TABLE BasepAppCertTable[2] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BasepConfigureAppCertDlls,
|
|
|
|
1,
|
|
|
|
L"AppCertDlls",
|
|
|
|
&BasepAppCertDllsList,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
0
|
2012-01-21 21:36:17 +00:00
|
|
|
}
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PSAFER_REPLACE_PROCESS_THREAD_TOKENS g_SaferReplaceProcessThreadTokens;
|
|
|
|
HMODULE gSaferHandle = (HMODULE)-1;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
VOID WINAPI
|
|
|
|
RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
|
|
|
|
|
|
|
|
#define CMD_STRING L"cmd /c "
|
|
|
|
|
2003-01-22 02:24:36 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-04-14 00:52:19 +00:00
|
|
|
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
StuffStdHandle(IN HANDLE ProcessHandle,
|
|
|
|
IN HANDLE StandardHandle,
|
|
|
|
IN PHANDLE Address)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE DuplicatedHandle;
|
2013-08-06 18:36:25 +00:00
|
|
|
SIZE_T NumberOfBytesWritten;
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
|
2013-08-06 18:36:25 +00:00
|
|
|
/* If there is no handle to duplicate, return immediately */
|
|
|
|
if (!StandardHandle) return;
|
|
|
|
|
|
|
|
/* Duplicate the handle */
|
|
|
|
Status = NtDuplicateObject(NtCurrentProcess(),
|
|
|
|
StandardHandle,
|
|
|
|
ProcessHandle,
|
|
|
|
&DuplicatedHandle,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
DUPLICATE_SAME_ACCESS |
|
|
|
|
DUPLICATE_SAME_ATTRIBUTES);
|
|
|
|
if (!NT_SUCCESS(Status)) return;
|
|
|
|
|
|
|
|
/* Write it */
|
|
|
|
NtWriteVirtualMemory(ProcessHandle,
|
|
|
|
Address,
|
|
|
|
&DuplicatedHandle,
|
|
|
|
sizeof(HANDLE),
|
|
|
|
&NumberOfBytesWritten);
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
WINAPI
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
BuildSubSysCommandLine(IN LPCWSTR SubsystemName,
|
|
|
|
IN LPCWSTR ApplicationName,
|
|
|
|
IN LPCWSTR CommandLine,
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
OUT PUNICODE_STRING SubsysCommandLine)
|
|
|
|
{
|
|
|
|
UNICODE_STRING CommandLineString, ApplicationNameString;
|
|
|
|
PWCHAR Buffer;
|
|
|
|
ULONG Length;
|
|
|
|
|
|
|
|
/* Convert to unicode strings */
|
|
|
|
RtlInitUnicodeString(&CommandLineString, ApplicationName);
|
|
|
|
RtlInitUnicodeString(&ApplicationNameString, CommandLine);
|
|
|
|
|
|
|
|
/* Allocate buffer for the output string */
|
|
|
|
Length = CommandLineString.MaximumLength + ApplicationNameString.MaximumLength + 32;
|
|
|
|
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
|
2013-09-14 10:20:11 +00:00
|
|
|
RtlInitEmptyUnicodeString(SubsysCommandLine, Buffer, (USHORT)Length);
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
if (!Buffer)
|
|
|
|
{
|
|
|
|
/* Fail, no memory */
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build the final subsystem command line */
|
|
|
|
RtlAppendUnicodeToString(SubsysCommandLine, SubsystemName);
|
|
|
|
RtlAppendUnicodeStringToString(SubsysCommandLine, &CommandLineString);
|
|
|
|
RtlAppendUnicodeToString(SubsysCommandLine, L" /C ");
|
|
|
|
RtlAppendUnicodeStringToString(SubsysCommandLine, &ApplicationNameString);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
WINAPI
|
|
|
|
BasepIsImageVersionOk(IN ULONG ImageMajorVersion,
|
|
|
|
IN ULONG ImageMinorVersion)
|
|
|
|
{
|
2018-01-10 08:24:22 +00:00
|
|
|
/* Accept images for NT 3.1 or higher */
|
|
|
|
if (ImageMajorVersion > 3 ||
|
|
|
|
(ImageMajorVersion == 3 && ImageMinorVersion >= 10))
|
|
|
|
{
|
|
|
|
/* ReactOS-specific: Accept images even if they are newer than our internal NT version. */
|
|
|
|
if (ImageMajorVersion > SharedUserData->NtMajorVersion ||
|
|
|
|
(ImageMajorVersion == SharedUserData->NtMajorVersion && ImageMinorVersion > SharedUserData->NtMinorVersion))
|
|
|
|
{
|
2019-11-03 22:41:34 +00:00
|
|
|
DPRINT1("Accepting image version %lu.%lu, although ReactOS is an NT %hu.%hu OS!\n",
|
2018-01-10 08:24:22 +00:00
|
|
|
ImageMajorVersion,
|
|
|
|
ImageMinorVersion,
|
|
|
|
SharedUserData->NtMajorVersion,
|
|
|
|
SharedUserData->NtMinorVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
WINAPI
|
|
|
|
BasepCheckWebBladeHashes(IN HANDLE FileHandle)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
CHAR Hash[16];
|
|
|
|
|
|
|
|
/* Get all the MD5 hashes */
|
|
|
|
Status = RtlComputeImportTableHash(FileHandle, Hash, 1);
|
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
/* Depending on which suite this is, run a bsearch and block the appropriate ones */
|
|
|
|
if (SharedUserData->SuiteMask & VER_SUITE_COMPUTE_SERVER)
|
|
|
|
{
|
|
|
|
DPRINT1("Egad! This is a ReactOS Compute Server and we should prevent you from using certain APIs...but we won't.");
|
|
|
|
}
|
|
|
|
else if (SharedUserData->SuiteMask & VER_SUITE_STORAGE_SERVER)
|
|
|
|
{
|
|
|
|
DPRINT1("Gasp! This is a ReactOS Storage Server and we should prevent you from using certain APIs...but we won't.");
|
|
|
|
}
|
|
|
|
else if (SharedUserData->SuiteMask & VER_SUITE_BLADE)
|
|
|
|
{
|
|
|
|
DPRINT1("Golly! This is a ReactOS Web Blade Server and we should prevent you from using certain APIs...but we won't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Actually, fuck it, don't block anything, we're open source */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
BasepSaveAppCertRegistryValue(IN PLIST_ENTRY List,
|
|
|
|
IN PWCHAR ComponentName,
|
|
|
|
IN PWCHAR DllName)
|
|
|
|
{
|
|
|
|
/* Pretty much the only thing this key is used for, is malware */
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
BasepConfigureAppCertDlls(IN PWSTR ValueName,
|
|
|
|
IN ULONG ValueType,
|
|
|
|
IN PVOID ValueData,
|
|
|
|
IN ULONG ValueLength,
|
|
|
|
IN PVOID Context,
|
|
|
|
IN PVOID EntryContext)
|
|
|
|
{
|
|
|
|
/* Add this to the certification list */
|
|
|
|
return BasepSaveAppCertRegistryValue(Context, ValueName, ValueData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
WINAPI
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
BasepIsProcessAllowed(IN LPWSTR ApplicationName)
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
NTSTATUS Status, Status1;
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
PWCHAR Buffer;
|
|
|
|
UINT Length;
|
|
|
|
HMODULE TrustLibrary;
|
|
|
|
PBASEP_APPCERT_ENTRY Entry;
|
|
|
|
ULONG CertFlag;
|
|
|
|
PLIST_ENTRY NextEntry;
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
UNICODE_STRING CertKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCertDlls");
|
|
|
|
OBJECT_ATTRIBUTES KeyAttributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&CertKey, OBJ_CASE_INSENSITIVE);
|
|
|
|
|
|
|
|
/* Try to initialize the certification subsystem */
|
|
|
|
while (!g_AppCertInitialized)
|
|
|
|
{
|
|
|
|
/* Defaults */
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
Buffer = NULL;
|
|
|
|
|
|
|
|
/* Acquire the lock while initializing and see if we lost a race */
|
|
|
|
RtlEnterCriticalSection(&gcsAppCert);
|
|
|
|
if (g_AppCertInitialized) break;
|
|
|
|
|
|
|
|
/* On embedded, there is a special DLL */
|
|
|
|
if (SharedUserData->SuiteMask & VER_SUITE_EMBEDDEDNT)
|
|
|
|
{
|
|
|
|
/* Allocate a buffer for the name */
|
|
|
|
Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
|
|
|
MAX_PATH * sizeof(WCHAR) +
|
|
|
|
sizeof(UNICODE_NULL));
|
|
|
|
if (!Buffer)
|
|
|
|
{
|
|
|
|
/* Fail if no memory */
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Now get the system32 directory in our buffer, make sure it fits */
|
|
|
|
Length = GetSystemDirectoryW(Buffer, MAX_PATH - sizeof("EmbdTrst.DLL"));
|
|
|
|
if ((Length) && (Length <= MAX_PATH - sizeof("EmbdTrst.DLL")))
|
|
|
|
{
|
|
|
|
/* Add a slash if needed, and add the embedded cert DLL name */
|
|
|
|
if (Buffer[Length - 1] != '\\') Buffer[Length++] = '\\';
|
|
|
|
RtlCopyMemory(&Buffer[Length],
|
|
|
|
L"EmbdTrst.DLL",
|
|
|
|
sizeof(L"EmbdTrst.DLL"));
|
|
|
|
|
|
|
|
/* Try to load it */
|
|
|
|
TrustLibrary = LoadLibraryW(Buffer);
|
|
|
|
if (TrustLibrary)
|
|
|
|
{
|
|
|
|
/* And extract the special function out of it */
|
|
|
|
fEmbeddedCertFunc = (PVOID)GetProcAddress(TrustLibrary,
|
|
|
|
"ImageOkToRunOnEmbeddedNT");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't get this far, set a failure code */
|
|
|
|
if (!fEmbeddedCertFunc) Status = STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Other systems have a registry entry for this */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Status1 = NtOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
|
|
|
|
if (NT_SUCCESS(Status1))
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
{
|
|
|
|
/* Close it, we'll query it through Rtl */
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
|
|
|
|
/* Do the query, which will call a special callback */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
L"Session Manager",
|
|
|
|
BasepAppCertTable,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
|
|
|
{
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free any buffer if we had one */
|
|
|
|
if (Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
|
|
|
|
|
|
|
/* Check for errors, or a missing embedded/custom certification DLL */
|
|
|
|
if (!NT_SUCCESS(Status) ||
|
|
|
|
(!(fEmbeddedCertFunc) && (IsListEmpty(&BasepAppCertDllsList))))
|
|
|
|
{
|
|
|
|
/* The subsystem is not active on this machine, so give up */
|
|
|
|
g_HaveAppCerts = FALSE;
|
|
|
|
g_AppCertStatus = Status;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We have certification DLLs active, remember this */
|
|
|
|
g_HaveAppCerts = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We are done the initialization phase, release the lock */
|
|
|
|
g_AppCertInitialized = TRUE;
|
|
|
|
RtlLeaveCriticalSection(&gcsAppCert);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there's no certification DLLs present, return the failure code */
|
|
|
|
if (!g_HaveAppCerts) return g_AppCertStatus;
|
|
|
|
|
|
|
|
/* Otherwise, assume success and make sure we have *something* */
|
|
|
|
ASSERT(fEmbeddedCertFunc || !IsListEmpty(&BasepAppCertDllsList));
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
/* If the something is an embedded certification DLL, call it and return */
|
|
|
|
if (fEmbeddedCertFunc) return fEmbeddedCertFunc(ApplicationName);
|
|
|
|
|
|
|
|
/* Otherwise we have custom certification DLLs, parse them */
|
|
|
|
NextEntry = BasepAppCertDllsList.Flink;
|
|
|
|
CertFlag = 2;
|
|
|
|
while (NextEntry != &BasepAppCertDllsList)
|
|
|
|
{
|
|
|
|
/* Make sure the entry has a callback */
|
|
|
|
Entry = CONTAINING_RECORD(NextEntry, BASEP_APPCERT_ENTRY, Entry);
|
|
|
|
ASSERT(Entry->fPluginCertFunc != NULL);
|
|
|
|
|
|
|
|
/* Call it and check if it failed */
|
|
|
|
Status = Entry->fPluginCertFunc(ApplicationName, 1);
|
|
|
|
if (!NT_SUCCESS(Status)) CertFlag = 3;
|
|
|
|
|
|
|
|
/* Move on */
|
|
|
|
NextEntry = NextEntry->Flink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now loop them again */
|
|
|
|
NextEntry = BasepAppCertDllsList.Flink;
|
|
|
|
while (NextEntry != &BasepAppCertDllsList)
|
|
|
|
{
|
|
|
|
/* Make sure the entry has a callback */
|
|
|
|
Entry = CONTAINING_RECORD(NextEntry, BASEP_APPCERT_ENTRY, Entry);
|
|
|
|
ASSERT(Entry->fPluginCertFunc != NULL);
|
|
|
|
|
|
|
|
/* Call it, this time with the flag from the loop above */
|
|
|
|
Status = Entry->fPluginCertFunc(ApplicationName, CertFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done, return the status */
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
WINAPI
|
|
|
|
BasepReplaceProcessThreadTokens(IN HANDLE TokenHandle,
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN HANDLE ThreadHandle)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
ANSI_STRING SaferiReplaceProcessThreadTokens = RTL_CONSTANT_STRING("SaferiReplaceProcessThreadTokens");
|
|
|
|
|
|
|
|
/* Enter the application certification lock */
|
|
|
|
RtlEnterCriticalSection(&gcsAppCert);
|
|
|
|
|
|
|
|
/* Check if we already know the function */
|
|
|
|
if (g_SaferReplaceProcessThreadTokens)
|
|
|
|
{
|
|
|
|
/* Call it */
|
|
|
|
Status = g_SaferReplaceProcessThreadTokens(TokenHandle,
|
|
|
|
ProcessHandle,
|
|
|
|
ThreadHandle) ?
|
|
|
|
STATUS_SUCCESS :
|
|
|
|
STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check if the app certification DLL isn't loaded */
|
|
|
|
if (!(gSaferHandle) ||
|
|
|
|
(gSaferHandle == (HMODULE)-1) ||
|
|
|
|
(gSaferHandle == (HMODULE)-2))
|
|
|
|
{
|
|
|
|
/* Then we can't call the function */
|
|
|
|
Status = STATUS_ENTRYPOINT_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We have the DLL, find the address of the Safer function */
|
|
|
|
Status = LdrGetProcedureAddress(gSaferHandle,
|
|
|
|
&SaferiReplaceProcessThreadTokens,
|
|
|
|
0,
|
|
|
|
(PVOID*)&g_SaferReplaceProcessThreadTokens);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Found it, now call it */
|
|
|
|
Status = g_SaferReplaceProcessThreadTokens(TokenHandle,
|
|
|
|
ProcessHandle,
|
|
|
|
ThreadHandle) ?
|
|
|
|
STATUS_SUCCESS :
|
|
|
|
STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We couldn't find it, so this must be an unsupported DLL */
|
|
|
|
LdrUnloadDll(gSaferHandle);
|
|
|
|
gSaferHandle = NULL;
|
|
|
|
Status = STATUS_ENTRYPOINT_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release the lock and return the result */
|
|
|
|
RtlLeaveCriticalSection(&gcsAppCert);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
BasepSxsCloseHandles(IN PBASE_MSG_SXS_HANDLES Handles)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(Handles != NULL);
|
|
|
|
ASSERT(Handles->Process == NULL || Handles->Process == NtCurrentProcess());
|
|
|
|
|
|
|
|
/* Close the file handle */
|
|
|
|
if (Handles->File)
|
|
|
|
{
|
|
|
|
Status = NtClose(Handles->File);
|
|
|
|
ASSERT(NT_SUCCESS(Status));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the section handle */
|
|
|
|
if (Handles->Section)
|
|
|
|
{
|
|
|
|
Status = NtClose(Handles->Section);
|
|
|
|
ASSERT(NT_SUCCESS(Status));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unmap the section view */
|
|
|
|
if (Handles->ViewBase.QuadPart)
|
|
|
|
{
|
|
|
|
Status = NtUnmapViewOfSection(NtCurrentProcess(),
|
2018-02-15 21:34:48 +00:00
|
|
|
(PVOID)(ULONG_PTR)Handles->ViewBase.QuadPart);
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
ASSERT(NT_SUCCESS(Status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
VOID
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
2011-07-20 15:54:21 +00:00
|
|
|
BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress)
|
2003-01-22 02:24:36 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
DPRINT("BaseProcessStartup(..) - setting up exception frame.\n");
|
|
|
|
|
|
|
|
_SEH2_TRY
|
2003-03-06 15:05:29 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Set our Start Address */
|
|
|
|
NtSetInformationThread(NtCurrentThread(),
|
|
|
|
ThreadQuerySetWin32StartAddress,
|
|
|
|
&lpStartAddress,
|
|
|
|
sizeof(PPROCESS_START_ROUTINE));
|
|
|
|
|
|
|
|
/* Call the Start Routine */
|
2012-02-19 20:09:49 +00:00
|
|
|
ExitThread(lpStartAddress());
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2018-10-20 13:38:21 +00:00
|
|
|
_SEH2_EXCEPT(UnhandledExceptionFilter(_SEH2_GetExceptionInformation()))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2012-02-19 20:09:49 +00:00
|
|
|
/* Get the Exit code from the SEH Handler */
|
|
|
|
if (!BaseRunningInServerProcess)
|
|
|
|
{
|
|
|
|
/* Kill the whole process, usually */
|
|
|
|
ExitProcess(_SEH2_GetExceptionCode());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If running inside CSRSS, kill just this thread */
|
|
|
|
ExitThread(_SEH2_GetExceptionCode());
|
|
|
|
}
|
2003-03-06 15:05:29 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
_SEH2_END;
|
2003-01-22 02:24:36 +00:00
|
|
|
}
|
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
BOOLEAN
|
2011-07-20 15:54:21 +00:00
|
|
|
WINAPI
|
2012-01-16 21:27:50 +00:00
|
|
|
BasePushProcessParameters(IN ULONG ParameterFlags,
|
|
|
|
IN HANDLE ProcessHandle,
|
|
|
|
IN PPEB RemotePeb,
|
|
|
|
IN LPCWSTR ApplicationPathName,
|
2011-12-04 16:34:58 +00:00
|
|
|
IN LPWSTR lpCurrentDirectory,
|
|
|
|
IN LPWSTR lpCommandLine,
|
|
|
|
IN LPVOID lpEnvironment,
|
|
|
|
IN LPSTARTUPINFOW StartupInfo,
|
|
|
|
IN DWORD CreationFlags,
|
2012-01-16 21:27:50 +00:00
|
|
|
IN BOOL InheritHandles,
|
|
|
|
IN ULONG ImageSubsystem,
|
|
|
|
IN PVOID AppCompatData,
|
|
|
|
IN ULONG AppCompatDataSize)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2011-12-04 16:34:58 +00:00
|
|
|
WCHAR FullPath[MAX_PATH + 5];
|
2012-01-16 21:27:50 +00:00
|
|
|
PWCHAR Remaining, DllPathString, ScanChar;
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters, RemoteParameters;
|
|
|
|
PVOID RemoteAppCompatData;
|
2011-07-20 15:54:21 +00:00
|
|
|
UNICODE_STRING DllPath, ImageName, CommandLine, CurrentDirectory;
|
2012-01-16 21:27:50 +00:00
|
|
|
UNICODE_STRING Desktop, Shell, Runtime, Title;
|
2011-07-20 15:54:21 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG EnviroSize;
|
|
|
|
SIZE_T Size;
|
2012-01-16 21:27:50 +00:00
|
|
|
BOOLEAN HavePebLock = FALSE, Result;
|
|
|
|
PPEB Peb = NtCurrentPeb();
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Get the full path name */
|
2011-12-04 16:34:58 +00:00
|
|
|
Size = GetFullPathNameW(ApplicationPathName,
|
|
|
|
MAX_PATH + 4,
|
|
|
|
FullPath,
|
|
|
|
&Remaining);
|
|
|
|
if ((Size) && (Size <= (MAX_PATH + 4)))
|
|
|
|
{
|
|
|
|
/* Get the DLL Path */
|
2012-05-20 14:06:09 +00:00
|
|
|
DllPathString = BaseComputeProcessDllPath(FullPath, lpEnvironment);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!DllPathString)
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-12-04 16:34:58 +00:00
|
|
|
|
|
|
|
/* Initialize Strings */
|
|
|
|
RtlInitUnicodeString(&DllPath, DllPathString);
|
2012-05-20 14:06:09 +00:00
|
|
|
RtlInitUnicodeString(&ImageName, FullPath);
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-20 14:06:09 +00:00
|
|
|
/* Couldn't get the path name. Just take the original path */
|
|
|
|
DllPathString = BaseComputeProcessDllPath((LPWSTR)ApplicationPathName,
|
|
|
|
lpEnvironment);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!DllPathString)
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2011-12-04 16:34:58 +00:00
|
|
|
/* Initialize Strings */
|
|
|
|
RtlInitUnicodeString(&DllPath, DllPathString);
|
2012-05-20 14:06:09 +00:00
|
|
|
RtlInitUnicodeString(&ImageName, ApplicationPathName);
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Initialize Strings */
|
|
|
|
RtlInitUnicodeString(&CommandLine, lpCommandLine);
|
|
|
|
RtlInitUnicodeString(&CurrentDirectory, lpCurrentDirectory);
|
|
|
|
|
|
|
|
/* Initialize more Strings from the Startup Info */
|
|
|
|
if (StartupInfo->lpDesktop)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Desktop, StartupInfo->lpDesktop);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Desktop, L"");
|
|
|
|
}
|
|
|
|
if (StartupInfo->lpReserved)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Shell, StartupInfo->lpReserved);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Shell, L"");
|
|
|
|
}
|
|
|
|
if (StartupInfo->lpTitle)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&Title, StartupInfo->lpTitle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-04 16:34:58 +00:00
|
|
|
RtlInitUnicodeString(&Title, ApplicationPathName);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This one is special because the length can differ */
|
|
|
|
Runtime.Buffer = (LPWSTR)StartupInfo->lpReserved2;
|
|
|
|
Runtime.MaximumLength = Runtime.Length = StartupInfo->cbReserved2;
|
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Enforce no app compat data if the pointer was NULL */
|
|
|
|
if (!AppCompatData) AppCompatDataSize = 0;
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Create the Parameter Block */
|
2012-01-16 21:27:50 +00:00
|
|
|
ProcessParameters = NULL;
|
2013-09-21 13:00:48 +00:00
|
|
|
DPRINT("ImageName: '%wZ'\n", &ImageName);
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("DllPath : '%wZ'\n", &DllPath);
|
|
|
|
DPRINT("CurDir : '%wZ'\n", &CurrentDirectory);
|
2013-09-21 13:00:48 +00:00
|
|
|
DPRINT("CmdLine : '%wZ'\n", &CommandLine);
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("Title : '%wZ'\n", &Title);
|
|
|
|
DPRINT("Desktop : '%wZ'\n", &Desktop);
|
|
|
|
DPRINT("Shell : '%wZ'\n", &Shell);
|
|
|
|
DPRINT("Runtime : '%wZ'\n", &Runtime);
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = RtlCreateProcessParameters(&ProcessParameters,
|
|
|
|
&ImageName,
|
|
|
|
&DllPath,
|
|
|
|
lpCurrentDirectory ?
|
|
|
|
&CurrentDirectory : NULL,
|
|
|
|
&CommandLine,
|
2012-01-16 21:27:50 +00:00
|
|
|
lpEnvironment,
|
2011-07-20 15:54:21 +00:00
|
|
|
&Title,
|
|
|
|
&Desktop,
|
|
|
|
&Shell,
|
|
|
|
&Runtime);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2011-12-04 16:34:58 +00:00
|
|
|
/* Clear the current directory handle if not inheriting */
|
|
|
|
if (!InheritHandles) ProcessParameters->CurrentDirectory.Handle = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Check if the user passed in an environment */
|
|
|
|
if (lpEnvironment)
|
|
|
|
{
|
|
|
|
/* We should've made it part of the parameters block, enforce this */
|
|
|
|
ASSERT(ProcessParameters->Environment == lpEnvironment);
|
|
|
|
lpEnvironment = ProcessParameters->Environment;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The user did not, so use the one from the current PEB */
|
|
|
|
HavePebLock = TRUE;
|
|
|
|
RtlAcquirePebLock();
|
|
|
|
lpEnvironment = Peb->ProcessParameters->Environment;
|
|
|
|
}
|
|
|
|
|
2011-12-04 16:34:58 +00:00
|
|
|
/* Save pointer and start lookup */
|
2012-01-16 21:27:50 +00:00
|
|
|
ScanChar = lpEnvironment;
|
|
|
|
if (lpEnvironment)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2011-12-04 16:34:58 +00:00
|
|
|
/* Find the environment size */
|
2014-02-08 22:22:21 +00:00
|
|
|
while (*ScanChar++) while (*ScanChar++);
|
|
|
|
EnviroSize = (ULONG)((ULONG_PTR)ScanChar - (ULONG_PTR)lpEnvironment);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Allocate and Initialize new Environment Block */
|
|
|
|
Size = EnviroSize;
|
|
|
|
ProcessParameters->Environment = NULL;
|
2012-04-25 10:17:29 +00:00
|
|
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
2011-07-20 15:54:21 +00:00
|
|
|
(PVOID*)&ProcessParameters->Environment,
|
|
|
|
0,
|
|
|
|
&Size,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Write the Environment Block */
|
2012-04-25 10:17:29 +00:00
|
|
|
Status = NtWriteVirtualMemory(ProcessHandle,
|
2011-12-04 16:34:58 +00:00
|
|
|
ProcessParameters->Environment,
|
2012-01-16 21:27:50 +00:00
|
|
|
lpEnvironment,
|
2011-12-04 16:34:58 +00:00
|
|
|
EnviroSize,
|
|
|
|
NULL);
|
2012-01-16 21:27:50 +00:00
|
|
|
|
|
|
|
/* No longer need the PEB lock anymore */
|
|
|
|
if (HavePebLock)
|
2011-12-04 16:34:58 +00:00
|
|
|
{
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Release it */
|
|
|
|
RtlReleasePebLock();
|
|
|
|
HavePebLock = FALSE;
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
2012-01-16 21:27:50 +00:00
|
|
|
|
|
|
|
/* Check if the write failed */
|
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write new parameters */
|
|
|
|
ProcessParameters->StartingX = StartupInfo->dwX;
|
|
|
|
ProcessParameters->StartingY = StartupInfo->dwY;
|
|
|
|
ProcessParameters->CountX = StartupInfo->dwXSize;
|
|
|
|
ProcessParameters->CountY = StartupInfo->dwYSize;
|
|
|
|
ProcessParameters->CountCharsX = StartupInfo->dwXCountChars;
|
|
|
|
ProcessParameters->CountCharsY = StartupInfo->dwYCountChars;
|
|
|
|
ProcessParameters->FillAttribute = StartupInfo->dwFillAttribute;
|
|
|
|
ProcessParameters->WindowFlags = StartupInfo->dwFlags;
|
|
|
|
ProcessParameters->ShowWindowFlags = StartupInfo->wShowWindow;
|
|
|
|
|
|
|
|
/* Write the handles only if we have to */
|
2011-12-04 16:34:58 +00:00
|
|
|
if (StartupInfo->dwFlags &
|
|
|
|
(STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
ProcessParameters->StandardInput = StartupInfo->hStdInput;
|
|
|
|
ProcessParameters->StandardOutput = StartupInfo->hStdOutput;
|
|
|
|
ProcessParameters->StandardError = StartupInfo->hStdError;
|
|
|
|
}
|
|
|
|
|
2014-09-07 22:53:49 +00:00
|
|
|
/* Use Special Flags for ConDllInitialize in Kernel32 */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (CreationFlags & DETACHED_PROCESS)
|
|
|
|
{
|
|
|
|
ProcessParameters->ConsoleHandle = HANDLE_DETACHED_PROCESS;
|
|
|
|
}
|
|
|
|
else if (CreationFlags & CREATE_NEW_CONSOLE)
|
|
|
|
{
|
|
|
|
ProcessParameters->ConsoleHandle = HANDLE_CREATE_NEW_CONSOLE;
|
|
|
|
}
|
2013-01-01 23:36:19 +00:00
|
|
|
else if (CreationFlags & CREATE_NO_WINDOW)
|
|
|
|
{
|
|
|
|
ProcessParameters->ConsoleHandle = HANDLE_CREATE_NO_WINDOW;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Inherit our Console Handle */
|
2012-01-16 21:27:50 +00:00
|
|
|
ProcessParameters->ConsoleHandle = Peb->ProcessParameters->ConsoleHandle;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Make sure that the shell isn't trampling on our handles first */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!(StartupInfo->dwFlags &
|
2011-12-04 16:34:58 +00:00
|
|
|
(STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE)))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Copy the handle if we are inheriting or if it's a console handle */
|
|
|
|
if ((InheritHandles) ||
|
|
|
|
(IsConsoleHandle(Peb->ProcessParameters->StandardInput)))
|
|
|
|
{
|
|
|
|
ProcessParameters->StandardInput = Peb->ProcessParameters->StandardInput;
|
|
|
|
}
|
|
|
|
if ((InheritHandles) ||
|
|
|
|
(IsConsoleHandle(Peb->ProcessParameters->StandardOutput)))
|
|
|
|
{
|
|
|
|
ProcessParameters->StandardOutput = Peb->ProcessParameters->StandardOutput;
|
|
|
|
}
|
|
|
|
if ((InheritHandles) ||
|
|
|
|
(IsConsoleHandle(Peb->ProcessParameters->StandardError)))
|
|
|
|
{
|
|
|
|
ProcessParameters->StandardError = Peb->ProcessParameters->StandardError;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Also set the Console Flag */
|
2011-12-04 16:34:58 +00:00
|
|
|
if ((CreationFlags & CREATE_NEW_PROCESS_GROUP) &&
|
|
|
|
(!(CreationFlags & CREATE_NEW_CONSOLE)))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
ProcessParameters->ConsoleFlags = 1;
|
|
|
|
}
|
Note, none of this code is being used/called yet.
[KERNEL32]: Implement BasepSxsCloseHandles, BasepReplaceProcessThreadTokens, BasepIsProcessAllowed, BasepCheckWebBladeHashes, BasepIsImageVersionOk which will be needed for the future CreateProcess re-implementation. These functions partly support SxS, Safer (Authz) and Application Certification features added in XP/2003. We also emulate support for Computer Server, Web Blade Server and Embedded ReactOS. The last function does correct image version checks to prevent invalid binaries from running.
[KERNEL32]: Implement BaseUpdateVDMEntry and BaseCheckForVDM using the new CSRSS messages (not implemented on the server-side yet). Stubplement BaseCheckVDM. These will be needed for future VDM-stub-support (primarly so we can run 16-bit installers).
[KERNEL32]: Implement BasepFreeAppCompatData, BasepCheckBadapp, and IsShimInfrastructureDisabled (exported as BaseIsAppcompatInfrastructureDisabled). These stub most of the required/exported application compatibility APIs, as long as someone sets DisableAppCompat in \\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatibility.
svn path=/trunk/; revision=54975
2012-01-15 14:49:49 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if there's a .local file present */
|
2012-01-16 21:27:50 +00:00
|
|
|
if (ParameterFlags & 1)
|
2011-12-04 16:34:58 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_LOCAL_DLL_PATH;
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if we failed to open the IFEO key */
|
2012-01-16 21:27:50 +00:00
|
|
|
if (ParameterFlags & 2)
|
2011-12-04 16:34:58 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_IMAGE_KEY_MISSING;
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Allocate memory for the parameter block */
|
|
|
|
Size = ProcessParameters->Length;
|
2012-01-16 21:27:50 +00:00
|
|
|
RemoteParameters = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
|
|
|
(PVOID*)&RemoteParameters,
|
|
|
|
0,
|
|
|
|
&Size,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Set the allocated size */
|
|
|
|
ProcessParameters->MaximumLength = Size;
|
|
|
|
|
|
|
|
/* Handle some Parameter Flags */
|
|
|
|
ProcessParameters->Flags |= (CreationFlags & PROFILE_USER) ?
|
|
|
|
RTL_USER_PROCESS_PARAMETERS_PROFILE_USER : 0;
|
|
|
|
ProcessParameters->Flags |= (CreationFlags & PROFILE_KERNEL) ?
|
|
|
|
RTL_USER_PROCESS_PARAMETERS_PROFILE_KERNEL : 0;
|
|
|
|
ProcessParameters->Flags |= (CreationFlags & PROFILE_SERVER) ?
|
|
|
|
RTL_USER_PROCESS_PARAMETERS_PROFILE_SERVER : 0;
|
2012-01-17 17:42:47 +00:00
|
|
|
ProcessParameters->Flags |= (Peb->ProcessParameters->Flags &
|
2011-07-20 15:54:21 +00:00
|
|
|
RTL_USER_PROCESS_PARAMETERS_DISABLE_HEAP_CHECKS);
|
|
|
|
|
|
|
|
/* Write the Parameter Block */
|
|
|
|
Status = NtWriteVirtualMemory(ProcessHandle,
|
|
|
|
RemoteParameters,
|
|
|
|
ProcessParameters,
|
|
|
|
ProcessParameters->Length,
|
|
|
|
NULL);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Write the PEB Pointer */
|
|
|
|
Status = NtWriteVirtualMemory(ProcessHandle,
|
2012-01-16 21:27:50 +00:00
|
|
|
&RemotePeb->ProcessParameters,
|
2011-07-20 15:54:21 +00:00
|
|
|
&RemoteParameters,
|
|
|
|
sizeof(PVOID),
|
|
|
|
NULL);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2012-01-17 17:42:47 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Check if there's any app compat data to write */
|
|
|
|
RemoteAppCompatData = NULL;
|
|
|
|
if (AppCompatData)
|
|
|
|
{
|
|
|
|
/* Allocate some space for the application compatibility data */
|
|
|
|
Size = AppCompatDataSize;
|
|
|
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
|
|
|
&RemoteAppCompatData,
|
|
|
|
0,
|
|
|
|
&Size,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2012-01-17 17:42:47 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Write the application compatibility data */
|
|
|
|
Status = NtWriteVirtualMemory(ProcessHandle,
|
|
|
|
RemoteAppCompatData,
|
|
|
|
AppCompatData,
|
|
|
|
AppCompatDataSize,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-12-04 16:34:58 +00:00
|
|
|
}
|
2012-01-17 17:42:47 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Write the PEB Pointer to the app compat data (might be NULL) */
|
|
|
|
Status = NtWriteVirtualMemory(ProcessHandle,
|
|
|
|
&RemotePeb->pShimData,
|
|
|
|
&RemoteAppCompatData,
|
|
|
|
sizeof(PVOID),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status)) goto FailPath;
|
2011-12-04 16:34:58 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Now write Peb->ImageSubSystem */
|
|
|
|
if (ImageSubsystem)
|
|
|
|
{
|
|
|
|
NtWriteVirtualMemory(ProcessHandle,
|
|
|
|
&RemotePeb->ImageSubsystem,
|
|
|
|
&ImageSubsystem,
|
|
|
|
sizeof(ImageSubsystem),
|
|
|
|
NULL);
|
|
|
|
}
|
2012-01-17 17:42:47 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
/* Success path */
|
|
|
|
Result = TRUE;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2012-01-16 21:27:50 +00:00
|
|
|
Quickie:
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Cleanup */
|
2012-01-16 21:27:50 +00:00
|
|
|
if (HavePebLock) RtlReleasePebLock();
|
2011-07-20 15:54:21 +00:00
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DllPath.Buffer);
|
2012-01-16 21:27:50 +00:00
|
|
|
if (ProcessParameters) RtlDestroyProcessParameters(ProcessParameters);
|
|
|
|
return Result;
|
|
|
|
FailPath:
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
DPRINT1("Failure to create process parameters: %lx\n", Status);
|
2012-01-16 21:27:50 +00:00
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
InitCommandLines(VOID)
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Read the UNICODE_STRING from the PEB */
|
|
|
|
BaseUnicodeCommandLine = NtCurrentPeb()->ProcessParameters->CommandLine;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Convert to ANSI_STRING for the *A callers */
|
|
|
|
Status = RtlUnicodeStringToAnsiString(&BaseAnsiCommandLine,
|
|
|
|
&BaseUnicodeCommandLine,
|
|
|
|
TRUE);
|
|
|
|
if (!NT_SUCCESS(Status)) RtlInitEmptyAnsiString(&BaseAnsiCommandLine, 0, 0);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessAffinityMask(IN HANDLE hProcess,
|
|
|
|
OUT PDWORD_PTR lpProcessAffinityMask,
|
|
|
|
OUT PDWORD_PTR lpSystemAffinityMask)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
PROCESS_BASIC_INFORMATION ProcessInfo;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query information on the process from the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
2010-01-09 20:51:33 +00:00
|
|
|
ProcessBasicInformation,
|
2016-07-03 13:48:50 +00:00
|
|
|
&ProcessInfo,
|
|
|
|
sizeof(ProcessInfo),
|
2010-01-09 20:51:33 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Fail */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
2004-11-02 21:51:25 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Copy the affinity mask, and get the system one from our shared data */
|
2011-07-20 15:54:21 +00:00
|
|
|
*lpProcessAffinityMask = (DWORD)ProcessInfo.AffinityMask;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
*lpSystemAffinityMask = (DWORD)BaseStaticServerData->SysInfo.ActiveProcessorsAffinityMask;
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
SetProcessAffinityMask(IN HANDLE hProcess,
|
|
|
|
IN DWORD_PTR dwProcessAffinityMask)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Directly set the affinity mask */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessAffinityMask,
|
|
|
|
(PVOID)&dwProcessAffinityMask,
|
|
|
|
sizeof(DWORD));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle failure */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Everything was ok */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessShutdownParameters(OUT LPDWORD lpdwLevel,
|
|
|
|
OUT LPDWORD lpdwFlags)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2012-11-02 18:00:47 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
2013-08-19 17:50:27 +00:00
|
|
|
PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &ApiMessage.Data.ShutdownParametersRequest;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Ask CSRSS for shutdown information */
|
2015-07-10 23:57:26 +00:00
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepGetProcessShutdownParam),
|
|
|
|
sizeof(*ShutdownParametersRequest));
|
|
|
|
if (!NT_SUCCESS(ApiMessage.Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return the failure from CSRSS */
|
2015-07-10 23:57:26 +00:00
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-01-03 17:42:27 +00:00
|
|
|
/* Get the data back */
|
2013-08-19 17:50:27 +00:00
|
|
|
*lpdwLevel = ShutdownParametersRequest->ShutdownLevel;
|
|
|
|
*lpdwFlags = ShutdownParametersRequest->ShutdownFlags;
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
SetProcessShutdownParameters(IN DWORD dwLevel,
|
|
|
|
IN DWORD dwFlags)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2012-11-02 18:00:47 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
2013-08-19 17:50:27 +00:00
|
|
|
PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &ApiMessage.Data.ShutdownParametersRequest;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Write the data into the CSRSS request and send it */
|
2013-08-19 17:50:27 +00:00
|
|
|
ShutdownParametersRequest->ShutdownLevel = dwLevel;
|
|
|
|
ShutdownParametersRequest->ShutdownFlags = dwFlags;
|
2015-07-10 23:57:26 +00:00
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepSetProcessShutdownParam),
|
|
|
|
sizeof(*ShutdownParametersRequest));
|
|
|
|
if (!NT_SUCCESS(ApiMessage.Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return the failure from CSRSS */
|
2015-07-10 23:57:26 +00:00
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* All went well */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessWorkingSetSizeEx(IN HANDLE hProcess,
|
|
|
|
OUT PSIZE_T lpMinimumWorkingSetSize,
|
|
|
|
OUT PSIZE_T lpMaximumWorkingSetSize,
|
|
|
|
OUT PDWORD Flags)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
QUOTA_LIMITS_EX QuotaLimits;
|
2011-07-20 15:54:21 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel about this */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessQuotaLimits,
|
|
|
|
&QuotaLimits,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(QuotaLimits),
|
2011-07-20 15:54:21 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return error */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Copy the quota information out */
|
2011-07-20 15:54:21 +00:00
|
|
|
*lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
|
|
|
|
*lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
*Flags = QuotaLimits.Flags;
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessWorkingSetSize(IN HANDLE hProcess,
|
|
|
|
OUT PSIZE_T lpMinimumWorkingSetSize,
|
|
|
|
OUT PSIZE_T lpMaximumWorkingSetSize)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
DWORD Dummy;
|
|
|
|
return GetProcessWorkingSetSizeEx(hProcess,
|
|
|
|
lpMinimumWorkingSetSize,
|
|
|
|
lpMaximumWorkingSetSize,
|
|
|
|
&Dummy);
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
SetProcessWorkingSetSizeEx(IN HANDLE hProcess,
|
|
|
|
IN SIZE_T dwMinimumWorkingSetSize,
|
|
|
|
IN SIZE_T dwMaximumWorkingSetSize,
|
|
|
|
IN DWORD Flags)
|
|
|
|
{
|
|
|
|
QUOTA_LIMITS_EX QuotaLimits;
|
|
|
|
NTSTATUS Status, ReturnStatus;
|
|
|
|
BOOL Result;
|
|
|
|
PVOID State;
|
|
|
|
ULONG Privilege = SE_INC_BASE_PRIORITY_PRIVILEGE;
|
|
|
|
|
|
|
|
/* Zero out the input structure */
|
|
|
|
RtlZeroMemory(&QuotaLimits, sizeof(QuotaLimits));
|
|
|
|
|
|
|
|
/* Check if the caller sent any limits */
|
|
|
|
if ((dwMinimumWorkingSetSize) && (dwMaximumWorkingSetSize))
|
|
|
|
{
|
|
|
|
/* Write the quota information */
|
|
|
|
QuotaLimits.MinimumWorkingSetSize = dwMinimumWorkingSetSize;
|
|
|
|
QuotaLimits.MaximumWorkingSetSize = dwMaximumWorkingSetSize;
|
|
|
|
QuotaLimits.Flags = Flags;
|
|
|
|
|
|
|
|
/* Acquire the required privilege */
|
|
|
|
Status = RtlAcquirePrivilege(&Privilege, 1, 0, &State);
|
|
|
|
|
|
|
|
/* Request the new quotas */
|
|
|
|
ReturnStatus = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessQuotaLimits,
|
|
|
|
&QuotaLimits,
|
|
|
|
sizeof(QuotaLimits));
|
|
|
|
Result = NT_SUCCESS(ReturnStatus);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Release the privilege and set succes code */
|
|
|
|
ASSERT(State != NULL);
|
|
|
|
RtlReleasePrivilege(State);
|
|
|
|
State = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* No limits, fail the call */
|
|
|
|
ReturnStatus = STATUS_INVALID_PARAMETER;
|
|
|
|
Result = FALSE;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return result code, set error code if this was a failure */
|
|
|
|
if (!Result) BaseSetLastNTError(ReturnStatus);
|
|
|
|
return Result;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
SetProcessWorkingSetSize(IN HANDLE hProcess,
|
|
|
|
IN SIZE_T dwMinimumWorkingSetSize,
|
|
|
|
IN SIZE_T dwMaximumWorkingSetSize)
|
|
|
|
{
|
|
|
|
/* Call the newer API */
|
|
|
|
return SetProcessWorkingSetSizeEx(hProcess,
|
|
|
|
dwMinimumWorkingSetSize,
|
|
|
|
dwMaximumWorkingSetSize,
|
|
|
|
0);
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessTimes(IN HANDLE hProcess,
|
|
|
|
IN LPFILETIME lpCreationTime,
|
|
|
|
IN LPFILETIME lpExitTime,
|
|
|
|
IN LPFILETIME lpKernelTime,
|
|
|
|
IN LPFILETIME lpUserTime)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
KERNEL_USER_TIMES Kut;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the times */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessTimes,
|
|
|
|
&Kut,
|
|
|
|
sizeof(Kut),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle failure */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Copy all the times and return success */
|
2011-07-20 15:54:21 +00:00
|
|
|
lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart;
|
|
|
|
lpCreationTime->dwHighDateTime = Kut.CreateTime.u.HighPart;
|
|
|
|
lpExitTime->dwLowDateTime = Kut.ExitTime.u.LowPart;
|
|
|
|
lpExitTime->dwHighDateTime = Kut.ExitTime.u.HighPart;
|
|
|
|
lpKernelTime->dwLowDateTime = Kut.KernelTime.u.LowPart;
|
|
|
|
lpKernelTime->dwHighDateTime = Kut.KernelTime.u.HighPart;
|
|
|
|
lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart;
|
|
|
|
lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HANDLE
|
|
|
|
WINAPI
|
|
|
|
GetCurrentProcess(VOID)
|
|
|
|
{
|
|
|
|
return (HANDLE)NtCurrentProcess();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HANDLE
|
|
|
|
WINAPI
|
|
|
|
GetCurrentThread(VOID)
|
|
|
|
{
|
|
|
|
return (HANDLE)NtCurrentThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
GetCurrentProcessId(VOID)
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
return HandleToUlong(NtCurrentTeb()->ClientId.UniqueProcess);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetExitCodeProcess(IN HANDLE hProcess,
|
|
|
|
IN LPDWORD lpExitCode)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
PROCESS_BASIC_INFORMATION ProcessBasic;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Ask the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
&ProcessBasic,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(ProcessBasic),
|
2011-07-20 15:54:21 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* We failed, was this because this is a VDM process? */
|
2017-10-01 14:42:04 +00:00
|
|
|
if (BaseCheckForVDM(hProcess, lpExitCode) != FALSE) return TRUE;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Not a VDM process, fail the call */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Succes case, return the exit code */
|
2011-07-20 15:54:21 +00:00
|
|
|
*lpExitCode = (DWORD)ProcessBasic.ExitStatus;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessId(IN HANDLE Process)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
PROCESS_BASIC_INFORMATION ProcessBasic;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(Process,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
&ProcessBasic,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(ProcessBasic),
|
2011-07-20 15:54:21 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle failure */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return the PID */
|
2011-07-20 15:54:21 +00:00
|
|
|
return (DWORD)ProcessBasic.UniqueProcessId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HANDLE
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
OpenProcess(IN DWORD dwDesiredAccess,
|
|
|
|
IN BOOL bInheritHandle,
|
|
|
|
IN DWORD dwProcessId)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
HANDLE ProcessHandle;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
CLIENT_ID ClientId;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Setup the input client ID structure */
|
2011-07-20 15:54:21 +00:00
|
|
|
ClientId.UniqueProcess = UlongToHandle(dwProcessId);
|
|
|
|
ClientId.UniqueThread = 0;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* This is needed just to define the inheritance flags */
|
2011-07-20 15:54:21 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
(bInheritHandle ? OBJ_INHERIT : 0),
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Now try to open the process */
|
|
|
|
Status = NtOpenProcess(&ProcessHandle,
|
|
|
|
dwDesiredAccess,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&ClientId);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle failure */
|
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Otherwise return a handle to the process */
|
2011-07-20 15:54:21 +00:00
|
|
|
return ProcessHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
RegisterWaitForInputIdle(IN WaitForInputIdleType lpfnRegisterWaitForInputIdle)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Write the global function pointer */
|
|
|
|
UserWaitForInputIdleRoutine = lpfnRegisterWaitForInputIdle;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetStartupInfoW(IN LPSTARTUPINFOW lpStartupInfo)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Get the process parameters */
|
2011-07-20 15:54:21 +00:00
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Copy the data out of there */
|
2011-07-20 15:54:21 +00:00
|
|
|
lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
2012-01-23 05:32:11 +00:00
|
|
|
lpStartupInfo->lpReserved = Params->ShellInfo.Buffer;
|
2011-07-20 15:54:21 +00:00
|
|
|
lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
|
|
|
|
lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
|
|
|
|
lpStartupInfo->dwX = Params->StartingX;
|
|
|
|
lpStartupInfo->dwY = Params->StartingY;
|
|
|
|
lpStartupInfo->dwXSize = Params->CountX;
|
|
|
|
lpStartupInfo->dwYSize = Params->CountY;
|
|
|
|
lpStartupInfo->dwXCountChars = Params->CountCharsX;
|
|
|
|
lpStartupInfo->dwYCountChars = Params->CountCharsY;
|
|
|
|
lpStartupInfo->dwFillAttribute = Params->FillAttribute;
|
|
|
|
lpStartupInfo->dwFlags = Params->WindowFlags;
|
|
|
|
lpStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
|
|
|
|
lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
|
|
|
|
lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Check if the standard handles are being used for other features */
|
|
|
|
if (lpStartupInfo->dwFlags & (STARTF_USESTDHANDLES |
|
|
|
|
STARTF_USEHOTKEY |
|
|
|
|
STARTF_SHELLPRIVATE))
|
|
|
|
{
|
|
|
|
/* These are, so copy the standard handles too */
|
|
|
|
lpStartupInfo->hStdInput = Params->StandardInput;
|
|
|
|
lpStartupInfo->hStdOutput = Params->StandardOutput;
|
|
|
|
lpStartupInfo->hStdError = Params->StandardError;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
ANSI_STRING TitleString, ShellString, DesktopString;
|
|
|
|
LPSTARTUPINFOA StartupInfo;
|
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Get the cached information as well as the PEB parameters */
|
|
|
|
StartupInfo = BaseAnsiStartupInfo;
|
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Check if this is the first time we have to get the cached version */
|
|
|
|
while (!StartupInfo)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Create new ANSI startup info */
|
|
|
|
StartupInfo = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
|
|
|
sizeof(*StartupInfo));
|
|
|
|
if (StartupInfo)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Zero out string pointers in case we fail to create them */
|
2018-07-07 16:56:40 +00:00
|
|
|
StartupInfo->lpReserved = NULL;
|
|
|
|
StartupInfo->lpDesktop = NULL;
|
|
|
|
StartupInfo->lpTitle = NULL;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Set the size */
|
|
|
|
StartupInfo->cb = sizeof(*StartupInfo);
|
|
|
|
|
|
|
|
/* Copy what's already stored in the PEB */
|
|
|
|
StartupInfo->dwX = Params->StartingX;
|
|
|
|
StartupInfo->dwY = Params->StartingY;
|
|
|
|
StartupInfo->dwXSize = Params->CountX;
|
|
|
|
StartupInfo->dwYSize = Params->CountY;
|
|
|
|
StartupInfo->dwXCountChars = Params->CountCharsX;
|
|
|
|
StartupInfo->dwYCountChars = Params->CountCharsY;
|
|
|
|
StartupInfo->dwFillAttribute = Params->FillAttribute;
|
|
|
|
StartupInfo->dwFlags = Params->WindowFlags;
|
|
|
|
StartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
|
|
|
|
StartupInfo->cbReserved2 = Params->RuntimeData.Length;
|
|
|
|
StartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
|
|
|
|
StartupInfo->hStdInput = Params->StandardInput;
|
|
|
|
StartupInfo->hStdOutput = Params->StandardOutput;
|
|
|
|
StartupInfo->hStdError = Params->StandardError;
|
|
|
|
|
|
|
|
/* Copy shell info string */
|
|
|
|
Status = RtlUnicodeStringToAnsiString(&ShellString,
|
|
|
|
&Params->ShellInfo,
|
|
|
|
TRUE);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Save it */
|
|
|
|
StartupInfo->lpReserved = ShellString.Buffer;
|
|
|
|
|
|
|
|
/* Copy desktop info string */
|
|
|
|
Status = RtlUnicodeStringToAnsiString(&DesktopString,
|
|
|
|
&Params->DesktopInfo,
|
|
|
|
TRUE);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Save it */
|
|
|
|
StartupInfo->lpDesktop = DesktopString.Buffer;
|
|
|
|
|
|
|
|
/* Copy window title string */
|
|
|
|
Status = RtlUnicodeStringToAnsiString(&TitleString,
|
|
|
|
&Params->WindowTitle,
|
|
|
|
TRUE);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Save it */
|
2012-01-23 05:32:11 +00:00
|
|
|
StartupInfo->lpTitle = TitleString.Buffer;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* We finished with the ANSI version, try to cache it */
|
2015-04-12 12:24:01 +00:00
|
|
|
if (!InterlockedCompareExchangePointer((PVOID*)&BaseAnsiStartupInfo,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
StartupInfo,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
/* We were the first thread through, use the data */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Someone beat us to it, use their data instead */
|
|
|
|
StartupInfo = BaseAnsiStartupInfo;
|
|
|
|
Status = STATUS_SUCCESS;
|
2012-05-20 14:06:09 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* We're going to free our own stuff, but not raise */
|
|
|
|
RtlFreeAnsiString(&TitleString);
|
|
|
|
}
|
|
|
|
RtlFreeAnsiString(&DesktopString);
|
|
|
|
}
|
|
|
|
RtlFreeAnsiString(&ShellString);
|
|
|
|
}
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No memory, fail */
|
|
|
|
Status = STATUS_NO_MEMORY;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Raise an error unless we got here due to the race condition */
|
|
|
|
if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now copy from the cached ANSI version */
|
|
|
|
lpStartupInfo->cb = StartupInfo->cb;
|
|
|
|
lpStartupInfo->lpReserved = StartupInfo->lpReserved;
|
|
|
|
lpStartupInfo->lpDesktop = StartupInfo->lpDesktop;
|
|
|
|
lpStartupInfo->lpTitle = StartupInfo->lpTitle;
|
|
|
|
lpStartupInfo->dwX = StartupInfo->dwX;
|
|
|
|
lpStartupInfo->dwY = StartupInfo->dwY;
|
|
|
|
lpStartupInfo->dwXSize = StartupInfo->dwXSize;
|
|
|
|
lpStartupInfo->dwYSize = StartupInfo->dwYSize;
|
|
|
|
lpStartupInfo->dwXCountChars = StartupInfo->dwXCountChars;
|
|
|
|
lpStartupInfo->dwYCountChars = StartupInfo->dwYCountChars;
|
|
|
|
lpStartupInfo->dwFillAttribute = StartupInfo->dwFillAttribute;
|
|
|
|
lpStartupInfo->dwFlags = StartupInfo->dwFlags;
|
|
|
|
lpStartupInfo->wShowWindow = StartupInfo->wShowWindow;
|
|
|
|
lpStartupInfo->cbReserved2 = StartupInfo->cbReserved2;
|
|
|
|
lpStartupInfo->lpReserved2 = StartupInfo->lpReserved2;
|
|
|
|
|
|
|
|
/* Check if the shell is hijacking the handles for other features */
|
|
|
|
if (lpStartupInfo->dwFlags &
|
|
|
|
(STARTF_USESTDHANDLES | STARTF_USEHOTKEY | STARTF_SHELLPRIVATE))
|
|
|
|
{
|
|
|
|
/* It isn't, so we can return the raw values */
|
|
|
|
lpStartupInfo->hStdInput = StartupInfo->hStdInput;
|
|
|
|
lpStartupInfo->hStdOutput = StartupInfo->hStdOutput;
|
|
|
|
lpStartupInfo->hStdError = StartupInfo->hStdError;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* It is, so make sure nobody uses these as console handles */
|
|
|
|
lpStartupInfo->hStdInput = INVALID_HANDLE_VALUE;
|
|
|
|
lpStartupInfo->hStdOutput = INVALID_HANDLE_VALUE;
|
|
|
|
lpStartupInfo->hStdError = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
FlushInstructionCache(IN HANDLE hProcess,
|
|
|
|
IN LPCVOID lpBaseAddress,
|
2015-09-01 23:45:48 +00:00
|
|
|
IN SIZE_T nSize)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Call the native function */
|
2015-09-01 23:45:48 +00:00
|
|
|
Status = NtFlushInstructionCache(hProcess, (PVOID)lpBaseAddress, nSize);
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle failure case */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* All good */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
ExitProcess(IN UINT uExitCode)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2012-11-02 18:00:47 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
|
|
|
PBASE_EXIT_PROCESS ExitProcessRequest = &ApiMessage.Data.ExitProcessRequest;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
ASSERT(!BaseRunningInServerProcess);
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
/* Acquire the PEB lock */
|
|
|
|
RtlAcquirePebLock();
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Kill all the threads */
|
2016-09-11 13:22:33 +00:00
|
|
|
NtTerminateProcess(NULL, uExitCode);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Unload all DLLs */
|
|
|
|
LdrShutdownProcess();
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Notify Base Server of process termination */
|
2012-11-02 18:00:47 +00:00
|
|
|
ExitProcessRequest->uExitCode = uExitCode;
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NULL,
|
2012-10-20 21:03:32 +00:00
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepExitProcess),
|
2015-07-10 23:57:26 +00:00
|
|
|
sizeof(*ExitProcessRequest));
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Now do it again */
|
|
|
|
NtTerminateProcess(NtCurrentProcess(), uExitCode);
|
|
|
|
}
|
|
|
|
_SEH2_FINALLY
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Release the PEB lock */
|
|
|
|
RtlReleasePebLock();
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
_SEH2_END;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* should never get here */
|
|
|
|
ASSERT(0);
|
|
|
|
while(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
TerminateProcess(IN HANDLE hProcess,
|
|
|
|
IN UINT uExitCode)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Check if no handle was passed in */
|
|
|
|
if (!hProcess)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Set error code */
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
else
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Otherwise, try to terminate the process */
|
|
|
|
Status = NtTerminateProcess(hProcess, uExitCode);
|
|
|
|
if (NT_SUCCESS(Status)) return TRUE;
|
|
|
|
|
|
|
|
/* It failed, convert error code */
|
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* This is the failure path */
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
* @implemented
|
2011-07-20 15:54:21 +00:00
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
FatalAppExitA(UINT uAction,
|
|
|
|
LPCSTR lpMessageText)
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
PUNICODE_STRING MessageTextU;
|
2011-07-20 15:54:21 +00:00
|
|
|
ANSI_STRING MessageText;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Initialize the string using the static TEB pointer */
|
|
|
|
MessageTextU = &NtCurrentTeb()->StaticUnicodeString;
|
2011-07-20 15:54:21 +00:00
|
|
|
RtlInitAnsiString(&MessageText, (LPSTR)lpMessageText);
|
|
|
|
|
2016-07-03 13:48:50 +00:00
|
|
|
/* Convert to unicode, or just exit normally if this failed */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
Status = RtlAnsiStringToUnicodeString(MessageTextU, &MessageText, FALSE);
|
|
|
|
if (!NT_SUCCESS(Status)) ExitProcess(0);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Call the Wide function */
|
|
|
|
FatalAppExitW(uAction, MessageTextU->Buffer);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
* @implemented
|
2011-07-20 15:54:21 +00:00
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
FatalAppExitW(IN UINT uAction,
|
|
|
|
IN LPCWSTR lpMessageText)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
UNICODE_STRING UnicodeString;
|
|
|
|
ULONG Response;
|
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2013-04-14 12:14:00 +00:00
|
|
|
/* Setup the string to print out */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
RtlInitUnicodeString(&UnicodeString, lpMessageText);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Display the hard error no matter what */
|
|
|
|
Status = NtRaiseHardError(STATUS_FATAL_APP_EXIT | HARDERROR_OVERRIDE_ERRORMODE,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
(PULONG_PTR)&UnicodeString,
|
2016-07-03 13:48:50 +00:00
|
|
|
#if DBG
|
|
|
|
/* On Checked builds, Windows allows the user to cancel the operation */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
OptionOkCancel,
|
2016-07-03 13:48:50 +00:00
|
|
|
#else
|
|
|
|
OptionOk,
|
|
|
|
#endif
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
&Response);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Give the user a chance to abort */
|
2021-01-18 21:15:02 +00:00
|
|
|
if ((NT_SUCCESS(Status)) && (Response == ResponseCancel))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Otherwise kill the process */
|
2011-07-20 15:54:21 +00:00
|
|
|
ExitProcess(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
FatalExit(IN int ExitCode)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
#if DBG
|
2016-07-03 13:48:50 +00:00
|
|
|
/* On Checked builds, Windows gives the user a nice little debugger UI */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
CHAR ch[2];
|
|
|
|
DbgPrint("FatalExit...\n");
|
|
|
|
DbgPrint("\n");
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
DbgPrompt( "A (Abort), B (Break), I (Ignore)? ", ch, sizeof(ch));
|
|
|
|
switch (ch[0])
|
|
|
|
{
|
|
|
|
case 'B': case 'b':
|
|
|
|
DbgBreakPoint();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'A': case 'a':
|
|
|
|
ExitProcess(ExitCode);
|
|
|
|
|
|
|
|
case 'I': case 'i':
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* On other builds, just kill the process */
|
2011-07-20 15:54:21 +00:00
|
|
|
ExitProcess(ExitCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetPriorityClass(IN HANDLE hProcess)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NTSTATUS Status;
|
2021-02-20 16:13:38 +00:00
|
|
|
PROCESS_PRIORITY_CLASS DECLSPEC_ALIGN(4) PriorityClass;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel */
|
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessPriorityClass,
|
|
|
|
&PriorityClass,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(PriorityClass),
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NULL);
|
|
|
|
if (NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle the conversion from NT to Win32 classes */
|
|
|
|
switch (PriorityClass.PriorityClass)
|
|
|
|
{
|
|
|
|
case PROCESS_PRIORITY_CLASS_IDLE: return IDLE_PRIORITY_CLASS;
|
|
|
|
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL: return BELOW_NORMAL_PRIORITY_CLASS;
|
|
|
|
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL: return ABOVE_NORMAL_PRIORITY_CLASS;
|
|
|
|
case PROCESS_PRIORITY_CLASS_HIGH: return HIGH_PRIORITY_CLASS;
|
|
|
|
case PROCESS_PRIORITY_CLASS_REALTIME: return REALTIME_PRIORITY_CLASS;
|
|
|
|
case PROCESS_PRIORITY_CLASS_NORMAL: default: return NORMAL_PRIORITY_CLASS;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Failure path */
|
|
|
|
BaseSetLastNTError(Status);
|
2020-09-12 19:38:06 +00:00
|
|
|
return 0;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
SetPriorityClass(IN HANDLE hProcess,
|
|
|
|
IN DWORD dwPriorityClass)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
PVOID State = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle conversion from Win32 to NT priority classes */
|
2011-07-20 15:54:21 +00:00
|
|
|
switch (dwPriorityClass)
|
|
|
|
{
|
|
|
|
case IDLE_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HIGH_PRIORITY_CLASS:
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REALTIME_PRIORITY_CLASS:
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Try to acquire the privilege. If it fails, just use HIGH */
|
|
|
|
State = BasepIsRealtimeAllowed(TRUE);
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
|
|
|
PriorityClass.PriorityClass += (State != NULL);
|
2011-07-20 15:54:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Unrecognized priority classes don't make it to the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Send the request to the kernel, and don't touch the foreground flag */
|
2011-07-20 15:54:21 +00:00
|
|
|
PriorityClass.Foreground = FALSE;
|
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessPriorityClass,
|
|
|
|
&PriorityClass,
|
|
|
|
sizeof(PROCESS_PRIORITY_CLASS));
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Release the privilege if we had it */
|
|
|
|
if (State) RtlReleasePrivilege(State);
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* All done */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessVersion(IN DWORD ProcessId)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
DWORD Version = 0;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
PIMAGE_NT_HEADERS NtHeader;
|
|
|
|
PIMAGE_DOS_HEADER DosHeader;
|
|
|
|
PPEB Peb;
|
2011-07-20 15:54:21 +00:00
|
|
|
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
PVOID BaseAddress;
|
|
|
|
ULONG e_lfanew;
|
2011-07-20 15:54:21 +00:00
|
|
|
HANDLE ProcessHandle = NULL;
|
|
|
|
NTSTATUS Status;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
USHORT VersionData[2];
|
|
|
|
BOOLEAN Result;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* We'll be accessing stuff that can fault, so protect everything with SEH */
|
2011-07-20 15:54:21 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* It this an in-process or out-of-process request? */
|
|
|
|
if (!(ProcessId) || (GetCurrentProcessId() == ProcessId))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* It's in-process, so just read our own header */
|
|
|
|
NtHeader = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress);
|
|
|
|
if (!NtHeader)
|
|
|
|
{
|
|
|
|
/* Unable to read the NT header, something is wrong here... */
|
|
|
|
Status = STATUS_INVALID_IMAGE_FORMAT;
|
|
|
|
goto Error;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Get the version straight out of the NT header */
|
|
|
|
Version = MAKELONG(NtHeader->OptionalHeader.MinorSubsystemVersion,
|
|
|
|
NtHeader->OptionalHeader.MajorSubsystemVersion);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Out-of-process, so open it */
|
2011-07-20 15:54:21 +00:00
|
|
|
ProcessHandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
|
|
|
|
FALSE,
|
|
|
|
ProcessId);
|
2013-09-12 10:06:34 +00:00
|
|
|
if (!ProcessHandle) _SEH2_YIELD(return 0);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Try to find out where its PEB lives */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(ProcessHandle,
|
|
|
|
ProcessBasicInformation,
|
|
|
|
&ProcessBasicInfo,
|
|
|
|
sizeof(ProcessBasicInfo),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status)) goto Error;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
Peb = ProcessBasicInfo.PebBaseAddress;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Now that we have the PEB, read the image base address out of it */
|
|
|
|
Result = ReadProcessMemory(ProcessHandle,
|
|
|
|
&Peb->ImageBaseAddress,
|
|
|
|
&BaseAddress,
|
|
|
|
sizeof(BaseAddress),
|
|
|
|
NULL);
|
|
|
|
if (!Result) goto Error;
|
|
|
|
|
|
|
|
/* Now read the e_lfanew (offset to NT header) from the base */
|
|
|
|
DosHeader = BaseAddress;
|
|
|
|
Result = ReadProcessMemory(ProcessHandle,
|
|
|
|
&DosHeader->e_lfanew,
|
|
|
|
&e_lfanew,
|
|
|
|
sizeof(e_lfanew),
|
|
|
|
NULL);
|
|
|
|
if (!Result) goto Error;
|
|
|
|
|
|
|
|
/* And finally, read the NT header itself by adding the offset */
|
|
|
|
NtHeader = (PVOID)((ULONG_PTR)BaseAddress + e_lfanew);
|
|
|
|
Result = ReadProcessMemory(ProcessHandle,
|
|
|
|
&NtHeader->OptionalHeader.MajorSubsystemVersion,
|
|
|
|
&VersionData,
|
|
|
|
sizeof(VersionData),
|
|
|
|
NULL);
|
|
|
|
if (!Result) goto Error;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Get the version straight out of the NT header */
|
|
|
|
Version = MAKELONG(VersionData[0], VersionData[1]);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
Error:
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* If there was an error anywhere, set the last error */
|
|
|
|
if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_SEH2_FINALLY
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Close the process handle */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (ProcessHandle) CloseHandle(ProcessHandle);
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* And return the version data */
|
2011-07-20 15:54:21 +00:00
|
|
|
return Version;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessIoCounters(IN HANDLE hProcess,
|
|
|
|
OUT PIO_COUNTERS lpIoCounters)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel. Structures are identical, so let it do the copy too. */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessIoCounters,
|
|
|
|
lpIoCounters,
|
|
|
|
sizeof(IO_COUNTERS),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* All done */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessPriorityBoost(IN HANDLE hProcess,
|
|
|
|
OUT PBOOL pDisablePriorityBoost)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG PriorityBoost;
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessPriorityBoost,
|
|
|
|
&PriorityBoost,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(PriorityBoost),
|
2011-07-20 15:54:21 +00:00
|
|
|
NULL);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Convert from ULONG to a BOOL */
|
|
|
|
*pDisablePriorityBoost = PriorityBoost ? TRUE : FALSE;
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
SetProcessPriorityBoost(IN HANDLE hProcess,
|
|
|
|
IN BOOL bDisablePriorityBoost)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
ULONG PriorityBoost;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Enforce that this is a BOOL, and send it to the kernel as a ULONG */
|
|
|
|
PriorityBoost = (bDisablePriorityBoost ? TRUE : FALSE);
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtSetInformationProcess(hProcess,
|
|
|
|
ProcessPriorityBoost,
|
|
|
|
&PriorityBoost,
|
|
|
|
sizeof(ULONG));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* All done */
|
2011-07-20 15:54:21 +00:00
|
|
|
return TRUE;
|
2004-03-14 11:11:17 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
BOOL
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
GetProcessHandleCount(IN HANDLE hProcess,
|
|
|
|
OUT PDWORD pdwHandleCount)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
ULONG phc;
|
|
|
|
NTSTATUS Status;
|
2010-01-09 20:51:33 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessHandleCount,
|
|
|
|
&phc,
|
2016-07-03 13:48:50 +00:00
|
|
|
sizeof(phc),
|
2011-07-20 15:54:21 +00:00
|
|
|
NULL);
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
2010-01-09 20:51:33 +00:00
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
/* Copy the count and return success */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
*pdwHandleCount = phc;
|
|
|
|
return TRUE;
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
BOOL
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
IsWow64Process(IN HANDLE hProcess,
|
|
|
|
OUT PBOOL Wow64Process)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
ULONG_PTR pbi;
|
|
|
|
NTSTATUS Status;
|
2010-01-09 20:51:33 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(hProcess,
|
|
|
|
ProcessWow64Information,
|
|
|
|
&pbi,
|
|
|
|
sizeof(pbi),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2010-01-09 20:51:33 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Handle error path */
|
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Enforce this is a BOOL, and return success */
|
2011-07-20 15:54:21 +00:00
|
|
|
*Wow64Process = (pbi != 0);
|
|
|
|
return TRUE;
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
LPSTR
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
2011-07-20 15:54:21 +00:00
|
|
|
GetCommandLineA(VOID)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
return BaseAnsiCommandLine.Buffer;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
LPWSTR
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
2011-07-20 15:54:21 +00:00
|
|
|
GetCommandLineW(VOID)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
return BaseUnicodeCommandLine.Buffer;
|
1996-01-23 01:02:17 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
ReadProcessMemory(IN HANDLE hProcess,
|
|
|
|
IN LPCVOID lpBaseAddress,
|
|
|
|
IN LPVOID lpBuffer,
|
|
|
|
IN SIZE_T nSize,
|
|
|
|
OUT SIZE_T* lpNumberOfBytesRead)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
NTSTATUS Status;
|
2000-02-19 19:37:13 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Do the read */
|
|
|
|
Status = NtReadVirtualMemory(hProcess,
|
|
|
|
(PVOID)lpBaseAddress,
|
|
|
|
lpBuffer,
|
|
|
|
nSize,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
&nSize);
|
|
|
|
|
|
|
|
/* In user-mode, this parameter is optional */
|
|
|
|
if (lpNumberOfBytesRead) *lpNumberOfBytesRead = nSize;
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
2002-10-20 16:40:12 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
/* We failed */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Return success */
|
|
|
|
return TRUE;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
BOOL
|
2011-07-20 15:54:21 +00:00
|
|
|
NTAPI
|
|
|
|
WriteProcessMemory(IN HANDLE hProcess,
|
|
|
|
IN LPVOID lpBaseAddress,
|
|
|
|
IN LPCVOID lpBuffer,
|
|
|
|
IN SIZE_T nSize,
|
|
|
|
OUT SIZE_T *lpNumberOfBytesWritten)
|
1996-01-23 01:02:17 +00:00
|
|
|
{
|
2010-01-09 20:51:33 +00:00
|
|
|
NTSTATUS Status;
|
2011-07-20 15:54:21 +00:00
|
|
|
ULONG OldValue;
|
|
|
|
SIZE_T RegionSize;
|
|
|
|
PVOID Base;
|
|
|
|
BOOLEAN UnProtect;
|
|
|
|
|
|
|
|
/* Set parameters for protect call */
|
|
|
|
RegionSize = nSize;
|
|
|
|
Base = lpBaseAddress;
|
|
|
|
|
|
|
|
/* Check the current status */
|
|
|
|
Status = NtProtectVirtualMemory(hProcess,
|
|
|
|
&Base,
|
|
|
|
&RegionSize,
|
|
|
|
PAGE_EXECUTE_READWRITE,
|
|
|
|
&OldValue);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Check if we are unprotecting */
|
|
|
|
UnProtect = OldValue & (PAGE_READWRITE |
|
|
|
|
PAGE_WRITECOPY |
|
|
|
|
PAGE_EXECUTE_READWRITE |
|
|
|
|
PAGE_EXECUTE_WRITECOPY) ? FALSE : TRUE;
|
|
|
|
if (!UnProtect)
|
|
|
|
{
|
|
|
|
/* Set the new protection */
|
|
|
|
Status = NtProtectVirtualMemory(hProcess,
|
|
|
|
&Base,
|
|
|
|
&RegionSize,
|
|
|
|
OldValue,
|
|
|
|
&OldValue);
|
|
|
|
|
|
|
|
/* Write the memory */
|
|
|
|
Status = NtWriteVirtualMemory(hProcess,
|
|
|
|
lpBaseAddress,
|
|
|
|
(LPVOID)lpBuffer,
|
|
|
|
nSize,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
&nSize);
|
|
|
|
|
|
|
|
/* In Win32, the parameter is optional, so handle this case */
|
|
|
|
if (lpNumberOfBytesWritten) *lpNumberOfBytesWritten = nSize;
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* We failed */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Flush the ITLB */
|
|
|
|
NtFlushInstructionCache(hProcess, lpBaseAddress, nSize);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check if we were read only */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
if (OldValue & (PAGE_NOACCESS | PAGE_READONLY))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
/* Restore protection and fail */
|
|
|
|
NtProtectVirtualMemory(hProcess,
|
|
|
|
&Base,
|
|
|
|
&RegionSize,
|
|
|
|
OldValue,
|
|
|
|
&OldValue);
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(STATUS_ACCESS_VIOLATION);
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Note: This is what Windows returns and code depends on it */
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, do the write */
|
|
|
|
Status = NtWriteVirtualMemory(hProcess,
|
|
|
|
lpBaseAddress,
|
|
|
|
(LPVOID)lpBuffer,
|
|
|
|
nSize,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
&nSize);
|
|
|
|
|
|
|
|
/* In Win32, the parameter is optional, so handle this case */
|
|
|
|
if (lpNumberOfBytesWritten) *lpNumberOfBytesWritten = nSize;
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* And restore the protection */
|
|
|
|
NtProtectVirtualMemory(hProcess,
|
|
|
|
&Base,
|
|
|
|
&RegionSize,
|
|
|
|
OldValue,
|
|
|
|
&OldValue);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* We failed */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(STATUS_ACCESS_VIOLATION);
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
|
|
|
|
/* Note: This is what Windows returns and code depends on it */
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Flush the ITLB */
|
|
|
|
NtFlushInstructionCache(hProcess, lpBaseAddress, nSize);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
/* We failed */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2010-01-09 20:51:33 +00:00
|
|
|
return FALSE;
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-07-20 15:54:21 +00:00
|
|
|
BOOL
|
2010-01-09 20:51:33 +00:00
|
|
|
WINAPI
|
2011-07-20 15:54:21 +00:00
|
|
|
ProcessIdToSessionId(IN DWORD dwProcessId,
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
OUT PDWORD pSessionId)
|
1999-05-11 15:28:11 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
PROCESS_SESSION_INFORMATION SessionInformation;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
CLIENT_ID ClientId;
|
|
|
|
HANDLE ProcessHandle;
|
2010-01-09 20:51:33 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Do a quick check if the pointer is not writable */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (IsBadWritePtr(pSessionId, sizeof(DWORD)))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Fail fast */
|
2011-07-20 15:54:21 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-08-27 05:00:03 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Open the process passed in by ID */
|
2011-07-20 15:54:21 +00:00
|
|
|
ClientId.UniqueProcess = UlongToHandle(dwProcessId);
|
|
|
|
ClientId.UniqueThread = 0;
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
|
|
|
Status = NtOpenProcess(&ProcessHandle,
|
|
|
|
PROCESS_QUERY_INFORMATION,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&ClientId);
|
|
|
|
if (NT_SUCCESS(Status))
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Query the session ID from the kernel */
|
2011-07-20 15:54:21 +00:00
|
|
|
Status = NtQueryInformationProcess(ProcessHandle,
|
|
|
|
ProcessSessionInformation,
|
|
|
|
&SessionInformation,
|
|
|
|
sizeof(SessionInformation),
|
|
|
|
NULL);
|
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
/* Close the handle and check if we succeeded */
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
NtClose(ProcessHandle);
|
2011-07-20 15:54:21 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Return the session ID */
|
2011-07-20 15:54:21 +00:00
|
|
|
*pSessionId = SessionInformation.SessionId;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/* Set error code and fail */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
#define AddToHandle(x,y) (x) = (HANDLE)((ULONG_PTR)(x) | (y));
|
|
|
|
#define RemoveFromHandle(x,y) (x) = (HANDLE)((ULONG_PTR)(x) & ~(y));
|
|
|
|
C_ASSERT(PROCESS_PRIORITY_CLASS_REALTIME == (PROCESS_PRIORITY_CLASS_HIGH + 1));
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2010-01-09 20:51:33 +00:00
|
|
|
BOOL
|
|
|
|
WINAPI
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
CreateProcessInternalW(IN HANDLE hUserToken,
|
2013-08-06 10:40:36 +00:00
|
|
|
IN LPCWSTR lpApplicationName,
|
|
|
|
IN LPWSTR lpCommandLine,
|
|
|
|
IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
|
|
|
IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
|
|
|
IN BOOL bInheritHandles,
|
|
|
|
IN DWORD dwCreationFlags,
|
|
|
|
IN LPVOID lpEnvironment,
|
|
|
|
IN LPCWSTR lpCurrentDirectory,
|
|
|
|
IN LPSTARTUPINFOW lpStartupInfo,
|
|
|
|
IN LPPROCESS_INFORMATION lpProcessInformation,
|
|
|
|
OUT PHANDLE hNewToken)
|
1999-05-11 15:28:11 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
//
|
|
|
|
// Core variables used for creating the initial process and thread
|
|
|
|
//
|
|
|
|
SECURITY_ATTRIBUTES LocalThreadAttributes, LocalProcessAttributes;
|
2011-07-20 15:54:21 +00:00
|
|
|
OBJECT_ATTRIBUTES LocalObjectAttributes;
|
|
|
|
POBJECT_ATTRIBUTES ObjectAttributes;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
SECTION_IMAGE_INFORMATION ImageInformation;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
2011-07-20 15:54:21 +00:00
|
|
|
CLIENT_ID ClientId;
|
2018-02-15 21:34:48 +00:00
|
|
|
ULONG NoWindow, StackSize, ErrorCode, Flags;
|
|
|
|
SIZE_T RegionSize;
|
2013-09-14 10:20:11 +00:00
|
|
|
USHORT ImageMachine;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ULONG ParameterFlags, PrivilegeValue, HardErrorMode, ErrorResponse;
|
|
|
|
ULONG_PTR ErrorParameters[2];
|
|
|
|
BOOLEAN InJob, SaferNeeded, UseLargePages, HavePrivilege;
|
|
|
|
BOOLEAN QuerySection, SkipSaferAndAppCompat;
|
|
|
|
CONTEXT Context;
|
2014-03-08 01:17:45 +00:00
|
|
|
BASE_API_MESSAGE CsrMsg[2];
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PBASE_CREATE_PROCESS CreateProcessMsg;
|
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
|
|
|
PVOID BaseAddress, PrivilegeState, RealTimePrivilegeState;
|
|
|
|
HANDLE DebugHandle, TokenHandle, JobHandle, KeyHandle, ThreadHandle;
|
|
|
|
HANDLE FileHandle, SectionHandle, ProcessHandle;
|
|
|
|
ULONG ResumeCount;
|
|
|
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
2016-12-20 19:51:44 +00:00
|
|
|
NTSTATUS Status, AppCompatStatus, SaferStatus, IFEOStatus, ImageDbgStatus;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PPEB Peb, RemotePeb;
|
|
|
|
PTEB Teb;
|
|
|
|
INITIAL_TEB InitialTeb;
|
|
|
|
PVOID TibValue;
|
|
|
|
PIMAGE_NT_HEADERS NtHeaders;
|
|
|
|
STARTUPINFOW StartupInfo;
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
|
|
|
|
UNICODE_STRING DebuggerString;
|
|
|
|
BOOL Result;
|
|
|
|
//
|
|
|
|
// Variables used for command-line and argument parsing
|
|
|
|
//
|
|
|
|
PCHAR pcScan;
|
|
|
|
SIZE_T n;
|
2013-08-05 18:33:52 +00:00
|
|
|
WCHAR SaveChar;
|
2016-07-09 22:23:23 +00:00
|
|
|
ULONG Length, FileAttribs, CmdQuoteLength;
|
2018-02-15 21:34:48 +00:00
|
|
|
ULONG ResultSize;
|
|
|
|
SIZE_T EnvironmentLength, CmdLineLength;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PWCHAR QuotedCmdLine, AnsiCmdCommand, ExtBuffer, CurrentDirectory;
|
2013-08-05 18:33:52 +00:00
|
|
|
PWCHAR NullBuffer, ScanString, NameBuffer, SearchPath, DebuggerCmdLine;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ANSI_STRING AnsiEnv;
|
|
|
|
UNICODE_STRING UnicodeEnv, PathName;
|
2013-08-05 18:33:52 +00:00
|
|
|
BOOLEAN SearchRetry, QuotesNeeded, CmdLineIsAppName, HasQuotes;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Variables used for Fusion/SxS (Side-by-Side Assemblies)
|
|
|
|
//
|
|
|
|
RTL_PATH_TYPE SxsPathType, PathType;
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
PRTL_BUFFER ByteBuffer;
|
|
|
|
PRTL_UNICODE_STRING_BUFFER ThisBuffer, Buffer, SxsStaticBuffers[5];
|
|
|
|
PRTL_UNICODE_STRING_BUFFER* BufferHead, SxsStringBuffer;
|
|
|
|
RTL_UNICODE_STRING_BUFFER SxsWin32ManifestPath, SxsNtManifestPath;
|
|
|
|
RTL_UNICODE_STRING_BUFFER SxsWin32PolicyPath, SxsNtPolicyPath;
|
|
|
|
RTL_UNICODE_STRING_BUFFER SxsWin32AssemblyDirectory;
|
|
|
|
BASE_MSG_SXS_HANDLES MappedHandles, Handles, FileHandles;
|
|
|
|
PVOID CapturedStrings[3];
|
|
|
|
SXS_WIN32_NT_PATH_PAIR ExePathPair, ManifestPathPair, PolicyPathPair;
|
2016-11-12 21:53:33 +00:00
|
|
|
SXS_OVERRIDE_MANIFEST OverrideManifest;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
UNICODE_STRING FreeString, SxsNtExePath;
|
|
|
|
PWCHAR SxsConglomeratedBuffer, StaticBuffer;
|
|
|
|
ULONG ConglomeratedBufferSizeBytes, StaticBufferSize, i;
|
|
|
|
#endif
|
|
|
|
ULONG FusionFlags;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Variables used for path conversion (and partially Fusion/SxS)
|
|
|
|
//
|
|
|
|
PWCHAR FilePart, PathBuffer, FreeBuffer;
|
|
|
|
BOOLEAN TranslationStatus;
|
|
|
|
RTL_RELATIVE_NAME_U SxsWin32RelativePath;
|
|
|
|
UNICODE_STRING PathBufferString, SxsWin32ExePath;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Variables used by Application Compatibility (and partially Fusion/SxS)
|
|
|
|
//
|
|
|
|
PVOID AppCompatSxsData, AppCompatData;
|
|
|
|
ULONG AppCompatSxsDataSize, AppCompatDataSize;
|
|
|
|
//
|
|
|
|
// Variables used by VDM (Virtual Dos Machine) and WOW32 (16-bit Support)
|
|
|
|
//
|
|
|
|
ULONG BinarySubType, VdmBinaryType, VdmTask, VdmReserve;
|
|
|
|
ULONG VdmUndoLevel;
|
|
|
|
BOOLEAN UseVdmReserve;
|
|
|
|
HANDLE VdmWaitObject;
|
|
|
|
ANSI_STRING VdmAnsiEnv;
|
|
|
|
UNICODE_STRING VdmString, VdmUnicodeEnv;
|
|
|
|
BOOLEAN IsWowApp;
|
2014-02-02 00:25:25 +00:00
|
|
|
PBASE_CHECK_VDM CheckVdmMsg;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Zero out the initial core variables and handles */
|
|
|
|
QuerySection = FALSE;
|
|
|
|
InJob = FALSE;
|
2016-12-20 19:51:44 +00:00
|
|
|
SkipSaferAndAppCompat = FALSE;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ParameterFlags = 0;
|
|
|
|
Flags = 0;
|
|
|
|
DebugHandle = NULL;
|
|
|
|
JobHandle = NULL;
|
|
|
|
TokenHandle = NULL;
|
|
|
|
FileHandle = NULL;
|
|
|
|
SectionHandle = NULL;
|
|
|
|
ProcessHandle = NULL;
|
|
|
|
ThreadHandle = NULL;
|
|
|
|
BaseAddress = (PVOID)1;
|
|
|
|
|
|
|
|
/* Zero out initial SxS and Application Compatibility state */
|
|
|
|
AppCompatData = NULL;
|
|
|
|
AppCompatDataSize = 0;
|
|
|
|
AppCompatSxsData = NULL;
|
|
|
|
AppCompatSxsDataSize = 0;
|
|
|
|
CaptureBuffer = NULL;
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
SxsConglomeratedBuffer = NULL;
|
|
|
|
#endif
|
|
|
|
FusionFlags = 0;
|
|
|
|
|
|
|
|
/* Zero out initial parsing variables -- others are initialized later */
|
|
|
|
DebuggerCmdLine = NULL;
|
|
|
|
PathBuffer = NULL;
|
|
|
|
SearchPath = NULL;
|
2018-07-07 16:56:40 +00:00
|
|
|
NullBuffer = NULL;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
FreeBuffer = NULL;
|
|
|
|
NameBuffer = NULL;
|
|
|
|
CurrentDirectory = NULL;
|
|
|
|
FilePart = NULL;
|
|
|
|
DebuggerString.Buffer = NULL;
|
2013-08-05 18:33:52 +00:00
|
|
|
HasQuotes = FALSE;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
QuotedCmdLine = NULL;
|
|
|
|
|
|
|
|
/* Zero out initial VDM state */
|
|
|
|
VdmAnsiEnv.Buffer = NULL;
|
|
|
|
VdmUnicodeEnv.Buffer = NULL;
|
|
|
|
VdmString.Buffer = NULL;
|
|
|
|
VdmTask = 0;
|
|
|
|
VdmUndoLevel = 0;
|
|
|
|
VdmBinaryType = 0;
|
|
|
|
VdmReserve = 0;
|
|
|
|
VdmWaitObject = NULL;
|
|
|
|
UseVdmReserve = FALSE;
|
|
|
|
IsWowApp = FALSE;
|
|
|
|
|
|
|
|
/* Set message structures */
|
2014-03-08 01:17:45 +00:00
|
|
|
CreateProcessMsg = &CsrMsg[0].Data.CreateProcessRequest;
|
|
|
|
CheckVdmMsg = &CsrMsg[1].Data.CheckVDMRequest;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Clear the more complex structures by zeroing out their entire memory */
|
|
|
|
RtlZeroMemory(&Context, sizeof(Context));
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
RtlZeroMemory(&FileHandles, sizeof(FileHandles));
|
|
|
|
RtlZeroMemory(&MappedHandles, sizeof(MappedHandles));
|
|
|
|
RtlZeroMemory(&Handles, sizeof(Handles));
|
|
|
|
#endif
|
|
|
|
RtlZeroMemory(&CreateProcessMsg->Sxs, sizeof(CreateProcessMsg->Sxs));
|
|
|
|
RtlZeroMemory(&LocalProcessAttributes, sizeof(LocalProcessAttributes));
|
|
|
|
RtlZeroMemory(&LocalThreadAttributes, sizeof(LocalThreadAttributes));
|
|
|
|
|
|
|
|
/* Zero out output arguments as well */
|
|
|
|
RtlZeroMemory(lpProcessInformation, sizeof(*lpProcessInformation));
|
|
|
|
if (hNewToken) *hNewToken = NULL;
|
|
|
|
|
|
|
|
/* Capture the special window flag */
|
|
|
|
NoWindow = dwCreationFlags & CREATE_NO_WINDOW;
|
|
|
|
dwCreationFlags &= ~CREATE_NO_WINDOW;
|
|
|
|
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
/* Setup the SxS static string arrays and buffers */
|
|
|
|
SxsStaticBuffers[0] = &SxsWin32ManifestPath;
|
|
|
|
SxsStaticBuffers[1] = &SxsWin32PolicyPath;
|
|
|
|
SxsStaticBuffers[2] = &SxsWin32AssemblyDirectory;
|
|
|
|
SxsStaticBuffers[3] = &SxsNtManifestPath;
|
|
|
|
SxsStaticBuffers[4] = &SxsNtPolicyPath;
|
|
|
|
ExePathPair.Win32 = &SxsWin32ExePath;
|
|
|
|
ExePathPair.Nt = &SxsNtExePath;
|
|
|
|
ManifestPathPair.Win32 = &SxsWin32ManifestPath.String;
|
|
|
|
ManifestPathPair.Nt = &SxsNtManifestPath.String;
|
|
|
|
PolicyPathPair.Win32 = &SxsWin32PolicyPath.String;
|
|
|
|
PolicyPathPair.Nt = &SxsNtPolicyPath.String;
|
|
|
|
#endif
|
2011-07-20 15:54:21 +00:00
|
|
|
|
2014-05-18 23:12:24 +00:00
|
|
|
DPRINT("CreateProcessInternalW: '%S' '%S' %lx\n", lpApplicationName, lpCommandLine, dwCreationFlags);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Finally, set our TEB and PEB */
|
|
|
|
Teb = NtCurrentTeb();
|
|
|
|
Peb = NtCurrentPeb();
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* This combination is illegal (see MSDN) */
|
|
|
|
if ((dwCreationFlags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE)) ==
|
|
|
|
(DETACHED_PROCESS | CREATE_NEW_CONSOLE))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
DPRINT1("Invalid flag combo used\n");
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Convert the priority class */
|
|
|
|
if (dwCreationFlags & IDLE_PRIORITY_CLASS)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else if (dwCreationFlags & BELOW_NORMAL_PRIORITY_CLASS)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else if (dwCreationFlags & NORMAL_PRIORITY_CLASS)
|
2009-06-15 22:16:49 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
2009-06-15 22:16:49 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else if (dwCreationFlags & ABOVE_NORMAL_PRIORITY_CLASS)
|
2001-08-15 20:35:39 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
|
|
|
}
|
|
|
|
else if (dwCreationFlags & HIGH_PRIORITY_CLASS)
|
|
|
|
{
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
|
|
|
}
|
|
|
|
else if (dwCreationFlags & REALTIME_PRIORITY_CLASS)
|
|
|
|
{
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
2013-08-06 10:40:36 +00:00
|
|
|
PriorityClass.PriorityClass += (BasepIsRealtimeAllowed(FALSE) != NULL);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Done with the priority masks, so get rid of them */
|
|
|
|
PriorityClass.Foreground = FALSE;
|
|
|
|
dwCreationFlags &= ~(NORMAL_PRIORITY_CLASS |
|
|
|
|
IDLE_PRIORITY_CLASS |
|
|
|
|
HIGH_PRIORITY_CLASS |
|
|
|
|
REALTIME_PRIORITY_CLASS |
|
|
|
|
BELOW_NORMAL_PRIORITY_CLASS |
|
|
|
|
ABOVE_NORMAL_PRIORITY_CLASS);
|
|
|
|
|
|
|
|
/* You cannot request both a shared and a separate WoW VDM */
|
|
|
|
if ((dwCreationFlags & CREATE_SEPARATE_WOW_VDM) &&
|
|
|
|
(dwCreationFlags & CREATE_SHARED_WOW_VDM))
|
|
|
|
{
|
|
|
|
/* Fail such nonsensical attempts */
|
|
|
|
DPRINT1("Invalid WOW flags\n");
|
2011-07-20 15:54:21 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
2001-08-15 20:35:39 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else if (!(dwCreationFlags & CREATE_SHARED_WOW_VDM) &&
|
|
|
|
(BaseStaticServerData->DefaultSeparateVDM))
|
|
|
|
{
|
|
|
|
/* A shared WoW VDM was not requested but system enforces separation */
|
|
|
|
dwCreationFlags |= CREATE_SEPARATE_WOW_VDM;
|
|
|
|
}
|
2010-01-09 20:51:33 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If a shared WoW VDM is used, make sure the process isn't in a job */
|
|
|
|
if (!(dwCreationFlags & CREATE_SEPARATE_WOW_VDM) &&
|
|
|
|
(NtIsProcessInJob(NtCurrentProcess(), NULL)))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Remove the shared flag and add the separate flag */
|
|
|
|
dwCreationFlags = (dwCreationFlags &~ CREATE_SHARED_WOW_VDM) |
|
|
|
|
CREATE_SEPARATE_WOW_VDM;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
1998-10-05 04:01:30 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Convert the environment */
|
|
|
|
if ((lpEnvironment) && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Scan the environment to calculate its Unicode size */
|
|
|
|
AnsiEnv.Buffer = pcScan = (PCHAR)lpEnvironment;
|
|
|
|
while ((*pcScan) || (*(pcScan + 1))) ++pcScan;
|
|
|
|
|
2018-02-15 21:34:48 +00:00
|
|
|
/* Make sure the environment is not too large */
|
|
|
|
EnvironmentLength = (pcScan + sizeof(ANSI_NULL) - (PCHAR)lpEnvironment);
|
|
|
|
if (EnvironmentLength > MAXUSHORT)
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Create our ANSI String */
|
2018-02-15 21:34:48 +00:00
|
|
|
AnsiEnv.Length = (USHORT)EnvironmentLength;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
AnsiEnv.MaximumLength = AnsiEnv.Length + sizeof(ANSI_NULL);
|
|
|
|
|
|
|
|
/* Allocate memory for the Unicode Environment */
|
|
|
|
UnicodeEnv.Buffer = NULL;
|
|
|
|
RegionSize = AnsiEnv.MaximumLength * sizeof(WCHAR);
|
|
|
|
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID)&UnicodeEnv.Buffer,
|
|
|
|
0,
|
|
|
|
&RegionSize,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Fail */
|
|
|
|
BaseSetLastNTError(Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-03-16 01:14:58 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Use the allocated size and convert */
|
2013-09-14 10:20:11 +00:00
|
|
|
UnicodeEnv.MaximumLength = (USHORT)RegionSize;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Status = RtlAnsiStringToUnicodeString(&UnicodeEnv, &AnsiEnv, FALSE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Fail */
|
|
|
|
NtFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID)&UnicodeEnv.Buffer,
|
|
|
|
&RegionSize,
|
|
|
|
MEM_RELEASE);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Now set the Unicode environment as the environment string pointer */
|
|
|
|
lpEnvironment = UnicodeEnv.Buffer;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2000-03-16 01:14:58 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Make a copy of the caller's startup info since we'll modify it */
|
|
|
|
StartupInfo = *lpStartupInfo;
|
|
|
|
|
|
|
|
/* Check if private data is being sent on the same channel as std handles */
|
2011-07-20 15:54:21 +00:00
|
|
|
if ((StartupInfo.dwFlags & STARTF_USESTDHANDLES) &&
|
|
|
|
(StartupInfo.dwFlags & (STARTF_USEHOTKEY | STARTF_SHELLPRIVATE)))
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Cannot use the std handles since we have monitor/hotkey values */
|
2011-07-20 15:54:21 +00:00
|
|
|
StartupInfo.dwFlags &= ~STARTF_USESTDHANDLES;
|
|
|
|
}
|
1999-10-13 22:35:55 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If there's a debugger, or we have to launch cmd.exe, we go back here */
|
|
|
|
AppNameRetry:
|
|
|
|
/* New iteration -- free any existing name buffer */
|
|
|
|
if (NameBuffer)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
|
|
|
|
NameBuffer = NULL;
|
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* New iteration -- free any existing free buffer */
|
|
|
|
if (FreeBuffer)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FreeBuffer);
|
|
|
|
FreeBuffer = NULL;
|
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* New iteration -- close any existing file handle */
|
|
|
|
if (FileHandle)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
NtClose(FileHandle);
|
|
|
|
FileHandle = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2008-11-03 12:27:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set the initial parsing state. This code can loop -- don't move this! */
|
2013-08-05 18:33:52 +00:00
|
|
|
ErrorCode = 0;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
SearchRetry = TRUE;
|
|
|
|
QuotesNeeded = FALSE;
|
|
|
|
CmdLineIsAppName = FALSE;
|
|
|
|
|
|
|
|
/* First check if we don't have an application name */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!lpApplicationName)
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* This should be the first time we attempt creating one */
|
|
|
|
ASSERT(NameBuffer == NULL);
|
|
|
|
|
|
|
|
/* Allocate a buffer to hold it */
|
2011-07-20 15:54:21 +00:00
|
|
|
NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
|
|
|
MAX_PATH * sizeof(WCHAR));
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (!NameBuffer)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2008-11-03 12:27:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Initialize the application name and our parsing parameters */
|
2013-08-05 18:33:52 +00:00
|
|
|
lpApplicationName = NullBuffer = ScanString = lpCommandLine;
|
2008-11-03 12:27:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check for an initial quote*/
|
|
|
|
if (*lpCommandLine == L'\"')
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We found a quote, keep searching for another one */
|
|
|
|
SearchRetry = FALSE;
|
2013-08-05 18:33:52 +00:00
|
|
|
ScanString++;
|
|
|
|
lpApplicationName = ScanString;
|
|
|
|
while (*ScanString)
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Have we found the terminating quote? */
|
2013-08-05 18:33:52 +00:00
|
|
|
if (*ScanString == L'\"')
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* We're done, get out of here */
|
2013-08-05 18:33:52 +00:00
|
|
|
NullBuffer = ScanString;
|
|
|
|
HasQuotes = TRUE;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Keep searching for the quote */
|
2013-08-05 18:33:52 +00:00
|
|
|
ScanString++;
|
|
|
|
NullBuffer = ScanString;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
StartScan:
|
|
|
|
/* We simply make the application name be the command line*/
|
2011-07-20 15:54:21 +00:00
|
|
|
lpApplicationName = lpCommandLine;
|
2013-08-05 18:33:52 +00:00
|
|
|
while (*ScanString)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if it starts with a space or tab */
|
2013-08-05 18:33:52 +00:00
|
|
|
if ((*ScanString == L' ') || (*ScanString == L'\t'))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Break out of the search loop */
|
2013-08-05 18:33:52 +00:00
|
|
|
NullBuffer = ScanString;
|
2011-07-20 15:54:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Keep searching for a space or tab */
|
2013-08-05 18:33:52 +00:00
|
|
|
ScanString++;
|
|
|
|
NullBuffer = ScanString;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-29 06:59:11 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We have found the end of the application name, terminate it */
|
2013-08-05 18:33:52 +00:00
|
|
|
SaveChar = *NullBuffer;
|
|
|
|
*NullBuffer = UNICODE_NULL;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* New iteration -- free any existing saved path */
|
|
|
|
if (SearchPath)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, SearchPath);
|
|
|
|
SearchPath = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now compute the final EXE path based on the name */
|
|
|
|
SearchPath = BaseComputeProcessExePath((LPWSTR)lpApplicationName);
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("Search Path: %S\n", SearchPath);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (!SearchPath)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* And search for the executable in the search path */
|
|
|
|
Length = SearchPathW(SearchPath,
|
2011-07-20 15:54:21 +00:00
|
|
|
lpApplicationName,
|
|
|
|
L".exe",
|
|
|
|
MAX_PATH,
|
|
|
|
NameBuffer,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
NULL);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Did we find it? */
|
|
|
|
if ((Length) && (Length < MAX_PATH))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
|
|
|
/* Get file attributes */
|
2016-07-09 22:23:23 +00:00
|
|
|
FileAttribs = GetFileAttributesW(NameBuffer);
|
|
|
|
if ((FileAttribs != INVALID_FILE_ATTRIBUTES) &&
|
|
|
|
(FileAttribs & FILE_ATTRIBUTE_DIRECTORY))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* This was a directory, fail later on */
|
|
|
|
Length = 0;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2013-08-04 20:46:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* It's a file! */
|
|
|
|
Length++;
|
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
2000-09-05 13:53:27 +00:00
|
|
|
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("Length: %lu Buffer: %S\n", Length, NameBuffer);
|
2000-09-05 13:53:27 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if there was a failure in SearchPathW */
|
|
|
|
if ((Length) && (Length < MAX_PATH))
|
|
|
|
{
|
|
|
|
/* Everything looks good, restore the name */
|
2013-08-05 18:33:52 +00:00
|
|
|
*NullBuffer = SaveChar;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
lpApplicationName = NameBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check if this was a relative path, which would explain it */
|
|
|
|
PathType = RtlDetermineDosPathNameType_U(lpApplicationName);
|
|
|
|
if (PathType != RtlPathTypeRelative)
|
|
|
|
{
|
|
|
|
/* This should fail, and give us a detailed LastError */
|
|
|
|
FileHandle = CreateFileW(lpApplicationName,
|
|
|
|
GENERIC_READ,
|
|
|
|
FILE_SHARE_READ |
|
|
|
|
FILE_SHARE_WRITE,
|
|
|
|
NULL,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
NULL);
|
|
|
|
if (FileHandle != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
/* It worked? Return a generic error */
|
|
|
|
CloseHandle(FileHandle);
|
|
|
|
FileHandle = NULL;
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(STATUS_OBJECT_NAME_NOT_FOUND);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Path was absolute, which means it doesn't exist */
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(STATUS_OBJECT_NAME_NOT_FOUND);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Did we already fail once? */
|
2013-08-05 18:33:52 +00:00
|
|
|
if (ErrorCode)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set the error code */
|
2013-08-05 18:33:52 +00:00
|
|
|
SetLastError(ErrorCode);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Not yet, cache it */
|
2013-08-05 18:33:52 +00:00
|
|
|
ErrorCode = GetLastError();
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Put back the command line */
|
2013-08-05 18:33:52 +00:00
|
|
|
*NullBuffer = SaveChar;
|
2011-07-20 15:54:21 +00:00
|
|
|
lpApplicationName = NameBuffer;
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* It's possible there's whitespace in the directory name */
|
2013-08-05 18:33:52 +00:00
|
|
|
if (!(*ScanString) || !(SearchRetry))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Not the case, give up completely */
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There are spaces, so keep trying the next possibility */
|
2013-08-05 18:33:52 +00:00
|
|
|
ScanString++;
|
|
|
|
NullBuffer = ScanString;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* We will have to add a quote, since there is a space */
|
|
|
|
QuotesNeeded = TRUE;
|
2013-08-05 18:33:52 +00:00
|
|
|
HasQuotes = TRUE;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
goto StartScan;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!(lpCommandLine) || !(*lpCommandLine))
|
|
|
|
{
|
|
|
|
/* We don't have a command line, so just use the application name */
|
|
|
|
CmdLineIsAppName = TRUE;
|
|
|
|
lpCommandLine = (LPWSTR)lpApplicationName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the application name to its NT path */
|
|
|
|
TranslationStatus = RtlDosPathNameToRelativeNtPathName_U(lpApplicationName,
|
|
|
|
&PathName,
|
|
|
|
NULL,
|
|
|
|
&SxsWin32RelativePath);
|
|
|
|
if (!TranslationStatus)
|
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
/* Path must be invalid somehow, bail out */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
DPRINT1("Path translation for SxS failed\n");
|
|
|
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the buffer that needs to be freed at the end */
|
|
|
|
ASSERT(FreeBuffer == NULL);
|
|
|
|
FreeBuffer = PathName.Buffer;
|
|
|
|
|
|
|
|
/* Check what kind of path the application is, for SxS (Fusion) purposes */
|
|
|
|
RtlInitUnicodeString(&SxsWin32ExePath, lpApplicationName);
|
|
|
|
SxsPathType = RtlDetermineDosPathNameType_U(lpApplicationName);
|
|
|
|
if ((SxsPathType != RtlPathTypeDriveAbsolute) &&
|
|
|
|
(SxsPathType != RtlPathTypeLocalDevice) &&
|
|
|
|
(SxsPathType != RtlPathTypeRootLocalDevice) &&
|
|
|
|
(SxsPathType != RtlPathTypeUncAbsolute))
|
|
|
|
{
|
|
|
|
/* Relative-type path, get the full path */
|
|
|
|
RtlInitEmptyUnicodeString(&PathBufferString, NULL, 0);
|
|
|
|
Status = RtlGetFullPathName_UstrEx(&SxsWin32ExePath,
|
|
|
|
NULL,
|
|
|
|
&PathBufferString,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&SxsPathType,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail the rest of the create */
|
|
|
|
RtlReleaseRelativeName(&SxsWin32RelativePath);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use this full path as the SxS path */
|
|
|
|
SxsWin32ExePath = PathBufferString;
|
|
|
|
PathBuffer = PathBufferString.Buffer;
|
|
|
|
PathBufferString.Buffer = NULL;
|
2013-09-17 22:49:56 +00:00
|
|
|
DPRINT("SxS Path: %S\n", PathBuffer);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Also set the .EXE path based on the path name */
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
SxsNtExePath = PathName;
|
|
|
|
#endif
|
|
|
|
if (SxsWin32RelativePath.RelativeName.Length)
|
|
|
|
{
|
|
|
|
/* If it's relative, capture the relative name */
|
|
|
|
PathName = SxsWin32RelativePath.RelativeName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise, it's absolute, make sure no relative dir is used */
|
|
|
|
SxsWin32RelativePath.ContainingDirectory = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now use the path name, and the root path, to try opening the app */
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("Path: %wZ. Dir: %p\n", &PathName, SxsWin32RelativePath.ContainingDirectory);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
InitializeObjectAttributes(&LocalObjectAttributes,
|
|
|
|
&PathName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
SxsWin32RelativePath.ContainingDirectory,
|
|
|
|
NULL);
|
|
|
|
Status = NtOpenFile(&FileHandle,
|
|
|
|
SYNCHRONIZE |
|
|
|
|
FILE_READ_ATTRIBUTES |
|
|
|
|
FILE_READ_DATA |
|
|
|
|
FILE_EXECUTE,
|
|
|
|
&LocalObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_DELETE,
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT |
|
|
|
|
FILE_NON_DIRECTORY_FILE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Try to open the app just for execute purposes instead */
|
|
|
|
Status = NtOpenFile(&FileHandle,
|
|
|
|
SYNCHRONIZE | FILE_EXECUTE,
|
|
|
|
&LocalObjectAttributes,
|
|
|
|
&IoStatusBlock,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_DELETE,
|
|
|
|
FILE_SYNCHRONOUS_IO_NONALERT |
|
|
|
|
FILE_NON_DIRECTORY_FILE);
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
2016-12-23 11:43:21 +00:00
|
|
|
/* Failure path, display which file failed to open */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
DPRINT1("Open file failed: %lx (%wZ)\n", Status, &PathName);
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Cleanup in preparation for failure or success */
|
|
|
|
RtlReleaseRelativeName(&SxsWin32RelativePath);
|
2016-12-22 22:37:26 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failure path, try to understand why */
|
|
|
|
if (RtlIsDosDeviceName_U(lpApplicationName))
|
|
|
|
{
|
|
|
|
/* If a device is being executed, return this special error code */
|
|
|
|
SetLastError(ERROR_BAD_DEVICE);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise return the converted NT error code */
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Did the caller specify a desktop? */
|
|
|
|
if (!StartupInfo.lpDesktop)
|
|
|
|
{
|
|
|
|
/* Use the one from the current process */
|
|
|
|
StartupInfo.lpDesktop = Peb->ProcessParameters->DesktopInfo.Buffer;
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Create a section for this file */
|
|
|
|
Status = NtCreateSection(&SectionHandle,
|
|
|
|
SECTION_ALL_ACCESS,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
PAGE_EXECUTE,
|
|
|
|
SEC_IMAGE,
|
|
|
|
FileHandle);
|
2013-09-13 09:02:56 +00:00
|
|
|
DPRINT("Section status: %lx\n", Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Are we running on Windows Embedded, Datacenter, Blade or Starter? */
|
|
|
|
if (SharedUserData->SuiteMask & (VER_SUITE_EMBEDDEDNT |
|
|
|
|
VER_SUITE_DATACENTER |
|
|
|
|
VER_SUITE_PERSONAL |
|
|
|
|
VER_SUITE_BLADE))
|
|
|
|
{
|
|
|
|
/* These SKUs do not allow running certain applications */
|
|
|
|
Status = BasepCheckWebBladeHashes(FileHandle);
|
|
|
|
if (Status == STATUS_ACCESS_DENIED)
|
|
|
|
{
|
|
|
|
/* And this is one of them! */
|
|
|
|
DPRINT1("Invalid Blade hashes!\n");
|
|
|
|
SetLastError(ERROR_ACCESS_DISABLED_WEBBLADE);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Did we get some other failure? */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* If we couldn't check the hashes, assume nefariousness */
|
|
|
|
DPRINT1("Tampered Blade hashes!\n");
|
|
|
|
SetLastError(ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Now do Winsafer, etc, checks */
|
|
|
|
Status = BasepIsProcessAllowed((LPWSTR)lpApplicationName);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail if we're not allowed to launch the process */
|
|
|
|
DPRINT1("Process not allowed to launch: %lx\n", Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
if (SectionHandle)
|
|
|
|
{
|
|
|
|
NtClose(SectionHandle);
|
|
|
|
SectionHandle = NULL;
|
|
|
|
}
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is a DOS VDM being forced, but we already have a WOW32 instance ready? */
|
|
|
|
if ((dwCreationFlags & CREATE_FORCEDOS) &&
|
|
|
|
(BaseStaticServerData->IsWowTaskReady))
|
|
|
|
{
|
2013-08-06 10:40:36 +00:00
|
|
|
/* This request can't be satisfied, instead, a separate VDM is needed */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
dwCreationFlags &= ~(CREATE_FORCEDOS | CREATE_SHARED_WOW_VDM);
|
|
|
|
dwCreationFlags |= CREATE_SEPARATE_WOW_VDM;
|
|
|
|
|
|
|
|
/* Set a failure code, ask for VDM reservation */
|
|
|
|
Status = STATUS_INVALID_IMAGE_WIN_16;
|
|
|
|
UseVdmReserve = TRUE;
|
|
|
|
|
|
|
|
/* Close the current handle */
|
|
|
|
NtClose(SectionHandle);
|
|
|
|
SectionHandle = NULL;
|
|
|
|
|
|
|
|
/* Don't query the section later */
|
|
|
|
QuerySection = FALSE;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Did we already do these checks? */
|
|
|
|
if (!SkipSaferAndAppCompat)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Is everything OK so far, OR do we have an non-MZ, non-DOS app? */
|
|
|
|
if ((NT_SUCCESS(Status)) ||
|
|
|
|
((Status == STATUS_INVALID_IMAGE_NOT_MZ) &&
|
|
|
|
!(BaseIsDosApplication(&PathName, Status))))
|
|
|
|
{
|
|
|
|
/* Clear the machine type in case of failure */
|
|
|
|
ImageMachine = 0;
|
|
|
|
|
|
|
|
/* Clean any app compat data that may have accumulated */
|
|
|
|
BasepFreeAppCompatData(AppCompatData, AppCompatSxsData);
|
|
|
|
AppCompatData = NULL;
|
|
|
|
AppCompatSxsData = NULL;
|
|
|
|
|
|
|
|
/* Do we have a section? */
|
|
|
|
if (SectionHandle)
|
|
|
|
{
|
|
|
|
/* Have we already queried it? */
|
|
|
|
if (QuerySection)
|
|
|
|
{
|
|
|
|
/* Nothing to do */
|
2016-12-20 19:51:44 +00:00
|
|
|
AppCompatStatus = STATUS_SUCCESS;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get some information about the executable */
|
2016-12-20 19:51:44 +00:00
|
|
|
AppCompatStatus = NtQuerySection(SectionHandle,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
SectionImageInformation,
|
|
|
|
&ImageInformation,
|
|
|
|
sizeof(ImageInformation),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we have section information now? */
|
2016-12-20 19:51:44 +00:00
|
|
|
if (NT_SUCCESS(AppCompatStatus))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Don't ask for it again, save the machine type */
|
|
|
|
QuerySection = TRUE;
|
|
|
|
ImageMachine = ImageInformation.Machine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is there a reason/Shim we shouldn't run this application? */
|
2016-12-20 19:51:44 +00:00
|
|
|
AppCompatStatus = BasepCheckBadapp(FileHandle,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
FreeBuffer,
|
|
|
|
lpEnvironment,
|
|
|
|
ImageMachine,
|
|
|
|
&AppCompatData,
|
|
|
|
&AppCompatDataSize,
|
|
|
|
&AppCompatSxsData,
|
|
|
|
&AppCompatSxsDataSize,
|
|
|
|
&FusionFlags);
|
2016-12-20 19:51:44 +00:00
|
|
|
if (!NT_SUCCESS(AppCompatStatus))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* This is usually the status we get back */
|
2016-12-20 19:51:44 +00:00
|
|
|
DPRINT1("App compat launch failure: %lx\n", AppCompatStatus);
|
|
|
|
if (AppCompatStatus == STATUS_ACCESS_DENIED)
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Convert it to something more Win32-specific */
|
|
|
|
SetLastError(ERROR_CANCELLED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Some other error */
|
2016-12-20 19:51:44 +00:00
|
|
|
BaseSetLastNTError(AppCompatStatus);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we have a section? */
|
|
|
|
if (SectionHandle)
|
|
|
|
{
|
|
|
|
/* Clean it up */
|
|
|
|
NtClose(SectionHandle);
|
|
|
|
SectionHandle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fail the call */
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
}
|
2002-08-26 11:24:29 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
//ASSERT((dwFusionFlags & ~SXS_APPCOMPACT_FLAG_APP_RUNNING_SAFEMODE) == 0);
|
2000-04-25 23:22:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Have we already done, and do we need to do, SRP (WinSafer) checks? */
|
|
|
|
if (!(SkipSaferAndAppCompat) &&
|
|
|
|
~(dwCreationFlags & CREATE_PRESERVE_CODE_AUTHZ_LEVEL))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Assume yes */
|
|
|
|
SaferNeeded = TRUE;
|
2011-07-20 15:54:21 +00:00
|
|
|
switch (Status)
|
|
|
|
{
|
|
|
|
case STATUS_INVALID_IMAGE_NE_FORMAT:
|
|
|
|
case STATUS_INVALID_IMAGE_PROTECT:
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
case STATUS_INVALID_IMAGE_WIN_16:
|
|
|
|
case STATUS_FILE_IS_OFFLINE:
|
|
|
|
/* For all DOS, 16-bit, OS/2 images, we do*/
|
|
|
|
break;
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
case STATUS_INVALID_IMAGE_NOT_MZ:
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* For invalid files, we don't, unless it's a .BAT file */
|
|
|
|
if (BaseIsDosApplication(&PathName, Status)) break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Any other error codes we also don't */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SaferNeeded = FALSE;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* But for success, we do */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Okay, so what did the checks above result in? */
|
|
|
|
if (SaferNeeded)
|
|
|
|
{
|
|
|
|
/* We have to call into the WinSafer library and actually check */
|
2016-12-20 19:51:44 +00:00
|
|
|
SaferStatus = BasepCheckWinSaferRestrictions(hUserToken,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
(LPWSTR)lpApplicationName,
|
|
|
|
FileHandle,
|
|
|
|
&InJob,
|
|
|
|
&TokenHandle,
|
|
|
|
&JobHandle);
|
2016-12-20 19:51:44 +00:00
|
|
|
if (SaferStatus == 0xFFFFFFFF)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Back in 2003, they didn't have an NTSTATUS for this... */
|
|
|
|
DPRINT1("WinSafer blocking process launch\n");
|
|
|
|
SetLastError(ERROR_ACCESS_DISABLED_BY_POLICY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2000-04-25 23:22:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Other status codes are not-Safer related, just convert them */
|
2016-12-20 19:51:44 +00:00
|
|
|
if (!NT_SUCCESS(SaferStatus))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2016-12-20 19:51:44 +00:00
|
|
|
DPRINT1("Error checking WinSafer: %lx\n", SaferStatus);
|
|
|
|
BaseSetLastNTError(SaferStatus);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The last step is to figure out why the section object was not created */
|
|
|
|
switch (Status)
|
|
|
|
{
|
|
|
|
case STATUS_INVALID_IMAGE_WIN_16:
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* 16-bit binary. Should we use WOW or does the caller force VDM? */
|
|
|
|
if (!(dwCreationFlags & CREATE_FORCEDOS))
|
|
|
|
{
|
|
|
|
/* Remember that we're launching WOW */
|
|
|
|
IsWowApp = TRUE;
|
|
|
|
|
|
|
|
/* Create the VDM environment, it's valid for WOW too */
|
|
|
|
Result = BaseCreateVDMEnvironment(lpEnvironment,
|
|
|
|
&VdmAnsiEnv,
|
|
|
|
&VdmUnicodeEnv);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
DPRINT1("VDM environment for WOW app failed\n");
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We're going to try this twice, so do a loop */
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
/* Pick which kind of WOW mode we want to run in */
|
|
|
|
VdmBinaryType = (dwCreationFlags &
|
|
|
|
CREATE_SEPARATE_WOW_VDM) ?
|
2014-02-01 22:24:46 +00:00
|
|
|
BINARY_TYPE_SEPARATE_WOW : BINARY_TYPE_WOW;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Get all the VDM settings and current status */
|
|
|
|
Status = BaseCheckVDM(VdmBinaryType,
|
|
|
|
lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
lpCurrentDirectory,
|
|
|
|
&VdmAnsiEnv,
|
2014-03-08 01:17:45 +00:00
|
|
|
&CsrMsg[1],
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
&VdmTask,
|
|
|
|
dwCreationFlags,
|
|
|
|
&StartupInfo,
|
|
|
|
hUserToken);
|
|
|
|
|
|
|
|
/* If it worked, no need to try again */
|
|
|
|
if (NT_SUCCESS(Status)) break;
|
|
|
|
|
|
|
|
/* Check if it's disallowed or if it's our second time */
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
if ((Status == STATUS_VDM_DISALLOWED) ||
|
|
|
|
(VdmBinaryType == BINARY_TYPE_SEPARATE_WOW) ||
|
|
|
|
(GetLastError() == ERROR_ACCESS_DENIED))
|
|
|
|
{
|
|
|
|
/* Fail the call -- we won't try again */
|
|
|
|
DPRINT1("VDM message failure for WOW: %lx\n", Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Try one more time, but with a separate WOW instance */
|
|
|
|
dwCreationFlags |= CREATE_SEPARATE_WOW_VDM;
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check which VDM state we're currently in */
|
2014-02-02 00:25:25 +00:00
|
|
|
switch (CheckVdmMsg->VDMState & (VDM_NOT_LOADED |
|
|
|
|
VDM_NOT_READY |
|
|
|
|
VDM_READY))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
case VDM_NOT_LOADED:
|
|
|
|
/* VDM is not fully loaded, so not that much to undo */
|
|
|
|
VdmUndoLevel = VDM_UNDO_PARTIAL;
|
|
|
|
|
|
|
|
/* Reset VDM reserve if needed */
|
|
|
|
if (UseVdmReserve) VdmReserve = 1;
|
|
|
|
|
|
|
|
/* Get the required parameters and names for launch */
|
|
|
|
Result = BaseGetVdmConfigInfo(lpCommandLine,
|
|
|
|
VdmTask,
|
|
|
|
VdmBinaryType,
|
|
|
|
&VdmString,
|
|
|
|
&VdmReserve);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
DPRINT1("VDM Configuration failed for WOW\n");
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the command-line with the VDM one instead */
|
|
|
|
lpCommandLine = VdmString.Buffer;
|
|
|
|
lpApplicationName = NULL;
|
|
|
|
|
|
|
|
/* We don't want a console, detachment, nor a window */
|
|
|
|
dwCreationFlags |= CREATE_NO_WINDOW;
|
|
|
|
dwCreationFlags &= ~(CREATE_NEW_CONSOLE | DETACHED_PROCESS);
|
|
|
|
|
|
|
|
/* Force feedback on */
|
|
|
|
StartupInfo.dwFlags |= STARTF_FORCEONFEEDBACK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case VDM_READY:
|
|
|
|
/* VDM is ready, so we have to undo everything */
|
|
|
|
VdmUndoLevel = VDM_UNDO_REUSE;
|
|
|
|
|
|
|
|
/* Check if CSRSS wants us to wait on VDM */
|
2014-02-02 00:25:25 +00:00
|
|
|
VdmWaitObject = CheckVdmMsg->WaitObjectForParent;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VDM_NOT_READY:
|
|
|
|
/* Something is wrong with VDM, we'll fail the call */
|
|
|
|
DPRINT1("VDM is not ready for WOW\n");
|
|
|
|
SetLastError(ERROR_NOT_READY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Since to get NULL, we allocate from 0x1, account for this */
|
|
|
|
VdmReserve--;
|
|
|
|
|
|
|
|
/* This implies VDM is ready, so skip everything else */
|
|
|
|
if (VdmWaitObject) goto VdmShortCircuit;
|
|
|
|
|
|
|
|
/* Don't inherit handles since we're doing VDM now */
|
|
|
|
bInheritHandles = FALSE;
|
|
|
|
|
|
|
|
/* Had the user passed in environment? If so, destroy it */
|
|
|
|
if ((lpEnvironment) &&
|
|
|
|
!(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
|
|
|
|
{
|
|
|
|
RtlDestroyEnvironment(lpEnvironment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We've already done all these checks, don't do them again */
|
|
|
|
SkipSaferAndAppCompat = TRUE;
|
|
|
|
goto AppNameRetry;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
// There is no break here on purpose, so FORCEDOS drops down!
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
case STATUS_INVALID_IMAGE_PROTECT:
|
|
|
|
case STATUS_INVALID_IMAGE_NOT_MZ:
|
|
|
|
case STATUS_INVALID_IMAGE_NE_FORMAT:
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We're launching an executable application */
|
|
|
|
BinarySubType = BINARY_TYPE_EXE;
|
|
|
|
|
|
|
|
/* We can drop here from other "cases" above too, so check */
|
|
|
|
if ((Status == STATUS_INVALID_IMAGE_PROTECT) ||
|
|
|
|
(Status == STATUS_INVALID_IMAGE_NE_FORMAT) ||
|
|
|
|
(BinarySubType = BaseIsDosApplication(&PathName, Status)))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We're launching a DOS application */
|
|
|
|
VdmBinaryType = BINARY_TYPE_DOS;
|
|
|
|
|
|
|
|
/* Based on the caller environment, create a VDM one */
|
|
|
|
Result = BaseCreateVDMEnvironment(lpEnvironment,
|
|
|
|
&VdmAnsiEnv,
|
|
|
|
&VdmUnicodeEnv);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
DPRINT1("VDM environment for DOS failed\n");
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the current state of the VDM subsystem */
|
|
|
|
Status = BaseCheckVDM(VdmBinaryType | BinarySubType,
|
|
|
|
lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
lpCurrentDirectory,
|
|
|
|
&VdmAnsiEnv,
|
2014-03-08 01:17:45 +00:00
|
|
|
&CsrMsg[1],
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
&VdmTask,
|
|
|
|
dwCreationFlags,
|
|
|
|
&StartupInfo,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failed to inquire about VDM, fail the call */
|
|
|
|
DPRINT1("VDM message failure for DOS: %lx\n", Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Handle possible VDM states */
|
2014-02-02 00:25:25 +00:00
|
|
|
switch (CheckVdmMsg->VDMState & (VDM_NOT_LOADED |
|
|
|
|
VDM_NOT_READY |
|
|
|
|
VDM_READY))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
case VDM_NOT_LOADED:
|
|
|
|
/* If VDM is not loaded, we'll do a partial undo */
|
|
|
|
VdmUndoLevel = VDM_UNDO_PARTIAL;
|
|
|
|
|
|
|
|
/* A VDM process can't also be detached, so fail */
|
|
|
|
if (dwCreationFlags & DETACHED_PROCESS)
|
|
|
|
{
|
|
|
|
DPRINT1("Detached process but no VDM, not allowed\n");
|
|
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the required parameters and names for launch */
|
|
|
|
Result = BaseGetVdmConfigInfo(lpCommandLine,
|
|
|
|
VdmTask,
|
|
|
|
VdmBinaryType,
|
|
|
|
&VdmString,
|
|
|
|
&VdmReserve);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
DPRINT1("VDM Configuration failed for DOS\n");
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the command-line to launch VDM instead */
|
|
|
|
lpCommandLine = VdmString.Buffer;
|
|
|
|
lpApplicationName = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VDM_READY:
|
|
|
|
/* VDM is ready, so we have to undo everything */
|
|
|
|
VdmUndoLevel = VDM_UNDO_REUSE;
|
|
|
|
|
|
|
|
/* Check if CSRSS wants us to wait on VDM */
|
2014-02-02 00:25:25 +00:00
|
|
|
VdmWaitObject = CheckVdmMsg->WaitObjectForParent;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VDM_NOT_READY:
|
|
|
|
/* Something is wrong with VDM, we'll fail the call */
|
|
|
|
DPRINT1("VDM is not ready for DOS\n");
|
|
|
|
SetLastError(ERROR_NOT_READY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Since to get NULL, we allocate from 0x1, account for this */
|
|
|
|
VdmReserve--;
|
|
|
|
|
|
|
|
/* This implies VDM is ready, so skip everything else */
|
|
|
|
if (VdmWaitObject) goto VdmShortCircuit;
|
|
|
|
|
|
|
|
/* Don't inherit handles since we're doing VDM now */
|
|
|
|
bInheritHandles = FALSE;
|
|
|
|
|
|
|
|
/* Had the user passed in environment? If so, destroy it */
|
|
|
|
if ((lpEnvironment) &&
|
|
|
|
!(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
|
|
|
|
{
|
|
|
|
RtlDestroyEnvironment(lpEnvironment);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use our VDM Unicode environment instead */
|
|
|
|
lpEnvironment = VdmUnicodeEnv.Buffer;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* It's a batch file, get the extension */
|
|
|
|
ExtBuffer = &PathName.Buffer[PathName.Length / sizeof(WCHAR) - 4];
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Make sure the extensions are correct */
|
|
|
|
if ((PathName.Length < (4 * sizeof(WCHAR))) ||
|
|
|
|
((_wcsnicmp(ExtBuffer, L".bat", 4)) &&
|
|
|
|
(_wcsnicmp(ExtBuffer, L".cmd", 4))))
|
|
|
|
{
|
2013-09-21 13:00:48 +00:00
|
|
|
DPRINT1("'%wZ': Invalid EXE, and not a batch or script file\n", &PathName);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
SetLastError(ERROR_BAD_EXE_FORMAT);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if we need to account for quotes around the path */
|
2013-08-05 18:33:52 +00:00
|
|
|
CmdQuoteLength = CmdLineIsAppName || HasQuotes;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (!CmdLineIsAppName)
|
|
|
|
{
|
2013-08-05 18:33:52 +00:00
|
|
|
if (HasQuotes) CmdQuoteLength++;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CmdQuoteLength++;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Calculate the length of the command line */
|
|
|
|
CmdLineLength = wcslen(lpCommandLine);
|
|
|
|
CmdLineLength += wcslen(CMD_STRING);
|
|
|
|
CmdLineLength += CmdQuoteLength + sizeof(ANSI_NULL);
|
|
|
|
CmdLineLength *= sizeof(WCHAR);
|
|
|
|
|
|
|
|
/* Allocate space for the new command line */
|
|
|
|
AnsiCmdCommand = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
|
|
|
CmdLineLength);
|
|
|
|
if (!AnsiCmdCommand)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Build it */
|
|
|
|
wcscpy(AnsiCmdCommand, CMD_STRING);
|
2013-08-05 18:33:52 +00:00
|
|
|
if ((CmdLineIsAppName) || (HasQuotes))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
wcscat(AnsiCmdCommand, L"\"");
|
|
|
|
}
|
|
|
|
wcscat(AnsiCmdCommand, lpCommandLine);
|
2013-08-05 18:33:52 +00:00
|
|
|
if ((CmdLineIsAppName) || (HasQuotes))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
wcscat(AnsiCmdCommand, L"\"");
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Create it as a Unicode String */
|
|
|
|
RtlInitUnicodeString(&DebuggerString, AnsiCmdCommand);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set the command line to this */
|
|
|
|
lpCommandLine = DebuggerString.Buffer;
|
|
|
|
lpApplicationName = NULL;
|
|
|
|
DPRINT1("Retrying with: %S\n", lpCommandLine);
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We've already done all these checks, don't do them again */
|
|
|
|
SkipSaferAndAppCompat = TRUE;
|
|
|
|
goto AppNameRetry;
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
case STATUS_INVALID_IMAGE_WIN_64:
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* 64-bit binaries are not allowed to run on 32-bit ReactOS */
|
|
|
|
DPRINT1("64-bit binary, failing\n");
|
|
|
|
SetLastError(ERROR_EXE_MACHINE_TYPE_MISMATCH);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
case STATUS_FILE_IS_OFFLINE:
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set the correct last error for this */
|
|
|
|
DPRINT1("File is offline, failing\n");
|
|
|
|
SetLastError(ERROR_FILE_OFFLINE);
|
|
|
|
break;
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
default:
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Any other error, convert it to a generic Win32 error */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Failed to create section: %lx\n", Status);
|
2011-07-20 15:54:21 +00:00
|
|
|
SetLastError(ERROR_BAD_EXE_FORMAT);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, this must be success */
|
|
|
|
ASSERT(Status == STATUS_SUCCESS);
|
|
|
|
break;
|
[KERNEL32]
- Add brackets around "case XXX:" so that I'm able to (un)fold regions of code when debugging and reading.
- Temporarily skip AppCompat functionality added by Alex, in order to "fix" (read: hack-fix) launch of .bat/.cmd files. Indeed, when .bat/.cmd files get started with the CreateProcess function, a call to NtCreateSection fails with status STATUS_INVALID_IMAGE_NOT_MZ, as expected (line 2952). But the new AppCompat code (lines 3028 and 3031-3033 and following, and 3114), executed whenever the status code from NtCreateSection is STATUS_SUCCESS or STATUS_INVALID_IMAGE_NOT_MZ or something else, overwrites the status code by other values, so that, after we return to the main code path (lines 3174 and following), the status code isn't STATUS_INVALID_IMAGE_NOT_MZ anymore but STATUS_SUCCESS or whatever, and then, we fail to run the .bat/.cmd file (that should be done at lines 3314-3316 and following).
To Alex_Ionescu: Have a look at this and fix it properly!!
svn path=/trunk/; revision=59855
2013-08-28 13:23:09 +00:00
|
|
|
}
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Is this not a WOW application, but a WOW32 VDM was requested for it? */
|
|
|
|
if (!(IsWowApp) && (dwCreationFlags & CREATE_SEPARATE_WOW_VDM))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Ignore the nonsensical request */
|
|
|
|
dwCreationFlags &= ~CREATE_SEPARATE_WOW_VDM;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-09-19 14:36:47 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Did we already check information for the section? */
|
|
|
|
if (!QuerySection)
|
|
|
|
{
|
|
|
|
/* Get some information about the executable */
|
|
|
|
Status = NtQuerySection(SectionHandle,
|
|
|
|
SectionImageInformation,
|
|
|
|
&ImageInformation,
|
|
|
|
sizeof(ImageInformation),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* We failed, bail out */
|
|
|
|
DPRINT1("Section query failed\n");
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Don't check this later */
|
|
|
|
QuerySection = TRUE;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if this was linked as a DLL */
|
|
|
|
if (ImageInformation.ImageCharacteristics & IMAGE_FILE_DLL)
|
2010-01-09 20:51:33 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* These aren't valid images to try to execute! */
|
|
|
|
DPRINT1("Trying to launch a DLL, failing\n");
|
|
|
|
SetLastError(ERROR_BAD_EXE_FORMAT);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2010-01-09 20:51:33 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2016-12-20 19:51:44 +00:00
|
|
|
/* Don't let callers pass in this flag -- we'll only get it from IFEO */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Flags &= ~PROCESS_CREATE_FLAGS_LARGE_PAGES;
|
|
|
|
|
|
|
|
/* Clear the IFEO-missing flag, before we know for sure... */
|
|
|
|
ParameterFlags &= ~2;
|
|
|
|
|
|
|
|
/* If the process is being debugged, only read IFEO if the PEB says so */
|
|
|
|
if (!(dwCreationFlags & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS)) ||
|
|
|
|
(NtCurrentPeb()->ReadImageFileExecOptions))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Let's do this! Attempt to open IFEO */
|
2016-12-20 19:51:44 +00:00
|
|
|
IFEOStatus = LdrOpenImageFileOptionsKey(&PathName, 0, &KeyHandle);
|
|
|
|
if (!NT_SUCCESS(IFEOStatus))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* We failed, set the flag so we store this in the parameters */
|
2016-12-20 19:51:44 +00:00
|
|
|
if (IFEOStatus == STATUS_OBJECT_NAME_NOT_FOUND) ParameterFlags |= 2;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Was this our first time going through this path? */
|
|
|
|
if (!DebuggerCmdLine)
|
|
|
|
{
|
|
|
|
/* Allocate a buffer for the debugger path */
|
|
|
|
DebuggerCmdLine = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
|
|
|
MAX_PATH * sizeof(WCHAR));
|
|
|
|
if (!DebuggerCmdLine)
|
|
|
|
{
|
|
|
|
/* Close IFEO on failure */
|
2016-12-20 19:51:44 +00:00
|
|
|
IFEOStatus = NtClose(KeyHandle);
|
|
|
|
ASSERT(NT_SUCCESS(IFEOStatus));
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Fail the call */
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now query for the debugger */
|
2016-12-20 19:51:44 +00:00
|
|
|
IFEOStatus = LdrQueryImageFileKeyOption(KeyHandle,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
L"Debugger",
|
|
|
|
REG_SZ,
|
|
|
|
DebuggerCmdLine,
|
|
|
|
MAX_PATH * sizeof(WCHAR),
|
|
|
|
&ResultSize);
|
2016-12-20 19:51:44 +00:00
|
|
|
if (!(NT_SUCCESS(IFEOStatus)) ||
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
(ResultSize < sizeof(WCHAR)) ||
|
|
|
|
(DebuggerCmdLine[0] == UNICODE_NULL))
|
|
|
|
{
|
|
|
|
/* If it's not there, or too small, or invalid, ignore it */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DebuggerCmdLine);
|
|
|
|
DebuggerCmdLine = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Also query if we should map with large pages */
|
2016-12-20 19:51:44 +00:00
|
|
|
IFEOStatus = LdrQueryImageFileKeyOption(KeyHandle,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
L"UseLargePages",
|
|
|
|
REG_DWORD,
|
|
|
|
&UseLargePages,
|
|
|
|
sizeof(UseLargePages),
|
|
|
|
NULL);
|
2016-12-20 19:51:44 +00:00
|
|
|
if ((NT_SUCCESS(IFEOStatus)) && (UseLargePages))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Do it! This is the only way this flag can be set */
|
|
|
|
Flags |= PROCESS_CREATE_FLAGS_LARGE_PAGES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're done with IFEO, can close it now */
|
2016-12-20 19:51:44 +00:00
|
|
|
IFEOStatus = NtClose(KeyHandle);
|
|
|
|
ASSERT(NT_SUCCESS(IFEOStatus));
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2000-04-25 23:22:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Make sure the image was compiled for this processor */
|
|
|
|
if ((ImageInformation.Machine < SharedUserData->ImageNumberLow) ||
|
|
|
|
(ImageInformation.Machine > SharedUserData->ImageNumberHigh))
|
|
|
|
{
|
|
|
|
/* It was not -- raise a hard error */
|
|
|
|
ErrorResponse = ResponseOk;
|
|
|
|
ErrorParameters[0] = (ULONG_PTR)&PathName;
|
|
|
|
NtRaiseHardError(STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
ErrorParameters,
|
|
|
|
OptionOk,
|
|
|
|
&ErrorResponse);
|
|
|
|
if (Peb->ImageSubsystemMajorVersion <= 3)
|
|
|
|
{
|
|
|
|
/* If it's really old, return this error */
|
|
|
|
SetLastError(ERROR_BAD_EXE_FORMAT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise, return a more modern error */
|
|
|
|
SetLastError(ERROR_EXE_MACHINE_TYPE_MISMATCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Go to the failure path */
|
|
|
|
DPRINT1("Invalid image architecture: %lx\n", ImageInformation.Machine);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if this isn't a Windows image */
|
|
|
|
if ((ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_WINDOWS_GUI) &&
|
|
|
|
(ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_WINDOWS_CUI))
|
|
|
|
{
|
|
|
|
/* Get rid of section-related information since we'll retry */
|
|
|
|
NtClose(SectionHandle);
|
|
|
|
SectionHandle = NULL;
|
|
|
|
QuerySection = FALSE;
|
|
|
|
|
|
|
|
/* The only other non-Windows image type we support here is POSIX */
|
|
|
|
if (ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_POSIX_CUI)
|
|
|
|
{
|
|
|
|
/* Bail out if it's something else */
|
|
|
|
SetLastError(ERROR_CHILD_NOT_COMPLETE);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now build the command-line to have posix launch this image */
|
|
|
|
Result = BuildSubSysCommandLine(L"POSIX /P ",
|
|
|
|
lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
&DebuggerString);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
/* Bail out if that failed */
|
|
|
|
DPRINT1("Subsystem command line failed\n");
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And re-try launching the process, with the new command-line now */
|
|
|
|
lpCommandLine = DebuggerString.Buffer;
|
|
|
|
lpApplicationName = NULL;
|
2000-04-25 23:22:57 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We've already done all these checks, don't do them again */
|
|
|
|
SkipSaferAndAppCompat = TRUE;
|
|
|
|
DPRINT1("Retrying with: %S\n", lpCommandLine);
|
|
|
|
goto AppNameRetry;
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Was this image built for a version of Windows whose images we can run? */
|
|
|
|
Result = BasepIsImageVersionOk(ImageInformation.SubSystemMajorVersion,
|
|
|
|
ImageInformation.SubSystemMinorVersion);
|
|
|
|
if (!Result)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* It was not, bail out */
|
2013-08-29 20:37:02 +00:00
|
|
|
DPRINT1("Invalid subsystem version: %hu.%hu\n",
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
ImageInformation.SubSystemMajorVersion,
|
|
|
|
ImageInformation.SubSystemMinorVersion);
|
|
|
|
SetLastError(ERROR_BAD_EXE_FORMAT);
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if there is a debugger associated with the application */
|
|
|
|
if (DebuggerCmdLine)
|
2002-08-26 11:24:29 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Get the length of the command line */
|
|
|
|
n = wcslen(lpCommandLine);
|
|
|
|
if (!n)
|
|
|
|
{
|
|
|
|
/* There's no command line, use the application name instead */
|
|
|
|
lpCommandLine = (LPWSTR)lpApplicationName;
|
|
|
|
n = wcslen(lpCommandLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Protect against overflow */
|
|
|
|
if (n > UNICODE_STRING_MAX_CHARS)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NAME_TOO_LONG);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now add the length of the debugger command-line */
|
|
|
|
n += wcslen(DebuggerCmdLine);
|
|
|
|
|
|
|
|
/* Again make sure we don't overflow */
|
|
|
|
if (n > UNICODE_STRING_MAX_CHARS)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NAME_TOO_LONG);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Account for the quotes and space between the two */
|
2013-11-26 15:09:21 +00:00
|
|
|
n += sizeof("\" \"") - sizeof(ANSI_NULL);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Convert to bytes, and make sure we don't overflow */
|
|
|
|
n *= sizeof(WCHAR);
|
|
|
|
if (n > UNICODE_STRING_MAX_BYTES)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NAME_TOO_LONG);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate space for the string */
|
|
|
|
DebuggerString.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, n);
|
|
|
|
if (!DebuggerString.Buffer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the length */
|
|
|
|
RtlInitEmptyUnicodeString(&DebuggerString,
|
|
|
|
DebuggerString.Buffer,
|
2013-09-14 10:20:11 +00:00
|
|
|
(USHORT)n);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
/* Now perform the command line creation */
|
|
|
|
ImageDbgStatus = RtlAppendUnicodeToString(&DebuggerString,
|
|
|
|
DebuggerCmdLine);
|
|
|
|
ASSERT(NT_SUCCESS(ImageDbgStatus));
|
|
|
|
ImageDbgStatus = RtlAppendUnicodeToString(&DebuggerString, L" ");
|
|
|
|
ASSERT(NT_SUCCESS(ImageDbgStatus));
|
|
|
|
ImageDbgStatus = RtlAppendUnicodeToString(&DebuggerString, lpCommandLine);
|
|
|
|
ASSERT(NT_SUCCESS(ImageDbgStatus));
|
|
|
|
|
|
|
|
/* Make sure it all looks nice */
|
|
|
|
DbgPrint("BASE: Calling debugger with '%wZ'\n", &DebuggerString);
|
|
|
|
|
|
|
|
/* Update the command line and application name */
|
|
|
|
lpCommandLine = DebuggerString.Buffer;
|
|
|
|
lpApplicationName = NULL;
|
|
|
|
|
|
|
|
/* Close all temporary state */
|
|
|
|
NtClose(SectionHandle);
|
|
|
|
SectionHandle = NULL;
|
|
|
|
QuerySection = FALSE;
|
|
|
|
|
|
|
|
/* Free all temporary memory */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
|
|
|
|
NameBuffer = NULL;
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FreeBuffer);
|
|
|
|
FreeBuffer = NULL;
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DebuggerCmdLine);
|
|
|
|
DebuggerCmdLine = NULL;
|
|
|
|
DPRINT1("Retrying with: %S\n", lpCommandLine);
|
|
|
|
goto AppNameRetry;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the process object attributes */
|
2011-11-03 00:30:44 +00:00
|
|
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
lpProcessAttributes,
|
|
|
|
NULL);
|
|
|
|
if ((hUserToken) && (lpProcessAttributes))
|
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
/* Augment them with information from the user */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
|
|
|
|
LocalProcessAttributes = *lpProcessAttributes;
|
|
|
|
LocalProcessAttributes.lpSecurityDescriptor = NULL;
|
|
|
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
|
|
|
&LocalProcessAttributes,
|
|
|
|
NULL);
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Check if we're going to be debugged */
|
|
|
|
if (dwCreationFlags & DEBUG_PROCESS)
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set process flag */
|
|
|
|
Flags |= PROCESS_CREATE_FLAGS_BREAKAWAY;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we're going to be debugged */
|
|
|
|
if (dwCreationFlags & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS))
|
|
|
|
{
|
|
|
|
/* Connect to DbgUi */
|
|
|
|
Status = DbgUiConnectToDbg();
|
|
|
|
if (!NT_SUCCESS(Status))
|
2009-04-13 11:58:39 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
DPRINT1("Failed to connect to DbgUI!\n");
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Get the debug object */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
DebugHandle = DbgUiGetThreadDebugObject();
|
2011-07-20 15:54:21 +00:00
|
|
|
|
|
|
|
/* Check if only this process will be debugged */
|
|
|
|
if (dwCreationFlags & DEBUG_ONLY_THIS_PROCESS)
|
|
|
|
{
|
2012-02-20 06:36:17 +00:00
|
|
|
/* Set process flag */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Flags |= PROCESS_CREATE_FLAGS_NO_DEBUG_INHERIT;
|
2009-04-13 11:58:39 +00:00
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set inherit flag */
|
|
|
|
if (bInheritHandles) Flags |= PROCESS_CREATE_FLAGS_INHERIT_HANDLES;
|
|
|
|
|
|
|
|
/* Check if the process should be created with large pages */
|
|
|
|
HavePrivilege = FALSE;
|
|
|
|
PrivilegeState = NULL;
|
|
|
|
if (Flags & PROCESS_CREATE_FLAGS_LARGE_PAGES)
|
|
|
|
{
|
|
|
|
/* Acquire the required privilege so that the kernel won't fail the call */
|
|
|
|
PrivilegeValue = SE_LOCK_MEMORY_PRIVILEGE;
|
2014-03-22 18:46:26 +00:00
|
|
|
Status = RtlAcquirePrivilege(&PrivilegeValue, 1, 0, &PrivilegeState);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Remember to release it later */
|
|
|
|
HavePrivilege = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the current TIB value since kernel overwrites it to store PEB */
|
|
|
|
TibValue = Teb->NtTib.ArbitraryUserPointer;
|
|
|
|
|
|
|
|
/* Tell the kernel to create the process */
|
|
|
|
Status = NtCreateProcessEx(&ProcessHandle,
|
|
|
|
PROCESS_ALL_ACCESS,
|
|
|
|
ObjectAttributes,
|
|
|
|
NtCurrentProcess(),
|
|
|
|
Flags,
|
|
|
|
SectionHandle,
|
|
|
|
DebugHandle,
|
|
|
|
NULL,
|
|
|
|
InJob);
|
|
|
|
|
|
|
|
/* Load the PEB address from the hacky location where the kernel stores it */
|
|
|
|
RemotePeb = Teb->NtTib.ArbitraryUserPointer;
|
|
|
|
|
|
|
|
/* And restore the old TIB value */
|
|
|
|
Teb->NtTib.ArbitraryUserPointer = TibValue;
|
|
|
|
|
|
|
|
/* Release the large page privilege if we had acquired it */
|
|
|
|
if (HavePrivilege) RtlReleasePrivilege(PrivilegeState);
|
|
|
|
|
|
|
|
/* And now check if the kernel failed to create the process */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Go to failure path */
|
|
|
|
DPRINT1("Failed to create process: %lx\n", Status);
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if there is a priority class to set */
|
|
|
|
if (PriorityClass.PriorityClass)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Reset current privilege state */
|
|
|
|
RealTimePrivilegeState = NULL;
|
|
|
|
|
|
|
|
/* Is realtime priority being requested? */
|
2013-11-26 15:09:21 +00:00
|
|
|
if (PriorityClass.PriorityClass == PROCESS_PRIORITY_CLASS_REALTIME)
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Check if the caller has real-time access, and enable it if so */
|
|
|
|
RealTimePrivilegeState = BasepIsRealtimeAllowed(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the new priority class and release the privilege */
|
|
|
|
Status = NtSetInformationProcess(ProcessHandle,
|
2011-07-20 15:54:21 +00:00
|
|
|
ProcessPriorityClass,
|
|
|
|
&PriorityClass,
|
|
|
|
sizeof(PROCESS_PRIORITY_CLASS));
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (RealTimePrivilegeState) RtlReleasePrivilege(RealTimePrivilegeState);
|
|
|
|
|
|
|
|
/* Check if we failed to set the priority class */
|
|
|
|
if (!NT_SUCCESS(Status))
|
2009-04-13 11:58:39 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Bail out on failure */
|
|
|
|
DPRINT1("Failed to set priority class: %lx\n", Status);
|
2011-07-23 18:54:29 +00:00
|
|
|
BaseSetLastNTError(Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if the caller wants the default error mode */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (dwCreationFlags & CREATE_DEFAULT_ERROR_MODE)
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Set Error Mode to only fail on critical errors */
|
|
|
|
HardErrorMode = SEM_FAILCRITICALERRORS;
|
|
|
|
NtSetInformationProcess(ProcessHandle,
|
2011-07-20 15:54:21 +00:00
|
|
|
ProcessDefaultHardErrorMode,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
&HardErrorMode,
|
2011-07-20 15:54:21 +00:00
|
|
|
sizeof(ULONG));
|
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if this was a VDM binary */
|
|
|
|
if (VdmBinaryType)
|
|
|
|
{
|
|
|
|
/* Update VDM by telling it the process has now been created */
|
|
|
|
VdmWaitObject = ProcessHandle;
|
|
|
|
Result = BaseUpdateVDMEntry(VdmEntryUpdateProcess,
|
|
|
|
&VdmWaitObject,
|
|
|
|
VdmTask,
|
|
|
|
VdmBinaryType);
|
2014-03-07 17:42:56 +00:00
|
|
|
|
|
|
|
if (!Result)
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Bail out on failure */
|
|
|
|
DPRINT1("Failed to update VDM with wait object\n");
|
|
|
|
VdmWaitObject = NULL;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point, a failure means VDM has to undo all the state */
|
|
|
|
VdmUndoLevel |= VDM_UNDO_FULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if VDM needed reserved low-memory */
|
|
|
|
if (VdmReserve)
|
|
|
|
{
|
|
|
|
/* Reserve the requested allocation */
|
2018-02-15 21:34:48 +00:00
|
|
|
RegionSize = VdmReserve;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
|
|
|
&BaseAddress,
|
|
|
|
0,
|
2018-02-15 21:34:48 +00:00
|
|
|
&RegionSize,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
MEM_RESERVE,
|
|
|
|
PAGE_EXECUTE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bail out on failure */
|
2014-11-22 23:13:41 +00:00
|
|
|
DPRINT1("Failed to reserve memory for VDM: %lx\n", Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
2018-02-15 21:34:48 +00:00
|
|
|
|
|
|
|
VdmReserve = (ULONG)RegionSize;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we've already queried information on the section */
|
|
|
|
if (!QuerySection)
|
|
|
|
{
|
|
|
|
/* We haven't, so get some information about the executable */
|
|
|
|
Status = NtQuerySection(SectionHandle,
|
|
|
|
SectionImageInformation,
|
|
|
|
&ImageInformation,
|
|
|
|
sizeof(ImageInformation),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bail out on failure */
|
|
|
|
DPRINT1("Failed to query section: %lx\n", Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we encounter a restart, don't re-query this information again */
|
|
|
|
QuerySection = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we need to apply SxS to this image? */
|
|
|
|
if (!(ImageInformation.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_ISOLATION))
|
|
|
|
{
|
|
|
|
/* Too bad, we don't support this yet */
|
|
|
|
DPRINT1("Image should receive SxS Fusion Isolation\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There's some SxS flag that we need to set if fusion flags have 1 set */
|
|
|
|
if (FusionFlags & 1) CreateProcessMsg->Sxs.Flags |= 0x10;
|
|
|
|
|
|
|
|
/* Check if we have a current directory */
|
2011-07-20 15:54:21 +00:00
|
|
|
if (lpCurrentDirectory)
|
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Allocate a buffer so we can keep a Unicode copy */
|
2014-11-08 22:19:07 +00:00
|
|
|
DPRINT("Current directory: %S\n", lpCurrentDirectory);
|
2011-07-20 15:54:21 +00:00
|
|
|
CurrentDirectory = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
(MAX_PATH * sizeof(WCHAR)) +
|
|
|
|
sizeof(UNICODE_NULL));
|
|
|
|
if (!CurrentDirectory)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Bail out if this failed */
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2010-01-09 21:57:00 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Get the length in Unicode */
|
|
|
|
Length = GetFullPathNameW(lpCurrentDirectory,
|
|
|
|
MAX_PATH,
|
|
|
|
CurrentDirectory,
|
|
|
|
&FilePart);
|
|
|
|
if (Length > MAX_PATH)
|
|
|
|
{
|
|
|
|
/* The directory is too long, so bail out */
|
|
|
|
SetLastError(ERROR_DIRECTORY);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the directory is actually valid */
|
2016-07-09 22:23:23 +00:00
|
|
|
FileAttribs = GetFileAttributesW(CurrentDirectory);
|
|
|
|
if ((FileAttribs == INVALID_FILE_ATTRIBUTES) ||
|
|
|
|
!(FileAttribs & FILE_ATTRIBUTE_DIRECTORY))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* It isn't, so bail out */
|
|
|
|
DPRINT1("Current directory is invalid\n");
|
2011-07-20 15:54:21 +00:00
|
|
|
SetLastError(ERROR_DIRECTORY);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Insert quotes if needed */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if ((QuotesNeeded) || (CmdLineIsAppName))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Allocate our buffer, plus enough space for quotes and a NULL */
|
2011-07-20 15:54:21 +00:00
|
|
|
QuotedCmdLine = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
0,
|
2013-08-05 18:33:52 +00:00
|
|
|
(wcslen(lpCommandLine) * sizeof(WCHAR)) +
|
|
|
|
(2 * sizeof(L'\"') + sizeof(UNICODE_NULL)));
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (QuotedCmdLine)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Copy the first quote */
|
|
|
|
wcscpy(QuotedCmdLine, L"\"");
|
|
|
|
|
|
|
|
/* Save the current null-character */
|
|
|
|
if (QuotesNeeded)
|
|
|
|
{
|
2013-08-05 18:33:52 +00:00
|
|
|
SaveChar = *NullBuffer;
|
|
|
|
*NullBuffer = UNICODE_NULL;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
2010-01-09 21:57:00 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Copy the command line and the final quote */
|
|
|
|
wcscat(QuotedCmdLine, lpCommandLine);
|
|
|
|
wcscat(QuotedCmdLine, L"\"");
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Copy the null-char back */
|
|
|
|
if (QuotesNeeded)
|
|
|
|
{
|
2013-08-05 18:33:52 +00:00
|
|
|
*NullBuffer = SaveChar;
|
|
|
|
wcscat(QuotedCmdLine, NullBuffer);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* We can't put quotes around the thing, so try it anyway */
|
|
|
|
if (QuotesNeeded) QuotesNeeded = FALSE;
|
|
|
|
if (CmdLineIsAppName) CmdLineIsAppName = FALSE;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
2013-08-05 18:33:52 +00:00
|
|
|
/* Use isolation if needed */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
if (CreateProcessMsg->Sxs.Flags & 1) ParameterFlags |= 1;
|
|
|
|
|
2013-08-05 18:33:52 +00:00
|
|
|
/* Set the new command-line if needed */
|
|
|
|
if ((QuotesNeeded) || (CmdLineIsAppName)) lpCommandLine = QuotedCmdLine;
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Call the helper function in charge of RTL_USER_PROCESS_PARAMETERS */
|
|
|
|
Result = BasePushProcessParameters(ParameterFlags,
|
|
|
|
ProcessHandle,
|
|
|
|
RemotePeb,
|
|
|
|
lpApplicationName,
|
|
|
|
CurrentDirectory,
|
2013-08-05 18:33:52 +00:00
|
|
|
lpCommandLine,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
lpEnvironment,
|
|
|
|
&StartupInfo,
|
|
|
|
dwCreationFlags | NoWindow,
|
|
|
|
bInheritHandles,
|
|
|
|
IsWowApp ? IMAGE_SUBSYSTEM_WINDOWS_GUI: 0,
|
|
|
|
AppCompatData,
|
|
|
|
AppCompatDataSize);
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
/* The remote process would have an undefined state, so fail the call */
|
|
|
|
DPRINT1("BasePushProcessParameters failed\n");
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the VDM command line string as it's no longer needed */
|
|
|
|
RtlFreeUnicodeString(&VdmString);
|
|
|
|
VdmString.Buffer = NULL;
|
|
|
|
|
|
|
|
/* Non-VDM console applications usually inherit handles unless specified */
|
|
|
|
if (!(VdmBinaryType) &&
|
|
|
|
!(bInheritHandles) &&
|
|
|
|
!(StartupInfo.dwFlags & STARTF_USESTDHANDLES) &&
|
|
|
|
!(dwCreationFlags & (CREATE_NO_WINDOW |
|
|
|
|
CREATE_NEW_CONSOLE |
|
|
|
|
DETACHED_PROCESS)) &&
|
|
|
|
(ImageInformation.SubSystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI))
|
|
|
|
{
|
|
|
|
/* Get the remote parameters */
|
|
|
|
Status = NtReadVirtualMemory(ProcessHandle,
|
|
|
|
&RemotePeb->ProcessParameters,
|
|
|
|
&ProcessParameters,
|
|
|
|
sizeof(PRTL_USER_PROCESS_PARAMETERS),
|
|
|
|
NULL);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Duplicate standard input unless it's a console handle */
|
|
|
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardInput))
|
|
|
|
{
|
2013-08-04 18:46:07 +00:00
|
|
|
StuffStdHandle(ProcessHandle,
|
|
|
|
Peb->ProcessParameters->StandardInput,
|
|
|
|
&ProcessParameters->StandardInput);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Duplicate standard output unless it's a console handle */
|
|
|
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardOutput))
|
|
|
|
{
|
2013-08-04 18:46:07 +00:00
|
|
|
StuffStdHandle(ProcessHandle,
|
|
|
|
Peb->ProcessParameters->StandardOutput,
|
|
|
|
&ProcessParameters->StandardOutput);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Duplicate standard error unless it's a console handle */
|
|
|
|
if (!IsConsoleHandle(Peb->ProcessParameters->StandardError))
|
|
|
|
{
|
2013-08-04 18:46:07 +00:00
|
|
|
StuffStdHandle(ProcessHandle,
|
|
|
|
Peb->ProcessParameters->StandardError,
|
|
|
|
&ProcessParameters->StandardError);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the Thread's Stack */
|
|
|
|
StackSize = max(256 * 1024, ImageInformation.MaximumStackSize);
|
|
|
|
Status = BaseCreateStack(ProcessHandle,
|
|
|
|
ImageInformation.CommittedStackSize,
|
|
|
|
StackSize,
|
|
|
|
&InitialTeb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Creating the thread stack failed: %lx\n", Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the Thread's Context */
|
|
|
|
BaseInitializeContext(&Context,
|
|
|
|
Peb,
|
|
|
|
ImageInformation.TransferAddress,
|
|
|
|
InitialTeb.StackBase,
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* Convert the thread attributes */
|
|
|
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
|
|
|
lpThreadAttributes,
|
|
|
|
NULL);
|
|
|
|
if ((hUserToken) && (lpThreadAttributes))
|
|
|
|
{
|
|
|
|
/* If the caller specified a user token, zero the security descriptor */
|
|
|
|
LocalThreadAttributes = *lpThreadAttributes;
|
|
|
|
LocalThreadAttributes.lpSecurityDescriptor = NULL;
|
|
|
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
|
|
|
&LocalThreadAttributes,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the Kernel Thread Object */
|
|
|
|
Status = NtCreateThread(&ThreadHandle,
|
|
|
|
THREAD_ALL_ACCESS,
|
|
|
|
ObjectAttributes,
|
|
|
|
ProcessHandle,
|
|
|
|
&ClientId,
|
|
|
|
&Context,
|
|
|
|
&InitialTeb,
|
|
|
|
TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* A process is not allowed to exist without a main thread, so fail */
|
|
|
|
DPRINT1("Creating the main thread failed: %lx\n", Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin filling out the CSRSS message, first with our IDs and handles */
|
|
|
|
CreateProcessMsg->ProcessHandle = ProcessHandle;
|
|
|
|
CreateProcessMsg->ThreadHandle = ThreadHandle;
|
|
|
|
CreateProcessMsg->ClientId = ClientId;
|
|
|
|
|
|
|
|
/* Write the remote PEB address and clear it locally, we no longer use it */
|
|
|
|
CreateProcessMsg->PebAddressNative = RemotePeb;
|
2018-02-15 21:34:48 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
DPRINT1("TODO: WOW64 is not supported yet\n");
|
|
|
|
CreateProcessMsg->PebAddressWow64 = 0;
|
|
|
|
#else
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
CreateProcessMsg->PebAddressWow64 = (ULONG)RemotePeb;
|
2018-02-15 21:34:48 +00:00
|
|
|
#endif
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
RemotePeb = NULL;
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Now check what kind of architecture this image was made for */
|
|
|
|
switch (ImageInformation.Machine)
|
|
|
|
{
|
|
|
|
/* IA32, IA64 and AMD64 are supported in Server 2003 */
|
|
|
|
case IMAGE_FILE_MACHINE_I386:
|
2014-02-02 00:25:25 +00:00
|
|
|
CreateProcessMsg->ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
break;
|
|
|
|
case IMAGE_FILE_MACHINE_IA64:
|
|
|
|
CreateProcessMsg->ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
|
|
|
|
break;
|
|
|
|
case IMAGE_FILE_MACHINE_AMD64:
|
|
|
|
CreateProcessMsg->ProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Anything else results in image unknown -- but no failure */
|
|
|
|
default:
|
|
|
|
DbgPrint("kernel32: No mapping for ImageInformation.Machine == %04x\n",
|
|
|
|
ImageInformation.Machine);
|
|
|
|
CreateProcessMsg->ProcessorArchitecture = PROCESSOR_ARCHITECTURE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Write the input creation flags except any debugger-related flags */
|
|
|
|
CreateProcessMsg->CreationFlags = dwCreationFlags &
|
|
|
|
~(DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS);
|
|
|
|
|
|
|
|
/* CSRSS needs to know if this is a GUI app or not */
|
|
|
|
if ((ImageInformation.SubSystemType == IMAGE_SUBSYSTEM_WINDOWS_GUI) ||
|
|
|
|
(IsWowApp))
|
|
|
|
{
|
2013-08-06 10:40:36 +00:00
|
|
|
/*
|
|
|
|
* For GUI apps we turn on the 2nd bit. This allow CSRSS server dlls
|
|
|
|
* (basesrv in particular) to know whether or not this is a GUI or a
|
|
|
|
* TUI application.
|
|
|
|
*/
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
AddToHandle(CreateProcessMsg->ProcessHandle, 2);
|
|
|
|
|
|
|
|
/* Also check if the parent is also a GUI process */
|
|
|
|
NtHeaders = RtlImageNtHeader(GetModuleHandle(NULL));
|
|
|
|
if ((NtHeaders) &&
|
|
|
|
(NtHeaders->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
2013-08-06 10:40:36 +00:00
|
|
|
/* Let it know that it should display the hourglass mouse cursor */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
AddToHandle(CreateProcessMsg->ProcessHandle, 1);
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* For all apps, if this flag is on, the hourglass mouse cursor is shown */
|
|
|
|
if (StartupInfo.dwFlags & STARTF_FORCEONFEEDBACK)
|
|
|
|
{
|
|
|
|
AddToHandle(CreateProcessMsg->ProcessHandle, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Likewise, the opposite holds as well */
|
|
|
|
if (StartupInfo.dwFlags & STARTF_FORCEOFFFEEDBACK)
|
|
|
|
{
|
|
|
|
RemoveFromHandle(CreateProcessMsg->ProcessHandle, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Also store which kind of VDM app (if any) this is */
|
|
|
|
CreateProcessMsg->VdmBinaryType = VdmBinaryType;
|
|
|
|
|
|
|
|
/* And if it really is a VDM app... */
|
|
|
|
if (VdmBinaryType)
|
|
|
|
{
|
|
|
|
/* Store the task ID and VDM console handle */
|
|
|
|
CreateProcessMsg->hVDM = VdmTask ? 0 : Peb->ProcessParameters->ConsoleHandle;
|
|
|
|
CreateProcessMsg->VdmTask = VdmTask;
|
|
|
|
}
|
|
|
|
else if (VdmReserve)
|
|
|
|
{
|
|
|
|
/* Extended VDM, set a flag */
|
|
|
|
CreateProcessMsg->VdmBinaryType |= BINARY_TYPE_WOW_EX;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if there's side-by-side assembly data associated with the process */
|
|
|
|
if (CreateProcessMsg->Sxs.Flags)
|
|
|
|
{
|
|
|
|
/* This should not happen in ReactOS yet */
|
|
|
|
DPRINT1("This is an SxS Message -- should not happen yet\n");
|
|
|
|
BaseSetLastNTError(STATUS_NOT_IMPLEMENTED);
|
|
|
|
NtTerminateProcess(ProcessHandle, STATUS_NOT_IMPLEMENTED);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We are finally ready to call CSRSS to tell it about our new process! */
|
2014-03-08 01:17:45 +00:00
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&CsrMsg[0],
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
CaptureBuffer,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX,
|
|
|
|
BasepCreateProcess),
|
|
|
|
sizeof(*CreateProcessMsg));
|
|
|
|
|
|
|
|
/* CSRSS has returned, free the capture buffer now if we had one */
|
|
|
|
if (CaptureBuffer)
|
|
|
|
{
|
|
|
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
|
|
|
CaptureBuffer = NULL;
|
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if CSRSS failed to accept ownership of the new Windows process */
|
2014-03-08 01:17:45 +00:00
|
|
|
if (!NT_SUCCESS(CsrMsg[0].Status))
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
{
|
|
|
|
/* Terminate the process and enter failure path with the CSRSS status */
|
|
|
|
DPRINT1("Failed to tell csrss about new process\n");
|
2014-03-08 01:17:45 +00:00
|
|
|
BaseSetLastNTError(CsrMsg[0].Status);
|
|
|
|
NtTerminateProcess(ProcessHandle, CsrMsg[0].Status);
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if we have a token due to Authz/Safer, not passed by the user */
|
|
|
|
if ((TokenHandle) && !(hUserToken))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Replace the process and/or thread token with the one from Safer */
|
|
|
|
Status = BasepReplaceProcessThreadTokens(TokenHandle,
|
|
|
|
ProcessHandle,
|
|
|
|
ThreadHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If this failed, kill the process and enter the failure path */
|
|
|
|
DPRINT1("Failed to update process token: %lx\n", Status);
|
|
|
|
NtTerminateProcess(ProcessHandle, Status);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if a job was associated with this process */
|
|
|
|
if (JobHandle)
|
|
|
|
{
|
|
|
|
/* Bind the process and job together now */
|
|
|
|
Status = NtAssignProcessToJobObject(JobHandle, ProcessHandle);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Kill the process and enter the failure path if binding failed */
|
|
|
|
DPRINT1("Failed to assign process to job: %lx\n", Status);
|
|
|
|
NtTerminateProcess(ProcessHandle, STATUS_ACCESS_DENIED);
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
Result = FALSE;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, resume the thread to actually get the process started */
|
|
|
|
if (!(dwCreationFlags & CREATE_SUSPENDED))
|
|
|
|
{
|
|
|
|
NtResumeThread(ThreadHandle, &ResumeCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
VdmShortCircuit:
|
|
|
|
/* We made it this far, meaning we have a fully created process and thread */
|
|
|
|
Result = TRUE;
|
|
|
|
|
|
|
|
/* Anyone doing a VDM undo should now undo everything, since we are done */
|
|
|
|
if (VdmUndoLevel) VdmUndoLevel |= VDM_UNDO_COMPLETED;
|
|
|
|
|
|
|
|
/* Having a VDM wait object implies this must be a VDM process */
|
|
|
|
if (VdmWaitObject)
|
|
|
|
{
|
|
|
|
/* Check if it's a 16-bit separate WOW process */
|
|
|
|
if (VdmBinaryType == BINARY_TYPE_SEPARATE_WOW)
|
|
|
|
{
|
|
|
|
/* OR-in the special flag to indicate this, and return to caller */
|
|
|
|
AddToHandle(VdmWaitObject, 2);
|
|
|
|
lpProcessInformation->hProcess = VdmWaitObject;
|
|
|
|
|
|
|
|
/* Check if this was a re-used VDM */
|
|
|
|
if (VdmUndoLevel & VDM_UNDO_REUSE)
|
2009-04-13 11:58:39 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* No Client ID should be returned in this case */
|
|
|
|
ClientId.UniqueProcess = 0;
|
|
|
|
ClientId.UniqueThread = 0;
|
2009-04-13 11:58:39 +00:00
|
|
|
}
|
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* OR-in the special flag to indicate this is not a separate VDM */
|
|
|
|
AddToHandle(VdmWaitObject, 1);
|
2009-04-13 11:58:39 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Return handle to the caller */
|
|
|
|
lpProcessInformation->hProcess = VdmWaitObject;
|
|
|
|
}
|
2001-02-10 22:01:50 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Close the original process handle, since it's not needed for VDM */
|
|
|
|
if (ProcessHandle) NtClose(ProcessHandle);
|
|
|
|
}
|
|
|
|
else
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* This is a regular process, so return the real process handle */
|
|
|
|
lpProcessInformation->hProcess = ProcessHandle;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-03-14 18:16:40 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Return the rest of the process information based on what we have so far */
|
|
|
|
lpProcessInformation->hThread = ThreadHandle;
|
|
|
|
lpProcessInformation->dwProcessId = HandleToUlong(ClientId.UniqueProcess);
|
|
|
|
lpProcessInformation->dwThreadId = HandleToUlong(ClientId.UniqueThread);
|
|
|
|
|
|
|
|
/* NULL these out here so we know to treat this as a success scenario */
|
|
|
|
ProcessHandle = NULL;
|
|
|
|
ThreadHandle = NULL;
|
2004-08-29 14:46:02 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
Quickie:
|
|
|
|
/* Free the debugger command line if one was allocated */
|
|
|
|
if (DebuggerCmdLine) RtlFreeHeap(RtlGetProcessHeap(), 0, DebuggerCmdLine);
|
|
|
|
|
|
|
|
/* Check if an SxS full path as queried */
|
|
|
|
if (PathBuffer)
|
2004-08-29 14:46:02 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Reinitialize the executable path */
|
|
|
|
RtlInitEmptyUnicodeString(&SxsWin32ExePath, NULL, 0);
|
|
|
|
SxsWin32ExePath.Length = 0;
|
2004-08-29 14:46:02 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Free the path buffer */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, PathBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if _SXS_SUPPORT_ENABLED_
|
|
|
|
/* Check if this was a non-VDM process */
|
|
|
|
if (!VdmBinaryType)
|
|
|
|
{
|
|
|
|
/* Then it must've had SxS data, so close the handles used for it */
|
|
|
|
BasepSxsCloseHandles(&Handles);
|
|
|
|
BasepSxsCloseHandles(&FileHandles);
|
|
|
|
|
|
|
|
/* Check if we built SxS byte buffers for this create process request */
|
|
|
|
if (SxsConglomeratedBuffer)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Loop all of them */
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
/* Check if this one was allocated */
|
|
|
|
ThisBuffer = SxsStaticBuffers[i];
|
|
|
|
if (ThisBuffer)
|
|
|
|
{
|
|
|
|
/* Get the underlying RTL_BUFFER structure */
|
|
|
|
ByteBuffer = &ThisBuffer->ByteBuffer;
|
|
|
|
if ((ThisBuffer != (PVOID)-8) && (ByteBuffer->Buffer))
|
|
|
|
{
|
|
|
|
/* Check if it was dynamic */
|
|
|
|
if (ByteBuffer->Buffer != ByteBuffer->StaticBuffer)
|
|
|
|
{
|
|
|
|
/* Free it from the heap */
|
|
|
|
FreeString.Buffer = (PWCHAR)ByteBuffer->Buffer;
|
|
|
|
RtlFreeUnicodeString(&FreeString);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the buffer to its static data */
|
|
|
|
ByteBuffer->Buffer = ByteBuffer->StaticBuffer;
|
|
|
|
ByteBuffer->Size = ByteBuffer->StaticSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the string to the static buffer */
|
|
|
|
RtlInitEmptyUnicodeString(&ThisBuffer->String,
|
|
|
|
(PWCHAR)ByteBuffer->StaticBuffer,
|
|
|
|
ByteBuffer->StaticSize);
|
|
|
|
if (ThisBuffer->String.Buffer)
|
|
|
|
{
|
|
|
|
/* Also NULL-terminate it */
|
|
|
|
*ThisBuffer->String.Buffer = UNICODE_NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Check if an environment was passed in */
|
|
|
|
if ((lpEnvironment) && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
|
|
|
|
{
|
|
|
|
/* Destroy it */
|
|
|
|
RtlDestroyEnvironment(lpEnvironment);
|
2004-08-29 14:46:02 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If this was the VDM environment too, clear that as well */
|
|
|
|
if (VdmUnicodeEnv.Buffer == lpEnvironment) VdmUnicodeEnv.Buffer = NULL;
|
|
|
|
lpEnvironment = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-08-29 14:46:02 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Unconditionally free all the name parsing buffers we always allocate */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, QuotedCmdLine);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDirectory);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FreeBuffer);
|
|
|
|
|
|
|
|
/* Close open file/section handles */
|
|
|
|
if (FileHandle) NtClose(FileHandle);
|
|
|
|
if (SectionHandle) NtClose(SectionHandle);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If we have a thread handle, this was a failure path */
|
|
|
|
if (ThreadHandle)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* So kill the process and close the thread handle */
|
|
|
|
NtTerminateProcess(ProcessHandle, 0);
|
|
|
|
NtClose(ThreadHandle);
|
2004-08-29 14:46:02 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* If we have a process handle, this was a failure path, so close it */
|
|
|
|
if (ProcessHandle) NtClose(ProcessHandle);
|
|
|
|
|
|
|
|
/* Thread/process handles, if any, are now processed. Now close this one. */
|
|
|
|
if (JobHandle) NtClose(JobHandle);
|
|
|
|
|
|
|
|
/* Check if we had created a token */
|
|
|
|
if (TokenHandle)
|
2011-07-20 15:54:21 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* And if the user asked for one */
|
|
|
|
if (hUserToken)
|
|
|
|
{
|
|
|
|
/* Then return it */
|
|
|
|
*hNewToken = TokenHandle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* User didn't want it, so we used it temporarily -- close it */
|
|
|
|
NtClose(TokenHandle);
|
|
|
|
}
|
2011-07-20 15:54:21 +00:00
|
|
|
}
|
2004-09-21 21:53:45 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Free any temporary app compatibility data, it's no longer needed */
|
|
|
|
BasepFreeAppCompatData(AppCompatData, AppCompatSxsData);
|
2004-09-21 21:53:45 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Free a few strings. The API takes care of these possibly being NULL */
|
|
|
|
RtlFreeUnicodeString(&VdmString);
|
|
|
|
RtlFreeUnicodeString(&DebuggerString);
|
2011-07-20 15:54:21 +00:00
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if we had built any sort of VDM environment */
|
|
|
|
if ((VdmAnsiEnv.Buffer) || (VdmUnicodeEnv.Buffer))
|
2004-09-21 21:53:45 +00:00
|
|
|
{
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Free it */
|
|
|
|
BaseDestroyVDMEnvironment(&VdmAnsiEnv, &VdmUnicodeEnv);
|
2004-09-21 21:53:45 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
/* Check if this was any kind of VDM application that we ended up creating */
|
|
|
|
if ((VdmUndoLevel) && (!(VdmUndoLevel & VDM_UNDO_COMPLETED)))
|
|
|
|
{
|
|
|
|
/* Send an undo */
|
|
|
|
BaseUpdateVDMEntry(VdmEntryUndo,
|
|
|
|
(PHANDLE)&VdmTask,
|
|
|
|
VdmUndoLevel,
|
|
|
|
VdmBinaryType);
|
|
|
|
|
|
|
|
/* And close whatever VDM handle we were using for notifications */
|
|
|
|
if (VdmWaitObject) NtClose(VdmWaitObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we ended up here with an allocated search path, and free it */
|
|
|
|
if (SearchPath) RtlFreeHeap(RtlGetProcessHeap(), 0, SearchPath);
|
|
|
|
|
|
|
|
/* Finally, return the API's result */
|
|
|
|
return Result;
|
2004-09-21 21:53:45 +00:00
|
|
|
}
|
|
|
|
|
2008-11-03 12:27:39 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2014-03-05 11:45:39 +00:00
|
|
|
DECLSPEC_HOTPATCH
|
2011-07-20 15:54:21 +00:00
|
|
|
CreateProcessW(LPCWSTR lpApplicationName,
|
|
|
|
LPWSTR lpCommandLine,
|
|
|
|
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
|
|
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
|
|
|
BOOL bInheritHandles,
|
|
|
|
DWORD dwCreationFlags,
|
|
|
|
LPVOID lpEnvironment,
|
|
|
|
LPCWSTR lpCurrentDirectory,
|
|
|
|
LPSTARTUPINFOW lpStartupInfo,
|
|
|
|
LPPROCESS_INFORMATION lpProcessInformation)
|
2008-11-03 12:27:39 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Call the internal (but exported) version */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
return CreateProcessInternalW(NULL,
|
2011-07-20 15:54:21 +00:00
|
|
|
lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
lpProcessAttributes,
|
|
|
|
lpThreadAttributes,
|
|
|
|
bInheritHandles,
|
|
|
|
dwCreationFlags,
|
|
|
|
lpEnvironment,
|
|
|
|
lpCurrentDirectory,
|
|
|
|
lpStartupInfo,
|
|
|
|
lpProcessInformation,
|
|
|
|
NULL);
|
2008-11-03 12:27:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 12:21:20 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
2011-07-20 15:54:21 +00:00
|
|
|
CreateProcessInternalA(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,
|
|
|
|
PHANDLE hNewToken)
|
2009-07-12 12:21:20 +00:00
|
|
|
{
|
2017-05-30 20:57:45 +00:00
|
|
|
UNICODE_STRING CommandLine;
|
2011-07-20 15:54:21 +00:00
|
|
|
UNICODE_STRING ApplicationName;
|
|
|
|
UNICODE_STRING CurrentDirectory;
|
|
|
|
BOOL bRetVal;
|
|
|
|
STARTUPINFOW StartupInfo;
|
|
|
|
|
2013-08-29 20:37:02 +00:00
|
|
|
DPRINT("dwCreationFlags %x, lpEnvironment %p, lpCurrentDirectory %p, "
|
|
|
|
"lpStartupInfo %p, lpProcessInformation %p\n",
|
2011-07-20 15:54:21 +00:00
|
|
|
dwCreationFlags, lpEnvironment, lpCurrentDirectory,
|
|
|
|
lpStartupInfo, lpProcessInformation);
|
|
|
|
|
|
|
|
/* Copy Startup Info */
|
|
|
|
RtlMoveMemory(&StartupInfo, lpStartupInfo, sizeof(*lpStartupInfo));
|
|
|
|
|
|
|
|
/* Initialize all strings to nothing */
|
2017-05-30 20:57:45 +00:00
|
|
|
CommandLine.Buffer = NULL;
|
2011-07-20 15:54:21 +00:00
|
|
|
ApplicationName.Buffer = NULL;
|
|
|
|
CurrentDirectory.Buffer = NULL;
|
|
|
|
StartupInfo.lpDesktop = NULL;
|
|
|
|
StartupInfo.lpReserved = NULL;
|
|
|
|
StartupInfo.lpTitle = NULL;
|
|
|
|
|
|
|
|
/* Convert the Command line */
|
|
|
|
if (lpCommandLine)
|
|
|
|
{
|
2017-05-30 20:57:45 +00:00
|
|
|
Basep8BitStringToDynamicUnicodeString(&CommandLine,
|
|
|
|
lpCommandLine);
|
2009-07-12 12:21:20 +00:00
|
|
|
}
|
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Convert the Name and Directory */
|
|
|
|
if (lpApplicationName)
|
|
|
|
{
|
|
|
|
Basep8BitStringToDynamicUnicodeString(&ApplicationName,
|
|
|
|
lpApplicationName);
|
|
|
|
}
|
|
|
|
if (lpCurrentDirectory)
|
|
|
|
{
|
|
|
|
Basep8BitStringToDynamicUnicodeString(&CurrentDirectory,
|
|
|
|
lpCurrentDirectory);
|
|
|
|
}
|
2009-07-12 12:21:20 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Now convert Startup Strings */
|
|
|
|
if (lpStartupInfo->lpReserved)
|
2009-07-12 12:21:20 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpReserved,
|
|
|
|
&StartupInfo.lpReserved);
|
|
|
|
}
|
|
|
|
if (lpStartupInfo->lpDesktop)
|
|
|
|
{
|
|
|
|
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpDesktop,
|
|
|
|
&StartupInfo.lpDesktop);
|
|
|
|
}
|
|
|
|
if (lpStartupInfo->lpTitle)
|
|
|
|
{
|
|
|
|
BasepAnsiStringToHeapUnicodeString(lpStartupInfo->lpTitle,
|
|
|
|
&StartupInfo.lpTitle);
|
2009-07-12 12:21:20 +00:00
|
|
|
}
|
2010-01-09 20:51:33 +00:00
|
|
|
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Call the Unicode function */
|
|
|
|
bRetVal = CreateProcessInternalW(hToken,
|
|
|
|
ApplicationName.Buffer,
|
2017-05-30 20:57:45 +00:00
|
|
|
CommandLine.Buffer,
|
2011-07-20 15:54:21 +00:00
|
|
|
lpProcessAttributes,
|
|
|
|
lpThreadAttributes,
|
|
|
|
bInheritHandles,
|
|
|
|
dwCreationFlags,
|
|
|
|
lpEnvironment,
|
|
|
|
CurrentDirectory.Buffer,
|
|
|
|
&StartupInfo,
|
|
|
|
lpProcessInformation,
|
|
|
|
hNewToken);
|
|
|
|
|
|
|
|
/* Clean up */
|
|
|
|
RtlFreeUnicodeString(&ApplicationName);
|
2017-05-30 20:57:45 +00:00
|
|
|
RtlFreeUnicodeString(&CommandLine);
|
2011-07-20 15:54:21 +00:00
|
|
|
RtlFreeUnicodeString(&CurrentDirectory);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpDesktop);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpReserved);
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpTitle);
|
|
|
|
|
|
|
|
/* Return what Unicode did */
|
|
|
|
return bRetVal;
|
2009-07-12 12:21:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-07-20 15:54:21 +00:00
|
|
|
* FUNCTION: The CreateProcess function creates a new process and its
|
|
|
|
* primary thread. The new process executes the specified executable file
|
|
|
|
* ARGUMENTS:
|
|
|
|
*
|
|
|
|
* lpApplicationName = Pointer to name of executable module
|
|
|
|
* lpCommandLine = Pointer to command line string
|
|
|
|
* lpProcessAttributes = Process security attributes
|
|
|
|
* lpThreadAttributes = Thread security attributes
|
|
|
|
* bInheritHandles = Handle inheritance flag
|
|
|
|
* dwCreationFlags = Creation flags
|
|
|
|
* lpEnvironment = Pointer to new environment block
|
|
|
|
* lpCurrentDirectory = Pointer to current directory name
|
|
|
|
* lpStartupInfo = Pointer to startup info
|
|
|
|
* lpProcessInformation = Pointer to process information
|
|
|
|
*
|
2009-07-12 12:21:20 +00:00
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
2014-03-05 11:45:39 +00:00
|
|
|
DECLSPEC_HOTPATCH
|
2011-07-20 15:54:21 +00:00
|
|
|
CreateProcessA(LPCSTR lpApplicationName,
|
|
|
|
LPSTR lpCommandLine,
|
|
|
|
LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
|
|
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
|
|
|
BOOL bInheritHandles,
|
|
|
|
DWORD dwCreationFlags,
|
|
|
|
LPVOID lpEnvironment,
|
|
|
|
LPCSTR lpCurrentDirectory,
|
|
|
|
LPSTARTUPINFOA lpStartupInfo,
|
|
|
|
LPPROCESS_INFORMATION lpProcessInformation)
|
2009-07-12 12:21:20 +00:00
|
|
|
{
|
2011-07-20 15:54:21 +00:00
|
|
|
/* Call the internal (but exported) version */
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
return CreateProcessInternalA(NULL,
|
2011-07-20 15:54:21 +00:00
|
|
|
lpApplicationName,
|
|
|
|
lpCommandLine,
|
|
|
|
lpProcessAttributes,
|
|
|
|
lpThreadAttributes,
|
|
|
|
bInheritHandles,
|
|
|
|
dwCreationFlags,
|
|
|
|
lpEnvironment,
|
|
|
|
lpCurrentDirectory,
|
|
|
|
lpStartupInfo,
|
|
|
|
lpProcessInformation,
|
|
|
|
NULL);
|
2009-07-12 12:21:20 +00:00
|
|
|
}
|
|
|
|
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
UINT
|
|
|
|
WINAPI
|
2016-09-04 07:50:55 +00:00
|
|
|
DECLSPEC_HOTPATCH
|
[KERNEL32]: Changes to proc.c:
- ReadProcessMemory/WriteProcessMemory only write to *lpNumberOfBytesRead/Written if user-mode passed in the parameter, as its an optional argument in Win32, but not in NT. Instead, use a local variable. This means that anyone calling ReadProcessMemory/WriteProcessMemory in ReactOS before with a NULL output argument (totally valid) was getting an error before!
- WriteProcessMemory actually returns STATUS_ACCESS_VIOLATION in a few cases, even if it's defined as a BOOL function. Code on Google shows major applications depending on this, which we weren't doing.
- Rewrite InitCommandLines to be much simpler. No normalization or copying or ANSi/OEM logic is needed.
- GetProcessAffinityMask should use the BaseStaticServerData from CSRSS instead of querying system information each time.
- GetProcessShutdownParameters and SetProcessShutdownParameters should use the LPC status code from CSRSS, not the LPC API status code.
- GetProcessWorkingSetSize now calls GetProcessWorkingSetSizeEx.
- Implement GetProcessWorkingSetSizeEx.
- SetProcessWorkingSetSize now calls SetProcessWorkingSetSizeEx.
- Implement SetProcessWorkingSetSizeEx.
- Acquire the required privilege in SetProcessWorkingSetSize(Ex).
- Fail with correct status code in SetProcessWorkingSetSize(Ex).
- GetExitCodeProcess should check if this is a VDM process and get the exit code that way.
- GetStartupInfoW should not fail if the input is NULL. It should crash.
- GetStartupInfoW was not filling out the lpReserved field, which should contain the ShellInfo buffer.
- GetStartupInfoW was always setting standard handles -- it should not do so if those are console handles.
- GetStartupInfoA was not thread-safe.
- GetStartupInfoA was assuming all Unicode->ANSI conversions will be successful.
- GetStartupInfoA was not filling out lpReserved either.
- ExitProcess was not using SEH and was not using the PEB lock.
- TerminateProcess was not setting ERROR_INVALID_HANDLE last error code.
- FatalAppExitA was not using static TEB buffer, and was always assuming success.
- FatalAppExitW was doing some sort of bizarre hack. It now raises as a hard error as it should.
- FatalExit now displays a debugger input interface on checked builds, just like Windows.
- SetPriorityClass now tries to acquire the real time privilege when needed, and handles failure to do so.
- GetProcessVersion rewritten to be cleaner and simpler.
- Annotate and reformat functions where needed.
- Rename lpfnGlobalRegisterWaitForInputIdle to UserWaitForInputIdleRoutine
- GetProcessPriorityBoost is now BOOL-safe.
- IsWow64Process now sets NT error code using only one API.
- CommandLineStringA/W -> BaseAnsiCommandLine/BaseUnicodeCommandLine.
svn path=/trunk/; revision=55092
2012-01-23 04:57:12 +00:00
|
|
|
WinExec(LPCSTR lpCmdLine,
|
|
|
|
UINT uCmdShow)
|
|
|
|
{
|
|
|
|
STARTUPINFOA StartupInfo;
|
|
|
|
PROCESS_INFORMATION ProcessInformation;
|
|
|
|
DWORD dosErr;
|
|
|
|
|
|
|
|
RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
|
|
|
StartupInfo.cb = sizeof(STARTUPINFOA);
|
|
|
|
StartupInfo.wShowWindow = (WORD)uCmdShow;
|
|
|
|
StartupInfo.dwFlags = 0;
|
|
|
|
|
|
|
|
if (!CreateProcessA(NULL,
|
|
|
|
(PVOID)lpCmdLine,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&StartupInfo,
|
|
|
|
&ProcessInformation))
|
|
|
|
{
|
|
|
|
dosErr = GetLastError();
|
|
|
|
return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != UserWaitForInputIdleRoutine)
|
|
|
|
{
|
|
|
|
UserWaitForInputIdleRoutine(ProcessInformation.hProcess,
|
|
|
|
10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
NtClose(ProcessInformation.hProcess);
|
|
|
|
NtClose(ProcessInformation.hThread);
|
|
|
|
|
|
|
|
return 33; /* Something bigger than 31 means success. */
|
|
|
|
}
|
|
|
|
|
1999-08-29 06:59:11 +00:00
|
|
|
/* EOF */
|