reactos/boot/environ/CMakeLists.txt
Joachim Henze f9dc3a86b6 [0.4.11][WIN32SS][RTL] Fix regression CORE-16769 + BSOD 0x50 CORE-13907
The main motivation to port all that back is to get rid of Win32K-BSODs 0x50 like CORE-13907
that could be triggered by user-mode-applications.
Technical reason was CORE-14857 "RtlImageNtHeaderEx needs SEH" and issues with hooks+callbacks.
All other tickets mentioned in here were regressions that we experienced on the long
journey towards perfecting the fixes on master head, and those were not happening yet in the older builds,
so they are mentioned in here only to allow tracking where that code went into.

Thanks to Jim Tabor, Mark Jansen & Thomas Faber
By squashed backmerge of the following commits:
0.4.15-dev-3440-g a89844f740
0.4.15-dev-3430-g 9cff384c22
0.4.14-dev-1287-g 568b6d0558
0.4.14-dev-1255-g 177ae91bf6
0.4.14-dev-1241-g 915a5764a9
0.4.14-dev-1240-g d8add40e89
0.4.14-dev-1002-g feb7df42b4

JIRA-tickets: CORE-13907, CORE-16769, CORE-14857, CORE-17856, CORE-17857, partially CORE-13019.
We also had some more dupes of CORE-13907 in JIRA, but I linked all of them (transitively)
towards the initial report, and resolved them without setting a fixVer for them.

In more detail:
--------------
[USER32] Fix BSOD 0x50 in 'WineVDM + Castle Of Winds' CORE-17856 CORE-17857

CORE-17856 BSOD 0x50 when starting Castle of the Winds second time, with WineVDM
CORE-17857 BSOD 0x50 on shutdown after closing Castle of the Winds with WineVDM

0.4.15-dev-3430-g 9cff384c22
0.4.15-dev-3440-g a89844f740
--------------
[NTUSER] Fix Strings and Format to Hooks

Allocate heap instead of data segment to be used for callbacks on user side.
Move and correct initial hook call out setup. Use it in more than one hook call.

This fixes issues with strings out of alignment and use of kernel pointers.

See CORE-13907 (HXD-portable BSOD) and CORE-16769 (HXD-portable exception)

Small wow update.

cherry picked from commit 0.4.14-dev-1287-g 568b6d0558
--------------
[RTL] Introduce RtlpImageNtHeader,
which implements the required functionality.
ntdll and ntoskrnl now have a wrapper for this, with SEH.
This protects the function against malformed / bad images,
whilst still being able to use the code in freeldr et al.
Idea from Thomas.
CORE-14857

cherry picked from commit 0.4.14-dev-1255-g 177ae91bf6
--------------
[WIN32SS] Form Sanity to Hook Callbacks

Fix WH_CALLWNDPROC/RET data to user hook calls.
Helps with CORE-13907 "(HXD-portable BSOD)"
Fixes the logging of "(win32ss/user/ntuser/callback.c:748) err: Failure to make Callback! Status 0xc00000fd" within CORE-13019, but not the whole ticket.

cherry picked from commit 0.4.14-dev-1241-g 915a5764a9
--------------
[USER32] Fix null return.

See CORE-16769 "HxD 1.7.7.0 portable unhandled exception"

cherry picked from commit 0.4.14-dev-1240-g d8add40e89
--------------
[WIN32SS] Fix a typo in dbg print

cherry picked from commit 0.4.14-dev-1002-g feb7df42b4
2022-03-17 14:00:15 +01:00

160 lines
4 KiB
CMake

include_directories(BEFORE include)
include_directories(BEFORE include/efi)
include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/cmlib)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs)
include_directories(${REACTOS_SOURCE_DIR}/drivers/filesystems)
add_definitions(-D_NTHAL_ -D_BLDR_ -D_NTSYSTEM_)
list(APPEND BOOTLIB_SOURCE
app/bootmgr/bootmgr.h
lib/bootlib.c
lib/misc/debug.c
lib/misc/bcd.c
lib/misc/bcdopt.c
lib/misc/bootreg.c
lib/misc/util.c
lib/misc/image.c
lib/misc/resource.c
lib/misc/font.c
lib/misc/rtlcompat.c
lib/rtl/libsupp.c
lib/firmware/fwutil.c
lib/firmware/efi/firmware.c
lib/mm/mm.c
lib/mm/pagealloc.c
lib/mm/heapalloc.c
lib/mm/blkalloc.c
lib/mm/descriptor.c
lib/platform/time.c
lib/io/blkcache.c
lib/io/etfs.c
lib/io/io.c
lib/io/device.c
lib/io/file.c
lib/io/fat.c
lib/io/display/display.c
lib/io/display/emscons.c
lib/io/display/guicons.c
lib/io/display/textcons.c
lib/io/display/efi/textcons.c
lib/io/display/efi/guicons.c
lib/io/display/efi/gop.c
lib/io/display/efi/uga.c)
if(ARCH STREQUAL "i386")
list(APPEND BOOTLIB_ASM_SOURCE
lib/arch/i386/transfer.s
)
list(APPEND BOOTLIB_SOURCE
lib/arch/i386/arch.c
lib/mm/i386/mmx86.c
)
elseif(ARCH STREQUAL "amd64")
list(APPEND BOOTLIB_ASM_SOURCE
#lib/arch/amd64/foo.asm
)
list(APPEND BOOTLIB_SOURCE
#lib/arch/amd64/foo.c
lib/arch/stub/arch.c
lib/mm/stub/mm.c
)
else()
list(APPEND BOOTLIB_SOURCE
lib/arch/stub/arch.c
lib/mm/stub/mm.c
)
endif()
add_asm_files(bootlib_asm ${BOOTLIB_ASM_SOURCE})
add_library(bootlib ${BOOTLIB_SOURCE} ${bootlib_asm})
add_pch(bootlib app/bootmgr/bootmgr.h BOOTLIB_SOURCE)
add_dependencies(bootlib bugcodes asm bootmsg xdk)
list(APPEND BOOTMGR_BASE_SOURCE
app/bootmgr/efiemu.c
app/bootmgr/bootmgr.c
)
add_executable(bootmgfw ${BOOTMGR_BASE_SOURCE} app/bootmgr/bootmgr.rc)
set_target_properties(bootmgfw PROPERTIES SUFFIX ".efi")
if(MSVC)
if (ARCH STREQUAL "arm")
add_target_link_flags(bootmgfw "/ignore:4078 /ignore:4254 /DRIVER")
else()
add_target_link_flags(bootmgfw "/ignore:4078 /ignore:4254 /DRIVER /FIXED")
endif()
else()
add_target_link_flags(bootmgfw "-Wl,--strip-all,--exclude-all-symbols")
endif()
set_image_base(bootmgfw 0x10000)
if(MSVC)
set_subsystem(bootmgfw EFI_APPLICATION)
else()
set_subsystem(bootmgfw 10)
endif()
set_entrypoint(bootmgfw EfiEntry)
target_link_libraries(bootmgfw bootlib cportlib cmlib rtl libcntpr)
if(STACK_PROTECTOR)
target_link_libraries(bootmgfw gcc_ssp)
elseif(RUNTIME_CHECKS)
target_link_libraries(bootmgfw runtmchk)
endif()
add_dependencies(bootmgfw asm bugcodes)
list(APPEND ROSLOAD_BASE_SOURCE
app/rosload/rosload.c
app/rosload/roslogo.c
)
if(ARCH STREQUAL "i386")
list(APPEND ROSLOAD_ASM_SOURCE
app/rosload/i386/osxfera.s
)
endif()
add_asm_files(rosload_asm ${ROSLOAD_ASM_SOURCE})
add_executable(rosload ${ROSLOAD_BASE_SOURCE} ${rosload_asm})
set_target_properties(rosload PROPERTIES SUFFIX ".efi")
if(MSVC)
add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER")
else()
add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols,--dynamicbase,--pic-executable")
endif()
set_image_base(rosload 0x10000)
if(MSVC)
set_subsystem(rosload BOOT_APPLICATION)
else()
set_subsystem(rosload 16)
endif()
if(ARCH STREQUAL "i386")
set_entrypoint(rosload OslMain 4)
else()
set_entrypoint(rosload OslMain)
endif()
target_link_libraries(rosload bootlib cportlib cmlib rtl libcntpr)
if(STACK_PROTECTOR)
target_link_libraries(rosload gcc_ssp)
elseif(RUNTIME_CHECKS)
target_link_libraries(rosload runtmchk)
endif()
add_dependencies(rosload asm bugcodes)
add_cd_file(TARGET rosload DESTINATION reactos/system32/boot NO_CAB FOR all)