mirror of
https://github.com/reactos/reactos.git
synced 2026-05-23 07:40:09 +08:00
[VCRUNTIME] Implement _chkesp / _chkesp_failed
This commit is contained in:
@@ -7,6 +7,10 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/ucrt)
|
||||
|
||||
include_directories(inc)
|
||||
|
||||
if(DBG)
|
||||
add_compile_definitions(_DEBUG) # TODO: define this globally
|
||||
endif()
|
||||
|
||||
# Silence GCC/Clang warnings
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||
CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
@@ -25,6 +29,7 @@ add_compile_definitions(
|
||||
if(${ARCH} STREQUAL "i386")
|
||||
list(APPEND VCRT_COMMON_ASM_SOURCES
|
||||
i386/__security_check_cookie.s
|
||||
i386/_chkesp.s
|
||||
)
|
||||
elseif(${ARCH} STREQUAL "amd64")
|
||||
list(APPEND VCRT_COMMON_ASM_SOURCES
|
||||
@@ -96,6 +101,12 @@ list(APPEND VCRT_RUNTIME_SOURCES
|
||||
purecall.cpp
|
||||
)
|
||||
|
||||
if(${ARCH} STREQUAL "i386")
|
||||
list(APPEND VCRT_RUNTIME_SOURCES
|
||||
i386/_chkesp_failed.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# Runtime library (linked into ucrtbase)
|
||||
add_library(vcruntime ${VCRT_RUNTIME_SOURCES} $<TARGET_OBJECTS:vcrt_common> $<TARGET_OBJECTS:setjmp>)
|
||||
target_link_libraries(vcruntime ${PSEH_LIB})
|
||||
|
||||
22
sdk/lib/vcruntime/i386/_chkesp.s
Normal file
22
sdk/lib/vcruntime/i386/_chkesp.s
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* PROJECT: ReactOS vcruntime library
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Implementation of _chkesp
|
||||
* COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
.code
|
||||
|
||||
EXTERN __chkesp_failed:PROC
|
||||
|
||||
PUBLIC __chkesp
|
||||
__chkesp:
|
||||
jnz _failed
|
||||
ret
|
||||
|
||||
_failed:
|
||||
jmp __chkesp_failed
|
||||
|
||||
END
|
||||
25
sdk/lib/vcruntime/i386/_chkesp_failed.c
Normal file
25
sdk/lib/vcruntime/i386/_chkesp_failed.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* PROJECT: ReactOS vcruntime library
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Implementation of _chkesp_failed
|
||||
* COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
#include <crtdbg.h>
|
||||
|
||||
void _chkesp_failed(void)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
/* Report the error to the user */
|
||||
_CrtDbgReport(_CRT_ERROR,
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
"",
|
||||
"The stack pointer was invalid after a function call. "
|
||||
"This indicates that a function was called with the "
|
||||
"wrong parmeters or calling convention.\n"
|
||||
"Click 'Retry' to debug the application.");
|
||||
#endif
|
||||
|
||||
__debugbreak();
|
||||
}
|
||||
Reference in New Issue
Block a user