2011-07-22 02:13:57 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Win32 Base API
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/win32/kernel32/client/vdm.c
|
2013-08-19 17:50:27 +00:00
|
|
|
* PURPOSE: Virtual DOS Machines (VDM) Support
|
2011-07-22 02:13:57 +00:00
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
|
|
|
#include <k32.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* TYPES **********************************************************************/
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
#define BINARY_UNKNOWN (0)
|
|
|
|
#define BINARY_PE_EXE32 (1)
|
|
|
|
#define BINARY_PE_DLL32 (2)
|
|
|
|
#define BINARY_PE_EXE64 (3)
|
|
|
|
#define BINARY_PE_DLL64 (4)
|
|
|
|
#define BINARY_WIN16 (5)
|
|
|
|
#define BINARY_OS216 (6)
|
|
|
|
#define BINARY_DOS (7)
|
|
|
|
#define BINARY_UNIX_EXE (8)
|
|
|
|
#define BINARY_UNIX_LIB (9)
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum _ENV_NAME_TYPE
|
|
|
|
{
|
|
|
|
EnvNameNotAPath = 1,
|
|
|
|
EnvNameSinglePath ,
|
|
|
|
EnvNameMultiplePath
|
|
|
|
} ENV_NAME_TYPE;
|
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
typedef struct _ENV_INFO
|
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
ENV_NAME_TYPE NameType;
|
|
|
|
ULONG NameLength;
|
2011-12-20 16:53:11 +00:00
|
|
|
PWCHAR Name;
|
|
|
|
} ENV_INFO, *PENV_INFO;
|
|
|
|
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
#define ENV_NAME_ENTRY(type, name) \
|
2015-09-27 16:16:26 +00:00
|
|
|
{(type), _ARRAYSIZE(name) - 1, (name)}
|
2015-08-24 01:32:00 +00:00
|
|
|
|
|
|
|
static ENV_INFO BasepEnvNameType[] =
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
ENV_NAME_ENTRY(EnvNameMultiplePath, L"PATH"),
|
|
|
|
ENV_NAME_ENTRY(EnvNameSinglePath , L"WINDIR"),
|
|
|
|
ENV_NAME_ENTRY(EnvNameSinglePath , L"SYSTEMROOT"),
|
|
|
|
ENV_NAME_ENTRY(EnvNameMultiplePath, L"TEMP"),
|
|
|
|
ENV_NAME_ENTRY(EnvNameMultiplePath, L"TMP"),
|
2011-12-20 16:53:11 +00:00
|
|
|
};
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
static UNICODE_STRING BaseDotComSuffixName = RTL_CONSTANT_STRING(L".com");
|
|
|
|
static UNICODE_STRING BaseDotPifSuffixName = RTL_CONSTANT_STRING(L".pif");
|
|
|
|
static UNICODE_STRING BaseDotExeSuffixName = RTL_CONSTANT_STRING(L".exe");
|
2011-12-20 16:53:11 +00:00
|
|
|
|
2011-07-22 02:13:57 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
ULONG
|
|
|
|
WINAPI
|
|
|
|
BaseIsDosApplication(IN PUNICODE_STRING PathName,
|
|
|
|
IN NTSTATUS Status)
|
|
|
|
{
|
|
|
|
UNICODE_STRING String;
|
|
|
|
|
|
|
|
/* Is it a .com? */
|
|
|
|
String.Length = BaseDotComSuffixName.Length;
|
|
|
|
String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
|
2013-08-19 17:50:27 +00:00
|
|
|
if (RtlEqualUnicodeString(&String, &BaseDotComSuffixName, TRUE)) return BINARY_TYPE_COM;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
|
|
|
/* Is it a .pif? */
|
|
|
|
String.Length = BaseDotPifSuffixName.Length;
|
|
|
|
String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
|
2013-08-19 17:50:27 +00:00
|
|
|
if (RtlEqualUnicodeString(&String, &BaseDotPifSuffixName, TRUE)) return BINARY_TYPE_PIF;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
|
|
|
/* Is it an exe? */
|
|
|
|
String.Length = BaseDotExeSuffixName.Length;
|
|
|
|
String.Buffer = &PathName->Buffer[(PathName->Length - String.Length) / sizeof(WCHAR)];
|
2013-08-19 17:50:27 +00:00
|
|
|
if (RtlEqualUnicodeString(&String, &BaseDotExeSuffixName, TRUE)) return BINARY_TYPE_EXE;
|
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-01 23:24:06 +00:00
|
|
|
NTSTATUS
|
2011-12-20 16:53:11 +00:00
|
|
|
WINAPI
|
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
|
|
|
BaseCheckVDM(IN ULONG BinaryType,
|
|
|
|
IN PCWCH ApplicationName,
|
|
|
|
IN PCWCH CommandLine,
|
|
|
|
IN PCWCH CurrentDirectory,
|
|
|
|
IN PANSI_STRING AnsiEnvironment,
|
2014-02-02 00:25:25 +00:00
|
|
|
IN PBASE_API_MESSAGE ApiMessage,
|
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
|
|
|
IN OUT PULONG iTask,
|
|
|
|
IN DWORD CreationFlags,
|
[KERNEL32]: Complete rewrite of CreateProcessInternalW based on Server 2003, instead of the original version that I wrote based on Windows 2000. This new version adds the right CSRSS support for VDM and Wow32, stubs the upcoming support for SxS, uses the new NtCreateProcessEx functionality, adds checks for SDB/Shim/AppCompat, adds checks for SRP (the old AppLocker), adds support for image file execution options, such as large pages and the debugger key, adds licensing checks, adds better path handling using the path APIs that Thomas, Hermes, and Myself re-wrote/improved in Rtl/NTDLL, and a whole lot more. Tested with a bunch of launches, downloads, and apps, and no immediate regressions were seen, but this is 3500 lines of code and nothing is perfect. Please file Jira issues as they come up -- I will maintain & fix this. Will also ask Hermes to start working on the VDM/WoW32 paths for the new NTVDM work that's happening, and I will start looking at SxS.
svn path=/trunk/; revision=59637
2013-08-04 16:58:54 +00:00
|
|
|
IN LPSTARTUPINFOW StartupInfo,
|
|
|
|
IN HANDLE hUserToken OPTIONAL)
|
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
|
|
|
{
|
2014-02-03 19:00:58 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PBASE_CHECK_VDM CheckVdm = &ApiMessage->Data.CheckVDMRequest;
|
2015-10-24 08:43:54 +00:00
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
|
2014-02-03 19:00:58 +00:00
|
|
|
PWCHAR CurrentDir = NULL;
|
|
|
|
PWCHAR ShortAppName = NULL;
|
|
|
|
PWCHAR ShortCurrentDir = NULL;
|
|
|
|
ULONG Length;
|
|
|
|
PCHAR AnsiCmdLine = NULL;
|
|
|
|
PCHAR AnsiAppName = NULL;
|
|
|
|
PCHAR AnsiCurDirectory = NULL;
|
|
|
|
PCHAR AnsiDesktop = NULL;
|
|
|
|
PCHAR AnsiTitle = NULL;
|
|
|
|
PCHAR AnsiReserved = NULL;
|
|
|
|
STARTUPINFOA AnsiStartupInfo;
|
|
|
|
ULONG NumStrings = 5;
|
|
|
|
|
2014-05-18 22:10:45 +00:00
|
|
|
/* Parameters validation */
|
|
|
|
if (ApplicationName == NULL || CommandLine == NULL)
|
2014-02-03 19:00:58 +00:00
|
|
|
{
|
2014-05-18 22:10:45 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2014-02-03 19:00:58 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 22:10:45 +00:00
|
|
|
/* Trim leading whitespace from ApplicationName */
|
|
|
|
while (*ApplicationName == L' ' || *ApplicationName == L'\t')
|
|
|
|
++ApplicationName;
|
|
|
|
|
2014-02-03 19:00:58 +00:00
|
|
|
/* Calculate the size of the short application name */
|
|
|
|
Length = GetShortPathNameW(ApplicationName, NULL, 0);
|
2014-05-18 22:10:45 +00:00
|
|
|
if (Length == 0)
|
|
|
|
{
|
|
|
|
Status = STATUS_OBJECT_PATH_INVALID;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
2014-02-03 19:00:58 +00:00
|
|
|
|
|
|
|
/* Allocate memory for the short application name */
|
|
|
|
ShortAppName = (PWCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
Length * sizeof(WCHAR));
|
|
|
|
if (!ShortAppName)
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the short application name */
|
2014-05-18 22:10:45 +00:00
|
|
|
if (GetShortPathNameW(ApplicationName, ShortAppName, Length) == 0)
|
2014-02-03 19:00:58 +00:00
|
|
|
{
|
|
|
|
/* Try to determine which error occurred */
|
|
|
|
switch (GetLastError())
|
|
|
|
{
|
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ERROR_INVALID_PARAMETER:
|
|
|
|
{
|
|
|
|
Status = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
Status = STATUS_OBJECT_PATH_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
2014-05-18 22:10:45 +00:00
|
|
|
/* Trim leading whitespace from CommandLine */
|
|
|
|
while (*CommandLine == L' ' || *CommandLine == L'\t')
|
|
|
|
++CommandLine;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CommandLine is usually formatted as: 'ApplicationName param0 ...'.
|
|
|
|
* So we want to strip the first token (ApplicationName) from it.
|
|
|
|
* Two cases are in fact possible:
|
|
|
|
* - either the first token is indeed ApplicationName, so we just skip it;
|
|
|
|
* - or the first token is not exactly ApplicationName, because it happened
|
|
|
|
* that somebody else already preprocessed CommandLine. Therefore we
|
|
|
|
* suppose that the first token corresponds to an application name and
|
|
|
|
* we skip it. Care should be taken when quotes are present in this token.
|
|
|
|
*/
|
|
|
|
if (*CommandLine)
|
|
|
|
{
|
|
|
|
/* The first part of CommandLine should be the ApplicationName... */
|
|
|
|
Length = wcslen(ApplicationName);
|
|
|
|
if (Length <= wcslen(CommandLine) &&
|
|
|
|
_wcsnicmp(ApplicationName, CommandLine, Length) == 0)
|
|
|
|
{
|
|
|
|
/* Skip it */
|
|
|
|
CommandLine += Length;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* ... but it is not, however we still have a token. We suppose that
|
|
|
|
* it corresponds to some sort of application name, so we skip it too.
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get rid of the first token. We stop when we see whitespace. */
|
|
|
|
while (*CommandLine && !(*CommandLine == L' ' || *CommandLine == L'\t'))
|
|
|
|
{
|
|
|
|
if (*CommandLine == L'\"')
|
|
|
|
{
|
|
|
|
/* We enter a quoted part, skip it */
|
|
|
|
++CommandLine;
|
|
|
|
while (*CommandLine && *CommandLine++ != L'\"') ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Go to the next character */
|
|
|
|
++CommandLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trim remaining whitespace from CommandLine that may be
|
|
|
|
* present between the application name and the parameters.
|
|
|
|
*/
|
|
|
|
while (*CommandLine == L' ' || *CommandLine == L'\t')
|
|
|
|
++CommandLine;
|
|
|
|
|
|
|
|
/* Get the current directory */
|
|
|
|
if (CurrentDirectory == NULL)
|
|
|
|
{
|
|
|
|
/* Allocate memory for the current directory path */
|
|
|
|
Length = GetCurrentDirectoryW(0, NULL);
|
|
|
|
CurrentDir = (PWCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
Length * sizeof(WCHAR));
|
|
|
|
if (CurrentDir == NULL)
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current directory */
|
|
|
|
GetCurrentDirectoryW(Length, CurrentDir);
|
|
|
|
CurrentDirectory = CurrentDir;
|
|
|
|
}
|
|
|
|
|
2014-02-03 19:00:58 +00:00
|
|
|
/* Calculate the size of the short current directory path */
|
|
|
|
Length = GetShortPathNameW(CurrentDirectory, NULL, 0);
|
|
|
|
|
|
|
|
/* Allocate memory for the short current directory path */
|
|
|
|
ShortCurrentDir = (PWCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
Length * sizeof(WCHAR));
|
|
|
|
if (!ShortCurrentDir)
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the short current directory path */
|
|
|
|
if (!GetShortPathNameW(CurrentDirectory, ShortCurrentDir, Length))
|
|
|
|
{
|
|
|
|
/* Try to determine which error occurred */
|
|
|
|
switch (GetLastError())
|
|
|
|
{
|
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ERROR_INVALID_PARAMETER:
|
|
|
|
{
|
|
|
|
Status = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
Status = STATUS_OBJECT_PATH_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the input parameters */
|
|
|
|
CheckVdm->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
CheckVdm->BinaryType = BinaryType;
|
|
|
|
CheckVdm->CodePage = CP_ACP;
|
|
|
|
CheckVdm->dwCreationFlags = CreationFlags;
|
|
|
|
CheckVdm->CurDrive = CurrentDirectory[0] - L'A';
|
|
|
|
CheckVdm->CmdLen = wcslen(CommandLine) + 1;
|
|
|
|
CheckVdm->AppLen = wcslen(ShortAppName) + 1;
|
|
|
|
CheckVdm->PifLen = 0; // TODO: PIF file support!
|
|
|
|
CheckVdm->CurDirectoryLen = wcslen(ShortCurrentDir) + 1;
|
|
|
|
CheckVdm->EnvLen = AnsiEnvironment->Length;
|
|
|
|
CheckVdm->DesktopLen = (StartupInfo->lpDesktop != NULL) ? (wcslen(StartupInfo->lpDesktop) + 1) : 0;
|
|
|
|
CheckVdm->TitleLen = (StartupInfo->lpTitle != NULL) ? (wcslen(StartupInfo->lpTitle) + 1) : 0;
|
|
|
|
CheckVdm->ReservedLen = (StartupInfo->lpReserved != NULL) ? (wcslen(StartupInfo->lpReserved) + 1) : 0;
|
|
|
|
|
|
|
|
if (StartupInfo->dwFlags & STARTF_USESTDHANDLES)
|
|
|
|
{
|
|
|
|
/* Set the standard handles */
|
2014-05-18 23:13:12 +00:00
|
|
|
CheckVdm->StdIn = StartupInfo->hStdInput;
|
2014-02-03 19:00:58 +00:00
|
|
|
CheckVdm->StdOut = StartupInfo->hStdOutput;
|
|
|
|
CheckVdm->StdErr = StartupInfo->hStdError;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for the ANSI strings */
|
2014-05-18 23:17:25 +00:00
|
|
|
// We need to add the newline characters '\r\n' to the command line
|
2014-05-18 22:10:45 +00:00
|
|
|
AnsiCmdLine = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->CmdLen + 2);
|
2014-02-03 19:00:58 +00:00
|
|
|
AnsiAppName = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->AppLen);
|
|
|
|
AnsiCurDirectory = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->CurDirectoryLen);
|
2015-09-12 16:03:53 +00:00
|
|
|
if (StartupInfo->lpDesktop)
|
|
|
|
AnsiDesktop = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
CheckVdm->DesktopLen);
|
|
|
|
if (StartupInfo->lpTitle)
|
|
|
|
AnsiTitle = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
CheckVdm->TitleLen);
|
|
|
|
if (StartupInfo->lpReserved)
|
|
|
|
AnsiReserved = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
CheckVdm->ReservedLen);
|
2014-02-03 19:00:58 +00:00
|
|
|
|
|
|
|
if (!AnsiCmdLine
|
|
|
|
|| !AnsiAppName
|
|
|
|
|| !AnsiCurDirectory
|
|
|
|
|| (StartupInfo->lpDesktop && !AnsiDesktop)
|
|
|
|
|| (StartupInfo->lpTitle && !AnsiTitle)
|
|
|
|
|| (StartupInfo->lpReserved && !AnsiReserved))
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the command line into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
CommandLine,
|
|
|
|
CheckVdm->CmdLen,
|
|
|
|
AnsiCmdLine,
|
|
|
|
CheckVdm->CmdLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2014-05-18 23:17:25 +00:00
|
|
|
/* Add the needed newline and NULL-terminate */
|
2014-05-18 23:13:12 +00:00
|
|
|
CheckVdm->CmdLen--; // Rewind back to the NULL character
|
|
|
|
AnsiCmdLine[CheckVdm->CmdLen++] = '\r';
|
|
|
|
AnsiCmdLine[CheckVdm->CmdLen++] = '\n';
|
|
|
|
AnsiCmdLine[CheckVdm->CmdLen++] = 0;
|
2014-02-03 19:00:58 +00:00
|
|
|
|
|
|
|
/* Convert the short application name into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
ShortAppName,
|
|
|
|
CheckVdm->AppLen,
|
|
|
|
AnsiAppName,
|
|
|
|
CheckVdm->AppLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Convert the short current directory path into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
ShortCurrentDir,
|
|
|
|
CheckVdm->CurDirectoryLen,
|
|
|
|
AnsiCurDirectory,
|
|
|
|
CheckVdm->CurDirectoryLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (StartupInfo->lpDesktop)
|
|
|
|
{
|
|
|
|
/* Convert the desktop name into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
StartupInfo->lpDesktop,
|
|
|
|
CheckVdm->DesktopLen,
|
|
|
|
AnsiDesktop,
|
|
|
|
CheckVdm->DesktopLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
NumStrings++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StartupInfo->lpTitle)
|
|
|
|
{
|
|
|
|
/* Convert the title into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
StartupInfo->lpTitle,
|
|
|
|
CheckVdm->TitleLen,
|
|
|
|
AnsiTitle,
|
|
|
|
CheckVdm->TitleLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
NumStrings++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StartupInfo->lpReserved)
|
|
|
|
{
|
|
|
|
/* Convert the reserved value into an ANSI string */
|
|
|
|
WideCharToMultiByte(CP_ACP,
|
|
|
|
0,
|
|
|
|
StartupInfo->lpReserved,
|
|
|
|
CheckVdm->ReservedLen,
|
|
|
|
AnsiReserved,
|
|
|
|
CheckVdm->ReservedLen,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
NumStrings++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill the ANSI startup info structure */
|
2015-09-12 16:03:53 +00:00
|
|
|
RtlCopyMemory(&AnsiStartupInfo, StartupInfo, sizeof(AnsiStartupInfo));
|
2014-02-03 19:00:58 +00:00
|
|
|
AnsiStartupInfo.lpReserved = AnsiReserved;
|
|
|
|
AnsiStartupInfo.lpDesktop = AnsiDesktop;
|
|
|
|
AnsiStartupInfo.lpTitle = AnsiTitle;
|
|
|
|
|
|
|
|
/* Allocate the capture buffer */
|
|
|
|
CaptureBuffer = CsrAllocateCaptureBuffer(NumStrings,
|
|
|
|
CheckVdm->CmdLen
|
|
|
|
+ CheckVdm->AppLen
|
|
|
|
+ CheckVdm->PifLen
|
|
|
|
+ CheckVdm->CurDirectoryLen
|
|
|
|
+ CheckVdm->DesktopLen
|
|
|
|
+ CheckVdm->TitleLen
|
|
|
|
+ CheckVdm->ReservedLen
|
|
|
|
+ CheckVdm->EnvLen
|
2015-09-12 16:03:53 +00:00
|
|
|
+ sizeof(*CheckVdm->StartupInfo));
|
2014-02-03 19:00:58 +00:00
|
|
|
if (CaptureBuffer == NULL)
|
|
|
|
{
|
|
|
|
Status = STATUS_NO_MEMORY;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Capture the command line */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiCmdLine,
|
|
|
|
CheckVdm->CmdLen,
|
|
|
|
(PVOID*)&CheckVdm->CmdLine);
|
|
|
|
|
|
|
|
/* Capture the application name */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiAppName,
|
|
|
|
CheckVdm->AppLen,
|
|
|
|
(PVOID*)&CheckVdm->AppName);
|
|
|
|
|
|
|
|
CheckVdm->PifFile = NULL; // TODO: PIF file support!
|
|
|
|
|
|
|
|
/* Capture the current directory */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiCurDirectory,
|
|
|
|
CheckVdm->CurDirectoryLen,
|
|
|
|
(PVOID*)&CheckVdm->CurDirectory);
|
|
|
|
|
|
|
|
/* Capture the environment */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiEnvironment->Buffer,
|
|
|
|
CheckVdm->EnvLen,
|
|
|
|
(PVOID*)&CheckVdm->Env);
|
|
|
|
|
|
|
|
/* Capture the startup info structure */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
&AnsiStartupInfo,
|
2015-09-12 16:03:53 +00:00
|
|
|
sizeof(*CheckVdm->StartupInfo),
|
2014-02-03 19:00:58 +00:00
|
|
|
(PVOID*)&CheckVdm->StartupInfo);
|
|
|
|
|
|
|
|
if (StartupInfo->lpDesktop)
|
|
|
|
{
|
|
|
|
/* Capture the desktop name */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiDesktop,
|
|
|
|
CheckVdm->DesktopLen,
|
|
|
|
(PVOID*)&CheckVdm->Desktop);
|
|
|
|
}
|
|
|
|
else CheckVdm->Desktop = NULL;
|
|
|
|
|
|
|
|
if (StartupInfo->lpTitle)
|
|
|
|
{
|
|
|
|
/* Capture the title */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiTitle,
|
|
|
|
CheckVdm->TitleLen,
|
|
|
|
(PVOID*)&CheckVdm->Title);
|
|
|
|
}
|
|
|
|
else CheckVdm->Title = NULL;
|
|
|
|
|
|
|
|
if (StartupInfo->lpReserved)
|
|
|
|
{
|
|
|
|
/* Capture the reserved parameter */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
AnsiReserved,
|
|
|
|
CheckVdm->ReservedLen,
|
|
|
|
(PVOID*)&CheckVdm->Reserved);
|
|
|
|
}
|
|
|
|
else CheckVdm->Reserved = NULL;
|
|
|
|
|
|
|
|
/* Send the message to CSRSS */
|
|
|
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)ApiMessage,
|
|
|
|
CaptureBuffer,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepCheckVDM),
|
2015-08-24 01:32:00 +00:00
|
|
|
sizeof(*CheckVdm));
|
2014-02-03 19:00:58 +00:00
|
|
|
|
2014-05-03 02:34:40 +00:00
|
|
|
/* Write back the task ID */
|
|
|
|
*iTask = CheckVdm->iTask;
|
2014-02-03 19:00:58 +00:00
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
|
|
|
|
/* Free the ANSI strings */
|
|
|
|
if (AnsiCmdLine) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiCmdLine);
|
|
|
|
if (AnsiAppName) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiAppName);
|
|
|
|
if (AnsiCurDirectory) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiCurDirectory);
|
|
|
|
if (AnsiDesktop) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiDesktop);
|
|
|
|
if (AnsiTitle) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiTitle);
|
|
|
|
if (AnsiReserved) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiReserved);
|
|
|
|
|
|
|
|
/* Free the capture buffer */
|
2015-10-24 08:43:54 +00:00
|
|
|
if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
|
2014-02-03 19:00:58 +00:00
|
|
|
|
2014-05-18 22:10:45 +00:00
|
|
|
/* Free the current directory, if it was allocated here, and its short path */
|
2014-02-03 19:00:58 +00:00
|
|
|
if (ShortCurrentDir) RtlFreeHeap(RtlGetProcessHeap(), 0, ShortCurrentDir);
|
|
|
|
if (CurrentDir) RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDir);
|
|
|
|
|
2014-05-18 22:10:45 +00:00
|
|
|
/* Free the short app name */
|
|
|
|
if (ShortAppName) RtlFreeHeap(RtlGetProcessHeap(), 0, ShortAppName);
|
|
|
|
|
2014-02-03 19:00:58 +00:00
|
|
|
return Status;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
BaseUpdateVDMEntry(IN ULONG UpdateIndex,
|
|
|
|
IN OUT PHANDLE WaitHandle,
|
|
|
|
IN ULONG IndexInfo,
|
|
|
|
IN ULONG BinaryType)
|
|
|
|
{
|
2012-11-02 18:00:47 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
2014-02-01 19:05:54 +00:00
|
|
|
PBASE_UPDATE_VDM_ENTRY UpdateVdmEntry = &ApiMessage.Data.UpdateVDMEntryRequest;
|
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
|
|
|
|
|
|
|
/* Check what update is being sent */
|
|
|
|
switch (UpdateIndex)
|
|
|
|
{
|
|
|
|
/* VDM is being undone */
|
|
|
|
case VdmEntryUndo:
|
2013-08-22 12:47:14 +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
|
|
|
/* Tell the server how far we had gotten along */
|
2013-08-22 16:10:34 +00:00
|
|
|
UpdateVdmEntry->iTask = HandleToUlong(*WaitHandle);
|
2012-11-02 18:00:47 +00:00
|
|
|
UpdateVdmEntry->VDMCreationState = IndexInfo;
|
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
|
|
|
break;
|
2013-08-22 12:47:14 +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
|
|
|
|
|
|
|
/* VDM is ready with a new process handle */
|
|
|
|
case VdmEntryUpdateProcess:
|
2013-08-22 12:47:14 +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
|
|
|
/* Send it the process handle */
|
2012-11-02 18:00:47 +00:00
|
|
|
UpdateVdmEntry->VDMProcessHandle = *WaitHandle;
|
|
|
|
UpdateVdmEntry->iTask = IndexInfo;
|
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
|
|
|
break;
|
2013-08-22 12:47:14 +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
|
|
|
}
|
|
|
|
|
|
|
|
/* Also check what kind of binary this is for the console handle */
|
|
|
|
if (BinaryType == BINARY_TYPE_WOW)
|
|
|
|
{
|
|
|
|
/* Magic value for 16-bit apps */
|
2012-11-02 18:00:47 +00:00
|
|
|
UpdateVdmEntry->ConsoleHandle = (HANDLE)-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
|
|
|
}
|
2012-11-02 18:00:47 +00:00
|
|
|
else if (UpdateVdmEntry->iTask)
|
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
|
|
|
{
|
|
|
|
/* No handle for true VDM */
|
2013-08-22 12:47:14 +00:00
|
|
|
UpdateVdmEntry->ConsoleHandle = NULL;
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-22 12:47:14 +00:00
|
|
|
/* Otherwise, use the regular console handle */
|
2012-11-02 18:00:47 +00:00
|
|
|
UpdateVdmEntry->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally write the index and binary type */
|
2012-11-02 18:00:47 +00:00
|
|
|
UpdateVdmEntry->EntryIndex = UpdateIndex;
|
|
|
|
UpdateVdmEntry->BinaryType = BinaryType;
|
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
|
|
|
|
|
|
|
/* Send the message to CSRSS */
|
2015-08-24 01:32:00 +00:00
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepUpdateVDMEntry),
|
|
|
|
sizeof(*UpdateVdmEntry));
|
|
|
|
if (!NT_SUCCESS(ApiMessage.Status))
|
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
|
|
|
{
|
|
|
|
/* Handle failure */
|
2015-08-24 01:32:00 +00:00
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
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
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this was an update, CSRSS returns a new wait handle */
|
|
|
|
if (UpdateIndex == VdmEntryUpdateProcess)
|
|
|
|
{
|
|
|
|
/* Return it to the caller */
|
2012-11-02 18:00:47 +00:00
|
|
|
*WaitHandle = UpdateVdmEntry->WaitObjectForParent;
|
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
|
|
|
}
|
2014-02-01 19:05:54 +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
|
|
|
/* We made it */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
BaseCheckForVDM(IN HANDLE ProcessHandle,
|
|
|
|
OUT LPDWORD ExitCode)
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
EVENT_BASIC_INFORMATION EventBasicInfo;
|
2012-11-02 18:00:47 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
2014-02-01 19:05:54 +00:00
|
|
|
PBASE_GET_VDM_EXIT_CODE GetVdmExitCode = &ApiMessage.Data.GetVDMExitCodeRequest;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
|
|
|
/* It's VDM if the process is actually a wait handle (an event) */
|
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
|
|
|
Status = NtQueryEvent(ProcessHandle,
|
2011-12-20 16:53:11 +00:00
|
|
|
EventBasicInformation,
|
|
|
|
&EventBasicInfo,
|
|
|
|
sizeof(EventBasicInfo),
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status)) 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
|
|
|
/* Setup the input parameters */
|
2012-11-02 18:00:47 +00:00
|
|
|
GetVdmExitCode->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
GetVdmExitCode->hParent = ProcessHandle;
|
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
|
|
|
|
|
|
|
/* Call CSRSS */
|
2012-11-02 18:00:47 +00:00
|
|
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
2012-10-17 23:10:40 +00:00
|
|
|
NULL,
|
2013-08-22 16:10:34 +00:00
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepGetVDMExitCode),
|
2015-08-24 01:32:00 +00:00
|
|
|
sizeof(*GetVdmExitCode));
|
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 (!NT_SUCCESS(Status)) return FALSE;
|
|
|
|
|
|
|
|
/* Get the exit code from the reply */
|
2012-11-02 18:00:47 +00:00
|
|
|
*ExitCode = GetVdmExitCode->ExitCode;
|
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
|
|
|
return TRUE;
|
2011-12-20 16:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
2013-08-22 12:47:14 +00:00
|
|
|
BaseGetVdmConfigInfo(IN LPCWSTR CommandLineReserved,
|
2011-12-20 16:53:11 +00:00
|
|
|
IN ULONG DosSeqId,
|
|
|
|
IN ULONG BinaryType,
|
|
|
|
IN PUNICODE_STRING CmdLineString,
|
|
|
|
OUT PULONG VdmSize)
|
|
|
|
{
|
|
|
|
WCHAR Buffer[MAX_PATH];
|
|
|
|
WCHAR CommandLine[MAX_PATH * 2];
|
|
|
|
ULONG Length;
|
|
|
|
|
|
|
|
/* Clear the buffer in case we fail */
|
|
|
|
CmdLineString->Buffer = 0;
|
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-22 12:47:14 +00:00
|
|
|
/* Always return the same size: 16 Mb */
|
2011-12-20 16:53:11 +00:00
|
|
|
*VdmSize = 0x1000000;
|
|
|
|
|
|
|
|
/* Get the system directory */
|
|
|
|
Length = GetSystemDirectoryW(Buffer, MAX_PATH);
|
|
|
|
if (!(Length) || (Length >= MAX_PATH))
|
|
|
|
{
|
|
|
|
/* Eliminate no path or path too big */
|
|
|
|
SetLastError(ERROR_INVALID_NAME);
|
|
|
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Check if this is VDM with a DOS Sequence ID */
|
|
|
|
if (DosSeqId)
|
|
|
|
{
|
2013-08-22 12:47:14 +00:00
|
|
|
/*
|
|
|
|
* Build the VDM string for it:
|
|
|
|
* -i%lx : Gives the DOS Sequence ID;
|
|
|
|
* %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM.
|
|
|
|
*/
|
2011-12-20 16:53:11 +00:00
|
|
|
_snwprintf(CommandLine,
|
2015-08-24 01:32:00 +00:00
|
|
|
ARRAYSIZE(CommandLine),
|
2011-12-20 16:53:11 +00:00
|
|
|
L"\"%s\\ntvdm.exe\" -i%lx %s%c",
|
|
|
|
Buffer,
|
|
|
|
DosSeqId,
|
2013-08-22 12:47:14 +00:00
|
|
|
(BinaryType == BINARY_TYPE_DOS) ? L" " : L"-w",
|
|
|
|
(BinaryType == BINARY_TYPE_SEPARATE_WOW) ? L's' : L' ');
|
2011-12-20 16:53:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-22 12:47:14 +00:00
|
|
|
/*
|
|
|
|
* Build the string for it without the DOS Sequence ID:
|
|
|
|
* %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM.
|
|
|
|
*/
|
2011-12-20 16:53:11 +00:00
|
|
|
_snwprintf(CommandLine,
|
2015-08-24 01:32:00 +00:00
|
|
|
ARRAYSIZE(CommandLine),
|
2013-08-22 12:47:14 +00:00
|
|
|
L"\"%s\\ntvdm.exe\" %s%c",
|
2011-12-20 16:53:11 +00:00
|
|
|
Buffer,
|
2013-08-22 12:47:14 +00:00
|
|
|
(BinaryType == BINARY_TYPE_DOS) ? L" " : L"-w",
|
|
|
|
(BinaryType == BINARY_TYPE_SEPARATE_WOW) ? L's' : L' ');
|
2011-12-20 16:53:11 +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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Create the actual string */
|
|
|
|
return RtlCreateUnicodeString(CmdLineString, CommandLine);
|
|
|
|
}
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
ENV_NAME_TYPE
|
2011-12-20 16:53:11 +00:00
|
|
|
WINAPI
|
|
|
|
BaseGetEnvNameType_U(IN PWCHAR Name,
|
|
|
|
IN ULONG NameLength)
|
|
|
|
{
|
|
|
|
PENV_INFO EnvInfo;
|
2015-08-24 01:32:00 +00:00
|
|
|
ENV_NAME_TYPE NameType;
|
|
|
|
ULONG i;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Start by assuming the environment variable doesn't describe paths */
|
|
|
|
NameType = EnvNameNotAPath;
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Loop all the environment names */
|
2015-08-24 01:32:00 +00:00
|
|
|
for (i = 0; i < ARRAYSIZE(BasepEnvNameType); i++)
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
|
|
|
/* Get this entry */
|
|
|
|
EnvInfo = &BasepEnvNameType[i];
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Check if it matches the name */
|
|
|
|
if ((EnvInfo->NameLength == NameLength) &&
|
2015-08-24 01:32:00 +00:00
|
|
|
(_wcsnicmp(EnvInfo->Name, Name, NameLength) == 0))
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
|
|
|
/* It does, return the type */
|
|
|
|
NameType = EnvInfo->NameType;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
return NameType;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
NTAPI
|
2015-08-24 01:32:00 +00:00
|
|
|
BaseCreateVDMEnvironment(IN PWCHAR lpEnvironment,
|
|
|
|
OUT PANSI_STRING AnsiEnv,
|
|
|
|
OUT PUNICODE_STRING UnicodeEnv)
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
#define IS_ALPHA(x) \
|
|
|
|
( ((x) >= L'A' && (x) <= L'Z') || ((x) >= L'a' && (x) <= L'z') )
|
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
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
// From lib/rtl/path.c :
|
|
|
|
// Can be put in some .h ??
|
|
|
|
#define IS_PATH_SEPARATOR(x) ((x) == L'\\' || (x) == L'/')
|
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
|
|
|
|
2015-09-12 16:03:53 +00:00
|
|
|
BOOL Success = FALSE;
|
2011-12-20 16:53:11 +00:00
|
|
|
NTSTATUS Status;
|
2015-08-24 01:32:00 +00:00
|
|
|
ULONG RegionSize, EnvironmentSize = 0;
|
|
|
|
PWCHAR Environment, NewEnvironment = NULL;
|
|
|
|
ENV_NAME_TYPE NameType;
|
|
|
|
ULONG NameLength, NumChars, Remaining;
|
|
|
|
PWCHAR SourcePtr, DestPtr, StartPtr;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
|
|
|
/* Make sure we have both strings */
|
2015-08-24 01:32:00 +00:00
|
|
|
if (!AnsiEnv || !UnicodeEnv)
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if an environment was passed in */
|
|
|
|
if (!lpEnvironment)
|
|
|
|
{
|
|
|
|
/* Nope, create one */
|
2014-05-02 17:11:13 +00:00
|
|
|
Status = RtlCreateEnvironment(TRUE, &Environment);
|
2015-08-24 01:32:00 +00:00
|
|
|
if (!NT_SUCCESS(Status)) goto Cleanup;
|
2011-12-20 16:53:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Use the one we got */
|
|
|
|
Environment = lpEnvironment;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we have something now ? */
|
|
|
|
if (!Environment)
|
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Still not, bail out */
|
2011-12-20 16:53:11 +00:00
|
|
|
SetLastError(ERROR_BAD_ENVIRONMENT);
|
2015-08-24 01:32:00 +00:00
|
|
|
goto Cleanup;
|
2011-12-20 16:53:11 +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
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/*
|
|
|
|
* Count how much space the whole environment takes. The environment block is
|
2015-08-24 01:42:52 +00:00
|
|
|
* doubly NULL-terminated (NULL from last string and final NULL terminator).
|
2015-08-24 01:32:00 +00:00
|
|
|
*/
|
2014-05-17 22:26:37 +00:00
|
|
|
SourcePtr = Environment;
|
2015-08-24 01:32:00 +00:00
|
|
|
while (!(*SourcePtr++ == UNICODE_NULL && *SourcePtr == UNICODE_NULL))
|
|
|
|
++EnvironmentSize;
|
|
|
|
EnvironmentSize += 2; // Add the two terminating NULLs
|
2011-12-20 16:53:11 +00:00
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/*
|
|
|
|
* Allocate a new copy large enough to hold all the environment with paths
|
|
|
|
* in their short form. Since the short form of a path can be a bit longer
|
|
|
|
* than its long form, for example in the case where characters that are
|
|
|
|
* invalid in the 8.3 representation are present in the long path name:
|
|
|
|
* 'C:\\a+b' --> 'C:\\A_B~1', or:
|
|
|
|
* 'C:\\a b' --> 'C:\\AB2761~1' (with checksum inserted),
|
|
|
|
* we suppose that the possible total number of extra characters needed to
|
|
|
|
* convert the long paths into their short form is at most equal to MAX_PATH.
|
|
|
|
*/
|
2011-12-20 16:53:11 +00:00
|
|
|
RegionSize = (EnvironmentSize + MAX_PATH) * sizeof(WCHAR);
|
2015-08-24 01:32:00 +00:00
|
|
|
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&NewEnvironment,
|
|
|
|
0,
|
|
|
|
&RegionSize,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2011-12-20 16:53:11 +00:00
|
|
|
{
|
|
|
|
/* We failed, bail out */
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
NewEnvironment = NULL;
|
2015-08-24 01:32:00 +00:00
|
|
|
goto Cleanup;
|
2011-12-20 16:53:11 +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
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Parse the environment block */
|
|
|
|
Remaining = MAX_PATH - 2; // '-2': remove the last two NULLs. FIXME: is it really needed??
|
2014-05-17 22:26:37 +00:00
|
|
|
SourcePtr = Environment;
|
|
|
|
DestPtr = NewEnvironment;
|
2011-12-20 16:53:11 +00:00
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Loop through all the environment strings */
|
2014-05-17 22:26:37 +00:00
|
|
|
while (*SourcePtr != UNICODE_NULL)
|
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
/*
|
|
|
|
* 1. Check the type of the environment variable and copy its name.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Regular environment variable */
|
|
|
|
if (*SourcePtr != L'=')
|
2014-05-17 22:26:37 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
StartPtr = SourcePtr;
|
|
|
|
|
|
|
|
/* Copy the environment variable name, including the '=' */
|
|
|
|
while (*SourcePtr != UNICODE_NULL)
|
2014-05-17 22:26:37 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
*DestPtr++ = *SourcePtr;
|
|
|
|
if (*SourcePtr++ == L'=') break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Guess the type of the environment variable */
|
|
|
|
NameType = BaseGetEnvNameType_U(StartPtr, SourcePtr - StartPtr - 1);
|
|
|
|
}
|
|
|
|
/* 'Current directory' environment variable (i.e. of '=X:=' form) */
|
|
|
|
else // if (*SourcePtr == L'=')
|
|
|
|
{
|
|
|
|
/* First assume we have a possibly malformed environment variable */
|
|
|
|
NameType = EnvNameNotAPath;
|
2014-05-17 22:26:37 +00:00
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Check for a valid 'Current directory' environment variable */
|
|
|
|
if (IS_ALPHA(SourcePtr[1]) && SourcePtr[2] == L':' && SourcePtr[3] == L'=')
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Small optimization: convert the path to short form only if
|
|
|
|
* the current directory is not the root directory (i.e. not
|
|
|
|
* of the '=X:=Y:\' form), otherwise just do a simple copy.
|
|
|
|
*/
|
|
|
|
if ( wcslen(SourcePtr) >= ARRAYSIZE("=X:=Y:\\")-1 &&
|
|
|
|
!( IS_ALPHA(SourcePtr[4]) && SourcePtr[5] == L':' &&
|
|
|
|
IS_PATH_SEPARATOR(SourcePtr[6]) && SourcePtr[7] == UNICODE_NULL ) )
|
2014-05-17 22:26:37 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
NameType = EnvNameSinglePath;
|
|
|
|
|
|
|
|
/* Copy the '=X:=' prefix */
|
|
|
|
*DestPtr++ = SourcePtr[0];
|
|
|
|
*DestPtr++ = SourcePtr[1];
|
|
|
|
*DestPtr++ = SourcePtr[2];
|
|
|
|
*DestPtr++ = SourcePtr[3];
|
|
|
|
SourcePtr += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
2015-08-24 01:42:52 +00:00
|
|
|
* Invalid stuff starting with '=', i.e.:
|
2015-08-24 01:32:00 +00:00
|
|
|
* =? (with '?' not being a letter)
|
|
|
|
* =X??? (with '?' not being ":=" and not followed by something longer than 3 characters)
|
|
|
|
* =X:=??? (with '?' not being "X:\\")
|
|
|
|
*
|
|
|
|
* 'NameType' is already set to 'EnvNameNotAPath'.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 22:26:37 +00:00
|
|
|
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/*
|
|
|
|
* 2. Copy the environment value and perform conversions accordingly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (NameType == EnvNameNotAPath)
|
|
|
|
{
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Copy everything, including the NULL terminator */
|
2015-08-24 01:32:00 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
*DestPtr++ = *SourcePtr;
|
|
|
|
} while (*SourcePtr++ != UNICODE_NULL);
|
|
|
|
}
|
|
|
|
else if (NameType == EnvNameSinglePath)
|
|
|
|
{
|
|
|
|
/* Convert the path to its short form */
|
|
|
|
NameLength = wcslen(SourcePtr);
|
|
|
|
NumChars = GetShortPathNameW(SourcePtr, DestPtr, NameLength + 1 + Remaining);
|
|
|
|
if (NumChars == 0 || NumChars > NameLength + Remaining)
|
|
|
|
{
|
|
|
|
/* If the conversion failed, just copy the original value */
|
|
|
|
RtlCopyMemory(DestPtr, SourcePtr, NameLength * sizeof(WCHAR));
|
|
|
|
NumChars = NameLength;
|
|
|
|
}
|
|
|
|
DestPtr += NumChars;
|
|
|
|
if (NumChars > NameLength)
|
|
|
|
Remaining -= (NumChars - NameLength);
|
|
|
|
|
|
|
|
SourcePtr += NameLength;
|
2014-05-17 22:26:37 +00:00
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Copy the NULL terminator */
|
2015-08-24 01:32:00 +00:00
|
|
|
*DestPtr++ = *SourcePtr++;
|
|
|
|
}
|
|
|
|
else // if (NameType == EnvNameMultiplePath)
|
|
|
|
{
|
|
|
|
WCHAR Delimiter;
|
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Loop through the list of paths (delimited by ';') and convert each path to its short form */
|
2015-08-24 01:32:00 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Copy any trailing ';' before going to the next path */
|
|
|
|
while (*SourcePtr == L';')
|
|
|
|
{
|
|
|
|
*DestPtr++ = *SourcePtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
StartPtr = SourcePtr;
|
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Find the next path list delimiter or the NULL terminator */
|
2015-08-24 01:32:00 +00:00
|
|
|
while (*SourcePtr != UNICODE_NULL && *SourcePtr != L';')
|
|
|
|
{
|
|
|
|
++SourcePtr;
|
|
|
|
}
|
|
|
|
Delimiter = *SourcePtr;
|
|
|
|
|
|
|
|
NameLength = SourcePtr - StartPtr;
|
|
|
|
if (NameLength)
|
|
|
|
{
|
|
|
|
/*
|
2015-08-24 01:42:52 +00:00
|
|
|
* Temporarily replace the possible path list delimiter by NULL.
|
|
|
|
* 'lpEnvironment' must point to a read+write memory buffer!
|
2015-08-24 01:32:00 +00:00
|
|
|
*/
|
|
|
|
*SourcePtr = UNICODE_NULL;
|
|
|
|
|
|
|
|
NumChars = GetShortPathNameW(StartPtr, DestPtr, NameLength + 1 + Remaining);
|
|
|
|
if ( NumChars == 0 ||
|
|
|
|
(Delimiter == L';' ? NumChars > NameLength + Remaining
|
|
|
|
: NumChars > NameLength /* + Remaining ?? */) )
|
|
|
|
{
|
|
|
|
/* If the conversion failed, just copy the original value */
|
|
|
|
RtlCopyMemory(DestPtr, StartPtr, NameLength * sizeof(WCHAR));
|
|
|
|
NumChars = NameLength;
|
2014-05-17 22:26:37 +00:00
|
|
|
}
|
2015-08-24 01:32:00 +00:00
|
|
|
DestPtr += NumChars;
|
|
|
|
if (NumChars > NameLength)
|
|
|
|
Remaining -= (NumChars - NameLength);
|
2014-05-17 22:26:37 +00:00
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* If removed, restore the path list delimiter in the source environment value and copy it */
|
2015-08-24 01:32:00 +00:00
|
|
|
if (Delimiter != UNICODE_NULL)
|
2014-05-17 22:26:37 +00:00
|
|
|
{
|
2015-08-24 01:32:00 +00:00
|
|
|
*SourcePtr = Delimiter;
|
|
|
|
*DestPtr++ = *SourcePtr++;
|
2014-05-17 22:26:37 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-24 01:32:00 +00:00
|
|
|
} while (*SourcePtr != UNICODE_NULL);
|
2014-05-17 22:26:37 +00:00
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Copy the NULL terminator */
|
2015-08-24 01:32:00 +00:00
|
|
|
*DestPtr++ = *SourcePtr++;
|
|
|
|
}
|
2014-05-17 22:26:37 +00:00
|
|
|
}
|
2011-12-20 16:53:11 +00:00
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* NULL-terminate the environment block */
|
2014-05-17 22:26:37 +00:00
|
|
|
*DestPtr++ = UNICODE_NULL;
|
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
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Initialize the Unicode string to hold it */
|
|
|
|
RtlInitEmptyUnicodeString(UnicodeEnv, NewEnvironment,
|
|
|
|
(DestPtr - NewEnvironment) * sizeof(WCHAR));
|
|
|
|
UnicodeEnv->Length = UnicodeEnv->MaximumLength;
|
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
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Create its ANSI version */
|
2011-12-20 16:53:11 +00:00
|
|
|
Status = RtlUnicodeStringToAnsiString(AnsiEnv, UnicodeEnv, TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Set last error if conversion failure */
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Everything went okay, so return success */
|
2015-09-12 16:03:53 +00:00
|
|
|
Success = TRUE;
|
2011-12-20 16:53:11 +00:00
|
|
|
NewEnvironment = NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
Cleanup:
|
|
|
|
/* Cleanup path starts here, start by destroying the environment copy */
|
|
|
|
if (!lpEnvironment && Environment) RtlDestroyEnvironment(Environment);
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* See if we are here due to failure */
|
|
|
|
if (NewEnvironment)
|
|
|
|
{
|
|
|
|
/* Initialize the paths to be empty */
|
|
|
|
RtlInitEmptyUnicodeString(UnicodeEnv, NULL, 0);
|
|
|
|
RtlInitEmptyAnsiString(AnsiEnv, NULL, 0);
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Free the environment copy */
|
|
|
|
RegionSize = 0;
|
|
|
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&NewEnvironment,
|
|
|
|
&RegionSize,
|
|
|
|
MEM_RELEASE);
|
|
|
|
ASSERT(NT_SUCCESS(Status));
|
|
|
|
}
|
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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Return the result */
|
2015-09-12 16:03:53 +00:00
|
|
|
return Success;
|
2011-12-20 16:53:11 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
BaseDestroyVDMEnvironment(IN PANSI_STRING AnsiEnv,
|
|
|
|
IN PUNICODE_STRING UnicodeEnv)
|
|
|
|
{
|
|
|
|
ULONG Dummy = 0;
|
|
|
|
|
2015-08-24 01:42:52 +00:00
|
|
|
/* Clear the ANSI buffer since Rtl creates this for us */
|
2015-08-24 01:32:00 +00:00
|
|
|
if (AnsiEnv->Buffer) RtlFreeAnsiString(AnsiEnv);
|
|
|
|
|
|
|
|
/* The Unicode buffer is build by hand, though */
|
|
|
|
if (UnicodeEnv->Buffer)
|
|
|
|
{
|
|
|
|
/* So clear it through the API */
|
|
|
|
NtFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&UnicodeEnv->Buffer,
|
|
|
|
&Dummy,
|
|
|
|
MEM_RELEASE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-07 00:18:13 +00:00
|
|
|
|
|
|
|
/* Check whether a file is an OS/2 or a very old Windows executable
|
|
|
|
* by testing on import of KERNEL.
|
|
|
|
*
|
|
|
|
* FIXME: is reading the module imports the only way of discerning
|
|
|
|
* old Windows binaries from OS/2 ones ? At least it seems so...
|
|
|
|
*/
|
|
|
|
static DWORD WINAPI
|
|
|
|
InternalIsOS2OrOldWin(HANDLE hFile, IMAGE_DOS_HEADER *mz, IMAGE_OS2_HEADER *ne)
|
|
|
|
{
|
|
|
|
DWORD CurPos;
|
|
|
|
LPWORD modtab = NULL;
|
|
|
|
LPSTR nametab = NULL;
|
|
|
|
DWORD Read, Ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
Ret = BINARY_OS216;
|
|
|
|
CurPos = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
|
|
|
|
|
|
|
|
/* read modref table */
|
|
|
|
if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_modtab, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
|
|
|
|
(!(modtab = HeapAlloc(GetProcessHeap(), 0, ne->ne_cmod * sizeof(WORD)))) ||
|
|
|
|
(!(ReadFile(hFile, modtab, ne->ne_cmod * sizeof(WORD), &Read, NULL))) ||
|
|
|
|
(Read != (DWORD)ne->ne_cmod * sizeof(WORD)))
|
|
|
|
{
|
|
|
|
goto broken;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read imported names table */
|
|
|
|
if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_imptab, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
|
|
|
|
(!(nametab = HeapAlloc(GetProcessHeap(), 0, ne->ne_enttab - ne->ne_imptab))) ||
|
|
|
|
(!(ReadFile(hFile, nametab, ne->ne_enttab - ne->ne_imptab, &Read, NULL))) ||
|
|
|
|
(Read != (DWORD)ne->ne_enttab - ne->ne_imptab))
|
|
|
|
{
|
|
|
|
goto broken;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < ne->ne_cmod; i++)
|
|
|
|
{
|
|
|
|
LPSTR module;
|
|
|
|
module = &nametab[modtab[i]];
|
|
|
|
if(!strncmp(&module[1], "KERNEL", module[0]))
|
|
|
|
{
|
|
|
|
/* very old windows file */
|
|
|
|
Ret = BINARY_WIN16;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
broken:
|
|
|
|
DPRINT1("InternalIsOS2OrOldWin(): Binary file seems to be broken\n");
|
|
|
|
|
|
|
|
done:
|
|
|
|
HeapFree(GetProcessHeap(), 0, modtab);
|
|
|
|
HeapFree(GetProcessHeap(), 0, nametab);
|
|
|
|
SetFilePointer(hFile, CurPos, NULL, FILE_BEGIN);
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
InternalGetBinaryType(HANDLE hFile)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned char magic[4];
|
|
|
|
unsigned char ignored[12];
|
|
|
|
unsigned short type;
|
|
|
|
} elf;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned long magic;
|
|
|
|
unsigned long cputype;
|
|
|
|
unsigned long cpusubtype;
|
|
|
|
unsigned long filetype;
|
|
|
|
} macho;
|
|
|
|
IMAGE_DOS_HEADER mz;
|
|
|
|
} Header;
|
|
|
|
char magic[4];
|
|
|
|
DWORD Read;
|
|
|
|
|
|
|
|
if((SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
|
|
|
|
(!ReadFile(hFile, &Header, sizeof(Header), &Read, NULL) ||
|
|
|
|
(Read != sizeof(Header))))
|
|
|
|
{
|
|
|
|
return BINARY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!memcmp(Header.elf.magic, "\177ELF", sizeof(Header.elf.magic)))
|
|
|
|
{
|
|
|
|
/* FIXME: we don't bother to check byte order, architecture, etc. */
|
|
|
|
switch(Header.elf.type)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
return BINARY_UNIX_EXE;
|
|
|
|
case 3:
|
|
|
|
return BINARY_UNIX_LIB;
|
|
|
|
}
|
|
|
|
return BINARY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2015-08-24 01:32:00 +00:00
|
|
|
/* Mach-o File with Endian set to Big Endian or Little Endian*/
|
2011-11-07 00:18:13 +00:00
|
|
|
if(Header.macho.magic == 0xFEEDFACE ||
|
|
|
|
Header.macho.magic == 0xCEFAEDFE)
|
|
|
|
{
|
|
|
|
switch(Header.macho.filetype)
|
|
|
|
{
|
|
|
|
case 0x8:
|
|
|
|
/* MH_BUNDLE */
|
|
|
|
return BINARY_UNIX_LIB;
|
|
|
|
}
|
|
|
|
return BINARY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not ELF, try DOS */
|
|
|
|
if(Header.mz.e_magic == IMAGE_DOS_SIGNATURE)
|
|
|
|
{
|
|
|
|
/* We do have a DOS image so we will now try to seek into
|
|
|
|
* the file by the amount indicated by the field
|
|
|
|
* "Offset to extended header" and read in the
|
|
|
|
* "magic" field information at that location.
|
|
|
|
* This will tell us if there is more header information
|
|
|
|
* to read or not.
|
|
|
|
*/
|
|
|
|
if((SetFilePointer(hFile, Header.mz.e_lfanew, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
|
|
|
|
(!ReadFile(hFile, magic, sizeof(magic), &Read, NULL) ||
|
|
|
|
(Read != sizeof(magic))))
|
|
|
|
{
|
|
|
|
return BINARY_DOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reading the magic field succeeded so
|
|
|
|
* we will try to determine what type it is.
|
|
|
|
*/
|
|
|
|
if(!memcmp(magic, "PE\0\0", sizeof(magic)))
|
|
|
|
{
|
|
|
|
IMAGE_FILE_HEADER FileHeader;
|
|
|
|
if(!ReadFile(hFile, &FileHeader, sizeof(IMAGE_FILE_HEADER), &Read, NULL) ||
|
|
|
|
(Read != sizeof(IMAGE_FILE_HEADER)))
|
|
|
|
{
|
|
|
|
return BINARY_DOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME - detect 32/64 bit */
|
|
|
|
|
|
|
|
if(FileHeader.Characteristics & IMAGE_FILE_DLL)
|
|
|
|
return BINARY_PE_DLL32;
|
|
|
|
return BINARY_PE_EXE32;
|
|
|
|
}
|
|
|
|
|
2014-05-02 17:11:13 +00:00
|
|
|
if(!memcmp(magic, "NE", 2))
|
2011-11-07 00:18:13 +00:00
|
|
|
{
|
|
|
|
/* This is a Windows executable (NE) header. This can
|
|
|
|
* mean either a 16-bit OS/2 or a 16-bit Windows or even a
|
|
|
|
* DOS program (running under a DOS extender). To decide
|
|
|
|
* which, we'll have to read the NE header.
|
|
|
|
*/
|
|
|
|
IMAGE_OS2_HEADER ne;
|
|
|
|
if((SetFilePointer(hFile, Header.mz.e_lfanew, NULL, FILE_BEGIN) == 1) ||
|
|
|
|
!ReadFile(hFile, &ne, sizeof(IMAGE_OS2_HEADER), &Read, NULL) ||
|
|
|
|
(Read != sizeof(IMAGE_OS2_HEADER)))
|
|
|
|
{
|
|
|
|
/* Couldn't read header, so abort. */
|
|
|
|
return BINARY_DOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(ne.ne_exetyp)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
return BINARY_WIN16;
|
|
|
|
case 5:
|
|
|
|
return BINARY_DOS;
|
|
|
|
default:
|
|
|
|
return InternalIsOS2OrOldWin(hFile, &Header.mz, &ne);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return BINARY_DOS;
|
|
|
|
}
|
|
|
|
return BINARY_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GetBinaryTypeW (
|
|
|
|
LPCWSTR lpApplicationName,
|
|
|
|
LPDWORD lpBinaryType
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HANDLE hFile;
|
|
|
|
DWORD BinType;
|
|
|
|
|
|
|
|
if(!lpApplicationName || !lpBinaryType)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hFile = CreateFileW(lpApplicationName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, 0, 0);
|
|
|
|
if(hFile == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BinType = InternalGetBinaryType(hFile);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
|
|
|
|
switch(BinType)
|
|
|
|
{
|
|
|
|
case BINARY_UNKNOWN:
|
|
|
|
{
|
|
|
|
WCHAR *dot;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* guess from filename
|
|
|
|
*/
|
|
|
|
if(!(dot = wcsrchr(lpApplicationName, L'.')))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(!lstrcmpiW(dot, L".COM"))
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_DOS_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if(!lstrcmpiW(dot, L".PIF"))
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_PIF_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
case BINARY_PE_EXE32:
|
|
|
|
case BINARY_PE_DLL32:
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_32BIT_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case BINARY_PE_EXE64:
|
|
|
|
case BINARY_PE_DLL64:
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_64BIT_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case BINARY_WIN16:
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_WOW_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case BINARY_OS216:
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_OS216_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case BINARY_DOS:
|
|
|
|
{
|
|
|
|
*lpBinaryType = SCS_DOS_BINARY;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case BINARY_UNIX_EXE:
|
|
|
|
case BINARY_UNIX_LIB:
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-30 14:16:47 +00:00
|
|
|
DPRINT1("Invalid binary type %lu returned!\n", BinType);
|
2011-11-07 00:18:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GetBinaryTypeA(IN LPCSTR lpApplicationName,
|
|
|
|
OUT LPDWORD lpBinaryType)
|
|
|
|
{
|
|
|
|
ANSI_STRING ApplicationNameString;
|
|
|
|
UNICODE_STRING ApplicationNameW;
|
|
|
|
BOOL StringAllocated = FALSE, Result;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
RtlInitAnsiString(&ApplicationNameString, lpApplicationName);
|
|
|
|
|
|
|
|
if (ApplicationNameString.Length * sizeof(WCHAR) >= NtCurrentTeb()->StaticUnicodeString.MaximumLength)
|
|
|
|
{
|
|
|
|
StringAllocated = TRUE;
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&ApplicationNameW, &ApplicationNameString, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString), &ApplicationNameString, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringAllocated)
|
|
|
|
{
|
|
|
|
Result = GetBinaryTypeW(ApplicationNameW.Buffer, lpBinaryType);
|
|
|
|
RtlFreeUnicodeString(&ApplicationNameW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = GetBinaryTypeW(NtCurrentTeb()->StaticUnicodeString.Buffer, lpBinaryType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2011-07-22 02:13:57 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
CmdBatNotification (
|
|
|
|
DWORD Unknown
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2014-02-01 19:05:54 +00:00
|
|
|
* @implemented
|
2011-07-22 02:13:57 +00:00
|
|
|
*/
|
2014-02-01 19:05:54 +00:00
|
|
|
VOID
|
2011-07-22 02:13:57 +00:00
|
|
|
WINAPI
|
2014-02-01 19:05:54 +00:00
|
|
|
ExitVDM(BOOL IsWow, ULONG iWowTask)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2014-02-01 19:05:54 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
|
|
|
PBASE_EXIT_VDM ExitVdm = &ApiMessage.Data.ExitVDMRequest;
|
|
|
|
|
|
|
|
/* Setup the input parameters */
|
|
|
|
ExitVdm->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
ExitVdm->iWowTask = IsWow ? iWowTask : 0; /* Always zero for DOS tasks */
|
|
|
|
ExitVdm->WaitObjectForVDM = NULL;
|
|
|
|
|
|
|
|
/* Call CSRSS */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepExitVDM),
|
2015-08-24 01:32:00 +00:00
|
|
|
sizeof(*ExitVdm));
|
2014-02-01 19:05:54 +00:00
|
|
|
|
|
|
|
/* Close the returned wait object handle, if any */
|
|
|
|
if (NT_SUCCESS(ApiMessage.Status) && (ExitVdm->WaitObjectForVDM != NULL))
|
|
|
|
{
|
|
|
|
CloseHandle(ExitVdm->WaitObjectForVDM);
|
|
|
|
}
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2014-03-29 04:05:09 +00:00
|
|
|
* @implemented
|
2011-07-22 02:13:57 +00:00
|
|
|
*/
|
2014-03-29 04:05:09 +00:00
|
|
|
BOOL
|
2011-07-22 02:13:57 +00:00
|
|
|
WINAPI
|
2014-03-02 02:50:40 +00:00
|
|
|
GetNextVDMCommand(PVDM_COMMAND_INFO CommandData)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2015-09-12 16:23:32 +00:00
|
|
|
BOOL Success = FALSE;
|
2014-03-29 04:05:09 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
BASE_API_MESSAGE ApiMessage;
|
|
|
|
PBASE_GET_NEXT_VDM_COMMAND GetNextVdmCommand = &ApiMessage.Data.GetNextVDMCommandRequest;
|
|
|
|
PBASE_IS_FIRST_VDM IsFirstVdm = &ApiMessage.Data.IsFirstVDMRequest;
|
2014-04-01 02:57:49 +00:00
|
|
|
PBASE_SET_REENTER_COUNT SetReenterCount = &ApiMessage.Data.SetReenterCountRequest;
|
2014-03-29 04:05:09 +00:00
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
|
2014-04-01 02:57:49 +00:00
|
|
|
ULONG NumStrings = 0;
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/*
|
|
|
|
* Special case to test whether the VDM is the first one.
|
|
|
|
*/
|
|
|
|
if (CommandData == NULL)
|
2014-03-29 04:05:09 +00:00
|
|
|
{
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Call CSRSS */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepIsFirstVDM),
|
|
|
|
sizeof(*IsFirstVdm));
|
|
|
|
if (!NT_SUCCESS(ApiMessage.Status))
|
2015-04-23 02:30:53 +00:00
|
|
|
{
|
2015-09-12 16:23:32 +00:00
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
|
|
|
return FALSE;
|
2015-04-23 02:30:53 +00:00
|
|
|
}
|
2015-09-12 16:23:32 +00:00
|
|
|
|
|
|
|
/* Return TRUE if this is the first VDM */
|
|
|
|
return IsFirstVdm->FirstVDM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CommandData != NULL */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Special case to increment or decrement the reentrancy count.
|
|
|
|
*/
|
|
|
|
if ((CommandData->VDMState == VDM_INC_REENTER_COUNT) ||
|
|
|
|
(CommandData->VDMState == VDM_DEC_REENTER_COUNT))
|
|
|
|
{
|
|
|
|
/* Setup the input parameters */
|
|
|
|
SetReenterCount->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
SetReenterCount->fIncDec = CommandData->VDMState;
|
|
|
|
|
|
|
|
/* Call CSRSS */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
NULL,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepSetReenterCount),
|
|
|
|
sizeof(*SetReenterCount));
|
|
|
|
if (!NT_SUCCESS(ApiMessage.Status))
|
2014-03-29 04:05:09 +00:00
|
|
|
{
|
2015-09-12 16:23:32 +00:00
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/*
|
|
|
|
* TODO!
|
|
|
|
* Special case to retrieve or set WOW information.
|
|
|
|
*/
|
|
|
|
// TODO: if CommandData->VDMState & (VDM_LIST_WOW_PROCESSES | VDM_LIST_WOW_TASKS | VDM_ADD_WOW_TASK)
|
|
|
|
// then call BasepGetNextVDMCommand in a simpler way!
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/*
|
|
|
|
* Regular case.
|
|
|
|
*/
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Clear the structure */
|
|
|
|
RtlZeroMemory(GetNextVdmCommand, sizeof(*GetNextVdmCommand));
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Setup the input parameters */
|
|
|
|
GetNextVdmCommand->iTask = CommandData->TaskId;
|
|
|
|
GetNextVdmCommand->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
GetNextVdmCommand->CmdLen = CommandData->CmdLen;
|
|
|
|
GetNextVdmCommand->AppLen = CommandData->AppLen;
|
|
|
|
GetNextVdmCommand->PifLen = CommandData->PifLen;
|
|
|
|
GetNextVdmCommand->CurDirectoryLen = CommandData->CurDirectoryLen;
|
|
|
|
GetNextVdmCommand->EnvLen = CommandData->EnvLen;
|
|
|
|
GetNextVdmCommand->DesktopLen = CommandData->DesktopLen;
|
|
|
|
GetNextVdmCommand->TitleLen = CommandData->TitleLen;
|
|
|
|
GetNextVdmCommand->ReservedLen = CommandData->ReservedLen;
|
|
|
|
GetNextVdmCommand->VDMState = CommandData->VDMState;
|
|
|
|
|
|
|
|
/* Count the number of strings */
|
|
|
|
if (CommandData->CmdLen) NumStrings++;
|
|
|
|
if (CommandData->AppLen) NumStrings++;
|
|
|
|
if (CommandData->PifLen) NumStrings++;
|
|
|
|
if (CommandData->CurDirectoryLen) NumStrings++;
|
|
|
|
if (CommandData->EnvLen) NumStrings++;
|
|
|
|
if (CommandData->DesktopLen) NumStrings++;
|
|
|
|
if (CommandData->TitleLen) NumStrings++;
|
|
|
|
if (CommandData->ReservedLen) NumStrings++;
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Allocate the capture buffer */
|
|
|
|
CaptureBuffer = CsrAllocateCaptureBuffer(NumStrings + 1,
|
|
|
|
GetNextVdmCommand->CmdLen
|
|
|
|
+ GetNextVdmCommand->AppLen
|
|
|
|
+ GetNextVdmCommand->PifLen
|
|
|
|
+ GetNextVdmCommand->CurDirectoryLen
|
|
|
|
+ GetNextVdmCommand->EnvLen
|
|
|
|
+ GetNextVdmCommand->DesktopLen
|
|
|
|
+ GetNextVdmCommand->TitleLen
|
|
|
|
+ GetNextVdmCommand->ReservedLen
|
|
|
|
+ sizeof(*GetNextVdmCommand->StartupInfo));
|
|
|
|
if (CaptureBuffer == NULL)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Capture the data */
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
sizeof(*GetNextVdmCommand->StartupInfo),
|
|
|
|
(PVOID*)&GetNextVdmCommand->StartupInfo);
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->CmdLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->CmdLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->CmdLine);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->AppLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->AppLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->AppName);
|
|
|
|
}
|
2014-04-01 02:57:49 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->PifLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->PifLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->PifFile);
|
|
|
|
}
|
2014-05-01 23:52:36 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->CurDirectoryLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->CurDirectoryLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->CurDirectory);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->EnvLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->EnvLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->Env);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->DesktopLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->DesktopLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->Desktop);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->TitleLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->TitleLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->Title);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->ReservedLen)
|
|
|
|
{
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
CommandData->ReservedLen,
|
|
|
|
(PVOID*)&GetNextVdmCommand->Reserved);
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
/* Call CSRSS */
|
|
|
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
CaptureBuffer,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepGetNextVDMCommand),
|
|
|
|
sizeof(*GetNextVdmCommand));
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Exit the waiting loop if we did not receive any event handle */
|
|
|
|
if (GetNextVdmCommand->WaitObjectForVDM == NULL)
|
|
|
|
break;
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Wait for the event to become signaled and try again */
|
|
|
|
Status = NtWaitForSingleObject(GetNextVdmCommand->WaitObjectForVDM,
|
|
|
|
FALSE, NULL);
|
|
|
|
if (Status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
/* Fail if we timed out, or if some other error happened */
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Set the retry flag, clear the exit code, and retry a query */
|
|
|
|
GetNextVdmCommand->VDMState |= VDM_FLAG_RETRY;
|
|
|
|
GetNextVdmCommand->ExitCode = 0;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
if (Status == STATUS_INVALID_PARAMETER)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* One of the buffer lengths was less than required. Store the correct ones.
|
|
|
|
* Note that the status code is not STATUS_BUFFER_TOO_SMALL as one would expect,
|
|
|
|
* in order to keep compatibility with Windows 2003 BASESRV.DLL.
|
|
|
|
*/
|
|
|
|
CommandData->CmdLen = GetNextVdmCommand->CmdLen;
|
|
|
|
CommandData->AppLen = GetNextVdmCommand->AppLen;
|
|
|
|
CommandData->PifLen = GetNextVdmCommand->PifLen;
|
|
|
|
CommandData->CurDirectoryLen = GetNextVdmCommand->CurDirectoryLen;
|
|
|
|
CommandData->EnvLen = GetNextVdmCommand->EnvLen;
|
|
|
|
CommandData->DesktopLen = GetNextVdmCommand->DesktopLen;
|
|
|
|
CommandData->TitleLen = GetNextVdmCommand->TitleLen;
|
|
|
|
CommandData->ReservedLen = GetNextVdmCommand->ReservedLen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Any other failure */
|
|
|
|
CommandData->CmdLen = 0;
|
|
|
|
CommandData->AppLen = 0;
|
|
|
|
CommandData->PifLen = 0;
|
|
|
|
CommandData->CurDirectoryLen = 0;
|
|
|
|
CommandData->EnvLen = 0;
|
|
|
|
CommandData->DesktopLen = 0;
|
|
|
|
CommandData->TitleLen = 0;
|
|
|
|
CommandData->ReservedLen = 0;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Write back the standard handles */
|
|
|
|
CommandData->StdIn = GetNextVdmCommand->StdIn;
|
|
|
|
CommandData->StdOut = GetNextVdmCommand->StdOut;
|
|
|
|
CommandData->StdErr = GetNextVdmCommand->StdErr;
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Write back the startup info */
|
|
|
|
RtlMoveMemory(&CommandData->StartupInfo,
|
|
|
|
GetNextVdmCommand->StartupInfo,
|
|
|
|
sizeof(*GetNextVdmCommand->StartupInfo));
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->CmdLen)
|
|
|
|
{
|
|
|
|
/* Write back the command line */
|
|
|
|
RtlMoveMemory(CommandData->CmdLine,
|
|
|
|
GetNextVdmCommand->CmdLine,
|
|
|
|
GetNextVdmCommand->CmdLen);
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->CmdLen = GetNextVdmCommand->CmdLen;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->AppLen)
|
|
|
|
{
|
|
|
|
/* Write back the application name */
|
|
|
|
RtlMoveMemory(CommandData->AppName,
|
|
|
|
GetNextVdmCommand->AppName,
|
|
|
|
GetNextVdmCommand->AppLen);
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->AppLen = GetNextVdmCommand->AppLen;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->PifLen)
|
|
|
|
{
|
|
|
|
/* Write back the PIF file name */
|
|
|
|
RtlMoveMemory(CommandData->PifFile,
|
|
|
|
GetNextVdmCommand->PifFile,
|
|
|
|
GetNextVdmCommand->PifLen);
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->PifLen = GetNextVdmCommand->PifLen;
|
|
|
|
}
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
if (CommandData->CurDirectoryLen)
|
|
|
|
{
|
|
|
|
/* Write back the current directory */
|
|
|
|
RtlMoveMemory(CommandData->CurDirectory,
|
|
|
|
GetNextVdmCommand->CurDirectory,
|
|
|
|
GetNextVdmCommand->CurDirectoryLen);
|
|
|
|
|
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->CurDirectoryLen = GetNextVdmCommand->CurDirectoryLen;
|
2014-03-29 04:05:09 +00:00
|
|
|
}
|
2015-09-12 16:23:32 +00:00
|
|
|
|
|
|
|
if (CommandData->EnvLen)
|
2014-03-29 04:05:09 +00:00
|
|
|
{
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Write back the environment */
|
|
|
|
RtlMoveMemory(CommandData->Env,
|
|
|
|
GetNextVdmCommand->Env,
|
|
|
|
GetNextVdmCommand->EnvLen);
|
2014-03-29 04:05:09 +00:00
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->EnvLen = GetNextVdmCommand->EnvLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommandData->DesktopLen)
|
|
|
|
{
|
|
|
|
/* Write back the desktop name */
|
|
|
|
RtlMoveMemory(CommandData->Desktop,
|
|
|
|
GetNextVdmCommand->Desktop,
|
|
|
|
GetNextVdmCommand->DesktopLen);
|
|
|
|
|
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->DesktopLen = GetNextVdmCommand->DesktopLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommandData->TitleLen)
|
|
|
|
{
|
|
|
|
/* Write back the title */
|
|
|
|
RtlMoveMemory(CommandData->Title,
|
|
|
|
GetNextVdmCommand->Title,
|
|
|
|
GetNextVdmCommand->TitleLen);
|
|
|
|
|
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->TitleLen = GetNextVdmCommand->TitleLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommandData->ReservedLen)
|
|
|
|
{
|
|
|
|
/* Write back the reserved parameter */
|
|
|
|
RtlMoveMemory(CommandData->Reserved,
|
|
|
|
GetNextVdmCommand->Reserved,
|
|
|
|
GetNextVdmCommand->ReservedLen);
|
|
|
|
|
|
|
|
/* Set the actual length */
|
|
|
|
CommandData->ReservedLen = GetNextVdmCommand->ReservedLen;
|
2014-03-29 04:05:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-12 16:23:32 +00:00
|
|
|
/* Write the remaining output parameters */
|
|
|
|
CommandData->TaskId = GetNextVdmCommand->iTask;
|
|
|
|
CommandData->CreationFlags = GetNextVdmCommand->dwCreationFlags;
|
|
|
|
CommandData->CodePage = GetNextVdmCommand->CodePage;
|
|
|
|
CommandData->ExitCode = GetNextVdmCommand->ExitCode;
|
|
|
|
CommandData->CurrentDrive = GetNextVdmCommand->CurrentDrive;
|
|
|
|
CommandData->VDMState = GetNextVdmCommand->VDMState;
|
|
|
|
CommandData->ComingFromBat = GetNextVdmCommand->fComingFromBat;
|
|
|
|
|
|
|
|
/* It was successful */
|
|
|
|
Success = TRUE;
|
|
|
|
|
2014-03-29 04:05:09 +00:00
|
|
|
Cleanup:
|
|
|
|
if (CaptureBuffer != NULL) CsrFreeCaptureBuffer(CaptureBuffer);
|
2015-09-12 16:23:32 +00:00
|
|
|
return Success;
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-02-10 13:56:55 +00:00
|
|
|
* @implemented
|
2011-07-22 02:13:57 +00:00
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
2014-02-10 13:56:55 +00:00
|
|
|
GetVDMCurrentDirectories(DWORD cchCurDirs, PCHAR lpszzCurDirs)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2014-02-10 13:56:55 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
|
|
|
PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &ApiMessage.Data.VDMCurrentDirsRequest;
|
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
|
|
|
|
|
|
|
/* Allocate the capture buffer */
|
|
|
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, cchCurDirs);
|
|
|
|
if (CaptureBuffer == NULL)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the input parameters */
|
|
|
|
VDMCurrentDirsRequest->cchCurDirs = cchCurDirs;
|
|
|
|
CsrAllocateMessagePointer(CaptureBuffer,
|
|
|
|
cchCurDirs,
|
|
|
|
(PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs);
|
|
|
|
|
|
|
|
/* Call CSRSS */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
CaptureBuffer,
|
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepGetVDMCurDirs),
|
2015-08-24 01:32:00 +00:00
|
|
|
sizeof(*VDMCurrentDirsRequest));
|
2014-02-10 13:56:55 +00:00
|
|
|
|
|
|
|
/* Set the last error */
|
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
|
|
|
|
|
|
|
if (NT_SUCCESS(ApiMessage.Status))
|
|
|
|
{
|
|
|
|
/* Copy the result */
|
|
|
|
RtlMoveMemory(lpszzCurDirs, VDMCurrentDirsRequest->lpszzCurDirs, cchCurDirs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the capture buffer */
|
|
|
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
|
|
|
|
|
|
|
/* Return the size if it was successful, or if the buffer was too small */
|
|
|
|
return (NT_SUCCESS(ApiMessage.Status) || (ApiMessage.Status == STATUS_BUFFER_TOO_SMALL))
|
|
|
|
? VDMCurrentDirsRequest->cchCurDirs : 0;
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-08-12 19:43:32 +00:00
|
|
|
* @implemented (undocumented)
|
2011-07-22 02:13:57 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
2014-08-12 19:43:32 +00:00
|
|
|
RegisterConsoleVDM(IN DWORD dwRegisterFlags,
|
|
|
|
IN HANDLE hStartHardwareEvent,
|
|
|
|
IN HANDLE hEndHardwareEvent,
|
|
|
|
IN HANDLE hErrorHardwareEvent,
|
|
|
|
IN DWORD dwUnusedVar,
|
|
|
|
OUT LPDWORD lpVideoStateLength,
|
|
|
|
OUT PVOID* lpVideoState, // PVIDEO_HARDWARE_STATE_HEADER*
|
|
|
|
IN PVOID lpUnusedBuffer,
|
|
|
|
IN DWORD dwUnusedBufferLength,
|
|
|
|
IN COORD dwVDMBufferSize,
|
|
|
|
OUT PVOID* lpVDMBuffer)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2014-08-12 19:43:32 +00:00
|
|
|
BOOL Success;
|
|
|
|
CONSOLE_API_MESSAGE ApiMessage;
|
|
|
|
PCONSOLE_REGISTERVDM RegisterVDMRequest = &ApiMessage.Data.RegisterVDMRequest;
|
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
|
|
|
|
|
|
|
|
/* Set up the data to send to the Console Server */
|
|
|
|
RegisterVDMRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
|
|
|
RegisterVDMRequest->RegisterFlags = dwRegisterFlags;
|
|
|
|
|
|
|
|
if (dwRegisterFlags != 0)
|
|
|
|
{
|
|
|
|
RegisterVDMRequest->StartHardwareEvent = hStartHardwareEvent;
|
|
|
|
RegisterVDMRequest->EndHardwareEvent = hEndHardwareEvent;
|
|
|
|
RegisterVDMRequest->ErrorHardwareEvent = hErrorHardwareEvent;
|
|
|
|
|
|
|
|
RegisterVDMRequest->VDMBufferSize = dwVDMBufferSize;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
RegisterVDMRequest->UnusedBufferLength = dwUnusedBufferLength;
|
|
|
|
|
|
|
|
/* Allocate a Capture Buffer */
|
|
|
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, dwUnusedBufferLength);
|
|
|
|
if (CaptureBuffer == NULL)
|
|
|
|
{
|
|
|
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Capture the buffer to write */
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
(PVOID)lpUnusedBuffer,
|
|
|
|
dwUnusedBufferLength,
|
|
|
|
(PVOID*)&RegisterVDMRequest->UnusedBuffer);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// CaptureBuffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the server */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
CaptureBuffer,
|
|
|
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepRegisterVDM),
|
|
|
|
sizeof(*RegisterVDMRequest));
|
|
|
|
|
|
|
|
/* Check for success */
|
|
|
|
Success = NT_SUCCESS(ApiMessage.Status);
|
|
|
|
|
|
|
|
/* Release the capture buffer if needed */
|
|
|
|
if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
|
|
|
|
|
|
|
|
/* Retrieve the results */
|
|
|
|
if (Success)
|
|
|
|
{
|
|
|
|
if (dwRegisterFlags != 0)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
*lpVideoStateLength = RegisterVDMRequest->VideoStateLength;
|
|
|
|
*lpVideoState = RegisterVDMRequest->VideoState;
|
|
|
|
*lpVDMBuffer = RegisterVDMRequest->VDMBuffer;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_ACCESS);
|
|
|
|
Success = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return success status */
|
|
|
|
return Success;
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
RegisterWowBaseHandlers (
|
|
|
|
DWORD Unknown0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
RegisterWowExec (
|
|
|
|
DWORD Unknown0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-02-10 14:24:36 +00:00
|
|
|
* @implemented
|
2011-07-22 02:13:57 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
2014-02-10 14:24:36 +00:00
|
|
|
SetVDMCurrentDirectories(DWORD cchCurDirs, PCHAR lpszzCurDirs)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2014-02-10 14:24:36 +00:00
|
|
|
BASE_API_MESSAGE ApiMessage;
|
|
|
|
PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &ApiMessage.Data.VDMCurrentDirsRequest;
|
|
|
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
|
|
|
|
|
|
|
/* Allocate the capture buffer */
|
|
|
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, cchCurDirs);
|
|
|
|
if (CaptureBuffer == NULL)
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(STATUS_NO_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the input parameters */
|
|
|
|
VDMCurrentDirsRequest->cchCurDirs = cchCurDirs;
|
|
|
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
|
|
|
lpszzCurDirs,
|
|
|
|
cchCurDirs,
|
|
|
|
(PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs);
|
|
|
|
|
|
|
|
/* Call CSRSS */
|
|
|
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
|
|
|
CaptureBuffer,
|
2014-02-10 14:26:41 +00:00
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepSetVDMCurDirs),
|
2015-08-24 01:32:00 +00:00
|
|
|
sizeof(*VDMCurrentDirsRequest));
|
2014-02-10 14:24:36 +00:00
|
|
|
|
|
|
|
/* Free the capture buffer */
|
|
|
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
|
|
|
|
|
|
|
/* Set the last error */
|
|
|
|
BaseSetLastNTError(ApiMessage.Status);
|
|
|
|
|
|
|
|
return NT_SUCCESS(ApiMessage.Status) ? TRUE : FALSE;
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
VDMConsoleOperation (
|
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2014-05-02 17:11:13 +00:00
|
|
|
BOOL
|
2011-07-22 02:13:57 +00:00
|
|
|
WINAPI
|
2014-05-02 17:11:13 +00:00
|
|
|
VDMOperationStarted(IN ULONG Unknown0)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
2014-05-02 17:11:13 +00:00
|
|
|
DPRINT1("VDMOperationStarted(%d)\n", Unknown0);
|
|
|
|
|
2014-08-12 19:43:32 +00:00
|
|
|
return BaseUpdateVDMEntry(VdmEntryUpdateControlCHandler,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
Unknown0);
|
2011-07-22 02:13:57 +00:00
|
|
|
}
|