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 **********************************************************************/
|
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
typedef struct _ENV_INFO
|
|
|
|
{
|
|
|
|
ULONG NameType;
|
|
|
|
ULONG NameLength;
|
|
|
|
PWCHAR Name;
|
|
|
|
} ENV_INFO, *PENV_INFO;
|
|
|
|
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
|
|
|
|
ENV_INFO BasepEnvNameType[] =
|
|
|
|
{
|
2013-08-22 12:47:14 +00:00
|
|
|
{3, sizeof(L"PATH") , L"PATH" },
|
|
|
|
{2, sizeof(L"WINDIR") , L"WINDIR" },
|
2011-12-20 16:53:11 +00:00
|
|
|
{2, sizeof(L"SYSTEMROOT"), L"SYSTEMROOT"},
|
2013-08-22 12:47:14 +00:00
|
|
|
{3, sizeof(L"TEMP") , L"TEMP" },
|
|
|
|
{3, sizeof(L"TMP") , L"TMP" },
|
2011-12-20 16:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
UNICODE_STRING BaseDotComSuffixName = RTL_CONSTANT_STRING(L".com");
|
|
|
|
UNICODE_STRING BaseDotPifSuffixName = RTL_CONSTANT_STRING(L".pif");
|
|
|
|
UNICODE_STRING BaseDotExeSuffixName = RTL_CONSTANT_STRING(L".exe");
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
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,
|
2012-11-02 18:00:47 +00:00
|
|
|
IN PCSR_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
|
|
|
{
|
|
|
|
/* This is not supported */
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
BaseUpdateVDMEntry(IN ULONG UpdateIndex,
|
|
|
|
IN OUT PHANDLE WaitHandle,
|
|
|
|
IN ULONG IndexInfo,
|
|
|
|
IN ULONG BinaryType)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
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 */
|
2012-11-02 18:00:47 +00:00
|
|
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
2012-10-17 23:10:40 +00:00
|
|
|
NULL,
|
2012-10-20 21:03:32 +00:00
|
|
|
CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepUpdateVDMEntry),
|
2012-11-02 18:00:47 +00:00
|
|
|
sizeof(BASE_UPDATE_VDM_ENTRY));
|
2013-03-09 22:16:26 +00:00
|
|
|
if (!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
|
|
|
{
|
|
|
|
/* Handle failure */
|
2013-03-09 22:16:26 +00:00
|
|
|
BaseSetLastNTError(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),
|
2012-11-02 18:00:47 +00:00
|
|
|
sizeof(BASE_GET_VDM_EXIT_CODE));
|
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,
|
|
|
|
sizeof(CommandLine),
|
|
|
|
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,
|
|
|
|
sizeof(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT
|
|
|
|
WINAPI
|
|
|
|
BaseGetEnvNameType_U(IN PWCHAR Name,
|
|
|
|
IN ULONG NameLength)
|
|
|
|
{
|
|
|
|
PENV_INFO EnvInfo;
|
|
|
|
ULONG NameType, i;
|
|
|
|
|
|
|
|
/* Start by assuming unknown type */
|
|
|
|
NameType = 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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Loop all the environment names */
|
|
|
|
for (i = 0; i < (sizeof(BasepEnvNameType) / sizeof(ENV_INFO)); i++)
|
|
|
|
{
|
|
|
|
/* 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) &&
|
|
|
|
!(_wcsnicmp(EnvInfo->Name, Name, NameLength)))
|
|
|
|
{
|
|
|
|
/* 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 what we found, or unknown if nothing */
|
|
|
|
return NameType;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
BaseDestroyVDMEnvironment(IN PANSI_STRING AnsiEnv,
|
|
|
|
IN PUNICODE_STRING UnicodeEnv)
|
|
|
|
{
|
|
|
|
ULONG Dummy = 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
|
|
|
/* Clear the ASCII buffer since Rtl creates this for us */
|
|
|
|
if (AnsiEnv->Buffer) RtlFreeAnsiString(AnsiEnv);
|
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
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
NTAPI
|
|
|
|
BaseCreateVDMEnvironment(IN PWCHAR lpEnvironment,
|
|
|
|
IN PANSI_STRING AnsiEnv,
|
|
|
|
IN PUNICODE_STRING UnicodeEnv)
|
|
|
|
{
|
|
|
|
BOOL Result;
|
|
|
|
ULONG RegionSize, EnvironmentSize = 0;
|
2013-06-29 06:08:57 +00:00
|
|
|
PWCHAR p, Environment, NewEnvironment = NULL;
|
2011-12-20 16:53:11 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* Make sure we have both strings */
|
|
|
|
if (!(AnsiEnv) || !(UnicodeEnv))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if an environment was passed in */
|
|
|
|
if (!lpEnvironment)
|
|
|
|
{
|
|
|
|
/* Nope, create one */
|
|
|
|
Status = RtlCreateEnvironment(TRUE, (PWCHAR*)&Environment);
|
|
|
|
if (!NT_SUCCESS(Status)) goto Quickie;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Use the one we got */
|
|
|
|
Environment = lpEnvironment;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we have something now ? */
|
|
|
|
if (!Environment)
|
|
|
|
{
|
|
|
|
/* Still not, fail out */
|
|
|
|
SetLastError(ERROR_BAD_ENVIRONMENT);
|
|
|
|
goto Quickie;
|
|
|
|
}
|
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
|
|
|
/* Count how much space the whole environment takes */
|
|
|
|
p = Environment;
|
|
|
|
while ((*p++ != UNICODE_NULL) && (*p != UNICODE_NULL)) EnvironmentSize++;
|
|
|
|
EnvironmentSize += sizeof(UNICODE_NULL);
|
|
|
|
|
|
|
|
/* Allocate a new copy */
|
|
|
|
RegionSize = (EnvironmentSize + MAX_PATH) * sizeof(WCHAR);
|
|
|
|
if (!NT_SUCCESS(NtAllocateVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&NewEnvironment,
|
|
|
|
0,
|
|
|
|
&RegionSize,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE)))
|
|
|
|
{
|
|
|
|
/* We failed, bail out */
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
NewEnvironment = NULL;
|
|
|
|
goto Quickie;
|
|
|
|
}
|
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
|
|
|
/* Begin parsing the new environment */
|
|
|
|
p = NewEnvironment;
|
|
|
|
|
|
|
|
/* FIXME: Code here */
|
|
|
|
|
|
|
|
/* Terminate it */
|
|
|
|
*p++ = 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
|
|
|
|
2011-12-20 16:53:11 +00:00
|
|
|
/* Initialize the unicode string to hold it */
|
|
|
|
EnvironmentSize = (p - NewEnvironment) * sizeof(WCHAR);
|
2013-09-14 10:20:11 +00:00
|
|
|
RtlInitEmptyUnicodeString(UnicodeEnv, NewEnvironment, (USHORT)EnvironmentSize);
|
|
|
|
UnicodeEnv->Length = (USHORT)EnvironmentSize;
|
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 ASCII version of it */
|
|
|
|
Status = RtlUnicodeStringToAnsiString(AnsiEnv, UnicodeEnv, TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Set last error if conversion failure */
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Everything went okay, so return success */
|
|
|
|
Result = TRUE;
|
|
|
|
NewEnvironment = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Quickie:
|
|
|
|
/* Cleanup path starts here, start by destroying the envrionment 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 */
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mach-o File with Endian set to Big Endian or Little Endian*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!memcmp(magic, "NE", 1))
|
|
|
|
{
|
|
|
|
/* 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),
|
|
|
|
sizeof(BASE_EXIT_VDM));
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
2014-02-01 02:49:02 +00:00
|
|
|
GetNextVDMCommand(PGET_NEXT_VDM_COMMAND_DATA CommandData)
|
2011-07-22 02:13:57 +00:00
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
GetVDMCurrentDirectories (
|
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
RegisterConsoleVDM (
|
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1,
|
|
|
|
DWORD Unknown2,
|
|
|
|
DWORD Unknown3,
|
|
|
|
DWORD Unknown4,
|
|
|
|
DWORD Unknown5,
|
|
|
|
DWORD Unknown6,
|
|
|
|
DWORD Unknown7,
|
|
|
|
DWORD Unknown8,
|
|
|
|
DWORD Unknown9,
|
|
|
|
DWORD Unknown10
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
RegisterWowBaseHandlers (
|
|
|
|
DWORD Unknown0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
RegisterWowExec (
|
|
|
|
DWORD Unknown0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
SetVDMCurrentDirectories (
|
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
VDMConsoleOperation (
|
|
|
|
DWORD Unknown0,
|
|
|
|
DWORD Unknown1
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
WINAPI
|
|
|
|
VDMOperationStarted (
|
|
|
|
DWORD Unknown0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
STUB;
|
|
|
|
return 0;
|
|
|
|
}
|