From 8d3045622e59e178b732a8a4e4d414982aa77901 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sun, 8 Apr 2018 22:28:29 +0300 Subject: [PATCH] [RTL] actctx.c: Use an alternative implicit activation context when an application is built for latest windows versions. Instead of loading systemcompatible.manifest as the implicit activation context, load forwardcompatible.manifest Add a new assembly containing all apisets called ReactOS.Apisets and make it a dependency to forwardcompatible.manifest --- boot/bootdata/packages/reactos.dff.in | 2 + dll/apisets/CMakeLists.txt | 4 +- dll/apisets/CMakeLists.txt.in | 4 +- ...64144ccf1df_1.0.0.0_none_deadbeef.manifest | 212 ++++++++++++++++++ media/CMakeLists.txt | 3 +- media/forwardcompatible.manifest | 14 ++ sdk/cmake/CMakeMacros.cmake | 4 + sdk/lib/rtl/actctx.c | 29 ++- 8 files changed, 268 insertions(+), 4 deletions(-) create mode 100644 dll/apisets/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest create mode 100644 media/forwardcompatible.manifest diff --git a/boot/bootdata/packages/reactos.dff.in b/boot/bootdata/packages/reactos.dff.in index 652aa91943b..96ace64430f 100644 --- a/boot/bootdata/packages/reactos.dff.in +++ b/boot/bootdata/packages/reactos.dff.in @@ -76,6 +76,8 @@ Signature = "$ReactOS$" 56 = winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.2600.2982_none_deadbeef 57 = winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.2982_none_deadbeef 58 = winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.23038_none_deadbeef +59 = winsxs\x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef +60 = winsxs\x86_reactos.newapi_6595b64144ccf1df_1.0.0.0_none_deadbeef .InfEnd diff --git a/dll/apisets/CMakeLists.txt b/dll/apisets/CMakeLists.txt index aaf12c3880d..facffcb5791 100644 --- a/dll/apisets/CMakeLists.txt +++ b/dll/apisets/CMakeLists.txt @@ -32,9 +32,11 @@ function (add_apiset apiset_name baseaddress) add_importlibs(${apiset_name} ${ARGN} kernel32 ntdll) - add_cd_file(TARGET ${apiset_name} DESTINATION reactos/system32 FOR all) + add_cd_file(TARGET ${apiset_name} DESTINATION reactos/winsxs/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef FOR all) endfunction() +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest DESTINATION reactos/winsxs/manifests FOR all) + # Apisets will be appended add_apiset(api-ms-win-appmodel-identity-l1-1-0 0x60000000 ) diff --git a/dll/apisets/CMakeLists.txt.in b/dll/apisets/CMakeLists.txt.in index 2399d21bf17..cbe9003f467 100644 --- a/dll/apisets/CMakeLists.txt.in +++ b/dll/apisets/CMakeLists.txt.in @@ -32,8 +32,10 @@ function (add_apiset apiset_name baseaddress) add_importlibs(${apiset_name} ${ARGN} kernel32 ntdll) - add_cd_file(TARGET ${apiset_name} DESTINATION reactos/system32 FOR all) + add_cd_file(TARGET ${apiset_name} DESTINATION reactos/winsxs/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef FOR all) endfunction() +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest DESTINATION reactos/winsxs/manifests FOR all) + # Apisets will be appended diff --git a/dll/apisets/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest b/dll/apisets/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest new file mode 100644 index 00000000000..c7a556e629e --- /dev/null +++ b/dll/apisets/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef.manifest @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/CMakeLists.txt b/media/CMakeLists.txt index 508ab792140..dd2a78ea9f8 100644 --- a/media/CMakeLists.txt +++ b/media/CMakeLists.txt @@ -13,4 +13,5 @@ add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/drivers/etc/protocol DESTINATION re add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/drivers/etc/services DESTINATION reactos/system32/drivers/etc FOR all) add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/sounds/ReactOS_LogOn.wav DESTINATION reactos/media FOR all) -add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/systemcompatible.manifest DESTINATION reactos/winsxs/manifests FOR all) \ No newline at end of file +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/systemcompatible.manifest DESTINATION reactos/winsxs/manifests FOR all) +add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/forwardcompatible.manifest DESTINATION reactos/winsxs/manifests FOR all) diff --git a/media/forwardcompatible.manifest b/media/forwardcompatible.manifest new file mode 100644 index 00000000000..785d62f8dbb --- /dev/null +++ b/media/forwardcompatible.manifest @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 5f622e04e86..a103c74e295 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -281,6 +281,10 @@ macro(dir_to_num dir var) set(${var} 57) elseif(${dir} STREQUAL reactos/winsxs/x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.23038_none_deadbeef) set(${var} 58) + elseif(${dir} STREQUAL reactos/winsxs/x86_reactos.apisets_6595b64144ccf1df_1.0.0.0_none_deadbeef) + set(${var} 59) + elseif(${dir} STREQUAL reactos/winsxs/x86_reactos.newapi_6595b64144ccf1df_1.0.0.0_none_deadbeef) + set(${var} 60) else() message(FATAL_ERROR "Wrong destination: ${dir}") endif() diff --git a/sdk/lib/rtl/actctx.c b/sdk/lib/rtl/actctx.c index e70363c7d13..2fe56c1d6ac 100644 --- a/sdk/lib/rtl/actctx.c +++ b/sdk/lib/rtl/actctx.c @@ -4935,6 +4935,9 @@ void actctx_init(void) HANDLE handle; WCHAR buffer[1024]; NTSTATUS Status; + BOOLEAN bForwardCompatible = FALSE; + ULONG Buffer[(sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * 10 + sizeof(ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION)) / sizeof(ULONG)]; + SIZE_T SizeRequired; ctx.cbSize = sizeof(ctx); ctx.lpSource = NULL; @@ -4947,12 +4950,36 @@ void actctx_init(void) process_actctx = check_actctx(handle); } + /* FIXME: use RosGetProcessCompatVersion when PR419 gets merged */ + Status = RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF, + NULL, + NULL, + CompatibilityInformationInActivationContext, + Buffer, + sizeof(Buffer), + &SizeRequired); + if (NT_SUCCESS(Status)) + { + DPRINT("RtlQueryInformationActivationContext for CompatibilityInformationInActivationContext suceeded\n"); + ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION* ContextCompatInfo; + ContextCompatInfo = (ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION*)Buffer; + /* No Compatibility elements present, bail out */ + if (ContextCompatInfo->ElementCount != 0) + { + DPRINT1("Found compatibility information in exe manifest (%d). Attempting to activate forward compatibility!\n", ContextCompatInfo->ElementCount); + bForwardCompatible = TRUE; + } + } + ctx.dwFlags = 0; ctx.hModule = NULL; ctx.lpResourceName = NULL; ctx.lpSource = buffer; RtlStringCchCopyW(buffer, 1024, SharedUserData->NtSystemRoot); - RtlStringCchCatW(buffer, 1024, L"\\winsxs\\manifests\\systemcompatible.manifest"); + if (!bForwardCompatible) + RtlStringCchCatW(buffer, 1024, L"\\winsxs\\manifests\\systemcompatible.manifest"); + else + RtlStringCchCatW(buffer, 1024, L"\\winsxs\\manifests\\forwardcompatible.manifest"); Status = RtlCreateActivationContext(0, (PVOID)&ctx, 0, NULL, NULL, &handle); if (NT_SUCCESS(Status)) {